OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Mon, 06 Aug 2012 04:52:29 -0500Improve Object Detection Qualityhttp://answers.opencv.org/question/1070/improve-object-detection-quality/I have a few basic questions regarding the object detection available on OpenCV.
1. I is said all over the internet that a good positive folder is a huge step of the traincascade process: good images may lead to good results. My question is: is there an optimal resolution this positive images should have?
2. About the negative folder, most times people say "random images not containing the object you want to recognize". Well, should i put images of other trained objects? Or should i put ridiculous images like forests and stuff? I'm a little lost regarding the contents of this folder..
3. When i create the vector, what importance has the size you pick? The bigger w and h parameters, the better? I doesn't really matter? I always put 32, but truth is i've tried with -w 50 -h 50 and it gave out a better result.
4. About groupRectangles(..) : what should the second and third arguments be? I guess if i use this function to try to reduce some redundant rectangles, i will DISABLE the possibility of identifying two of the same object on the same picture, right?Thu, 02 Aug 2012 08:50:43 -0500http://answers.opencv.org/question/1070/improve-object-detection-quality/Comment by sammy for <p>I have a few basic questions regarding the object detection available on OpenCV.</p>
<ol>
<li><p>I is said all over the internet that a good positive folder is a huge step of the traincascade process: good images may lead to good results. My question is: is there an optimal resolution this positive images should have?</p></li>
<li><p>About the negative folder, most times people say "random images not containing the object you want to recognize". Well, should i put images of other trained objects? Or should i put ridiculous images like forests and stuff? I'm a little lost regarding the contents of this folder..</p></li>
<li><p>When i create the vector, what importance has the size you pick? The bigger w and h parameters, the better? I doesn't really matter? I always put 32, but truth is i've tried with -w 50 -h 50 and it gave out a better result.</p></li>
<li><p>About groupRectangles(..) : what should the second and third arguments be? I guess if i use this function to try to reduce some redundant rectangles, i will DISABLE the possibility of identifying two of the same object on the same picture, right?</p></li>
</ol>
http://answers.opencv.org/question/1070/improve-object-detection-quality/?comment=1071#post-id-1071I know someone who spent half an year, full time, just optimizing all those parameters for a given detection task, by trial and error.Thu, 02 Aug 2012 09:05:40 -0500http://answers.opencv.org/question/1070/improve-object-detection-quality/?comment=1071#post-id-1071Comment by Bia6969 for <p>I have a few basic questions regarding the object detection available on OpenCV.</p>
<ol>
<li><p>I is said all over the internet that a good positive folder is a huge step of the traincascade process: good images may lead to good results. My question is: is there an optimal resolution this positive images should have?</p></li>
<li><p>About the negative folder, most times people say "random images not containing the object you want to recognize". Well, should i put images of other trained objects? Or should i put ridiculous images like forests and stuff? I'm a little lost regarding the contents of this folder..</p></li>
<li><p>When i create the vector, what importance has the size you pick? The bigger w and h parameters, the better? I doesn't really matter? I always put 32, but truth is i've tried with -w 50 -h 50 and it gave out a better result.</p></li>
<li><p>About groupRectangles(..) : what should the second and third arguments be? I guess if i use this function to try to reduce some redundant rectangles, i will DISABLE the possibility of identifying two of the same object on the same picture, right?</p></li>
</ol>
http://answers.opencv.org/question/1070/improve-object-detection-quality/?comment=1083#post-id-1083Well, that's motivating ;)Thu, 02 Aug 2012 10:33:25 -0500http://answers.opencv.org/question/1070/improve-object-detection-quality/?comment=1083#post-id-1083Answer by Kirill Kornyakov for <p>I have a few basic questions regarding the object detection available on OpenCV.</p>
<ol>
<li><p>I is said all over the internet that a good positive folder is a huge step of the traincascade process: good images may lead to good results. My question is: is there an optimal resolution this positive images should have?</p></li>
<li><p>About the negative folder, most times people say "random images not containing the object you want to recognize". Well, should i put images of other trained objects? Or should i put ridiculous images like forests and stuff? I'm a little lost regarding the contents of this folder..</p></li>
<li><p>When i create the vector, what importance has the size you pick? The bigger w and h parameters, the better? I doesn't really matter? I always put 32, but truth is i've tried with -w 50 -h 50 and it gave out a better result.</p></li>
<li><p>About groupRectangles(..) : what should the second and third arguments be? I guess if i use this function to try to reduce some redundant rectangles, i will DISABLE the possibility of identifying two of the same object on the same picture, right?</p></li>
</ol>
http://answers.opencv.org/question/1070/improve-object-detection-quality/?answer=1132#post-id-1132 1. Your questions #1 and #3 are related to each other. Resolution of positive samples should be just larger than w and h parameters during training. All your positives are simply resized to this resolution. "Good" positive doesn't mean good resolution. In fact you have to position every sample carefully. I think you know that traincascade is going to calculate some features, and this features have position within patch. That means that features of objects should be located in the same relative position within sample. For instance, for faces you can put a nose to the center. This is especially important for profile faces, because faces aligned to the right and to the left are *different* objects. To be more specific, they are the same shifted object which you can find with sliding window. So, you have to think on how you should crop your positive images. They are usually should be centered in uniform way. On other hand you have to allow some variation in the training set. So, the nose should float around the center, and faces should be rotated a little.
2. First of all you have to use all available negatives. And the idea to use other objects is good. Important aspect is to use many images with natural background for your objects. Human faces can be seen everywhere, but you should definitely have in-door images. For animals you need forests, deserts, etc. But do not limit yourself to natural backgrounds only.
3. The size is somehow related to the size of important features of your object. My opinion is that you should choose the smallest size while preserving all the important gradients of the object. If you use too large size, you use redundant information, this is like overfitting. For faces you need gradient between eyes and forehead, but the skin between eyes and eyebrows is usually not important. I think you understand what I mean. You should also keep in mind that your detector will not work on objects which are smaller than the discussed size, this is second reason why to keep it small.
4. Your statement about `groupRectangles` is generally not true. With reasonable `eps` the function groups only overlapped rectangles, and the algorithm is still able to return multiple objects. It is usually quite simple to find proper `eps` for your particular case.
So, the real secret is in getting and cropping your positives. For non-rigid objects you need thousands of them, and find a compromise between uniform positioning and adding some variance. For negatives use as much images as you have, but you may need a couple of thousands.Sat, 04 Aug 2012 02:11:26 -0500http://answers.opencv.org/question/1070/improve-object-detection-quality/?answer=1132#post-id-1132Comment by Bia6969 for <ol>
<li>Your questions #1 and #3 are related to each other. Resolution of positive samples should be just larger than w and h parameters during training. All your positives are simply resized to this resolution. "Good" positive doesn't mean good resolution. In fact you have to position every sample carefully. I think you know that traincascade is going to calculate some features, and this features have position within patch. That means that features of objects should be located in the same relative position within sample. For instance, for faces you can put a nose to the center. This is especially important for profile faces, because faces aligned to the right and to the left are <em>different</em> objects. To be more specific, they are the same shifted object which you can find with sliding window. So, you have to think on how you should crop your positive images. They are usually should be centered in uniform way. On other hand you have to allow some variation in the training set. So, the nose should float around the center, and faces should be rotated a little.</li>
<li>First of all you have to use all available negatives. And the idea to use other objects is good. Important aspect is to use many images with natural background for your objects. Human faces can be seen everywhere, but you should definitely have in-door images. For animals you need forests, deserts, etc. But do not limit yourself to natural backgrounds only.</li>
<li>The size is somehow related to the size of important features of your object. My opinion is that you should choose the smallest size while preserving all the important gradients of the object. If you use too large size, you use redundant information, this is like overfitting. For faces you need gradient between eyes and forehead, but the skin between eyes and eyebrows is usually not important. I think you understand what I mean. You should also keep in mind that your detector will not work on objects which are smaller than the discussed size, this is second reason why to keep it small.</li>
<li>Your statement about <code>groupRectangles</code> is generally not true. With reasonable <code>eps</code> the function groups only overlapped rectangles, and the algorithm is still able to return multiple objects. It is usually quite simple to find proper <code>eps</code> for your particular case.</li>
</ol>
<p>So, the real secret is in getting and cropping your positives. For non-rigid objects you need thousands of them, and find a compromise between uniform positioning and adding some variance. For negatives use as much images as you have, but you may need a couple of thousands.</p>
http://answers.opencv.org/question/1070/improve-object-detection-quality/?comment=1171#post-id-1171Thanks for you answer!!
I find really interesting there is a lot of information about detecting faces and people but when it comes to rigid objects, like the brand of a computer or a stapler, there is very few. (I mean online)
About the groupRectangles, i've given up on trying to use it, because i can't get it to detect more than one object at a time.
But thank you very much, anyway :)Mon, 06 Aug 2012 04:52:29 -0500http://answers.opencv.org/question/1070/improve-object-detection-quality/?comment=1171#post-id-1171