OpenCV 2.4.3rc and CUDA 4.2: "OpenCV Error: No GPU support"
Solution 1:
You are using those OpenCV binaries which are compiled without GPU support.
C:\opencv\build\x86\...
are without GPU support.
You have to use the binaries and lib files which are present in the build\gpu
folder.
C:\opencv\build\gpu\x86\...
are with GPU support.
UPDATE:
Procedure:
In Visual Studio 2010, go to project properties. In the VC++ Directories, you will see the following page:
Add the path of OpenCV include
folder in the Include Directories textbox. Make sure that multiple paths are separated by a semicolon and there is no space in any of the path.
Similarly add the path of OpenCV lib
folders for both the GPU and Non-GPU versions in the Library Directories Textbox. (Don't forget the semicolon)
Important: When writing the paths in the box, first write the GPU path and after that, the Non-GPU path.
Next step is adding the path of bin
folder of OpenCV. But not in visual studio, but in the Path
Environment variable as shown below:
- Right Click
My Computer
- Go To Properties
- Go to
Environment Variables
section - Edit the System Variable
Path
- Append
C:\OpenCV\build\gpu\x86\vc10\bin
andC:\OpenCV\build\x86\vc10\bin
to the Path. Don't forget to separate different values with semicolon. Also---> GPU Comes First. - Save and exit.
Restart Visual Studio. The linker and #include
directive will now recognize the OpenCV libraries.
As we have added the path of the GPU libraries also, so complete GPU support will be available in OpenCV.
To use GPU functionality of OpenCV, you just have to do the following:
#include opencv2/gpu/gpu.hpp
- Specify
opencv_gpu243d.lib
for Debug Configuration, oropencv_gpu243.lib
for Release Configuration in the Additional Dependencies field in theLinker->Input
section of project properties.
Some Additional Info:
In Visual Studio, there is an easy way to link libraries instead of specifying them in the project properties.
Just write these lines in the very start of your code:
#ifdef _DEBUG
#pragma comment(lib,"opencv_core243d")
#pragma comment(lib,"opencv_highgui243d")
#else
#pragma comment(lib,"opencv_core243")
#pragma comment(lib,"opencv_highgui243")
#endif