一、环境配置
Basically since openCV 2.4.4 if you want GPU support you need to rebuilt openCV with CUDA enabled. This topic explains in detail on how to do that.
可参考:
http://docs.opencv.org/modules/gpu/doc/introduction.html
How to Build OpenCV 2.4.6 with GPU Module in Windows
http://www.programmerfish.com/how-to-build-opencv-2-4-6-with-gpu-module-in-windows/#.Uspi8j9U8xF
Step by Step Guide on Running OpenCV in Microsoft Visual Studio
http://www.programmerfish.com/running-opencv-in-microsoft-visual-studio/#.UsoW3z9U8xF
二、使用方法
在介绍OpenCV中GPU模块使用之前,先回顾下CUDA的一般使用方法,其基本步骤如下:
1.主机代码执行;
2.传输数据到GPU;
3.确定grid,block大小;
4.调用内核函数,GPU运行程序;
5.传输结果到CPU;
6.继续主机代码执行。
OpenCV中GPU模块的使用的步骤与CUDA的基本使用方法类似,只是OpenCV中GPU模块,已经封装的内核函数的调用,其使用步骤如下:
1.验证OpenCV是否已启用GPU模块。
2.上传待处理数据到GPU (Mat --> GpuMat)。
3.调用OpenCV支持的GPU的处理函数。
4.下载处理结果到CPU (GpuMat ---> Mat)。