【问题标题】:opencv feature-matching eropencv 特征匹配器
【发布时间】: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


【解决方案1】:

我也遇到了这个问题。我已经解决了,但我不确定这个解决方案是否适合这个问题。我将分享我的解决方案。

我错误地在“附加依赖项”中添加了一些发布模型中需要的 .lib 文件,例如 opencv_bgsegm341.lib。

删除后,程序运行成功。

我希望这会对你有所帮助。

【讨论】:

    猜你喜欢
    • 2018-05-08
    • 1970-01-01
    • 2017-08-13
    • 2014-04-04
    • 2011-09-04
    • 2018-03-10
    • 1970-01-01
    • 1970-01-01
    • 2014-04-11
    相关资源
    最近更新 更多