Ask Your Question

lee7ster's profile - activity

2017-06-23 06:16:35 -0600 received badge  Popular Question (source)
2016-04-18 16:26:02 -0600 received badge  Popular Question (source)
2013-05-08 12:37:21 -0600 commented answer correct parameters for createsamples and traincascade

Thanks for your response -- I have also tried taking ~1000 positive images of the baby (samples of some images here : Is there any reason it would do the same thing even with gathering many images of both positives/negatives?

2013-05-05 21:52:23 -0600 asked a question correct parameters for createsamples and traincascade

I am currently using opencv_createsamples and opencv_traincascade to create an xml file and run it on the android platform (using opencv-facedetection sample)

I just wanted to make sure I was using the right image sizes and parameters etc;

1) For createsamples I have a positive image of a baby with a black background called "IMG1.png"

I have another file called bg.dat that holds paths like img2/file1.jpg, im2/file2.jpg, etc The background jpg's are all 352x288

IMG1.png is an image of size 2400 1500, about which 90% w/h is the baby and the rest is a black Background.

I then call the command; -img IMG1.png -num 1000 -bg bg.dat -vec samples.vec -maxxangle 0.6 -maxzangle 0.3 -maxidev 30 -bgcolor 0 -bgthresh 10 -w 26 -h 22

to create samples.vec

2) After that, using the same images as img2/file.jpg with the same file names as bg.dat called "negatives.dat" and run the command;

-data cascade -vec samples.vec -bg negatives.dat -numPos 900 -numNeg 900 -numStages 20 -featureType LBP -w 26 -h 22 -minHitRate 0.999 -maxfalsealarm 0.5 -precalcValBufSize 2048 -precalcIdxBufSize 2048

The background images are again 352.x288 in original size.

Does anyone know if this would cause any inconsistancies? (Such as jpg vs png, size compression etc). When I traverse the sample.vec the quality all seem very low since it is 26x22. I am getting a lot of false positives from my training which is why I wanted to confirm these formats/sizes all line up ... thanks!

2013-05-02 05:33:07 -0600 received badge  Student (source)
2013-05-01 16:32:03 -0600 received badge  Editor (source)
2013-05-01 16:31:34 -0600 asked a question OpenCV_traincascade giving a lot of false positives

I am currently trying to use openCV's haartraining and traincascade to recognize babies in a box (or even babies) in a maze. For some reason I am getting a lot of false positives in the negatives (pictures of the maze without babies/box).

I have tried the following;

1) 1000 + positives images, 500+ negative images and use it as a batch.

2) give 1 cropped image with black background (bgcolor 0, bgtresh > 0) for transparent background, then ask OpenCV haartraining to apply transformations, 500 positive, 500 negative. The command I used to create the transformations was; -img IMG01.jpg -num 500 -bg negatives.dat -vec samples.vec -maxxangle 0.6 -maxzangle 0.3 -maxidev 30 -bgcolor 0 -bgthresh 10 -w 26 -h 22

3) I cropped 500 images of just the baby at different angles from the positive samples, but I think this approach may be flawed. It was just an alternative I tried since documentation was just a bit ambiguous.

Given a sample vector file, which I looked at to make sure was good using command -vec samples.vec, I used the following command to compile the xml file, which took a few hours on average! ... -data cascade -vec samples.vec -bg negatives.dat -numPos 500 (or 1000 for manual positive pictures I took) -numNeg 533 -numStages 20 -featureType LBP -w 26 -h 22 -minHitRate 0.999 -maxfalsealarm 0.5 -precalcValBufSize 2048 -precalcIdxBufSize 2048

I make sure the files give out reasonable sizes and the training takes a few hours, so I think it is set up correctly but is learning incorrectly somhow!

all images pre-processing was 352x288

It is weird that both trainings, and various others, resulted in a lot of false positives. Discussion with my professor lead us to believe it was for some reason recognizing lines as positives (which would explain why it is giving false positives).

Here are some samples of my positives;

Here are some samples of my negatives;

Image Hosted by
Image Hosted by

Here is the one picture that I used to transform:

Image Hosted by

I will continue to work towards getting the false positives to not recognize, but any help or suggestions from more experienced OpenCV users would be greatly appreciated! I am also just copy-pasting the xml into the android face-recognition sample and running it on my android phone if anything could possibly get broken on that end too!