0.6.1 • Published 7 years ago

ndollar-js v0.6.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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.
0.6.1

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago