I want to be able to take a GPX track of a twisty road and have an algorithm count the number of corners. I guess it will have to be done comparing the "bearings" of subsequent tracks. Howeve开发者_Go百科r I'm new to this and wonder if there is a simple solution out there.
If you took your coordinates and were able to determine when the bearings changed, you would have the answer. To do this, we could find the best fit of straight line on the points given. This is the segmented least squares problem - given a set of points, find the minimum cost line segments that fit the points.
There is a tradeoff cost between least-sqaures error and adding a new line (otherwise, creating line segments for every two points would have zero error), you will have to play with the parameters for this yourself with your data.
See
- http://www.cs.princeton.edu/~wayne/cs423/lectures/dynamic-programming-4up.pdf
- Segmented least squares algorithm, don't understand this dynamic programming concept at all
精彩评论