First time here? Check out the FAQ!

Ask Your Question
0

opencv4.2.0 cuda.hpp

asked Jan 14 '0

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

Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered Jan 14 '0

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.

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Jan 14 '0

Seen: 365 times

Last updated: Jan 14 '20