Ask Your Question

Revision history [back]

opencv4.2.0 cuda.hpp

Hi, I am trying to compile a simple C++ program that I found on the internet, but I am not sure if it is supported by opencv4.2.0 or not, because I couldn't find cuda.hpp in /usr/local/include/opencv4/opencv2. When I comment out the #include "opencv2/cuda.hpp" part, the code seems to work. Here is the code below:

#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/imgcodecs.hpp"
//#include "opencv2/cuda.hpp"
#include "opencv2/cudaarithm.hpp"
using namespace cv;

int main (int argc, char* argv[])
{
try
{
    cv::Mat src_host = cv::imread("image.png", IMREAD_GRAYSCALE);
    cv::cuda::GpuMat dst, src;
    src.upload(src_host);
    cv::cuda::threshold(src, dst, 128.0, 255.0, THRESH_BINARY);
    cv::Mat result_host;
    dst.download(result_host);
    cv::imshow("Result", result_host);
    cv::waitKey();
}
catch(const cv::Exception& ex)
{
    std::cout << "Error: " << ex.what() << std::endl;
}
return 0;
}

Does opencv4.2.0 comes with cuda.hpp or is it enough to use cudaarithm.hpp