Ask Your Question
2

How to train cascade classifier

asked 2012-07-03 13:13:18 -0600

KDS gravatar image

updated 2012-08-09 01:48:58 -0600

Kirill Kornyakov gravatar image

Hello,

I am having trouble implementing the HaarDetectObjects function (using OpenCV / Python). The script attempts to identify electronic components (resistors, capacitors, etc.) on a PCB. I have created a large bank of positive and negative images to use for the Haar Training, but am unsure how to go about taking the list of images and generating the cascade XML file. Following some information found online, I have created two text files listing the positive and negative images. My understanding is that these files will then be used by the program located at opencv\samples\c\convert_cascade, which will need to be compiled. However, I have been unable to compile the necessary files to be able to run convert_cascade.

If anyone has generated a custom cascade and knows what I might be doing wrong, please let me know. I greatly appreciate your help and thank you in advance for your time. If any more information would be helpful, please let me know.

In summary, I am at a loss for how to generate a cascade XML file.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
6

answered 2012-07-04 08:41:00 -0600

rantanplan gravatar image

updated 2012-10-02 05:58:26 -0600

V.G. gravatar image

Hi KDS,
you have to create a .vec file from your positives file using the opencv_createsamples tool, e.g.

opencv_createsamples -info positives.dat -num 1000 -vec positives.vec -w 24 -h 24

This would create a positives.vec file from 1000 positve samples listed in positives.dat. The sample width and height are 24. This .vec file is than passed to opencv_traincascade for training. For the negatives you just pass a file containing the file names of your negative samples. For further informations i found this, that, and that good resources. But you've probably found them already...

To create the opencv_createsamples tool you should configure OpenCV with BUILD_EXAMPLES=ON (i think).

edit flag offensive delete link more

Comments

Thank you, very much. I greatly appreciate your help. I just realized that I had not thanked you for your answer - sorry for the delay. Regards, KDS

KDS gravatar imageKDS ( 2012-08-07 10:39:35 -0600 )edit
1

KDS, the good way to thank for an answer is by marking it as the correct answer :). Only you as owner of the question can do that.

Michael Burdinov gravatar imageMichael Burdinov ( 2012-08-09 02:00:25 -0600 )edit

Can someone describe what the "mergevec" function actually does? it seems that for every positive sample, it generates a *.vec file. But then we still need to merge them? I'm at a loss on this merging process. Thanks

Trak888 gravatar imageTrak888 ( 2014-02-20 22:21:53 -0600 )edit

mergevec is not something officially and will merge vectors of images.

Use case: opencv_createsamples without the -info will create variations of your image (read docu one that) and place them into specified vector file

Example: opencv_createsamples was used to create a vector for image A variations opencv_createsamples was used to create a vector for image B variations Now you want to combine these vector into one - you would use mergevec.

The alternative is to create no variation of the images but specify the -info argument with a list of images and the location of the object to find.

About how good it is to create mutation of the orignal image - see that discussion here http://answers.opencv.org/question/55....

holger gravatar imageholger ( 2018-04-27 08:27:37 -0600 )edit
0

answered 2018-08-18 02:21:08 -0600

Hi, i found the HaarCascade Trainer GUI Version. So, you can train them easily.

HaarCascade Trainer GUI Version

Why do you use HaarCascade Algorithm ? I think you can use Tensorflow API

Tensorflow API

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-07-03 13:13:18 -0600

Seen: 3,996 times

Last updated: Aug 18 '18