The task here is to generate a 2D path for a robot which replicates a (hand) drawn line. The line is a simple shape being a curve or squiggle and always has one start and one end point. An example of a squiggle is pictured here.
I used OpenCV's cv2.findContours which finds both sides of the line and so generates a list of coordinates that describe both sides. What I need is a single coordinate path that would (in effect) run down the center of the line, this being the path that the robot would follow.
scikit-image's skimage.measure.find_contours generated a similar result.
I tried with an image that has one edge such as:
so that the algorithm finds only one edge. The resulting coordinate path is closer to what I need however results in a closed polygon and a coordinate path like this:
The boundary (straight) edge of the image is included, which is not desired.
So I guess I have two options that I can see. One is an algorithm that finds the mid-point between two edges along a curve (rather than finding both edges). Option two is to ignore the boundary edge of the image simply by filtering out those coordinates in that region, but that seems clunky.













I have a solution to this particular problem which is to use cv2.findContours which as mentioned finds both sides of a line then generating the robot path by simply using only the first 50% of the points. This works as, conveniently, the algorithm must track along one side of the line then back along the other side. I only need one side and accuracy is not that important in this application.