Ask Your Question

FeatureDetector with mask input (third parameter)

asked 2013-04-19 09:36:00 -0600

JohannesZ gravatar image

Hi there,

I am trying to use the FeatureDetector with SIFT/SURF. Using it without a mask, just like:

detector->detect(cv::Mat& input, std::vector<cv::keypoint>& keypoints) works perfect for me.

I am getting in problems when I try to use an additional mask. The documentation tells me to use a "8-bit integer matrix with non-zero values"

const Mat& mask=Mat()

Unfortunately, I do not understand what data type is meant here. Is this a CV_8U or CV_8S? I have tried several times, but I always get a segmentation fault.

Could you please help me what I am doing wrong? Thanks a lot! Johannes

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2013-07-07 07:00:40 -0600

pheips gravatar image

It was a bug in the OpenCV, that according to the issue tracker should be fixed in 2.4.6. The check if keypoints are in the mask area has wrongly be done with Scale-Space Coordinates of the keypoints.

edit flag offensive delete link more

answered 2013-04-19 09:50:35 -0600

Guanta gravatar image

I guess your matrix need to be of type CV_8UC1, ie. Mat mask = cv::Mat::zeros(rows, cols, CV_8UC1), or easier: just use Mat1b mask = cv::Mat1b::zeros(rows,cols), then set the areas to one where you would like to detect keypoints.

edit flag offensive delete link more


Hi, thanks for your fast anwer! CV_8UC1 or the Mat1b does no work... I get an segmentation fault again.

The mask should have the same dimensionsions as the input image, right?

JohannesZ gravatar imageJohannesZ ( 2013-04-19 10:03:22 -0600 )edit

yes, hmm, if it's really integer (which doesn't make much sense in my eyes) you could try CV_32SC1, or Mat1i, respectively.

Guanta gravatar imageGuanta ( 2013-04-19 10:23:26 -0600 )edit

Question Tools

1 follower


Asked: 2013-04-19 09:36:00 -0600

Seen: 758 times

Last updated: Jul 07 '13