Object Recognition and Scene Understanding(五)OpenCV中peopledetect详细介绍

本文详细介绍了OpenCV中的HOG(Histogram of Oriented Gradients)特征在行人检测中的应用,包括默认检测算子的获取、detectMultiScale函数参数调整的影响以及存在的误区——自带分类器可能不适用于所有场景。解决方法是针对特定应用场景重新训练分类器得到适合的detector。

opencv2以后加入了hog相关的内容,并且给出了示例,用的是法国人Navneet Dalal最早在CVPR2005会议上提出的方法。

先是使用HOG进行People Detection的,已经提供了完整的方法,在peopledetect.cpp中,主要的方法有HOG特征提取以及训练还有识别,你可以通过 hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());用已经训练好的模型直接检测。用hog.detectMultiScale...)进行检测。

 

1.程序说明

#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;

//const char* image_filename = "people.jpg";
const char* image_filename = "./../2.jpg";

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;
    }

	if (argc >1)
	{
		image_filename = argv[1];
	}

    img = imread(image_filename);
	if (!img.data)
	{
		printf( "Unable to load the image\n"
                "Pass it 
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值