Skip to content

Implementation of the $N Multistroke Recognizer.

License

Notifications You must be signed in to change notification settings

hereblur/NDollarJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NDollar

Implementation of the $N Multistroke Recognizer, in TypeScript/UMD package.

Installation

simply:

  npm install ndollar-js

or for web browsers,

  <script src="../dist/nDollar.js"></script>

Example, Using as a node module

    var nDollar = require("ndollar-js");
    var useBoundedRotationInvariance = true;
    var recognizer = new nDollar.Recognizer( useBoundedRotationInvariance );

    recognizer.LoadDefaultGestures( );

    var triangle = [[new nDollar.Point(30, 7),  new nDollar.Point(103, 7)],
                    [new nDollar.Point(103, 7), new nDollar.Point(66, 87)],
                    [new nDollar.Point(66, 87), new nDollar.Point(30, 7)]
                   ];

    recognizer.AddGesture( "triangle", triangle);

    var myHandDrawingOfTriangle = [ [new nDollar.Point(20, 7),   new nDollar.Point(54, 8),  new nDollar.Point(100, 10)],
                                    [new nDollar.Point(103, 7),  new nDollar.Point(82, 47), new nDollar.Point(66, 87)],
                                    [new nDollar.Point(66, 87),  new nDollar.Point(45, 45), new nDollar.Point(30, 7)]
                                   ];

    result = recognizer.recognize( myHandDrawingOfTriangle, requireSameNoOfStrokes, useProtractor);
    /*
      result = { Name: "triangle", Score: 8.076 }
    */

Example, Using in the web browsers

  var useBoundedRotationInvariance = true;
  var recognizer = new nDollar.Recognizer(useBoundedRotationInvariance);
  var strokes = [];
  var stroking = []

  recognizer.LoadDefaultGestures(  );

  var triangle = [[new nDollar.Point(30, 7),  new nDollar.Point(103, 7)],
                  [new nDollar.Point(103, 7), new nDollar.Point(66, 87)],
                  [new nDollar.Point(66, 87), new nDollar.Point(30, 7)]
                 ];

  recognizer.AddGesture( "triangle", triangle);

  var myHandDrawingOfTriangle = [ [new nDollar.Point(20, 7),   new nDollar.Point(54, 8),  new nDollar.Point(100, 10)],
                                  [new nDollar.Point(103, 7),  new nDollar.Point(82, 47), new nDollar.Point(66, 87)],
                                  [new nDollar.Point(66, 87),  new nDollar.Point(45, 45), new nDollar.Point(30, 7)]
                                 ];

  result = recognizer.recognize( myHandDrawingOfTriangle, requireSameNoOfStrokes, useProtractor);
    /*
      result = { Name: "triangle", Score: 8.076 }
    */

Class Recognizer

You can check [https://depts.washington.edu/aimgroup/proj/dollar/ndollar.html] to get the idea of what it's can do and parameters you can play with.

The Recognizer class is the main clas who do all the works. We can just create instance by

var recognizer = new nDollar.Recognizer( useBoundedRotationInvariance );

Then we need to add knowledge to it by either loading defaults or create your own gestures.

recognizer.LoadDefaultGestures( )

This load pre-built 16 shapes of gestures same as in the original.

Original.

Or you can create your own shapes

  var triangle = [[new nDollar.Point(30, 7),  new nDollar.Point(103, 7)],
                  [new nDollar.Point(103, 7), new nDollar.Point(66, 87)],
                  [new nDollar.Point(66, 87), new nDollar.Point(30, 7)]
                 ];

  recognizer.AddGesture( "triangle", triangle);

Then you can test your gesture to the recognizer.

result = recognizer.recognize( handDrawingOfTriangle, requireSameNoOfStrokes, useProtractor);

Recognize options

  • useBoundedRotationInvariance : Strict the orientation of shape, If this is true, It's will not match the shape if it's too much different angle.
  • requireSameNoOfStrokes : Match the shape only when stroke count is equal.
  • useProtractor : select alghorithm to compare shape, between original Golden Section Search and Protactor search.

About

Implementation of the $N Multistroke Recognizer.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published