Compiling error cv::gpu

前端 未结 2 837
我在风中等你
我在风中等你 2020-12-15 09:50

I\'m using OpenCV master branch (3.0.0. dev) with CUDA on Ubuntu 12.04, and trying to compile the following opencv with gpu code:

#include 
#         


        
2条回答
  •  执念已碎
    2020-12-15 10:26

    The gpu module was redesigned in OpenCV 3.0. It was splitted onto several modules, it was renamed to cuda and gpu:: namespace was renamed to cuda::. The correct code for OpenCV 3.0:

    #include 
    #include "opencv2/opencv.hpp"
    #include "opencv2/core.hpp"
    #include "opencv2/highgui.hpp"
    #include "opencv2/cudaarithm.hpp"
    
    using namespace cv;
    
    int main (int argc, char* argv[])
    {
        try
        {
            cv::Mat src_host = cv::imread("file.png", cv::IMREAD_GRAYSCALE);
            cv::cuda::GpuMat dst, src;
            src.upload(src_host);
            cv::cuda::threshold(src, dst, 128.0, 255.0, cv::THRESH_BINARY);
            cv::Mat result_host(dst);
            cv::imshow("Result", result_host);
            cv::waitKey();
        }
        catch(const cv::Exception& ex)
        {
            std::cout << "Error: " << ex.what() << std::endl;
        }
        return 0;
    }
    

提交回复
热议问题