Im am currently trying to train a HaarCascade classifier. I got to a point where the training process is working and I was able to train a at least "working" classifier. Which will detect a lot of correctly. Now I am trying to improve the results by adding more positive and negative samples.
As the classifier is working a lot of the time I decided to let it run over a testing dataset and crop out positively classified images. These cropped images were manually cleaned by me. I now want to add these new positive images to my training dataset.
After starting another training run I ran into the following error:
POS current samples: 166 POS current samples: 167 POS current samples: 168 POS OpenCV Error: Bad argument (Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file. ) in CvCascadeImageReader::PosReader::get, file D:\\cv\\opencv_3.2.0\\sources_withTextModule\\apps\\traincascade\\imagestorage.cpp, line 158
Includes all parameters of the opencv calls. I also shortened the paths to relative to improve readability.
**************************************************
*************** CREATING SAMPLES *****************
**************************************************
Object : project_name/trainingdata
Fixing file names in negative images folder.
Fixing file names in positive images folder.
Creating negative list project_name/trainingdata/neg.lst
Creating positive list project_name/trainingdata/pos.lst
Running : opencv_createsamples
Info file name: project_name\trainingdata\pos.lst
Img file name: (NULL)
Vec file name: project_name\trainingdata\pos_samples.vec
BG file name: (NULL)
Num: 319
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Show samples: FALSE
Width: 24
Height: 24
Max Scale: -1
Create training samples from images collection...
Done. Created 319 samples
**************************************************
************* TRAINING CLASSIFIER ****************
**************************************************
Running : opencv_traincascade
PARAMETERS:
cascadeDirName: project_name\trainingdata\classifier
vecFileName: project_name\trainingdata\pos_samples.vec
bgFileName: project_name\trainingdata\neg.lst
numPos: 319
numNeg: 1000
numStages: 16
precalcValBufSize[Mb] : 4096
precalcIdxBufSize[Mb] : 4096
acceptanceRatioBreakValue : -1
stageType: BOOST
featureType: HAAR
sampleWidth: 24
sampleHeight: 24
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC
Number of unique features given windowSize [24,24] : 162336
===== TRAINING 0-stage =====
<BEGIN
POS current samples: 1
POS current samples: 2
POS current samples: 3
(...) normal training log produced by opencv (stage0 works without any errors)
(...) then failing at stage1
POS current samples: 167
POS current samples: 168
POS
OpenCV Error: Bad argument (Can not get new positive sample. The most
possible reason is insufficient count of samples in given vec-file.
) in CvCascadeImageReader::PosReader::get, file
D:\cv\opencv_3.2.0\sources_withTextModule\apps\traincascade\imagestorage.cpp, line 158
As I this is my first time attempting this I am still experimenting a lot so there are a few things that could be going wrong but I am not really sure so I thought I might add these here to be confirmed by someone who knows this stuff.
1- You must use positive more than negative image! your positive images is less than negative images! 2- For avoid of this error use minHitRate= 0.999
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.