Ask Your Question
0

Detecting Matches results in error about masks?

asked 2018-06-09 09:42:30 -0500

sazr gravatar image

When I attempt to get the matches between 2 key descriptor lists I get the following error:

OpenCV Error: Assertion failed (masks.size() == imageCount) in cv::DescriptorMatcher::checkMasks, file C:\build\master_winpack-build-win64-vc14\opencv\modules\features2d\src\matchers.cpp, line 617

I'm unsure what I am doing wrong? The error occurs when I call cv::BFMatcher::match() and I am not passsing any masks into the function. Any idea what the issue could be?

My code is:

std::vector<Mat> descriptors1, descriptors2;

descriptors1.push_back(Mat({
    174.483, 19.170, 12.503, 10.454, -81.230, 0.003765
}).reshape(1));

descriptors2.push_back(Mat({
    137.942, 24.953, 31.512, 27.309, -69.655, 0.000575
    }).reshape(1));
descriptors2.push_back(Mat({
    133.888, 14.031, 18.080, 13.974, -114.655, 0.00191
    }).reshape(1));
descriptors2.push_back(Mat({
    165.547, 36.802, 19.982, 34.661, 28.909, 0.000625
    }).reshape(1));
descriptors2.push_back(Mat({
    188.496, 19.021, 10.202, 8.445, -78.267, 0.005702
    }).reshape(1));
descriptors2.push_back(Mat({
    192.788, 23.360, 14.752, 20.407, 89.840, 0.001577
    }).reshape(1));
descriptors2.push_back(Mat({
    182.088, 29.258, 17.928, 28.822, 74.453, 0.000868
    }).reshape(1));
descriptors2.push_back(Mat(std::vector<double>{
    161.119, 34.396, 19.787, 22.862, 91.313, 0.001094
    }).reshape(1));
descriptors2.push_back(Mat({
    159.954, 17.733, 14.422, 11.519, -83.997, 0.002935
}).reshape(1));

cv::BFMatcher matcher(NORM_L2);
std::vector<cv::DMatch> matches;
matcher.match(descriptors1, descriptors2, matches);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-06-09 10:21:05 -0500

berak gravatar image

3 problems:

  1. it wants a Mat (with each descriptor on a row), not a vector<Mat>
  2. your reshape does not anything
  3. for some reason, the BFMatcher only accepts uchar or float features, not double.


so,

Mat descriptors1, descriptors2; // initially empty

descriptors1.push_back(Mat({
    // either put an f to the end of the numbers, or you'll have to convert it later
    174.483f, 19.170f, 12.503f, 10.454f, -81.230f, 0.003765f  
}).reshape(1,1)); // <-- omitting the 2nd arg will leave the shape unchanged !
edit flag offensive delete link more

Comments

@berak thanks much appreciated

sazr gravatar imagesazr ( 2018-06-09 10:36:54 -0500 )edit

and sorry again for being a bit sloppy on the last question, which partly caused your current problems

berak gravatar imageberak ( 2018-06-09 11:19:10 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-06-09 09:42:30 -0500

Seen: 85 times

Last updated: Jun 09 '18