多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 基于GPU加速的OpenCV人体检测(Full Body Detection) ### 1、CUDA和OpenCV的安装 首先,确定一下自己的平台是否安装好了CUDA和OpenCV。 CUDA的安装可以参考:[http://blog.csdn.net/frd2009041510/article/details/42042807](http://blog.csdn.net/frd2009041510/article/details/42042807)和[http://blog.csdn.net/frd2009041510/article/details/42925205](http://blog.csdn.net/frd2009041510/article/details/42925205) OpenCV的安装可以参考:[http://blog.csdn.net/frd2009041510/article/details/42930113](http://blog.csdn.net/frd2009041510/article/details/42930113) ### 2、Simply build the OpenCV HOG (Hough Of Gradients) sample person detector program ~~~ cd opencv-2.4.9/samples/gpu g++ hog.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o hog ~~~ 进入目录: ![](https://box.kancloud.cn/2016-05-07_572d61737f9a4.jpg) 编译: ![](https://box.kancloud.cn/2016-05-07_572d617395e43.jpg) ### 3、run the HOG demo ~~~ ./hog --video 768x576.avi ~~~ 注意:You can run the HOG demo such as on a pre-recorded video of people walking around. The HOG demo displays a graphical output, hence you should plug a HDMI monitor in or use a remote viewer such as X Tunneling or VNC or TeamViewer on your desktop in order to see the output. 结果截图如下: ![](https://box.kancloud.cn/2016-05-07_572d6173aacd9.jpg) ![](https://box.kancloud.cn/2016-05-07_572d6173c2d62.jpg) 如果有摄像头,可以执行下面的命令来完成演示: ~~~ ./hog --camera 0 ~~~ ![](https://box.kancloud.cn/2016-05-07_572d61740fe61.jpg) 注意:Note: This looks for whole bodies and assumes they are small, so you need to stand atleast 5m away from the camera if you want it to detect you! 结果截图如下: ![](https://box.kancloud.cn/2016-05-07_572d617423687.jpg) ### 4、HOG demo中的一些控制命令 **You can toggle between CPU vs GPU by pressing 'm', where you will see that the GPU is typically 5x faster at HOG than the CPU!** ![](https://box.kancloud.cn/2016-05-07_572d617451017.jpg)