I\'m building the opencv_traincascade.exe tool from source code (OpenCV 2.4.0) using vs2010 on windows 7. I want to train a LBP classifier, so I\'m using opencv_traincascade
As to me(ubuntu16) it is file path issue.Below is my file structure.
xy@xy:~/face_sample/face_csdn$ ll
total 7144
drwx------ 5 xy xy 4096 Jun 6 17:58 ./
drwxrwxr-x 3 xy xy 4096 Jun 5 19:03 ../
drwx------ 2 xy xy 376832 Jun 6 17:50 negdata/
drwx------ 2 xy xy 516096 Jun 6 17:11 posdata/
-rw-rw-r-- 1 xy xy 6408012 Jun 6 17:15 pos.vec
drwxrwxr-x 2 xy xy 4096 Jun 6 17:54 xml/
posdata
is my positive image dir which contains pathpos.txt(image absolute path)
xy@xy:~/face_sample/face_csdn$ ll -th posdata/ | head - 5
==> standard input <==
total 75M
drwx------ 5 xy xy 4.0K Jun 6 17:58 ../
drwx------ 2 xy xy 504K Jun 6 17:11 ./
-rw-rw-r-- 1 xy xy 1.1M Jun 6 17:11 pathpos.txt
-rw-rw-r-- 1 xy xy 938 Mar 24 2014 18540.jpg
-rw-rw-r-- 1 xy xy 919 Mar 24 2014 18541.jpg
-rw-rw-r-- 1 xy xy 922 Mar 24 2014 18542.jpg
-rw-rw-r-- 1 xy xy 931 Mar 24 2014 18543.jpg
Ao to pathpos.txt
I use absolute path of the image
xy@xy:~/face_sample/face_csdn$ head -5 posdata/pathpos.txt
/home/xy/face_sample/face_csdn/posdata/10000.jpg 1 0 0 20 20
/home/xy/face_sample/face_csdn/posdata/10001.jpg 1 0 0 20 20
/home/xy/face_sample/face_csdn/posdata/10002.jpg 1 0 0 20 20
/home/xy/face_sample/face_csdn/posdata/10003.jpg 1 0 0 20 20
/home/xy/face_sample/face_csdn/posdata/10004.jpg 1 0 0 20 20
Go back to parent dir, and have a look of negative txt file(negative image path)
Then have a train:
The above is just show how to use opencv_traincascade to train.
I also encounter the above problem mainly about image path.
I’ve had this issue several times, and it ended up being caused by me generating my .vec
file with the wrong dimensions specified for my positive images.
For example, I had 700 positive images that were 100×100 pixels, and I successfully generated my .vec
with them. So my text file looked like this:
/filepath/directory/image1.jpg 1 0 0 100 100
/filepath/directory/image2.jpg 1 0 0 100 100
…
But then when I tried to train my cascade HAAR file, the images were too big. So I resized them to 50×50, and recreated my .vec
(specifying in the command line the new size) with the downsized images.
The .vec
supposedly successfully created, but when I then try to train, I get the error. Once I recreated my text file with the correct dimensions, recreated my .vec
file, and tried to train again, the error went away. The other issue I've had is when the negatives file has errors in it, like a bad path or some other issue; all the other comments have good suggestions for figuring out what might be wrong with the -bg file too. Hope this helps.
I am also learning how to use OpenCV object detection tools.
I noticed that if the bg file (in your case "D:\OpenCV\Classifiers\lbpclassifier1\temp\negative\infofile.txt") has a wrong format or contains a entry with non-existent file, opencv_traincascade produces error.
Hope it helps.
i also have this problem before. but after i reduce the param [maxFalseAlarmRate] ,like set small than 0.1 , it works ok. hope this have some help.