Ask Your Question
0

cascade classifier takes hours in testing one image

asked 2016-05-18 01:39:48 -0600

Pulkit gravatar image

I am trying to train a cascade classifier with matlab and c++. I am trying to detect optic disc in retinal fundus images. number for positive samples i have used are around 12000(after flipping) and negative samples are 10000. Max hit rate is 0.995 and false alarm rate is 0.1. I trained a classifier using matlab for 40 stages using haar and one with hog features. Testin for one image takes hours and returns very bad results. if anyone can tell me what i am doing wrong it would be very help full. Even if i reduce the number of stages to 20 it still takes hours to test.

PS:- Dimensions of positive and negative images is roughy around 800x1200. C++ classifier is not yet trained.Its been 15 days. May be i will get results from c++ when hell freezes over.

Thanks.

edit retag flag offensive close merge delete

Comments

Hi Pulkit,

I am using cascade classifiers for the same application only difference being I am doing it in real time at 30fps in fundus and OCT both. i would suggest down-sampling the image. Optic Disc is a very prominent feature and there is no need to use such high resolution. Also train your classifier on floaters, glare, shadows from eye lashes, etc to improve accuracy. I would suggest you to time your stages of down-sampling, feature extraction and prediction individually. I assume feature extraction is taking most of the time in your case.

FYI: I am getting 5ms prediction time per image after optimizing all of my stages.

ocean0074 gravatar imageocean0074 ( 2018-12-10 15:45:21 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-05-18 02:19:36 -0600

LorenaGdL gravatar image

updated 2016-05-18 03:17:34 -0600

  1. I trained a classifier using matlab - I'm afraid this is not the place to ask then, but...
  2. Dimensions of positive and negative images is roughly around 800x1200 - that's a lot. You're forcing you're detection window to be of such size, so your test images should be much larger than that (yo apply a proper multiscale sliding window). Do you really need such resolution?
  3. You're using 40 stages, and with a false alarm rate = 0.1, I bet every stage has a quasi-infinite number of features to test. Given that, and that you're using Matlab, well, I'm not too surprised of it being so slow.
  4. You should take a look at other informative posts in the forum from @StevenPuttemans with helpful advice, as the pos:neg sample ratio

Extra information added by @StevenPuttemans

  1. Like @LorenaGdL states, if you trained your model using matlab, you are at the wrong address here. You will need to ask help on it on the Matlab central then. We cannot guarantee that models trained by the matlab interface are 100% compatible with current OpenCV implementation.
  2. Can you supply your training parameters? Without it is kind of useless for us to start digging. Please edit the question and provide the full command given and the output generated before stage 0 by the training tool.
  3. As said, weak classifiers should perform just better than random guessing on the negatives, so with a false alarm rate slightly lower than 0.5. Using 0.1 defeats the purpose of cascade classifiers. Your stages will be so complex that thousand of features will need to be evaluated for each window given to the classifier. This will result in huge processing times.
  4. I am guessing you are giving wrong values to -w and -h so please again, provide more info.
  5. Your ration positives to negatives is weird. You will always have more negative cases then positives, so try using a ration of 1:2 1:5 or even 1:10.

Also, if you are inexperienced in this field, I suggest reading chapter 5 of OpenCV 3 Blueprints, which discusses each parameter and it possible influence in great detail.

edit flag offensive delete link more

Comments

Let me pitch in to this and make some additions, because most info can already be seen as an answer :)

StevenPuttemans gravatar imageStevenPuttemans ( 2016-05-18 02:41:43 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-05-18 01:39:48 -0600

Seen: 328 times

Last updated: May 18 '16