EmguCV:用于检测器描述符的正确变量是什么?错误:“OpenCV:>类型=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 版本时,却出现了更多问题。
我已经尝试将 descTemplate
和 descImg
更改为 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论