Slide 1

Slide 1 text

CMUnistrokeGestureRecognizer Chris Miles Freelance Software Engineer iOS Specialist @chrismiles http:/ /chrismiles.info/ Friday, 8 February 13

Slide 2

Slide 2 text

Infinity Blade Friday, 8 February 13

Slide 3

Slide 3 text

Palm OS Graffiti Friday, 8 February 13

Slide 4

Slide 4 text

Unistroke Gesture Friday, 8 February 13

Slide 5

Slide 5 text

$1 Unistroke Recognizer http:/ /depts.washington.edu/aimgroup/proj/dollar/ Friday, 8 February 13

Slide 6

Slide 6 text

$1 Goals Resilient to movement & sampling speed Rotation, scale, position invariance No advanced maths (e.g., matrix inversions, derivatives, integrals) Easily written with few lines of code Friday, 8 February 13

Slide 7

Slide 7 text

$1 Goals Fast enough for interactive use Define gestures with minimum of only one example Return top results ordered by score [0-1] Provide recognition rates that are competitive with more complex algorithms Friday, 8 February 13

Slide 8

Slide 8 text

Friday, 8 February 13

Slide 9

Slide 9 text

Friday, 8 February 13

Slide 10

Slide 10 text

Friday, 8 February 13

Slide 11

Slide 11 text

Step 1: Resample Resample to N equidistantly spaced points 32 ≤ N ≤ 256 Friday, 8 February 13

Slide 12

Slide 12 text

Step 2: Rotate Rotate to "Indicative Angle" Indicative Angle is the angle required to rotate the gesture’s first point to 0° about the centroid of the gesture Friday, 8 February 13

Slide 13

Slide 13 text

Step 3: Scale & Translate Scale to a reference square Translate the centroid to (0,0) Friday, 8 February 13

Slide 14

Slide 14 text

Step 4: Recognise Calculate the average distance di between corresponding points of candidate C and each template Ti This is the "Path-Distance" Friday, 8 February 13

Slide 15

Slide 15 text

Step 4: Recognise The template Ti with the least path- distance to C is the winner Calculate a [0-1] score with: Friday, 8 February 13

Slide 16

Slide 16 text

Step 4: Recognise Optional: Rotation Invariance Attempt to align two gestures C and Ti more optimally A strategy called Golden Section Search is used to scan best fit between ±45° from indicative angle with threshold 2° Friday, 8 February 13

Slide 17

Slide 17 text

Step 4: Recognise Alternatively: Protractor method Similar steps 1-3: Resample, rotate, scale & translate Step 4 compares a vector representation of the gesture against templates using Optimal-Cosine- Distance Friday, 8 February 13

Slide 18

Slide 18 text

CMUnistrokeGestureRecognizer UIGestureRecognizer Core algorithm implemented in C GLKMath for optimal vector math Friday, 8 February 13

Slide 19

Slide 19 text

@interface CMUnistrokeGestureRecognizer : UIGestureRecognizer @property (nonatomic, weak) id unistrokeDelegate; @property (nonatomic, assign) float minimumScoreThreshold; @property (nonatomic, assign) BOOL protactorMethodEnabled; @property (nonatomic, assign) BOOL rotationInvarianceEnabled; @property (nonatomic, strong, readonly) CMUnistrokeGestureResult *result; @property (nonatomic, strong, readonly) UIBezierPath *strokePath; - (void)registerUnistrokeWithName:(NSString *)name bezierPath: (UIBezierPath *)path; - (void)clearAllUnistrokes; @end Friday, 8 February 13

Slide 20

Slide 20 text

@protocol CMUnistrokeGestureRecognizerDelegate @optional - (void)unistrokeGestureRecognizer:(CMUnistrokeGestureRecognizer *)unistrokeGestureRecognizer isEvaluatingStrokePath:(UIBezierPath *)strokePath; - (void)unistrokeGestureRecognizerDidFailToRecognize: (CMUnistrokeGestureRecognizer *)unistrokeGestureRecognizer; @end Friday, 8 February 13

Slide 21

Slide 21 text

$N Multistroke Recognizer Friday, 8 February 13

Slide 22

Slide 22 text

$P Point-Cloud Recognizer Friday, 8 February 13

Slide 23

Slide 23 text

Friday, 8 February 13

Slide 24

Slide 24 text

https:/ /github.com/chrismiles/CMUnistrokeGestureRecognizer Chris Miles @chrismiles http:/ /chrismiles.info/ Friday, 8 February 13