Ask Your Question

Need tips for a localized cascade detection

asked 2014-09-01 06:53:17 -0500

Samjakar gravatar image

updated 2014-09-01 06:54:10 -0500

Hi I use cascade classifier to detect patterns of interest in a video. I need to limit my detection only in certain areas of the image. The co-ordinates change based on from which view the photo was taken. nevertheless, I am able to apply a few filters / erosion and am able to arrive at a pattern where I get a thick White (close too pixel value 255) patch across the image that segregate my region of interest and the region I am not interested in. How should I programmatically choose the region "above" this white patch and not consider the rest of the image? Any ideas?

A more practical example: Imagine looking at a picture taken in a football/soccor stadium. The image has a lot of spectators, a view of the playground and the sky above. So, I apply certain filters etc.. to mark the area of the spectators as a white region. But, I need my cascade classifiers to detect only the region above this patch (sky region) and ignore any patterns below this. Any ideas?

Please let me know I need to provide any additional information to get help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-09-01 11:20:47 -0500

thdrksdfthmn gravatar image

I have looked at the detectMultiScale function; it has no mask parameter. In this case I would suggest you to create an image based on the mask you have and copy all the information you need from the input image into another one and detect on that image, where the image is just one colour, I think it is very fast the detection. I am saying something like:

cv::Mat imageToDetect;
inputImage.copyTo(imageToDetect, mask);
detector.detectMultiScale(imageToDetect, objects, 1.1, 3, 0, yourMinSize, yourMaxSize);

You can also do some kind of ROI (region of interest) of the important area like a boundingRect of the contours of the important areas and do a for loop and detect on each imageToDetect(roi) or inputImage(roi);. In this case do not forget to add the x and y coordinate of the roi.

edit flag offensive delete link more


Thanks for your response, thdrksdfthmn. I understand that I need to feed in my ROI as the input to the detectmultiscale function. My concern is how would I programmatically identify the region that lies above the thresholded sequence of near-white cells. Please see the image attached in dropbox I have manually drawn a red line in the image. My ROI is the space above the red line ( a lot of consecutive white spaces). How would I programmatically acheive this? Should I check the average pixel value of each row and check if it is close to 255 ? Or is there a better more intelligent way?

Samjakar gravatar imageSamjakar ( 2014-09-02 02:32:34 -0500 )edit

You can do a threshold. Then you will have a binary image. If you will always have a white region that goes from left to right (with no interuption, or do a closure morphology on the binary image). Find countours, and for each contour search the min and max X coordinate, for finding if it is from left to right. Take the max Y coord (from the 2 points with max/min X) and create a cv::Rect roi(0, 0, img.width, maxY);; Maybe you can optimize it; it is the first idea that came in my mind after seeing the image

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-09-02 03:03:05 -0500 )edit

Thanks for your response, thdrksdfthmn. I will try this out and will let you know.

Samjakar gravatar imageSamjakar ( 2014-09-02 06:00:08 -0500 )edit

Question Tools


Asked: 2014-09-01 06:53:17 -0500

Seen: 727 times

Last updated: Sep 01 '14