enlarging & contracting closed ofPolyline

is there a way of ‘enlarging’ or contracting a closed ofPolyline (which represents a contour detected using the kinect)?
ive got the polyline from the contourfinder.

I’ve tried a method using the normals of each 2 consecuetive points but its very jittery, however this does in principle what I want. Only when the expended contour overlaps (eg strange arm movements and such) it gives problems.

I’m actually looking for something like the opencv::dilate and erode functions, but for contours. I need to do it quite a lot (eg draw 100 contours each 5 pixels “wider”), so the opencv aproach doens’t work that well…

Thanks!

clipper can add offsets to polygons: http://www.angusj.com/delphi/clipper.php

oooh awesome! exactly what I needed.
There is even an addon for it:
https://github.com/bakercp/ofxClipper

Thanks!

okay it didnt go as easy as I hoped :smiley:

First, the correct name is offsetting or buffering polygons, thanks to the tip of sth.

The ofxCLipper addons works very good but didn’t fit my porposes: for jittery lines (contours from noisy kinect images; projected into 2D projector space) it uses lots of cpu. A 400-point contour took 30ms-40ms for 10 pixel offset, which is unacceptable (i should need from 10 to 500 offset).

So I’ve tried another approach:

  • fill fbo with a tessalated path (resized to 640x400)
  • apply x times erode/dilate shader (pingpongbuffer)
  • upscale result to origingal resolution
  • controurfinder
  • slight smoothing
    -> polylines I needed!
    It takes about 5 to 10 ms depending on the required offset.
    It is not as accurate as Clipper, but it works.