mrnugget / opencv-haar-classifier-training

Learn how to train your own OpenCV Haar classifier
Other
735 stars 470 forks source link

I got Error during training : Bad argument #23

Closed ktkathi closed 8 years ago

ktkathi commented 8 years ago

Hello mrnugget I use this command for haar training : opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt -numStages 15 -minHitRate 0.995 -maxFalseAlarmRate 0.5 -numPos 700 -numNeg 301 -w 200 -h 100 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024 -featureType LBP

and i got this error:

 ===== TRAINING 0-stage =====
<BEGIN
POS current samples: OpenCV Error: Bad argument (Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
) in get, file /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/apps/traincascade/imagestorage.cpp, line 162
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/apps/traincascade/imagestorage.cpp:162: error: (-5) Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
 in function get

Aborted (core dumped)524

Please advice. Thank you.

mrnugget commented 8 years ago

So how about "Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file."? Do you have enough samples?

ktkathi commented 8 years ago

I have positive image : 500 sample negative image : 500 sample (size of file: w 200 h 100, file type: png)

and i create sample with this command : perl bin/createsamples.pl positives.txt negatives.txt samples 500 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 200 -h 100"

after i use this command for training: opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt -numStages 15 -minHitRate 0.995 -maxFalseAlarmRate 0.5 -numPos 500 -numNeg 500 -w 200 -h 100 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024 -featureType LBP

what wrong parameter that i used it?

Please advice. Thank you.

mrnugget commented 8 years ago

I can't spot something that's obviously wrong. Are you using OpenCV 2.4.9?

ktkathi commented 8 years ago

I try again but it's work no error. What happen? That's true?(see in picture) capture

mrnugget commented 8 years ago

No idea :)

On Mon, 14 Nov 2016 at 11:23, ktkathi notifications@github.com wrote:

I try again but it's work no error. What happen? That's true?(see in picture) [image: capture] https://cloud.githubusercontent.com/assets/3676454/20261092/fb0a3f9e-aa8e-11e6-82b8-8c9a5ef384b6.PNG

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/mrnugget/opencv-haar-classifier-training/issues/23#issuecomment-260299148, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIV5RxXDllUVfxFK9DcZQegof31o-Ydks5q-DaogaJpZM4KxHI3 .

ktkathi commented 8 years ago

Hello Mr.Nugget I'm Finish trained 15 stage and then i follow your description to generate xml file. After i run this command : ./facedetect --cascade="~/finished_classifier.xml"

the result is

image

is right? where finished_classifier.xml?

and i see in path opencv-haar-classifier-training-master/classifier , i found cascade.xml , params.xml and all stage.xml file. Is this true result?

What file that i use to my android application?

please advice me, Thank you so much.

mrnugget commented 8 years ago

Use the path to casecade.xml instead of the ~/finished_classifier.xml, which is just a placeholder.

ktkathi commented 8 years ago

Thanks a lot ;-)

mrnugget commented 8 years ago

Glad it worked!