Search code examples
opencvobject-detectioncascade-classifierviola-jones

Can I use a .vec file with one positive image for OpenCV object detection if my object is standardized?


I'm building a classifier to detect an electrical outlet. Specifically the three holes of an outlet, like so:

electrical outlet

Do I need to do something more than create a .vec file with quite a bit of angle variation to generating positives using OpenCV's createsamples utility? It seems so because my object is standardized (except for potentially being darkly colored between the outlet holes).

I see many people provide an info.dat or similar file that contains paths to many positive images, including the number and location of the object-to-be-detected in the positive file. If I can avoid this extra work and still get excellent detection results, I would like to.

I do want to be able to detect different size outlets (i.e. from various distances) and from all detectable angles.

If there are ideal dimensions for this file before creating samples with it, that would be helpful too.


Solution

  • Turns out, I think the answer is no.

    I did not get good detection results until I created an annotations.txt file with OpenCV's opencv_annotation tool. I strongly recommend using the annotation tool and then creating a .vec file while passing the -info param, like so:

    opencv_createsamples -info annotations.txt ...

    If others find this question/answer and want more help I wrote up a tutorial on how to do this stuff. Hope it helps~

    http://johnallen.github.io/opencv-object-detection-tutorial/