opencv-haar-classifier-training icon indicating copy to clipboard operation
opencv-haar-classifier-training copied to clipboard

Can not see finished_classifier.xml file

Open lyhoangnam-archway opened this issue 7 years ago • 15 comments

Dear pro! I tried to convert a picture to an "image_learning.xml" file I cloned your project and do step by step, there was no error!

I got the results from "opencv-haar-classifier-training\classifier" folder There were 1 params.xml file and 9 stage.xml file

image

I wonder where is the finished_classifier.xml ?

Thanks for help!

Ly Hoang Nam

lyhoangnam-archway avatar Jan 21 '18 09:01 lyhoangnam-archway

hi man. what did you do to have vec files in perl bin/createsample.bin. i have try the code yet not creating any file in samples forlder

johnd3v avatar Jan 22 '18 07:01 johnd3v

Dear @johnd3v ! I do as the guide in this repository: Step 5

perl bin/createsamples.pl positives.txt negatives.txt samples 1500\
   "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1\
   -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40"

Which error occured with you?

lyhoangnam-archway avatar Jan 22 '18 07:01 lyhoangnam-archway

@lyhoangnam-archway thanks for the reply. i got only this sir. screenshot from 2018-01-22 18-32-32

no file created in sample folder

johnd3v avatar Jan 22 '18 10:01 johnd3v

Dear @johnd3v ! It did not throw any error, I think that all seem to be done Try next step(number 6). I think so!

lyhoangnam-archway avatar Jan 23 '18 01:01 lyhoangnam-archway

@lyhoangnam-archway thanks for the reply. i tried step6 yet this is the result.

badly need to create my own classifier for my last year research

johnd3v avatar Jan 23 '18 03:01 johnd3v

Dear @johnd3v ! Can you get your result? I still waiting for the author...he do not reply my question!

:( :( :(

lyhoangnam-archway avatar Jan 23 '18 03:01 lyhoangnam-archway

Dear @johnd3v ! naotoshio seo explained this mechanism in creating samples. how means, vector samples are images which include positives in negative background images. so, it all depends on your object how complex it is and whether +ve images needed more or -ve images needed more to generate the .vec files. i got this error many times while creating samples using createsamples.pl file at that time i change the ratio of +ves and -ves then it will work fine. and one noticeable point is here size also matters because if positive image is having more resolution than -ve image then it cant be impose its features on -ve background. so its good if all images having same size. but one thing disappointing me is i haven't get exact information on this! till searching for this..........

saideepthik avatar Feb 22 '18 06:02 saideepthik

@lyhoangnam-archway ! There were 1 params.xml file and 9 stage.xml file I wonder where is the finished_classifier.xml ? because classifier achieved the accuracy in training the .vec files at the stage of 9th. please look this image. classifier

f you want to convert an intermediate haartraining output dir tree data into a xml file, there is a software at the OpenCV/samples/c/convert_cascade.c (that is, in your installation directory). Compile it. how to compile ? -->> https://www.learnopencv.com/how-to-compile-opencv-sample-code/ so, you can create the cascade.xml file using this command $ convert_cascade --size="<sample_width>x<sampe_height>" <haartraining_ouput_dir> <ouput_file> example : convert_cascade --size="20x20" classifier haarcascade.xml

saideepthik avatar Feb 22 '18 08:02 saideepthik

Dear @saideepthik ! It means that I have to manually merge all stage.xml file to finished_classifier.xml I think that this tool will do all of this step...

lyhoangnam-archway avatar Feb 22 '18 08:02 lyhoangnam-archway

@lyhoangnam-archway "I have to manually merge all stage.xml file to finished_classifier.xml I think that this tool will do all of this step..." for this, actually say no need to do manually just give less number of stages while training or else give more positives and negatives do same from first step (delete .vec files in samples folder then do) you will get cascade.xml file

saideepthik avatar Feb 27 '18 10:02 saideepthik

@johnd3v I hope it's not too late. I had the same issue as you do. It was an OpenCV bug. I was working with a newer version of OpenCV (3.4.1). The code works when I use it with OpenCV version 3.2.0. No files were generated because a segmentation fault was thrown by opencv_createsamples. Hope this helps. The issue can be closed.

kapslocker avatar Apr 04 '18 03:04 kapslocker

i already run

perl bin/createsamples.pl positives.txt negatives.txt samples 1500
"opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1
-maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40"

but there is no sample.vec created, anyone can help me ?

arizalzr avatar Jun 03 '18 18:06 arizalzr

@saideepthik how to change the image ratio ? can you help my problem ?

arizalzr avatar Jun 03 '18 18:06 arizalzr

@arizalzr Ratio in the sense increase or decrease the number of input images (positive images and negative images) for the training. check while testing the image detection whether r u getting more false positives or not, if getting false positives means just take (save as images ) those false positives give as negative images and train the same. observable thing is sometime u need to give more appropriate positive images (depends on how complicated is your object to be detected) it will give good results. try u will get...........

saideepthik avatar Jun 04 '18 06:06 saideepthik

@saideepthik why after run this :

perl bin/createsamples.pl positives.txt negatives.txt samples 1500 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1
-maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40"

there is no sample.vec created ? can you help me to solve this ?

arizalzr avatar Jun 04 '18 07:06 arizalzr