Question

I trying to train haar cascade classificator for card suite detection (which no rotation and has no distortion on image)

For example I have file Clubs.png which contents clubs image on white background 20x20 pixels

This tutorial is so tangled http://note.sonots.com/SciSoftware/haartraining.html

My image varies only in sizes, no distortion or angling.

Which commands I must enter in aim to get Clubs.xml file?

Was it helpful?

Solution

As @Neon22 mentioned, great tutorial. From my experience, it's quite a lengthy process(collecting positive and negative samples, training, generating haar cascade), but then again maybe I was doing it wrong.

For detecting cards, it might be useful to have a look at OpenCV SURF as well.

OpenCV SURF

Check out toxi's video.

Funny you mention cards, Eugene Zatepyakin did an actionscript port called ASSURF:

ASSURF cards

OTHER TIPS

If you are interested in making your xml file then this may help http://nayakamitarup.blogspot.in/2011/07/how-to-make-your-own-haar-trained-xml.html

But if you are interested in making it rotation invariant, then surf seems like a better option. http://nayakamitarup.blogspot.in/2011/06/2d-ar-using-surf-based-application-of.html

Try this tutorial instead. http://cgi.cse.unsw.edu.au/~cs4411/wiki/index.php?title=OpenCV_Guide

but the tutorial you identify is quite good. I used it to get my haar classifier sorted out. The facedetect sample code included in opencv 2.1 distribution is a good example for checking the resulting xml file. (I use python)

I found several problems with the supplied help applicatoins. 1. createsamples will not read a description file with more than 8 samples from the same image - manually break your relationship file up into several lines with no more than 8 rectangles per image.

The haar training would not continue if my .vec file was made with images of width and height > 24 pixels

Main issue with haar appears to be that it is not invariant to scale and you need thousands of test images - which is what the createsamples program will help you to do with single images but will not if you have a description file of individual sample images. Hence the tutorials extra code to allow createsamples to be called many times and for the resulting vec files to be merged into a single super vec file.

You can refer :
http://opencv-hub.blogspot.in/2016/03/how-to-train-your-own-opencv-haar-classifier-haar-training-train-cascade.html
for making your own haar-cascade xml file.
This OpenCV Tutorial is on C++ where in they have mentioned in detail the methods of Haar Training.Also Note that Haar is not rotation invariant.
Thus as soon as you rotate the image, it wont get detected.
You need to use SURF for that purpose.
But Object detection through Haar is much faster than that of SURF. If you want to learn how to use the trained Haar Cascade File you can refer:
http://opencv-hub.blogspot.in/2016/03/how-to-do-real-time-face-detection-using-haar-cascade.html
The Code of real time face detection would be analogous to that of real time object detection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top