OpenCV :: matchShapes()示例? [英] OpenCV::matchShapes() example?

查看:369
本文介绍了OpenCV :: matchShapes()示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用matchShapes()函数在查询图像中查找对象.

比方说,我有一本书的模型图像,我想提取其形状,然后尝试在另一幅图像中找到这本书(其形状).

我在Google上搜索了很多,但是找不到任何有关如何使用matchShapes实现这一目标的真实示例.该文档缺乏. Someoen可以在C ++中做一个小例子吗?

非常感谢! (请注意,我知道我可以使用SIFT/ORB等,但我想使用matchShapes())

解决方案

步骤1:检测书籍的轮廓并将其存储在vector<Point>中.

第2步:检测另一幅图像上的轮廓.

第3步:迭代检测到的轮廓,并使在第1步中检测到的形状与在另一幅图像上检测到的每个轮廓相匹配.您已检测到vector<vector<Point> >轮廓.遍历它们,将步骤1中的模型vector<Point>从轮廓传递给matchShape()函数.请参阅我的答案此处如何使用matchShape()函数. >

请注意,书籍在其他图像上的形状必须与模型图像上的形状相同.它只能旋转,移位或缩放.

I would like to use matchShapes() function to find an object inside a query image.

Let's say I have a model image of a book, i want to extract its shape and then try to find this book (its shape) inside another image.

I have googled a lot but couldn't find any real example on how to use matchShapes to achive this. The documentation lacks. Can someoen make a little example in C++ ?

Thanks a lot! (Note I know I can use SIFT/ORB etc, but i want to use matchShapes())

解决方案

Step 1: Detect contour of book and store it in vector<Point>.

Step 2: Detect contours on another image.

Step 3: Iterate over detected contours and match shape detected in Step 1 with each contour detected on another image. You have detected vector<vector<Point> > contours. Iterating over them you pass model vector<Point> from Step 1 and vector<Point> from contours to matchShape() function. See my answer here how to use matchShape() function.

Note that book must have the same shape on another image as on model image. It can only be rotated, displaced or scaled.

这篇关于OpenCV :: matchShapes()示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆