Learning about opencv -- hog. detectmultiscale

Source: Internet
Author: User
Tags svm

From: http://blog.csdn.net/sangni007/article/details/7544401

 

I have been scratching my head for a problem over the past few days, so I am not in a mood for a few days. Today I want to understand something and remember it. I forgot it later.

The problem that has plagued me over the past few days is the hog. detectmultiscale () function.

I see some hog articles on the Internet from a complete image to detect the target object, a very Nb box, the box is so accurate, such as opencv comes with the sample: http://blog.csdn.net/sangni007/article/details/7453987

I am always envious! As a result, I tried it and it turned out to be a tragedy!

First, I used the previous hog + SVM method to train the classifier. During the training, the logo of the public and the negative samples were messy.

Http://blog.csdn.net/sangni007/article/details/7471222

Save the XML file,

Define a hogdescriptor hog1;

Hog1.load ("svm_data.xml ");

Hog1.detectmultiscale (IMG, found );

But it cannot be detected !!! It would have been because detectmultiscale () would not have been used, and it was difficult to use it later. This result has been bothering me, and I don't know whether it is not trained or the function is wrong ~ % >_< % ~

Today, I suddenly understood the problem:

The SVM classifier of XML that I train, that is,OutputOnly 1 and 0 (corresponding output result !!!), Only the public logo can be predicted, but the target cannot be detected because it is not a detector.

In fact, this is just a vague understanding. I hope to give some guidance to you ~~~

 

Comment summary:

1. The principle of the detector is actually to add a classifier to the sliding window.

2. the binary classifier outputs 0, 1. multiclass classification can be 0, 1, 2 ......; then the detector should be similar. It is also the first to create a model and determine whether it is 0, 1, or 2 in the search ...... A detector can be used to detect a target object in a large image. For example, to detect pedestrians in an image, DETECTOR ~ is required ~. Of course, you can use a sliding window and classifier to detect the target ~

3. I did this to detect other objects,
Hogdescriptor * hog = new hogdescriptor ();
Vector <float> * descriptors = new STD: vector <float> ();
Hog-> compute (imgt, * descriptors, size (8, 8); // imgt is the target to be detected
Hog-> setsvmdetector (* descriptors );
....
Hog-> detectmultiscale (IMG, found, 0, size (8, 8), size (32, 32), 1.05, 2 );
However, the final detection result is not accurate, and the imgt is extracted from the IMG. Now I don't know what's going on. Do you need multiple imgt when generating descriptors? Reply: Calculate (compute) first, then train, and finally detect the target image ~ 4. opencv SVM cannot be used for regression (regression, degradation). Therefore, only label ~~ is output ~~ We recommend that svm_light or libsvm + opencv5, 5th parameters refer to window border fill size 6, detectmultiscale () parameters specific representative of those meanings, refer to the following document http://docs.opencv.org/modules/gpu/doc/object_detection.html? Highlight = huge GPU: hogdescriptor: detectmultiscale (const gpumat & IMG, vector <rect> & found_locations, double values, size win_stride, size padding, double scale0, int group_threshold) the fourth parameter is the window stride, indicating the size of the window moving after a detection, that is, the distance of each window moving. during training, the sample size is usually set to the same size as the window size, at the beginning, you may need to resize the sample (to deal with multi-scale problems, you can use multi-scale hog feature and then use PCA to reduce the dimension )~~ The fifth parameter is the same as the detectmultiscale function of the CPU hog ~~ Indicates filling the boundary of the image to be detected. If it is set to (), the center of the detection window cannot start scanning from ~~ It's just like using a spatial filter to filter images ~~ If the row and Col of an image are set to (64, 64) by 128,128, the calculated hog feature is naturally slow. The explanation in this document is a false parameter used to maintain CPU compatibility. It must be (0, 0), but it is also possible to use (64, 64) or other parameters. Change (64, 64) in the sample to (0, 0) and find that the running time is shortened, such as CPU utilization. 7. detectmultiscale () is used for detection, while the SVM classifier of XML is actually used for identification 8. A linear SVM detector must be constructed using detectmultiscale ().

I have been scratching my head for a problem over the past few days, so I am not in a mood for a few days. Today I want to understand something and remember it. I forgot it later.

The problem that has plagued me over the past few days is the hog. detectmultiscale () function.

I see some hog articles on the Internet from a complete image to detect the target object, a very Nb box, the box is so accurate, such as opencv comes with the sample: http://blog.csdn.net/sangni007/article/details/7453987

I am always envious! As a result, I tried it and it turned out to be a tragedy!

First, I used the previous hog + SVM method to train the classifier. During the training, the logo of the public and the negative samples were messy.

Http://blog.csdn.net/sangni007/article/details/7471222

Save the XML file,

Define a hogdescriptor hog1;

Hog1.load ("svm_data.xml ");

Hog1.detectmultiscale (IMG, found );

But it cannot be detected !!! It would have been because detectmultiscale () would not have been used, and it was difficult to use it later. This result has been bothering me, and I don't know whether it is not trained or the function is wrong ~ % >_< % ~

Today, I suddenly understood the problem:

The SVM classifier of XML that I train, that is,OutputOnly 1 and 0 (corresponding output result !!!), Only the public logo can be predicted, but the target cannot be detected because it is not a detector.

In fact, this is just a vague understanding. I hope to give some guidance to you ~~~

 

Comment summary:

1. The principle of the detector is actually to add a classifier to the sliding window.

2. the binary classifier outputs 0, 1. multiclass classification can be 0, 1, 2 ......; then the detector should be similar. It is also the first to create a model and determine whether it is 0, 1, or 2 in the search ...... A detector can be used to detect a target object in a large image. For example, to detect pedestrians in an image, DETECTOR ~ is required ~. Of course, you can use a sliding window and classifier to detect the target ~

3. I did this to detect other objects,
Hogdescriptor * hog = new hogdescriptor ();
Vector <float> * descriptors = new STD: vector <float> ();
Hog-> compute (imgt, * descriptors, size (8, 8); // imgt is the target to be detected
Hog-> setsvmdetector (* descriptors );
....
Hog-> detectmultiscale (IMG, found, 0, size (8, 8), size (32, 32), 1.05, 2 );
However, the final detection result is not accurate, and the imgt is extracted from the IMG. Now I don't know what's going on. Do you need multiple imgt when generating descriptors?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.