You could write a Recursive Boundary Splitting algorithm.

Basically (treating the curve as a sequence of points) , to begin

with you create a line between the start point of the curve, and the

end point of the curve.

Taking the line you have created, you find the point along the curve

"furthest" from that line. That means iterating through the curves

points (between the start and endpoint), and measuring its distance to

the line from each point.

Once you have found the furthest point, you split the curve at that

point. So instead of having one line from the start point to the end

point, you now have two lines: one from the start point to the point

you found (the furthest point from the old line) and a second from the

point you found to the end point.

Taking the lefmost line, you do the same as above, and split it again

at the point furthest from the line. Now the curve has 3 lines

approximating it. You continue to split the lines into smaller and

smaller segments until you have met some predefined criteria (This is

usually that the furthest point from your line is under a certain

distance)

The nice thing about this algorithm, is that it can be done recursively.

Hopefully you understand what I am saying as it's a kind of difficult

to explain in words! I have some code (not opencv though) that might

explain it better if you would like

Have a look here:

http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithmhttp://cs.joensuu.fi/~koles/approximation/Ch3_2.html--- In

[hidden email], HoangNguyen <hoangnguyen79@...> wrote:

>

> I'm looking for an algorithm that breaks an arbitrary curve into

line segments, satisfying some criteria (e.g: optimizing some error

function). Anybody got any hint?

>

> Thanks

> Hoang

>

>

>

> New Email addresses available on Yahoo!

> Get the Email name you've always wanted on the new @ymail and

@rocketmail.

> Hurry before someone else does!

>

http://mail.promotions.yahoo.com/newdomains/aa/>

> [Non-text portions of this message have been removed]

>