Ask Your Question
0

[Solved] Ubuntu 14 opencv3.0.0 Training your own detector | packtpub.com error ...

asked 2017-07-11 13:30:32 -0600

gfx gravatar image

updated 2017-07-12 07:40:18 -0600

As a title, for first time in my life I try to use a cascade classifier ... first step: from mpg4 grab from camera, obtain 150 png image of my targhet ... well cropped, with my targhet oriented in different ways and with different type of light intensity .... In the same manner obtain 800 image of background ... then I try make all step of the tutorial for obtain my detector... but nothing: when use opencv_traincascade app I obtain only these error ->

Train dataset for temp stage can not be filled. Branch training terminated.
Cascade classifier can't be trained. Check the used training parameters.

So After some experiment, as suggest from here packpub tutorial I downloaded from here UIUCI DataCar the data folder, then:

  1. copy all pos image from download/CarData/TrainImages to /home/b/Scrivania/pos ..
  2. copy all neg image from download/CarData/TrainImages to /home/b/Scrivania/neg ..
  3. use "find" command to make /home/b/Scrivania/positives.txt file
  4. use "find" command to make /home/b/Scrivania/bg.txt file
  5. copy/paste/rename /home/b/Scrivania/positives.txt into /home/b/Scrivania/car.info & add " 1 0 0 100 40" after ".pgm"
  6. opencv_createsamples -info /home/b/Scrivania/cars.info -num 550 -w 48 -h 24 -vec /home/b/Scrivania/cars.vec
  7. verify the .vec file ... seems all ok ..
  8. opencv_traincascade -data /home/b/Scrivania/data -vec /home/b/Scrivania/cars.vec -bg /home/Scrivania/b/Scrivania/bg.txt -numStages 10 -nsplits 2 -minhitrate 0.999 -maxfalsealarm 0.5 -numPos 500 -numNeg 500 -w 48 -h 24
  9. obtain the error exactly as my image, folder and file ... the error :
  10. Train dataset for temp stage can not be filled. Branch training terminated. Cascade classifier can't be trained. Check the used training parameters.

At this point I hope that everything depends on the fact that the tutorial refers to opencv2.4 and I use opencv3.0.0 ... so what are the points I'm wrong??

regards gfx

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-12 07:34:24 -0600

gfx gravatar image

updated 2017-07-12 07:39:24 -0600

long story short .... as other similar thread on argument .... the file path was wrong ....

the path valid in every situation, TESTED ONLY ON UBUNTU (using gedit "classic" scheme colour+characters):

  1. /home/yourFolder/pos (folder of positives images)
  2. /home/yourFolder/neg (folder of negatives images)
  3. /home/yourFolder/positives.txt
  4. /home/yourFolder/cars.info
  5. /home/yourFolder/cars.vec
  6. /home/yourFolder/bg.txt
  7. /home/yourFolder/data (folder of result "xml" file)
  8. in my case: yourFolder = b/Scrivania

the erroneus PATH:

  1. inside positives.txt = pos/yourimage.png <--- these is right
  2. inside cars.info = pos/yourimage.png 1 0 0 100 40 <--- these is right
  3. inside bg.txt = neg/yourimage.png THESE IS ABSOLUTELY WRONG
  4. OTHER IS ALL RIGHT

THE RIGHT PATH INSIDE FILE:

  1. inside positives.txt = pos/yourimage.png <--- OK
    1. inside cars.info = pos/yourimage.png 1 0 0 100 40 <--- OK
    2. inside bg.txt = /home/yourFolder/neg/yourimage.png THESE RIGHT
    3. OTHER IS ALL RIGHT

so is possible to use the command as explain into tutorial and make the cascade ....

THE COMMAND:

  1. for make cars.info file:
    find /home/yourFolder/pos -name '*.pgm' -exec echo {} 1 0 0 100 40 \; > /home/yourFolder/cars.info
  2. for make bg.txt file:
    find /home/yourFolder/neg -iname '*.pgm' -exec echo {} \; > /home/yourFolder/bg.txt
  3. for make cars.vec:
    opencv_createsamples -info /home/yourFolder/pos/cars.info -numPos 550 -w 48 -h 24 -vec /home/yourFolder/cars.vec
  4. for traincascade:
    opencv_traincascade -data /home/yourFolder/data -vec /home/yourFolder/cars.vec -bg ~/home/yourFolder/bg.txt -numPos 500 -numNeg 500 -numStages 2 -w 48 -h 24 -featureType LBP

Problem Solved!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-07-11 13:30:32 -0600

Seen: 1,565 times

Last updated: Jul 12 '17