SVM分类器,其基于用于“对象检测”的HOG特征。在OpenCV [英] SVM classifier based on HOG features for "object detection" in OpenCV

查看:296
本文介绍了SVM分类器,其基于用于“对象检测”的HOG特征。在OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,我想检测图像中的对象;我的目标是使用HOG功能。通过使用OpenCV SVM实现,我可以找到用于检测人的代码,并且我阅读了关于调整参数以便检测对象而不是人的一些论文。不幸的是,我不能这样做有几个原因;首先,我可能调整参数不正确,第二,我不是一个好的程序员在C + +,但我必须用C ++ / OpenCV ... 在这里,您可以使用C ++ / OpenCV找到用于检测HOG功能的代码。 >

假设我要检测此图片。现在,我将告诉你我在代码中改变了什么,但它没有与我一起工作。



我试图改变的代码:

  HOGDescriptor hog; 
hog.setSVMDetector(HOGDescriptor :: getDefaultPeopleDetector());

我尝试更改 getDefaultPeopleDetector()以下参数,但它不工作:

 (Size(64,128),Size(16,16)大小(8,8),大小(8,8),9,0,-1,0,0.2,true,cv :: HOGDescriptor :: DEFAULT_NLEVELS)

然后我尝试创建一个向量,但是当我打印结果时,它似乎是空的。

 矢量< float>探测器; 

HOGDescriptor hog(Size(64,128),Size(16,16),Size(8,8),Size(8,8),9,0,-1,0, true,cv :: HOGDescriptor :: DEFAULT_NLEVELS);

hog.setSVMDetector(detector);

请帮我解决这个问题。

解决方案

为了使用opencv HOG描述符和SVM分类器检测任意对象,您需要先训练分类器。使用参数在这里不会有帮助,对不起。



广义上,您需要完成以下步骤:



步骤1)准备要检测的对象的一些训练图像(正样本)。



步骤2)检测训练样本的HOG特征并使用此功能训练SVM分类器(也在OpenCV中提供)。



步骤3)使用训练的SVM分类器的系数HOGDescriptor :: setSVMDetector()方法。



只有这样,您才能使用peopledetector.cpp示例代码来检测要检测的对象。


I have a project, which I want to detect objects in the images; my aim is to use HOG features. By using OpenCV SVM implementation , I could find the code for detecting people, and I read some papers about tuning the parameters in order to detect object instead of people. Unfortunately, I couldn't do that for a few reasons; first of all, I am probably tuning the parameters incorrectly, second of all, I am not a good programmer in C++ but I have to do it with C++/OpenCV... here you can find the code for detecting HOG features for people by using C++/OpenCV.

Let's say that I want to detect the object in this image. Now, I will show you what I have tried to change in the code but it didn't work out with me.

The code that I tried to change:

HOGDescriptor hog;
hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());

I tried to change getDefaultPeopleDetector() with the following parameters, but it didn't work:

(Size(64, 128), Size(16, 16), Size(8, 8), Size(8, 8), 9, 0,-1, 0, 0.2, true, cv::HOGDescriptor::DEFAULT_NLEVELS)

I then tried to make a vector, but when I wanted to print the results, it seems to be empty.

vector<float> detector;

HOGDescriptor hog(Size(64, 128), Size(16, 16), Size(8, 8), Size(8, 8), 9, 0,-1, 0, 0.2, true, cv::HOGDescriptor::DEFAULT_NLEVELS);

hog.setSVMDetector(detector);

Please, I need help solving this problem.

解决方案

In order to detect arbitrary objects with using opencv HOG descriptors and SVM classifier, you need to first train the classifier. Playing with the parameters will not help here, sorry :( .

In broad terms, you will need to complete the following steps:

Step 1) Prepare some training images of the objects you want to detect (positive samples). Also you will need to prepare some images with no objects of interest (negative samples).

Step 2) Detect HOG features of the training sample and use this features to train an SVM classifier (also provided in OpenCV).

Step 3) Use the coefficients of the trained SVM classifier in HOGDescriptor::setSVMDetector() method.

Only then, you can use the peopledetector.cpp sample code, to detect the objects you want to detect.

这篇关于SVM分类器,其基于用于“对象检测”的HOG特征。在OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆