EmguCV:用于检测器描述符的正确变量是什么?错误:“OpenCV:>类型=0”

发布于 01-15 21:32 字数 1187 浏览 5 评论 0原文

我正在尝试检测关键点和描述符以将模板与另一个图像进行匹配。

我开始遵循这个 OpenCV 教程,切换到 ORB 检测器(因为 SURF 算法已获得专利),但当我执行 KnnMatch() 时,它抛出异常。

这是我的代码:

Mat template = new Mat(templatePath, ImreadModes.Grayscale);
ORB orbDetector = new ORB(1000);
VectorOfKeyPoint keyPointTemplate = new VectorOfKeyPoint();
VectorOfKeyPoint keyPointImg = new VectorOfKeyPoint();
var descTemplate = new Mat();
var descImg = new Mat();
orbDetector.DetectAndCompute(template, new Mat(), keyPointTemplate, descTemplate, false);
orbDetector.DetectAndCompute(und, new Mat(), keyPointImg, descImg, false);
KdTreeIndexParams ip = new KdTreeIndexParams();
SearchParams sp = new SearchParams();
FlannBasedMatcher matcher = new FlannBasedMatcher(ip, sp);
VectorOfVectorOfDMatch knnMatches = new VectorOfVectorOfDMatch();
matcher.KnnMatch(descTemplate, descImg, knnMatches, 2); // exception: OpenCV: > type=0

我能找到的唯一示例代码是使用 < code>FAST 但是,由于它是 9 年前发布的,代码已经过时了,当我尝试适应当前的 EmguCV 版本时,却出现了更多问题。

我已经尝试将 descTemplatedescImg 更改为 VectorOf* 但我没有成功。

I'm trying to detect the keypoints and descriptors to match a template with another image.

I started to follow this OpenCV tutorial, switched to ORB detector (as SURF algorithm is patented) but it's throwing an exception when I perform the KnnMatch().

Here's my code:

Mat template = new Mat(templatePath, ImreadModes.Grayscale);
ORB orbDetector = new ORB(1000);
VectorOfKeyPoint keyPointTemplate = new VectorOfKeyPoint();
VectorOfKeyPoint keyPointImg = new VectorOfKeyPoint();
var descTemplate = new Mat();
var descImg = new Mat();
orbDetector.DetectAndCompute(template, new Mat(), keyPointTemplate, descTemplate, false);
orbDetector.DetectAndCompute(und, new Mat(), keyPointImg, descImg, false);
KdTreeIndexParams ip = new KdTreeIndexParams();
SearchParams sp = new SearchParams();
FlannBasedMatcher matcher = new FlannBasedMatcher(ip, sp);
VectorOfVectorOfDMatch knnMatches = new VectorOfVectorOfDMatch();
matcher.KnnMatch(descTemplate, descImg, knnMatches, 2); // exception: OpenCV: > type=0

The only example code I could find is this official documentation that uses FAST but, as it was published 9 years ago, the code is outdated and when I tried to adapt to current EmguCV version gave only more issues.

I already tried changing descTemplate and descImg to VectorOf* but I had no luck with it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文