opencv的GPU版本的编译工作搞了很长时间,总结一下:
GPU : NVIDIA GTX1050
注:因为pc配置与环境的多样化,致使opencv的gpu编译出来的变种多样化,在不同配置和环境的机器上无法共用,需要重新编译。
opencv解压之后得到opencv包,现在我们有两个包:
1 opencv文件夹(opencv解压之后的,里面有build和sources两个子文件夹)
2 cuda_vc14文件夹(我们新建的,用来放opencv编译过程生成的文件)
General configuration for OpenCV 2.4.13.2 =====================================
Version control: unknown
Platform:
Host: Windows 10.0.15063 AMD64
CMake: 3.9.6
CMake generator: Visual Studio 14 2015 Win64
CMake build tool: C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe
MSVC: 1900
C/C++:
Built as dynamic libs?: YES
C++ Compiler: E:/vs2015/VC/bin/x86_amd64/cl.exe (ver 19.0.24210.0)
C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /EHa /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /wd4251 /wd4275 /wd4589 /wd4359 /MP8 /MD /O2 /Ob2 /DNDEBUG /Zi
C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /EHa /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /wd4251 /wd4275 /wd4589 /wd4359 /MP8 /MDd /Zi /Ob0 /Od /RTC1
C Compiler: E:/vs2015/VC/bin/x86_amd64/cl.exe
C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /MP8 /MD /O2 /Ob2 /DNDEBUG /Zi
C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /MP8 /MDd /Zi /Ob0 /Od /RTC1
Linker flags (Release): /machine:x64 /INCREMENTAL:NO /debug
Linker flags (Debug): /machine:x64 /debug /INCREMENTAL
ccache: NO
Precompiled headers: YES
OpenCV modules:
To be built: core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib stitching superres ts videostab
Disabled: world
Disabled by dependency: -
Unavailable: androidcamera dynamicuda java python viz
Windows RT support: NO
GUI:
QT: NO
Win32 UI: YES
OpenGL support: NO
VTK support: NO
Media I/O:
ZLib: build (ver 1.2.7)
JPEG: build (ver 62)
PNG: build (ver 1.5.27)
TIFF: build (ver 42 - 4.0.2)
JPEG 2000: build (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
Video I/O:
Video for Windows: YES
DC1394 1.x: NO
DC1394 2.x: NO
FFMPEG: YES (prebuilt binaries)
avcodec: YES (ver 55.18.102)
avformat: YES (ver 55.12.100)
avutil: YES (ver 52.38.100)
swscale: YES (ver 2.3.100)
avresample: YES (ver 1.0.1)
OpenNI: NO
OpenNI PrimeSensor Modules: NO
PvAPI: NO
GigEVisionSDK: NO
DirectShow: YES
Media Foundation: NO
XIMEA: NO
Intel PerC: NO
Other third-party libraries:
Use IPP: NO
Use Eigen: NO
Use TBB: NO
Use OpenMP: NO
Use GCD NO
Use Concurrency YES
Use C=: NO
Use Cuda: YES (ver 8.0)
Use OpenCL: YES
NVIDIA CUDA
Use CUFFT: YES
Use CUBLAS: YES
USE NVCUVID: NO
NVIDIA GPU arch: 20 21 30 35
NVIDIA PTX archs: 30
Use fast math: NO
Tiny gpu module: NO
OpenCL:
Version: dynamic
Include path: E:/opencv2.4.13/opencv/sources/3rdparty/include/opencl/1.2
Use AMD FFT: NO
Use AMD BLAS: NO
Python:
Interpreter: NO
Java:
ant: NO
JNI: NO
Java tests: NO
Documentation:
Build Documentation: NO
Sphinx: NO
PdfLaTeX compiler: NO
Doxygen: NO
Tests and samples:
Tests: YES
Performance tests: YES
C/C++ Examples: NO
Install path: E:/opencv2.4.13/cuda_vc14/install
cvconfig.h is in: E:/opencv2.4.13/cuda_vc14
-----------------------------------------------------------------
#include
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/legacy/legacy.hpp"
#include
#include
// GPU
#include "opencv2/gpu/gpu.hpp"
using namespace cv;
using namespace std;
using namespace cv::gpu;
int main()
{
ORB_GPU orb_gpu;
vector dkeyPoints_1, dkeyPoints_2;
GpuMat ddescriptors_1, ddescriptors_2;
Mat des_1, des_2;
/*
orb_gpu(dimg_1, GpuMat(), dkeyPoints_1, ddescriptors_1);
orb_gpu(dimg_2, GpuMat(), dkeyPoints_2, ddescriptors_2);
ddescriptors_1.download(des_1);
ddescriptors_2.download(des_2);
BruteForceMatcher matcher;
vector matches;
matcher.match(des_1, des_2, matches);
double max_dist = 0; double min_dist = 100;
//-- Quick calculation of max and min distances between keypoints
for (int i = 0; i < des_1.rows; i++)
{
double dist = matches[i].distance;
if (dist < min_dist) min_dist = dist;
if (dist > max_dist) max_dist = dist;
}
printf("-- Max dist : %f \n", max_dist);
printf("-- Min dist : %f \n", min_dist);
//-- Draw only "good" matches (i.e. whose distance is less than 0.6*max_dist )
//-- PS.- radiusMatch can also be used here.
std::vector< DMatch > good_matches;
for (int i = 0; i < des_1.rows; i++)
{
if (matches[i].distance < 0.6*max_dist)
{
good_matches.push_back(matches[i]);
}
}
Mat img_matches;
drawMatches(img_1, dkeyPoints_1, img_2, dkeyPoints_2,
good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
vector(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
imshow("Match", img_matches);
cvWaitKey();
imwrite("Match.jpg", img_matches);
*/
return 0;
}
速度上的优势:
参考博客:
http://blog.csdn.net/qq_15947787/article/details/78545254
http://blog.csdn.net/u011428870/article/details/50997812