1. Check the local configuration and whether the graphics card type supports nvidia gpu;
2. From http://www.nvidia.cn/Download/index.aspx? Lang = cn download and install the latest driver;
3. download the latest version of Cuda toolkit5.0 from https://developer.nvidia.com/cu?toolkit=local machine, and verify that the installation is correct through the sample program;
4. Add c: \ ProgramFiles \ nvidia gpu computing toolkit \ Cuda \ V5.0 \ bin to the environment variable;
5. Slave nodes;
6. download the latest opencv2.4.6 from the http://opencv.org/downloads.html and decompress it to the D: \ soft \ opencv2.4.6 folder;
7. download and install the latest cmake2.8.11.2from http://www.cmake.org/cmake/resources/software.html;
8. Open cmake, select the D: \ soft \ opencv2.4.6 \ opencv folder in Where isthe source code:, and select D in where to buildthe Binaries: /soft/opencv2.4.6/vs2010_gpu folder, which is created manually;
9. Click the Configure button. In the displayed dialog box, select Visual Studio 10 and click Finish;
10. If a red box appears, check build_examples, with_tbb, with_cublas, with_cuda, with_cufft, and click the Configure button again;
11. If a red box is displayed, change the value of tbb_include_dirs to D: \ soft \ opencv2.4.6 \ TBB \ tbb41_20130613oss \ include to the directory where the include in TBB is located. Then click the Configure button again;
12. How can I see the red box, tbb_lib_dir, tbb_stddef_path, and click the Configure button again;
13. If the following information box contains: Use TBB: Yes (ver 4.1 interface 6105) and use Cuda: Yes (ver5.0), we have correctly configured inteltbb and Cuda;
14. Click Generate to generate the opencv. sln file in the D: \ soft \ opencv2.4.6 \ vs2010_gpu folder;
15. Use vs2010 as an administrator to open the opencv. sln file and select View -->
Properties manager --> select Microsoft. cpp. win32.user on debug and release in all_build, and add inteltbb and Cuda
Executable directories, include directories, and library
Directories, right-click --> properties: VC ++ directories, include
Directories: D: \ soft \ opencv2.4.6 \ TBB \ tbb41_20130613oss \ include
C: \ Program Files \ nvidiagpu computing toolkit \ Cuda \ V5.0 \ include; library directories: D: \ soft \ opencv2.4.6 \ TBB \ tbb41_20130613oss \ Lib \ ia32 \ VC10
C: \ Program Files \ nvidia gpu computingtoolkit \ Cuda \ V5.0 \ Lib \ Win32; executable directories: D: \ soft \ opencv2.4.6 \ TBB \ tbb41_20130613oss \ bin \ ia32 \ VC10
C: \ Program Files \ nvidia gpu computing toolkit \ Cuda \ V5.0 \ bin;
16. Select opencv_gpu in modules, right-click and choose Properties> linker> input> ignore.
Specificdefault libraries joins libcmtlibcmtd;
17. Select solution under debug and release respectively.
In explorer, right-click solution opencv, Run "rebuild solution", click Install under cmaketargets, and build will be in D: \ soft \ opencv2.4.3 \ vs2010 \ install stores the corresponding dynamic library in the bin folder, and the corresponding static library in the Lib folder;
18. Open vs2010, create a console application, and configure the opencv environment for vs2010: select View -->
Properties manager --> select Microsoft. cpp. win32.user on debug and release, and right click --> properties: VC ++
Directories, include directories: D: \ soft \ opencv2.4.6 \ vs2010_gpu \ install \ include; D: \ soft \ opencv2.4.6 \ vs2010_gpu \ install \ include \ opencv; D: \ soft \ opencv2.4.6 \ vs2010_gpu \ install \ include \ opencv2; library
Directories: D: \ soft \ opencv2.4.6 \ vs2010_gpu \ install \ Lib;
19. Select the project --> properties --> Configuration properties --> linker --> input --> additionaldependencies: Debug and release, and add the corresponding. Lib library;
20. Add D: \ soft \ opencv2.4.6 \ vs2010_gpu \ install \ bin to the Windows system environment variable path and restart.
Note:
(1) When installing the Cuda toolkit, it is best not to modify its default installation directory;
(2) TBB is not required or does not need to be installed;
(3) To shorten the Compilation Time, you can change the values of cuda_arch_bin and cuda_arch_ptx in cmake;
(4) It is best to disable 360 security guard and anti-virus software before compilation;
(5) You can also enable opencv. sln without the Administrator identity;
(6) You do not need to modify the attribute configuration of the opencv_gpu module. The default value is enough;
(7) A dialog box appears several times during compilation. If the macro dialog box appears, click the "cancel" option. If other statements are displayed, select the "yes" option;
(8) The compiled library can also be directly applied to the opencl module in opencv.
For example, if the result of idevicesnum is not 0, the installation configuration is correct.
#include "stdafx.h"#include <opencv2/opencv.hpp>#include <opencv2/gpu/gpu.hpp> using namespace cv;using namespace cv::gpu; int_tmain(int argc, _TCHAR* argv[]){ int iDevicesNum = getCudaEnabledDeviceCount(); cout<<iDevicesNum<<endl; return 0;}
References:
1. http://opencv.willowgarage.com/wiki/OpenCV_GPU
2,
Http://docs.opencv.org/modules/gpu/doc/introduction.html
3,
Http://wenku.baidu.com/view/81e29c6f011ca300a6c390dd.html
4,
Http://blog.cuvilib.com/2011/03/22/how-to-build-opencv-2-2-with-gpu-cuda-on-windows-7/
5,
Http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-microsoft-windows/index.html