OpenCV+Contrib+CUDA configuration under WINDOWS (CUDA10.1,VS2017,opencv3.4.5)

Posted by HTF on Sat, 10 Aug 2019 16:08:29 +0200

After two days, we finally got it, Big Head!! First used VS2019, compiled four or five times has been unsuccessful, angry, uninstall VS2019, CUDA, reinstall VS2017, CUDA, and then a success, is so amazing!

Important Reference Articles:

Configuration process

1. Install VS2017 first, you must install this first, because then install CUDA, depending on this.

2. Install CUDA.

3. Download opencv and opencv_contrib, both of which must have the same version number. The two paths on my computer are:

D:\Softwares\opencv3.4.5
D:\Softwares\opencv3.4.5\opencv_contrib-3.4.5

4. Download Cmake. My version is 3.14.6.

5. Start compiling. Please refer to the link article above for details. In particular, in the process of Configure, if there is red, please keep Configure until the red disappears, otherwise it will not succeed. The build directory is in the opencv3.4.5 directory, and the new build_gpu folder is created: everything that is generated after that is here.

D:\Softwares\opencv3.4.5\opencv\build_gpu

6. OpenCV.sln is opened with VS2017, and the process of choosing the generation-regeneration solution is very long. My own computer needs two hours and keeps outputting warning information. This can be ignored without affecting the final result. After I finished generating, 171 output succeeded and 4 failed, but I couldn't find which four failed. It was embarrassing. These four should be generated separately later.

7. Verify that the installation is successful.

New VS2017 console application, x64

Engineering Attributes -- Configuration Attributes -- VC++ Directory -- Contains directories to add:

D:\Softwares\opencv3.4.5\opencv\build_gpu\install\include
D:\Softwares\opencv3.4.5\opencv\build_gpu\install\include\opencv
D:\Softwares\opencv3.4.5\opencv\build_gpu\install\include\opencv2

 

Engineering Attributes - Configuration Attributes - VC++ Directory - Library Directory

D:\Softwares\opencv3.4.5\opencv\build_gpu\install\x64\vc15\lib

Engineering attributes -- Configuration attributes -- Linkers -- Inputs -- Additional dependencies added: (56 in total)

opencv_aruco345d.lib
opencv_bgsegm345d.lib
opencv_bioinspired345d.lib
opencv_calib3d345d.lib
opencv_ccalib345d.lib
opencv_core345d.lib
opencv_cudaarithm345d.lib
opencv_cudabgsegm345d.lib
opencv_cudacodec345d.lib
opencv_cudafeatures2d345d.lib
opencv_cudafilters345d.lib
opencv_cudaimgproc345d.lib
opencv_cudalegacy345d.lib
opencv_cudaobjdetect345d.lib
opencv_cudaoptflow345d.lib
opencv_cudastereo345d.lib
opencv_cudawarping345d.lib
opencv_cudev345d.lib
opencv_datasets345d.lib
opencv_dnn345d.lib
opencv_dpm345d.lib
opencv_face345d.lib
opencv_features2d345d.lib
opencv_flann345d.lib
opencv_fuzzy345d.lib
opencv_highgui345d.lib
opencv_img_hash345d.lib
opencv_imgcodecs345d.lib
opencv_imgproc345d.lib
opencv_line_descriptor345d.lib
opencv_ml345d.lib
opencv_objdetect345d.lib
opencv_optflow345d.lib
opencv_phase_unwrapping345d.lib
opencv_photo345d.lib
opencv_plot345d.lib
opencv_reg345d.lib
opencv_rgbd345d.lib
opencv_saliency345d.lib
opencv_shape345d.lib
opencv_stereo345d.lib
opencv_stitching345d.lib
opencv_structured_light345d.lib
opencv_superres345d.lib
opencv_surface_matching345d.lib
opencv_text345d.lib
opencv_tracking345d.lib
opencv_video345d.lib
opencv_videoio345d.lib
opencv_videostab345d.lib
opencv_xfeatures2d345d.lib
opencv_ximgproc345d.lib
opencv_xobjdetect345d.lib
opencv_xphoto345d.lib
opencv_dnn_objdetect345d.lib
opencv_hfs345d.lib

8. Verification procedure:

#include "stdafx.h"
#include <iostream>
#include "opencv2/opencv_modules.hpp"
#include "opencv2/core.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/cudafeatures2d.hpp"
#include "opencv2/xfeatures2d/cuda.hpp"

using namespace std;
using namespace cv;
using namespace cv::cuda;

int main()
{
	//Test the graphics card method 1 (this method can read the graphics card model)
	printShortCudaDeviceInfo(getDevice());

	//Test graphics card method 2
	int iDevicesNum = getCudaEnabledDeviceCount();
	cout << "Devices Num:"<<iDevicesNum << endl;

	//Test graphics card method 3
	DeviceInfo _deviceInfo;
	bool _isDeviceOK = _deviceInfo.isCompatible();
	cout << "IsGPUDeviceOK : " << _isDeviceOK << endl;

	return 0;
}

The output results are as follows:

Device 0:  "GeForce MX250"  2048Mb, sm_61, Driver/Runtime ver.10.10/10.10
Devices Num:1
IsGPUDeviceOK : 1
 Press any key to continue....

The first line is my computer's graphics card information, the second line is that there is only one piece, and the third line is that the program recognizes the GPU.

Topics: OpenCV cmake