Correct Image Preparation for haartraining

asked 2013-10-30 04:08:13 -0600

mswcpt gravatar image

The following method has been used to attempt to train a classifier to detect fingers:

  1. Film several hands with fingers open for about 20-30 seconds each at 30 FPS.
  2. Extract the positive images into set of +/- 3000 bmp images all same size.
  3. Using bounding box method, create a description file of the positive image sets by selecting a finger to be bound and setting that data to the positive.txt description file.
  4. Film several scenes/objects that do not contain the object to be detected for negative image sets.
  5. Extract the negative images into set of +/- 2000 bmp images all same size.
  6. List the files in a txt description file (ls > negative.txt)
  7. Pack 3 & 6 into .vec file using opencv_createsamples.
  8. Begin training classifier.

I have found that this is not accurate.

Is there perhaps a different method of image preparation: - more films? - hundreds of different fingers? - a new bounding box for each finger on a different hand?

Is there something I'm not doing? What is opinion from experts in positive image preparation to get best result?

Thanks.

edit retag flag offensive close merge delete

Comments

Step 7, the vector element is only created with the positive images, not with the negative set. Start by removing those.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-10-30 04:42:30 -0600 )edit

How is your positive.txt structured?

It has to have information not only about the dirs of the positive images, as well as the how many positives each image has and the bounding box that has them.

If you only have 1 object per image they should look as following

path/pos_img_001 1 0 0 width height and so on. Check this tutorial http://achuwilson.wordpress.com/2011/07/01/create-your-own-haar-classifier-for-detecting-objects-in-opencv/?blogsub=confirming#subscribe-blog

Pedro Batista gravatar imagePedro Batista ( 2013-10-30 05:34:07 -0600 )edit

It is structured like this:

pos0001.BMP 1 429 41 82 247

pos0002.BMP 1 438 42 71 242

pos0003.BMP 1 426 43 83 237

pos0004.BMP 1 435 46 70 229

Does that look correct?

Re: Blog - I have seen that blog and got the code from there initially which worked fine to create the bounding box executable. Thanks.

I will try removing the -ve description file from the input parameter in opencv_createsamples stage and then see what happens - will revert.

mswcpt gravatar imagemswcpt ( 2013-10-31 00:47:57 -0600 )edit

BTW that list is annotated vertically in the positive.txt file - not horizontal as it is coming out in the comment

mswcpt gravatar imagemswcpt ( 2013-10-31 00:51:44 -0600 )edit

Hi - OK - I removed the negative description file from the create samples stage and then did another training session. It went very quickly and the result is even worse - no detection at all. Here is link to terminal output: https://www.dropbox.com/s/6hkz6fzja3g2lcn/Traininattempt.rtf Please let me know if you see anything strange? If not, perhaps you can assist by telling me a better way to prepare images that I may not be aware of. Thanks in advance.

mswcpt gravatar imagemswcpt ( 2013-11-01 01:38:38 -0600 )edit