Ask Your Question
1

matchShapes() example

asked Jul 30 '12

yes123 gravatar image

updated Jul 30 '12

Hello Guys,

I would like to use matchShapes() function for finding 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())

Preview: (hide)

1 answer

Sort by » oldest newest most voted
3

answered Jul 31 '12

Michael Burdinov gravatar image

First you will need to get contours of shapes from image. For example use Canny() to find edges in images. Than use findContours() on image of edges to get contours.

Than you can use matchShapes() to find contour that is most similar to your model contour (among all contours extracted by findContours()).

Note that this approach is very fast comparing to other methods of object detection, but if you can't get single contour around your book you will not able to find it. matchShapes() compares single contour to single contour.

Preview: (hide)

Comments

Thanks a lot. that's a nice explanation. So after I have comapred all contours of a model image with each other of the query image I can know which couple of contours match best, and then maybe drawing them in the query image ?

yes123 gravatar imageyes123 (Jul 31 '12)edit

Yep, this is the main idea.

Michael Burdinov gravatar imageMichael Burdinov (Jul 31 '12)edit

MatchShapes() is true for scaling and rotation?

anwaar786 gravatar imageanwaar786 (Feb 14 '13)edit

What do you mean by "true for scaling and rotation"?

Michael Burdinov gravatar imageMichael Burdinov (Feb 15 '13)edit

What is the internal algorithm for operating on grayscale images? Are they converted to contours first?

jtlz2 gravatar imagejtlz2 (Jul 19 '17)edit

Question Tools

Stats

Asked: Jul 30 '12

Seen: 10,147 times

Last updated: Jul 31 '12