基于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/42925205
OpenCV的安装可以参考: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
进入目录:
编译:
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.
结果截图如下:
如果有摄像头,可以执行下面的命令来完成演示:
./hog --camera 0
注意: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!
结果截图如下:
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!