Shape Recognition from 2D Points

If there aren't too many distinct shapes, here is what I woud try:

  • turn the curves to a (length, angle) representation; the length can be estimated as the sums of segment lengths, and the angle as the direction of the segments;

  • to be able to compare two representations, normalize the total length to unit (this will make the comparison size-independent), and sample at regular distances; said differently, obtain a vector of N angles at points equally spaced along the curve;

  • now to recognize a curve, compute the sum of absolute differences with similar vectors obtained from reference model, and keep the smallest sum.

enter image description here

There is no need for strict accuracy.


Note that this representation is not rotation-invariant, on purpose. It is also sensitive to the drawing order (from one endpoint to the other, or conversely), this can be unwanted. Finally, beware of the closed paths (circles), that people might start anywhere.