Ask Your Question
0

segmentation fault on traincascade

asked 2015-03-10 09:07:44 -0600

rafafirenze gravatar image

Hello.

I'm getting this weird error. I have 437 positive images and 3019 negative images.

The positive images all taken of 35x35 pixels.

This is the command that I use:

opencv_traincascade -data data -vec lv.vec -bg bg.txt -numPos 437 -numNeg 3019 -numStages 10 -w 35 -h 35

if I use -featureType LBP, it hangs on the 0-stage not calculating anything. If I remove it, this is what happens:

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   437 : 437
NEG count : acceptanceRatio    3019 : 1
Precalculation time: 3
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.988738|
+----+---------+---------+
|   4|        1| 0.998344|
+----+---------+---------+
|   5|        1| 0.998675|
+----+---------+---------+
Segmentation fault: 11

When I try to retry the process, I get:

PARAMETERS:
cascadeDirName: data
vecFileName: /Users/rafaelruizmunoz/Desktop/metal/lv.vec
bgFileName: bg.txt
numPos: 437
numNeg: 3019
numStages: 10
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: HAAR
sampleWidth: 35
sampleHeight: 35
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC

Stage 0 is loaded

===== TRAINING 1-stage =====
<BEGIN
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 get, file /Users/rafaelruizmunoz/Downloads/opencv/apps/traincascade/imagestorage.cpp, line 163
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/rafaelruizmunoz/Downloads/opencv/apps/traincascade/imagestorage.cpp:163: error: (-5) Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
 in function get

Abort trap: 6

Does anyone know what is happening?

Thank you in advance.

edit retag flag offensive close merge delete

Comments

Aren't there too few positives relative to the number of negatives?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-03-10 09:10:08 -0600 )edit

Hi @thdrksdfthmn , in my experience I've just used cascades downloaded from Internet... would you reccomend me a ratio of pos/neg ??

rafafirenze gravatar imagerafafirenze ( 2015-03-10 09:18:03 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-03-10 09:22:03 -0600

fedor gravatar image

updated 2015-03-10 09:23:03 -0600

Hi ! In error already writen the answer - " Can not get new positive sample " How you can read in the docs opencv_traincascade arguments numPos and numNeg is number of positive/negative samples used in training for every classifier stage. So if you have 437 positive samples put as numPos argument 437 / numStages.

edit flag offensive delete link more

Comments

Hello @fedor, thank you for your answer. I reduced the number to 315 and I did the -numPos / numStages, setting -numStages to 10. So the new command would be :

opencv_traincascade -data data -vec "/Users/rafaelruizmunoz/Desktop/metal/lv.vec" -bg bg.txt -numPos 31 -numNeg 3019 -numStages 10 -w 35 -h 35

But I got Segmentation fault again.

rafafirenze gravatar imagerafafirenze ( 2015-03-10 09:58:14 -0600 )edit

I've tried to make a -numNeg lower as well

rafafirenze gravatar imagerafafirenze ( 2015-03-10 10:04:47 -0600 )edit

numNeg must be around 300 . If you will have errors with numNeg = 300 then write full error, like you did before :)

fedor gravatar imagefedor ( 2015-03-10 10:12:41 -0600 )edit

Sorry, doesn't change very much:

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   43 : 43
NEG count : acceptanceRatio    300 : 1
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1| 0.833333|
+----+---------+---------+
|   3|        1| 0.726667|
+----+---------+---------+
|   4|        1|     0.78|
+----+---------+---------+
Segmentation fault: 11
rafafirenze gravatar imagerafafirenze ( 2015-03-10 10:20:23 -0600 )edit

hmm, yes, not very informative

maybe, if you "try to retry the process" you will get more informative error

fedor gravatar imagefedor ( 2015-03-10 18:00:00 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-03-10 09:07:44 -0600

Seen: 1,590 times

Last updated: Mar 10 '15