Reputation: 111
I am trying to install the cuda toolkit so I can use the gpu functions in opencv. I've read all the documentation and the getting started guide with windows. I've downloaded the CUDA 6.5 toolkit, and installed it. I tried running this sample code:
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/gpu/gpu.hpp"
int main (int argc, char* argv[])
{
try
{
cv::Mat src_host = cv::imread("file.png", CV_LOAD_IMAGE_GRAYSCALE);
cv::gpu::GpuMat dst, src;
src.upload(src_host);
cv::gpu::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;
}
however I get linker errors. A little digging led me to this question, recommending to include the C:\opencv\build\gpu\x86...libraries and binaries. My problem is that the gpu folder does not exist in my opencv install folder.
A little more digging and I found this suggesting the use of CMake. But it also requires the SDK! First of all, there is no mention of the SDK on the nvidia website. It doesnt exist in their downloads page. So I ignored that part and followed the steps listed, CMake could not find any of the CUDA directories (despite them being installed in the default locations). I located them manually, generated the opencv solution then built that in visual studio. This has now been 'building' for a few hours (VS says ready however).
What is the point of building the openCV solution it generated? How do I get the gpu folder for openCV.
Upvotes: 0
Views: 910
Reputation: 173
if you can't see gpu folder in build folder of opencv, it means that your opencv compiled without gpu library, you must use opencv source and CMake to build opencv and then compile it.
also you can see these links:
https://initialneil.wordpress.com/2014/09/25/opencv-2-4-9-cuda-6-5-visual-studio-2013/
http://blog.csdn.net/JOE_FANNIE/article/details/50394892
Upvotes: 1
Reputation: 250
When you extract the opencv, it has a folder named source. you should compile this source with Cmake. after configuration check WITH_CUDA option. then try to build OpenCv.sln in VS from both Release and Debug mode.
Upvotes: 1