问题
I am currently looking for some guide/samples on how to implement the OS X Yosemite’s markup like features. i.e., auto detecting/guess freehand drawing to match users’ intention of whether they are trying to draw circle, square, or triangle.
Please refer the image below, the left side represents the users freehand drawing and the right is auto-detected shapes replaced by OS X markup.
回答1:
Recognizing objects from gestures is a subject of ongoing research. There is a class of algorithms called "$ recognizers" that you might want to look at. The original algorithm is "The $1 Recognizer" which is worth a read.
It is not that difficult to implement such recognizers, as long as you are limited to a specific class of shapes. The $1 recognizer (if I recall correctly) only works for a continuous path (so "X" would not work because it requires two strokes). However, later work has extended the $1 recognizer for non-continuous cases.
来源:https://stackoverflow.com/questions/31370054/how-to-detect-users-freehand-drawing-to-primitive-geometrical-objects-like-squa