Ask Your Question
1

How to use CascadeClassifier with a mask

asked Oct 17 '12

501 Not Implemented gravatar image

updated Oct 17 '12

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

Preview: (hide)

2 answers

Sort by » oldest newest most voted
1

answered Oct 18 '12

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.

Preview: (hide)

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.

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 (Jun 22 '16)edit
1

answered Sep 27 '13

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.

Preview: (hide)

Question Tools

Stats

Asked: Oct 17 '12

Seen: 2,988 times

Last updated: Sep 27 '13