openCV库自带的行人检测demo求助【100分】

WTK-CV WTK-CV 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如下是源代码
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"

#include <stdio.h>
#include <string.h>
#include <ctype.h>

using namespace cv;
using namespace std;

void help()
{
printf(
"\nDemonstrate the use of the HoG descriptor using\n"
" HOGDescriptor::hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());\n"
"Usage:\n"
"./peopledetect (<image_filename> | <image_list>.txt)\n\n");
}

int main(int argc, char** argv)
{
Mat img;
FILE* f = 0;
char _filename[1024];

if( argc == 1 )
{
printf("Usage: peopledetect (<image_filename> | <image_list>.txt)\n");
return 0;
}
img = imread(argv[1]);

if( img.data )
{
strcpy(_filename, argv[1]);
}
else
{
f = fopen(argv[1], "rt");
if(!f)
{
fprintf( stderr, "ERROR: the specified file could not be loaded\n");
return -1;
}
}

HOGDescriptor hog;
hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
namedWindow("people detector", 1);

for(;;)
{
char* filename = _filename;
if(f)
{
if(!fgets(filename, (int)sizeof(_filename)-2, f))
break;
//while(*filename && isspace(*filename))
// ++filename;
if(filename[0] == '#')
continue;
int l = strlen(filename);
while(l > 0 && isspace(filename[l-1]))
--l;
filename[l] = '\0';
img = imread(filename);
}
printf("%s:\n", filename);
if(!img.data)
continue;

fflush(stdout);
vector<Rect> found, found_filtered;
double t = (double)getTickCount();
// run the detector with default parameters. to get a higher hit-rate
// (and more false alarms, respectively), decrease the hitThreshold and
// groupThreshold (set groupThreshold to 0 to turn off the grouping completely).
hog.detectMultiScale(img, found, 0, Size(8,8), Size(32,32), 1.05, 2);
t = (double)getTickCount() - t;
printf("tdetection time = %gms\n", t*1000./cv::getTickFrequency());
size_t i, j;
for( i = 0; i < found.size(); i++ )
{
Rect r = found[i];
for( j = 0; j < found.size(); j++ )
if( j != i && (r & found[j]) == r)
break;
if( j == found.size() )
found_filtered.push_back(r);
}
for( i = 0; i < found_filtered.size(); i++ )
{
Rect r = found_filtered[i];
// the HOG detector returns slightly larger rectangles than the real objects.
// so we slightly shrink the rectangles to get a nicer output.
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(img, r.tl(), r.br(), cv::Scalar(0,255,0), 3);
}
imshow("people detector", img);
int c = waitKey(0) & 255;
if( c == 'q' || c == 'Q' || !f)
break;
}
if(f)
fclose(f);
return 0;
}


弄了好久,代码编译正常,通过。运行时,提示0xc000000d, 初始化失败。刚开始以为是HOGDescriptor初始化有问题,可自己重新初始化,依然报错0xc000000d。

也看过一个CSDN上的同样帖子,问题一样,他最后解决了,只是给了个确实是初始化对象失败的原因,但是没说具体修改方案,我也一直在弄了,还没解决掉,所以给个高分求助各位大侠

3Q
...全文

相关推荐

100fps行人检测代码

这个程序代码是根据2012年的一篇论文《Pedestrian detection at 100 frames per second》实现的,可以在CPU或GPU上运行,检测性能比常规的HOG提高很多。

gzs

基于OpenCv开发的图像检索DEMO

基于OpenCv开发的图像检索DEMO,速度较快,效果较好,可以作为一般意义下的图像相似度检索服务!根据具体项目改改即可使用!

liubin315927

VS2008 MFC下用OpenCV2.0进行图像读取和边缘检测

VS2008 MFC下用OpenCV2.0进行图像读取和边缘检测,通过对话框来打开图像文件、然后图像大小进行缩放、适当地显示在图片控件的框架内。

邹宇华

opencv检测红色区域

打开一张图像,即可以检测图像中的所有红色区域

weiyuping68

Python使用Opencv实现边缘检测以及轮廓检测

Canny边缘检测器是一种被广泛使用的算法,并被认为是边缘检测最优的算法,该方法使用了比高斯差分算法更复杂的技巧,如多向灰度梯度和滞后阈值化。Canny边缘检测器算法基本步骤:平滑图像:通过使用合适的模糊半径执行高斯模糊来减少图像内的噪声。计算图像的梯度:这里计算图像的梯度,并将梯度分类为垂直、水平和斜对角。这一步的输出用于在下一步中计算真正的边缘。非最大值抑制:利用上一步计算出来的梯度方向,检测某一像素在梯度的正方向和负方向上是否是局部最大值,如果是,则抑制该像素(像素不属于边缘)。这是一种边缘细化技术,用最急剧的变换选出边缘点。用滞后阈值化选择边缘:最后一步,检查某一条边缘是否明显到足以作

weixin_38630463
评论 26
收藏 已收藏
分享
返回顶部
WTK-CV
图形处理/算法 19,463 成员 50,678 内容