Comparing and Smoothing Time-series of Polylines

I’m using TSPS + ofxOSC to read in contours from my webcam. I’m creating a polyline from the osc messages and displaying it on my screen.

There’s a bit of noise and flickering, depending on the TSPS inputs. I wanted to smooth this out by implementing some kind of persistence layer that compares the new polyline with the current one, and either ignores the new one, or updates them smoothly with some kind of lerp.

Are there any pointers as to how to:
(i) Compare polylines?
(ii) Interpolate between them?

My naive solutions consist mostly of pair-wise comparison of the nodes to match them, and then doing interpolations between them. I also looked at Frechet distance, but it seems overly complicated.

Hi, the most straight forwards way, although maybe not the most elegant is to resample both polylines so these have the same number of vertices. There is no certainty if their first vertex is “the same one”, so you’ll need a way to find out if it is. Maybe these might not be necesary, you need to test. Then you can measure the distance between each correspondent vertex (using the square distances will save you a square root calculation) add them all and determine, based on this if these two polylines are similar or not. Then, if you want to lerp these, just create a new polyline which is made of the lerped correspondent points.
hope this helps

1 Like