Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Detecting Matches results in error about masks?

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);