【发布时间】:2018-04-27 18:17:47
【问题描述】:
我正在使用 opencv 并将其添加到 c++ 项目中。但是,我在特征匹配方面遇到了问题。代码在这里:
cv::Ptr<Feature2D> f2d = xfeatures2d::SIFT::create();
std::vector<KeyPoint> keypoints_1, keypoints_2;
Mat descriptors_1, descriptors_2;
f2d->detectAndCompute(img_Org_Y_mat, Mat(), keypoints_1, descriptors_1);
f2d->detectAndCompute(img_Rec_Y_mat, Mat(), keypoints_2, descriptors_2);
vector<DMatch> matches;
BFMatcher matcher(NORM_L2);
matcher.match(descriptors_1, descriptors_2, matches);
最后一行有问题:
OpenCV Error: Assertion failed (masks.size() == imageCount) in
cv::DescriptorMatcher::checkMasks, file C:\Opencv2\opencv
master\modules\features2d\src\matchers.cpp, line 617
它在程序中写道:
Unhandled exception at 0x00007FF803FA9E08 in TAppEncoder.exe: Microsoft C++
exception: cv::Exception at memory location 0x000000CE624E9050.
【问题讨论】:
-
此错误表示通常是 matcher.match 的第 4 个参数的掩码与 imageCount 的大小不同。由于您没有将任何内容作为掩码传递,因此我假设您要么在删除该参数后忘记重新编译项目,要么使用旧版本的 opencv。你用的是哪个版本的opencv?
-
我使用的是 Opencv 3.3,我对掩码一无所知。我将其更改为 noArray 或 Mat() ,但仍然有问题。
标签: c++ opencv feature-extraction