资源简介

OpenCV2.4.4实现HOG行人检测 使用时请自行修改工程的include目录和lib目录配置。

资源截图

代码片段和文件信息

#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;
using namespace cv;

int main()
{

Mat src = imread(“5.png“);
HOGDescriptor hog;//HOG特征检测器
hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());//设置SVM分类器为默认参数
vector found found_filtered;//矩形框数组
hog.detectMultiScale(src found 0 Size(88) Size(3232) 1.05 2);//对图像进行多尺度检测

cout<<“矩形个数:“< //找出所有没有嵌套的矩形框r并放入found_filtered中如果有嵌套的话则取外面最大的那个矩形框放入found_filtered中
for(int i=0; i < found.size(); i++)
{
Rect r = found[i];
int j=0;
for(; j < found.size(); j++)
if(j != i && (r & found[j]) == r)
break;
if( j == found.size())
found_filtered.push_back(r);
}
cout<<“过滤后矩形的个数:“<
//画矩形框,因为hog检测出的矩形框比实际人体框要稍微大些所以这里需要做一些调整
for(int i=0; i {
Rect r = found_filtered[i];
r.x += cvRound(r.width*0.1);
r.width = cvRound(r.width*0.8);
r.y += cvRound(r.height*0.07);
r.height = cvRound(r.height*0.8);
rectangle(src r.tl() r.br() Scalar(02550) 3);
}

imwrite(“ImgProcessed.jpg“src);
namedWindow(“src“0);
imshow(“src“src);
waitKey();//注意:imshow之后一定要加waitKey,否则无法显示图像



system(“pause“);
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      74752  2013-11-13 20:51  HOG_OpenCV_Single\Debug\HOG_OpenCV_Single.exe

     文件     786456  2013-11-13 20:51  HOG_OpenCV_Single\Debug\HOG_OpenCV_Single.ilk

     文件    1338368  2013-11-13 20:51  HOG_OpenCV_Single\Debug\HOG_OpenCV_Single.pdb

     文件     174277  2013-10-22 16:53  HOG_OpenCV_Single\HOG_OpenCV_Single\00000.jpg

     文件     170327  2013-10-22 16:53  HOG_OpenCV_Single\HOG_OpenCV_Single\00695.jpg

     文件     788547  2013-10-21 21:44  HOG_OpenCV_Single\HOG_OpenCV_Single\1.png

     文件     813015  2013-10-21 21:47  HOG_OpenCV_Single\HOG_OpenCV_Single\2.png

     文件      90689  2007-01-10 01:37  HOG_OpenCV_Single\HOG_OpenCV_Single\2007_000423.jpg

     文件     128121  2007-01-09 20:47  HOG_OpenCV_Single\HOG_OpenCV_Single\2007_007769.jpg

     文件     145669  2008-01-18 22:48  HOG_OpenCV_Single\HOG_OpenCV_Single\2008_000844.jpg

     文件     818604  2013-10-21 21:48  HOG_OpenCV_Single\HOG_OpenCV_Single\3.png

     文件    1610478  2013-10-21 21:48  HOG_OpenCV_Single\HOG_OpenCV_Single\4.png

     文件     911894  2013-10-21 21:49  HOG_OpenCV_Single\HOG_OpenCV_Single\5.png

     文件        714  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\cl.command.1.tlog

     文件      14030  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\CL.read.1.tlog

     文件        406  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\CL.write.1.tlog

     文件        406  2013-11-10 15:37  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\HOG_OpenCV_Single.exe.embed.manifest

     文件        472  2013-11-10 15:37  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\HOG_OpenCV_Single.exe.embed.manifest.res

     文件        381  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\HOG_OpenCV_Single.exe.intermediate.manifest

     文件         61  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\HOG_OpenCV_Single.lastbuildstate

     文件       2751  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\HOG_OpenCV_Single.log

     文件     245197  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\HOG_OpenCV_Single.obj

     文件        224  2013-11-10 15:37  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\HOG_OpenCV_Single_manifest.rc

     文件          2  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\link-cvtres.read.1.tlog

     文件          2  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\link-cvtres.write.1.tlog

     文件          2  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\link.3584-cvtres.read.1.tlog

     文件          2  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\link.3584-cvtres.write.1.tlog

     文件          2  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\link.3584.read.1.tlog

     文件          2  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\link.3584.write.1.tlog

     文件          2  2013-11-13 20:51  HOG_OpenCV_Single\HOG_OpenCV_Single\Debug\link.6092-cvtres.read.1.tlog

............此处省略42个文件信息

评论

共有 条评论