Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV haar training for static image

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?

like image 922
Dmitriy Kudinov Avatar asked Nov 07 '10 17:11

Dmitriy Kudinov


3 Answers

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

like image 150
George Profenza Avatar answered Oct 04 '22 06:10

George Profenza


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

like image 26
amit Avatar answered Oct 04 '22 07:10

amit


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.

like image 21
Neon22 Avatar answered Oct 04 '22 05:10

Neon22