Ask Your Question
1

matchShapes() example

asked 2012-07-30 16:48:11 -0600

yes123 gravatar image

updated 2012-07-30 16:54:09 -0600

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())

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2012-07-31 04:00:26 -0600

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.

edit flag offensive delete link more

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 ( 2012-07-31 11:20:43 -0600 )edit

Yep, this is the main idea.

Michael Burdinov gravatar imageMichael Burdinov ( 2012-07-31 14:19:15 -0600 )edit

MatchShapes() is true for scaling and rotation?

anwaar786 gravatar imageanwaar786 ( 2013-02-14 12:25:29 -0600 )edit

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

Michael Burdinov gravatar imageMichael Burdinov ( 2013-02-14 23:18:10 -0600 )edit

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

jtlz2 gravatar imagejtlz2 ( 2017-07-19 08:07:32 -0600 )edit

Question Tools

Stats

Asked: 2012-07-30 16:48:11 -0600

Seen: 9,962 times

Last updated: Jul 31 '12