Ask Your Question
-1

How to create our own Haarcascade.xml.

asked Jul 26 '14

Punith K gravatar image

updated Dec 6 '0

How to create an haar classifier, by using some set of images/trainig set.

Preview: (hide)

Comments

1
2
1

I do appreciate people helping out BUT PLEASE put in some effort and use the search functionality... this been asked a million times before. Therefore my -1...

StevenPuttemans gravatar imageStevenPuttemans (Jul 26 '14)edit
1

That is a truly apt statement Steven. Even a simple google search will pop out all solutions from our forum.

Thank you guys for your answers. After searching all possibilities for creating haar classifier in Ubuntu 14.04 and in windows, there were no proper solution given, i have seen so many people posting their comment saying there are lot of errors. I want at least bug free tutorials to create my Haarcascade.

Punith K gravatar imagePunith K (Jul 30 '14)edit

Hi, @abhishek Kumar, I refered your opencv-haar-training from your answer, I found the following error while merging it,

./mergevec samples.txt samples.vec OpenCV Error: Assertion failed (elements_read == 1) in icvGetHaarTraininDataFromVecCallback, file cvhaartraining.cpp, line 1859 terminate called after throwing an instance of 'cv::Exception' what(): cvhaartraining.cpp:1859: error: (-215) elements_read == 1 in function icvGetHaarTraininDataFromVecCallback

Aborted (core dumped)

Punith K gravatar imagePunith K (Jul 30 '14)edit
1

I do not know where people get the idea that you need the mergetool. It is not standard openCV functionality but something built by a third person. The official train cascade tutorial has every single information you need! And it works perfectly here on Ubuntu 14.04 AND Windows 7 / 8.1. I am making a step by step tutorial for my project finals, will create a link to it once it is ready!

StevenPuttemans gravatar imageStevenPuttemans (Jul 30 '14)edit

@steven ..... The merge is being used so that greater number of samples can be prepared. The opencv_createsamples function when applied on a set of images provides only the same number of samples as the number of images in the training. But when applied on single image multiple samples can be generated. So I have created a perl file that takes images one by one and then applies the create samples function. And the merging code to pass on every vec file to a single one.

1

Which is actually the WORST way for creating a cascade model. Everyone with actual applications will tell you that a model cannot be build by using the artificial example generation of the createsamples utility. It will create a terrible set of unnatural training samples which results in a model trying to capture stuff that can never happen in real life situations. I always suggest people to move on from that documented approach and just put effort in gathering training sets with actual data. State-of-the-art detection algorithms avoid these artificial translations rotations and so on at all costs!

StevenPuttemans gravatar imageStevenPuttemans (Jul 31 '14)edit

I think that is indeed a good idea. The merging functionality comes from the time that haartraining utility was used. I am sure that if you know exactly what you doing, it can still be usefull in some cases BUT people are using it for the wrong reasons.

StevenPuttemans gravatar imageStevenPuttemans (Jul 31 '14)edit

1 answer

Sort by » oldest newest most voted
0

answered Jul 31 '14

@steven will consider your comment and will update my tutorial on haar-cascades :)

Preview: (hide)

Question Tools

Stats

Asked: Jul 26 '14

Seen: 3,473 times

Last updated: Jul 26 '14