Ask Your Question
1

How to use CascadeClassifier with a mask

asked 2012-10-17 13:44:24 -0600

501 Not Implemented gravatar image

updated 2012-10-17 13:45:24 -0600

Hi, i want to speed up my Object-detection. The idea is that the algorithm only search in the region of the mask. Is there a simple solution to realize this? for example the mask look loke this:
Uploaded with ImageShack.us

i can use findContour, but i think thats not effectiv by masks with a wide spread.

greetings

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2012-10-18 12:34:56 -0600

Kirill Kornyakov gravatar image

There is no simple solution for this. You'll need to modify the source code in the place where CascadeClassifier::runAt method is called, I mean internals of the CascadeClassifier. You can find the place where it is called, and try to add an if statement for checking your mask. But this is not all, because CascadeClassifier uses image pyramids, that means that you also need to scale your mask, so it correctly can be used for every scale.

So, it is not trivial, but feasible. But I can say that in our experiments the time we need for building the mask was larger than the time we were saving later. And if your mask is not good, you can loose some objects. Thus, I would suggest skipping frames and using some kind of tracking between detections. Check the DetectionBasedTracker class as a simple example.

edit flag offensive delete link more

Comments

thanks for your answers. My problem is that i have some images with high quality(>8MP). These image have smal faces (50x50px) that i want detect. My idea is to set a binary mask that based on the skincolor and run the facedetector over the mask. In time i use cvFindContour() and run haarcascade over roi.

501 Not Implemented gravatar image501 Not Implemented ( 2012-10-21 14:01:04 -0600 )edit

if the mask regions are small compared to the whole image, you could run the classifier on subimages? This will not give benefits in each situation where a mask could be applied, but whenever you have isolated ROIs as candidates, you can run the classifier on them (maybe add some additional border) instead of on the whole image!

Micka gravatar imageMicka ( 2016-06-22 05:44:56 -0600 )edit
1

answered 2013-09-27 03:16:21 -0600

lidong04 gravatar image

Actually there is an abstract class MaskGenerator inside CascadeClassifier, which had implemented the classification with mask. It is necessary to realize the virtual function generateMask() in your derived class. Also note that masked CascadeClassifier is only working with new format cascade classifiers. OpenCV source code opencv/modules/objdetect/src/cascadedetect.cpp could help in detail.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-10-17 13:44:24 -0600

Seen: 2,947 times

Last updated: Sep 27 '13