资源简介

包含opencv自带的行人检测的代码 cpp和.h文件,代码使用的opencv版本为2413,其他版本皆可,配置方面就不多说了,百度私聊皆可。文件中2_1.jpg为效果较好的检测结果,其他图片看情况,赚个小积分,欢迎各位捧场。

资源截图

代码片段和文件信息

// HogTest.cpp : 定义控制台应用程序的入口点。
//

#include “stdafx.h“
#include
#include“string.h“
#include


using namespace std;
using namespace cv;


int _tmain(int argc _TCHAR* argv[])
{

Mat image;
image= imread(“2.jpg“);
//imshow(“原图“image);
HOGDescriptor hog;//HOG特征检测器
vector found found_filtered;//矩形框数组
hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());//设置SVM分类器为默认参数
//resize(image image Size(1024 640));
//g_frameList.push_back(image);
hog.detectMultiScale(image found 0 Size(8 8) Size(32 32) 1.06 2);//对图像进行多尺度检测
//imshow(“原图1“ image);
int i j;
for (i = 0; i < found.size(); i++)
{
Rect r = found[i];
j = 0;
for (; j < found.size(); j++)
if (j != i && (r & found[j]) == r)
break;
if (j == found.size())
found_filtered.push_back(r);
}
//found.clear();
//画矩形框,因为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(image r.tl() r.br()Scalar(0 255 0) 3);
}
//found_filtered.clear();
imwrite(“2_1.jpg“image);
imshow(“video“ image);
waitKey(36000);
//system(“pause“);
return 0;
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-07-27 17:33  HogTest\
     文件       32098  2017-07-18 11:06  HogTest\2.jpg
     文件       73393  2017-07-27 17:31  HogTest\2_1.jpg
     文件        1424  2017-07-27 17:31  HogTest\HogTest.cpp
     文件         507  2017-07-20 14:15  HogTest\stdafx.h
     文件         200  2017-07-27 17:36  HogTest\一些注意事项.txt

评论

共有 条评论