Ask Your Question
0

OpenCV_CreateSamples and Training can't read negatives.txt

asked 2016-04-20 07:51:10 -0500

Robb gravatar image

updated 2016-04-22 07:12:18 -0500

OS: WIN 64 (German verison) BUILD In 32

around 3229 positives, 3000 negatives, all pos. are 24x24, all neg. are of different, larger resolutions (640x480 and bigger)

It seems it can't open the negatives.txt i created.

positives.txt looks like:

./Pos/1006.jpg 1 0 0 24 24
./Pos/1007.jpg 1 0 0 24 24

negatives.txt (=neg.txt) looks like:

./negatives/3212.jpg 
./negatives/3213.jpg 
./negatives/3214.jpg

also tried it with full path and without the "./" (no difference and it works with the positives). Converting negatives.txt to Ansi or UTF-8 without BOM hasn't helped either.

If i understood it correctly, he should place images randomly into one of the background images i have in my negatives.txt.

./opencv_createsamples -info positives.txt -bg neg.txt -num 1000 -maxidev 100 -vec training.vec -show

only shows positives

./opencv_createsamples -img ./pos/1015.jpg -bg neg.txt -num 1000 -maxidev 100 -vec test.vec -show

shows nothing and

./opencv_createsamples -vec test.vec -show

crashes with

OpenCV Error: Assertion failed (elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1) in cvShowVecSamples, file E:\opencv_src\apps\createsamples\utility.cpp, line 1619

Also i tried to build a training.vec with the negatives just to see if it will show something there. Trying to have a look into it "-show" does not return anything. Creating samples with only positives works flawless but the training will crash with different errors and is way too fast.

/opencv_traincascade -data result -vec training.vec -bg neg.txt -numPos 900 -numNeg 2900 -numStages 4 -precalcValBufSize 2048 -precalcIdxBufSize 2048 -numThreads 3 -featureType LBP -w 24 -h 24 -minHitRate 0.99 -maxFalseAlarmRate 0.5

Examples

POS count : consumed   900 : 900
NEG count : acceptanceRatio    2900 : 1
Precalculation time: 1.077

+----+---------+---------+

|  N |    HR   |    FA   |

+----+---------+---------+

|   1|        1|        1|

+----+---------+---------+

|   2| 0.995556| 0.107586|

+----+---------+---------+


END>
Training until now has taken 0 days 0 hours 0 minutes 1 seconds.

===== TRAINING 1-stage =====
<BEGIN
POS count : consumed   900 : 904
NEG count : acceptanceRatio    2900 : 0.121905
Precalculation time: 1.084

+----+---------+---------+

|  N |    HR   |    FA   |

+----+---------+---------+

|   1|        1|        1|

+----+---------+---------+

|   2|        1|        1|

+----+---------+---------+

|   3| 0.994444| 0.113103|

+----+---------+---------+

END>

Training until now has taken 0 days 0 hours 0 minutes 3 seconds.

POS count : consumed   900 : 910
Train dataset for temp stage can not be filled. Branch training terminated.

When reducing minHitRate to 0.9:

POS count : consumed   300 : 320
NEG count : acceptanceRatio    9 : 0.05625
Required leaf false alarm rate achieved. Branch training terminated.
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-04-21 07:39:43 -0500

Robb gravatar image

Answer (will post it under it when I'am allowed)

I tried it also on another PC with Ubuntu same problem.

But i could solve it. I took the negative pictures from this Tutorial: http://note.sonots.com/SciSoftware/ha... They are all grey so i never thought this could be the problem. When i was desperate enough i simply did nearly all i did to my positives to my negatives ( all aside from reducing resolution) Converted all the allready gray negatives into grayscale solved the problem. (in folder : for i in *.jpg; do convert $i -colorspace gray $i; done)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-04-20 07:49:51 -0500

Seen: 245 times

Last updated: Apr 22 '16