Ask Your Question
0

Rotate/Resize Contour Segments

asked 2017-02-28 13:46:42 -0600

jpistorino gravatar image

updated 2017-02-28 18:25:05 -0600

I am using OpenCV 3.1.1 with VS2012 C++ on a Win10 64 bit machine.

I am hoping that this is not a stupid question.

I am working on comparing contour segments for shape matching as in: Xingang, et al., "Bag of Contour Fragments for Robust Shape Classification" (2014). http://dl.acm.org/citation.cfm?id=258

I have a series of points that define a segment of a contour, further I have a series of these segments. What I want to do is normalize each segment so that they have the same X length, with varying Y values.

Further, the segments should be rotated so that the maximum length is along the X axis when you normalize them. For example, horizontal and vertical lines of the same length would normalize to the same value.

If the segments were just straight lines, that would be one problem. However, the segments are likely to have curves, etc.

Once the segments are aligned on the same axis and normalized, you can compare each segment in a way that is both scale and rotation invariant.

The segments are specified by a series of points in a vector. So, my question is: what is the best way to do this?

Thanks for any help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-03-01 22:36:22 -0600

jpistorino gravatar image

I figured out one way to do everything but the scale.

First, use minAreaRect to get a rotated rectangle that encloses all the points.

Then, use getRotationMatrix2d to figure out the rotation matrix that will transform the rectangle to a zero angle.

Then, use transform with the original points list and the rotation matrix to transform the points.

You still have to work out the scaling but that seems doable.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-02-28 13:46:42 -0600

Seen: 2,666 times

Last updated: Mar 01 '17