Ask Your Question
0

opencv4.2.0 cuda.hpp

asked 2020-01-13 23:45:51 -0600

efe gravatar image

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

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2020-01-14 03:11:36 -0600

The OpenCV pre-built binaries are not built with CUDA and do not include the CUDA modules (anything in the cv::cuda namespace).

To use compile the code you found on the internet you will have to build OpenCV 4.2.0 with CUDA yourself first.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-01-13 23:45:16 -0600

Seen: 291 times

Last updated: Jan 14 '20