Ask Your Question

la lluvia's profile - activity

2015-04-24 13:20:04 -0600 received badge  Teacher (source)
2015-04-24 05:04:30 -0600 answered a question get images from opencv_createsamples, annotations, png files

You have to create your own training set (positive and negative(background) images). opencv_createsamples prepares your positive images for traincascade. If you want to detect cars in the images, you should crop N images of cars saved as .png or .jpg. And make a list of them and with opencv_createsamples make a .vec file which traincascade use. Negative (background) images are images that doesn't contain object you want to detect, in this case car. It can be anything you want (flowers, empty road, sky, wood, people...) but it's better if it was the environment you expect to find your cars (road, parking place...).

So to answer your questions:

  1. it's not used for creating positive samples. it's used to help your traincascade to learn what is not a car.

  2. background images are not used to create .vec file of positive images. Only positives images (images of cars) are needed.

  3. i not sure what are you trying to say here but negative images should be without object you are trying to detect.

  4. You have to create by your own positive and negative images and make a list of each in .txt file with correct path.

2015-04-24 02:05:24 -0600 answered a question opencv_createsamples correct parameters

I would consider making the ratio of positive and negatives 1:2. So if you have 8188 negative take approximately 4000 positive samples. Also you should consider this if you don't want your traincascade crashes. Some already used positive samples can be filtered by each previous stage (i.e. recognized as background) so if you put maximum of your positive sample and traincascade rejects some of them it can cause a crash. And also i think you have a lot of background in your positive samples, you should consider cropping the flowers from some of them. But it's just my opinion :)

2015-04-23 04:22:21 -0600 received badge  Necromancer (source)
2015-01-15 03:41:26 -0600 received badge  Enthusiast
2014-11-06 04:12:01 -0600 answered a question opencv_createsamples from image collections allowing create samples same count as positive images

It's because same positives are recognized as background, so your -numPos is smaller than 500. Refer to this answer, that should do it: http://answers.opencv.org/question/36250/why-does-opencv_traincacadeexe-crash/#36265

2014-11-01 11:32:14 -0600 commented answer BackgroundSubtractorMOG() with images not providing good results

You can try to filter it (change brightness) and then play with your variance for deciding what goes to background and what doesn't. I myself never tried it.

2014-10-31 08:38:00 -0600 answered a question BackgroundSubtractorMOG() with images not providing good results

BackGroundSubractor is usually used for video because it learns gradually through time what belongs to background and what doesn't. If you have few background images with different illumination than image on which you want to detect people, they will all belong to foreground when BackGroundSubractorMOG is run. You should have in mind that GMM Background Subractor is not illumination invariant. You could ran some background images just before new people show up, so you want have false alarms. Also keep in mind that BackGroundSubractorMOG needs some time to adopt background, you can manage it with learning ratio (Alpha):

static const int defaultHistory2 = 500;

Larger defaultHistory2 -> slower it updates to background. But i advise you to use set of images with difference not larger than few seconds, couse you will have a lot of noise in your foreground mask.

To sum it up:

  1. I wouldn't recommend it.
  2. Yes, you have to teach your BackGroundSubractorMOG what is background first.
  3. You can remember BackGroundSubractorMOG paramethers and run it again, but your foreground mask will be noisy and if illumination is different you could end up with lot of false alarms.
2014-08-26 05:26:05 -0600 commented question gradient of an image

Here is an example of Sobel operator which computes an approximation of the gradient of an image intensity function. http://docs.opencv.org/2.4.4/doc/tutorials/imgproc/imgtrans/sobel_derivatives/sobel_derivatives.html?highlight=sobel

2014-08-26 05:20:42 -0600 commented question Can you stop and continue Cascade training? (Probably LBP)

You can't stop training but you can quit training and start from the stage which finished last. Every stage when it finishes creates xml file which is loaded when you start again same cascade training.

2014-08-20 01:37:31 -0600 commented question opencv_traincascade.exe = Assertion Failed (s >= 0) Help?

Check size of your negatives, they have to be larger than h i w you specified.

2014-07-04 01:27:18 -0600 answered a question Why does opencv_traincacade.exe crash

Parameter -numPos is positive samples count that is used to train each stage in detector cascade. But some already used samples can be filtered by each previous stage (i.e. recognized as background), but no more than (1 - minHitRate) * numPos on each stage. So vec-file has to contain

= (numPos + (numStages-1) * (1 - minHitRate) * numPos) + S, where S is a count of samples from vec-file that can be recognized as background right away.

You have to calculate numPos for your training set, an example is given here: [http://stackoverflow.com/questions/10863560/haar-training-opencv-assertion-failed]

Hope it helps!

2014-07-02 04:02:33 -0600 received badge  Critic (source)
2014-06-10 09:20:48 -0600 commented answer Machine learning save/load problem

with front slashes works. my mistake. thanks

2014-06-10 06:22:40 -0600 commented answer Machine learning save/load problem

I've just solved the problem. Apparently in CvSVM::load function filename must be without path. So this was wrong:

mySVM1.load("C:\classifier.xml");

and changing it to this

mySVM1.load("classifier.xml"); works perfectly. I think this is a bug in OpenCV 2.4.4.0

2014-06-10 01:21:26 -0600 received badge  Editor (source)
2014-06-10 01:20:47 -0600 answered a question Machine learning save/load problem

Does anybody else have this problem? Wampir did you manage to fix it?

"Bad argument (The SVM should be trained first) in CvSVM::predict"

Steven, I've seen your post but it doesn't seems to be a problem.

I'm trying to load saved SVM classifier:

mySVM.save("C:\classifier.xml");

mySVM.load("C:\classifier.xml");

I saved it as .xml, file seems to be correctly saved. Thanks!

2014-03-06 03:13:50 -0600 received badge  Supporter (source)