如何在OpenCV中利用SIFT提取的特征得到目标物体周围的矩形
我正在 OpenCV 中进行对象检测项目,其中包括将模板图像中的对象与参考图像进行匹配。使用 SIFT 算法可以准确地检测和匹配特征,但我想要围绕匹配特征的矩形 我的算法使用 KD-Tree est ean First 技术来获取匹配项
I'm doing project in OpenCV on object detection which consists of matching the object in template image with the reference image. Using SIFT algorithm the features get acurately detected and matched but I want a rectagle around the matched features
My algorithm uses the KD-Tree est ean First technique to get the matches
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想要在检测到的对象周围有一个矩形,此处您可以找到与此完全相同的代码示例。您只需要在单应性 H 周围绘制一个矩形
。希望它有所帮助。祝你好运。
If you want a rectangle around the detected object, here you have code example with exactly that. You just need to draw a rectangle around the homography H.
Hope it helps. Good luck.
我使用以下代码(改编自 OpenCV 中的 SURF 算法(modules/features2d/src/surf.cpp))来提取关键点的周围。
除了基于矩形和 ROI 的其他示例之外,此代码根据特征检测算法确定的方向和比例返回正确定向的面片(两者都在 KeyPoint 结构中可用)。
对几个不同图像的检测结果的示例:
我不确定比例是否是完全没问题,但它取自 SURF 源,结果看起来与我相关。
I use the following code, adapted from the SURF algoritm in OpenCV (modules/features2d/src/surf.cpp) to extract a surrounding of a keypoint.
Apart from other examples based on rectangles and ROI, this code returns the patch correctly oriented according to the orientation and scale determined by the feature detection algorithm (both available in the
KeyPoint
struct).An example of the results of the detection on several different images:
I am not sure if the scale is entirely OK, but it is taken from the SURF source and the results look relevant to me.