Ask Your Question
0

Picture and Samples Sizes opencv_traincascade

asked 2016-10-26 11:27:08 -0600

DerrickB gravatar image

Hello OpenCV Community,

i know there are millions Questions and Answers to the topic opencv_traincascade and i read and searched as much as i could. But i am still not sure about this, so I would like to ask this specific question.

Topic Background:

I try to train a Person Recognition based on den cv::CascadeClassifier in a specific environment.

I have 4000 positives samples of a person in the Format 48x96. (the Picture is just the Person)

I have 200 negative samples of the environment in a big Format (e.g. 480x270)

Questions:

  1. Do i need to cut the negative Samples in many, many small Pictures with 48x96 or is opencv_traincascade.exe doing this by itself?

  2. My info.txt looks like this: "rawdata/img1 1 0 0 48 96" Is this correct when the whole picture is a person?

  3. The arguments "-w" "-h" in opencv_createsamples.exe and opencv_traincascade.exe have to be 48x96?

  4. The arguments "-numPos" "-numNeg" in opencv_createsamples.exe and opencv_traincascade.exe have to be the Amount of Pictures i have? Or the Amount the program will create from the few i have?

I hope the Questions are understandable. I am still new to OpenCV. Thank you very much,

Kind regards, Derrick

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-10-26 12:09:03 -0600

berak gravatar image

updated 2016-10-28 04:51:23 -0600

let's go down your list:

1: no, it will try to make as many negative samples as it can from that, based on a sliding window using your positive size, moving sequentially AND multiscale (fixed scale step to differentiate enough) over your input image.

(just know, that it's a bad idea to feed 20 10k negative imgs showing plant leaves, while you're trying to pick a car on a street, -- choose wisely here.) Agreed to this, make sure your negative dataset is representative to your problem or be prepared to collect millions of samples...

2: yes, correct , if your positive images actually are that way.

3: yes. (well, let's say "same" for both, whatever your window-size is)

4: that's kinda complicated. since the "boosting" part of the training algo will shuffle some of your "positives" to the "negative" side -- allow some space there, (e.g., have 20% more actual positives in your vec file, than given to "-numPositives"

28/10/2016 StevenPuttemans: added updates inside the text ;)

edit flag offensive delete link more

Comments

1

@StevenPuttemans - please cross-check.

berak gravatar imageberak ( 2016-10-26 12:15:14 -0600 )edit

Thank you very much for the fast and clear answer @berak !

DerrickB gravatar imageDerrickB ( 2016-10-26 13:04:51 -0600 )edit

I tried it like this with just a few sample but it needs very long to calculate (about 25min to this point):

===== TRAINING 0-stage =====

<begin< p="">

POS count : consumed 200 : 200

NEG count : acceptanceRatio 400 : 1

Precalculation time: 9.345

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

| N | HR | FA |

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

| 1| 1| 1|

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

| 2| 1| 1|

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

| 3| 1| 1|

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

DerrickB gravatar imageDerrickB ( 2016-10-26 13:08:50 -0600 )edit

Do you have any Idea where the Problem is??? It has to be the Format, when i try it with 20x20 its very fast

PARAMETERS:

cascadeDirName: cascades

vecFileName: vector/posvector.vec

bgFileName: bg.txt

numPos: 200

numNeg: 400

numStages: 15

precalcValBufSize[Mb] : 1024

precalcIdxBufSize[Mb] : 1024

acceptanceRatioBreakValue : -1

stageType: BOOST

featureType: HAAR

sampleWidth: 48

sampleHeight: 96

boostType: GAB

minHitRate: 0.995

maxFalseAlarmRate: 0.5

weightTrimRate: 0.95

maxDepth: 1

maxWeakCount: 100

mode: BASIC

Number of unique features given windowSize [48,96] : 10256640

DerrickB gravatar imageDerrickB ( 2016-10-26 13:11:07 -0600 )edit

The fact that it sticks at 1 1 for a long time means your data is inseparable... but that seems weird. Can you add samples of your data?

StevenPuttemans gravatar imageStevenPuttemans ( 2016-10-28 04:52:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-10-26 11:25:34 -0600

Seen: 662 times

Last updated: Oct 28 '16