qdollar-super-quick-recognizer 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.md +104 -0
- package/dist/constants/configurations.d.ts +6 -0
- package/dist/constants/gestures.d.ts +69 -0
- package/dist/core/QDollarRecognizer.d.ts +14 -0
- package/dist/core/QDollarRecognizer.test.d.ts +1 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.es.js +416 -0
- package/dist/index.es.js.map +1 -0
- package/dist/models/Point.d.ts +8 -0
- package/dist/models/PointCloud.d.ts +7 -0
- package/dist/models/Result.d.ts +6 -0
- package/dist/utilities/cloudMatch.d.ts +8 -0
- package/dist/utilities/math.d.ts +3 -0
- package/dist/utilities/transform.d.ts +6 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Smart Up Co., Ltd
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
|
|
2
|
+
# $Q Super-Quick Recognizer
|
|
3
|
+
|
|
4
|
+
[](https://badge.fury.io/js/qdollar-super-quick-recognizer)
|
|
5
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
6
|
+
|
|
7
|
+
A modern, strongly-typed, and modular TypeScript implementation of the **$Q Super-Quick Recognizer**.
|
|
8
|
+
|
|
9
|
+
This library is a high-performance, **multi-stroke** gesture recognizer. Unlike the original $1 recognizer, $Q supports gestures made of multiple lines (like "X", "T", or Kanji) and uses a Lookup Table (LUT) for ultra-fast recognition.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install the package using your preferred package manager:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# npm
|
|
17
|
+
npm install qdollar-super-quick-recognizer
|
|
18
|
+
|
|
19
|
+
# yarn
|
|
20
|
+
yarn add qdollar-super-quick-recognizer
|
|
21
|
+
|
|
22
|
+
# pnpm
|
|
23
|
+
pnpm add qdollar-super-quick-recognizer
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### 1\. Recognizing Default Gestures
|
|
29
|
+
|
|
30
|
+
The recognizer comes with 16 standard multi-stroke gestures (T, N, D, P, X, H, I, exclamation, star, etc.).
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import {
|
|
34
|
+
Point,
|
|
35
|
+
QDollarRecognizer,
|
|
36
|
+
DEFAULT_GESTURES,
|
|
37
|
+
} from "qdollar-super-quick-recognizer";
|
|
38
|
+
|
|
39
|
+
// Initialize with default multi-stroke gestures
|
|
40
|
+
const recognizer = new QDollarRecognizer(DEFAULT_GESTURES);
|
|
41
|
+
|
|
42
|
+
// Points include an ID to identify which stroke they belong to
|
|
43
|
+
const userPoints = [
|
|
44
|
+
new Point(30, 146, 1), new Point(106, 222, 1), // Stroke 1
|
|
45
|
+
new Point(30, 225, 2), new Point(106, 146, 2) // Stroke 2
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
// Returns a sorted array of Result objects (highest score first)
|
|
49
|
+
const results = recognizer.recognize(userPoints);
|
|
50
|
+
|
|
51
|
+
if (results.length > 0) {
|
|
52
|
+
const bestMatch = results[0];
|
|
53
|
+
console.log(
|
|
54
|
+
`Recognized as: ${bestMatch.name} (Score: ${Math.round(bestMatch.score * 100)}%)`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 2\. Adding Custom Multi-stroke Gestures
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const recognizer = new QDollarRecognizer([]);
|
|
63
|
+
|
|
64
|
+
// Define a custom 2-stroke gesture
|
|
65
|
+
const myShape = [
|
|
66
|
+
new Point(10, 10, 1), new Point(100, 10, 1), // Line 1
|
|
67
|
+
new Point(50, 10, 2), new Point(50, 100, 2) // Line 2
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
recognizer.addGesture("my-custom-shape", myShape);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### `QDollarRecognizer`
|
|
76
|
+
|
|
77
|
+
#### `recognize(points: Point[]): Result[]`
|
|
78
|
+
|
|
79
|
+
Calculates the similarity between the input points and loaded templates. Returns a list of results sorted by score (descending).
|
|
80
|
+
|
|
81
|
+
#### `addGesture(name: string, points: Point[]): number`
|
|
82
|
+
|
|
83
|
+
Adds a new template to the recognizer.
|
|
84
|
+
|
|
85
|
+
#### `deleteUserGestures(): number`
|
|
86
|
+
|
|
87
|
+
Resets the templates to the initial set passed during construction.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
This project is licensed under the **New BSD License** - see the [LICENSE](./LICENSE) file for details.
|
|
92
|
+
|
|
93
|
+
## Acknowledgements
|
|
94
|
+
|
|
95
|
+
The core algorithm is a TypeScript port of the **$Q Super-Quick Recognizer** originally developed by:
|
|
96
|
+
|
|
97
|
+
- Radu-Daniel Vatavu, Ph.D. (University Stefan cel Mare of Suceava)
|
|
98
|
+
- Lisa Anthony, Ph.D. (University of Florida)
|
|
99
|
+
- Jacob O. Wobbrock, Ph.D. (University of Washington)
|
|
100
|
+
|
|
101
|
+
*Vatavu, R.-D., Anthony, L. and Wobbrock, J.O. (2018). $Q: A Super-Quick, Articulation-Invariant $1-Family Recognizer. Proceedings of the ACM Conference on Human Factors in Computing Systems (CHI '18). Montreal, Quebec (April 21-26, 2018). New York: ACM Press, paper no. 531.*
|
|
102
|
+
|
|
103
|
+
Original JavaScript code is distributed under the New BSD License.
|
|
104
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Point } from '../models/Point';
|
|
2
|
+
export declare const GESTURE_T: {
|
|
3
|
+
name: string;
|
|
4
|
+
points: Point[];
|
|
5
|
+
};
|
|
6
|
+
export declare const GESTURE_N: {
|
|
7
|
+
name: string;
|
|
8
|
+
points: Point[];
|
|
9
|
+
};
|
|
10
|
+
export declare const GESTURE_D: {
|
|
11
|
+
name: string;
|
|
12
|
+
points: Point[];
|
|
13
|
+
};
|
|
14
|
+
export declare const GESTURE_P: {
|
|
15
|
+
name: string;
|
|
16
|
+
points: Point[];
|
|
17
|
+
};
|
|
18
|
+
export declare const GESTURE_X: {
|
|
19
|
+
name: string;
|
|
20
|
+
points: Point[];
|
|
21
|
+
};
|
|
22
|
+
export declare const GESTURE_H: {
|
|
23
|
+
name: string;
|
|
24
|
+
points: Point[];
|
|
25
|
+
};
|
|
26
|
+
export declare const GESTURE_I: {
|
|
27
|
+
name: string;
|
|
28
|
+
points: Point[];
|
|
29
|
+
};
|
|
30
|
+
export declare const GESTURE_EXCLAMATION: {
|
|
31
|
+
name: string;
|
|
32
|
+
points: Point[];
|
|
33
|
+
};
|
|
34
|
+
export declare const GESTURE_LINE: {
|
|
35
|
+
name: string;
|
|
36
|
+
points: Point[];
|
|
37
|
+
};
|
|
38
|
+
export declare const GESTURE_STAR_5: {
|
|
39
|
+
name: string;
|
|
40
|
+
points: Point[];
|
|
41
|
+
};
|
|
42
|
+
export declare const GESTURE_NULL: {
|
|
43
|
+
name: string;
|
|
44
|
+
points: Point[];
|
|
45
|
+
};
|
|
46
|
+
export declare const GESTURE_ARROWHEAD: {
|
|
47
|
+
name: string;
|
|
48
|
+
points: Point[];
|
|
49
|
+
};
|
|
50
|
+
export declare const GESTURE_PITCHFORK: {
|
|
51
|
+
name: string;
|
|
52
|
+
points: Point[];
|
|
53
|
+
};
|
|
54
|
+
export declare const GESTURE_STAR_6: {
|
|
55
|
+
name: string;
|
|
56
|
+
points: Point[];
|
|
57
|
+
};
|
|
58
|
+
export declare const GESTURE_ASTERISK: {
|
|
59
|
+
name: string;
|
|
60
|
+
points: Point[];
|
|
61
|
+
};
|
|
62
|
+
export declare const GESTURE_HALF_NOTE: {
|
|
63
|
+
name: string;
|
|
64
|
+
points: Point[];
|
|
65
|
+
};
|
|
66
|
+
export declare const DEFAULT_GESTURES: {
|
|
67
|
+
name: string;
|
|
68
|
+
points: Point[];
|
|
69
|
+
}[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Point } from '../models/Point';
|
|
2
|
+
import { PointCloud } from '../models/PointCloud';
|
|
3
|
+
import { Result } from '../models/Result';
|
|
4
|
+
export declare class QDollarRecognizer {
|
|
5
|
+
pointClouds: PointCloud[];
|
|
6
|
+
private initialCount;
|
|
7
|
+
constructor(initialData?: {
|
|
8
|
+
name: string;
|
|
9
|
+
points: Point[];
|
|
10
|
+
}[]);
|
|
11
|
+
recognize(points: Point[]): Result[];
|
|
12
|
+
addGesture(name: string, points: Point[]): number;
|
|
13
|
+
deleteUserGestures(): number;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{x;y;id;intX=0;intY=0;constructor(e,t,n){this.x=e,this.y=t,this.id=n}},t=32,n=new e(0,0,0),r=1024,i=64,a=r/64;function o(e,t){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r}function s(e,t){return Math.sqrt(o(e,t))}function c(t,n){let r=p(t)/(n-1),i=0,a=[t[0]],o=[...t];for(let t=1;t<o.length;t++)if(o[t].id===o[t-1].id){let n=s(o[t-1],o[t]);if(i+n>=r){let s=new e(o[t-1].x+(r-i)/n*(o[t].x-o[t-1].x),o[t-1].y+(r-i)/n*(o[t].y-o[t-1].y),o[t].id);a.push(s),o.splice(t,0,s),i=0}else i+=n}return a.length===n-1&&a.push(new e(o[o.length-1].x,o[o.length-1].y,o[o.length-1].id)),a}function l(t){let n=1/0,r=-1/0,i=1/0,a=-1/0;for(let e of t)n=Math.min(n,e.x),i=Math.min(i,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y);let o=Math.max(r-n,a-i);return t.map(t=>new e((t.x-n)/o,(t.y-i)/o,t.id))}function u(t,n){let r=m(t);return t.map(t=>new e(t.x+n.x-r.x,t.y+n.y-r.y,t.id))}function d(e){for(let t of e)t.intX=Math.round((t.x+1)/2*(r-1)),t.intY=Math.round((t.y+1)/2*(r-1));return e}function f(e){let t=Array.from({length:64},()=>Array(64));for(let n=0;n<64;n++)for(let r=0;r<64;r++){let i=-1,a=1/0;for(let t=0;t<e.length;t++){let o=Math.round(e[t].intX/16),s=Math.round(e[t].intY/16),c=(o-n)*(o-n)+(s-r)*(s-r);c<a&&(a=c,i=t)}t[n][r]=i}return t}function p(e){let t=0;for(let n=1;n<e.length;n++)e[n].id===e[n-1].id&&(t+=s(e[n-1],e[n]));return t}function m(t){let n=0,r=0;for(let e of t)n+=e.x,r+=e.y;return new e(n/t.length,r/t.length,0)}var h=class{name;points;lut;constructor(e,t){this.name=e,this.points=c(t,32),this.points=l(this.points),this.points=u(this.points,n),this.points=d(this.points),this.lut=f(this.points)}},g=class{name;score;time;constructor(e,t,n){this.name=e,this.score=t,this.time=n}};function _(e,t,n){let r=e.points.length,i=Math.floor(r**.5),a=y(e.points,t.points,i,t.lut),o=y(t.points,e.points,i,e.lut);for(let s=0,c=0;s<r;s+=i,c++)a[c]<n&&(n=Math.min(n,v(e.points,t.points,s,n))),o[c]<n&&(n=Math.min(n,v(t.points,e.points,s,n)));return n}function v(e,t,n,r){let i=e.length,a=Array.from({length:i},(e,t)=>t),s=n,c=i,l=0;do{let n=-1,u=1/0;for(let r=0;r<a.length;r++){let i=o(e[s],t[a[r]]);i<u&&(u=i,n=r)}if(a.splice(n,1),l+=c*u,l>=r)return l;c--,s=(s+1)%i}while(s!==n);return l}function y(e,t,n,r){let i=e.length,a=Array(Math.floor(i/n)+1).fill(0),s=Array(i);a[0]=0;for(let n=0;n<i;n++){let c=Math.round(e[n].intX/16),l=Math.round(e[n].intY/16),u=r[c][l],d=o(e[n],t[u]);s[n]=n===0?d:s[n-1]+d,a[0]+=(i-n)*d}for(let e=n,t=1;e<i;e+=n,t++)a[t]=a[0]+e*s[i-1]-i*s[e-1];return a}var b={name:`T`,points:[new e(30,7,1),new e(103,7,1),new e(66,7,2),new e(66,87,2)]},x={name:`N`,points:[new e(177,92,1),new e(177,2,1),new e(182,1,2),new e(246,95,2),new e(247,87,3),new e(247,1,3)]},S={name:`D`,points:[new e(345,9,1),new e(345,87,1),new e(351,8,2),new e(363,8,2),new e(372,9,2),new e(380,11,2),new e(386,14,2),new e(391,17,2),new e(394,22,2),new e(397,28,2),new e(399,34,2),new e(400,42,2),new e(400,50,2),new e(400,56,2),new e(399,61,2),new e(397,66,2),new e(394,70,2),new e(391,74,2),new e(386,78,2),new e(382,81,2),new e(377,83,2),new e(372,85,2),new e(367,87,2),new e(360,87,2),new e(355,88,2),new e(349,87,2)]},C={name:`P`,points:[new e(507,8,1),new e(507,87,1),new e(513,7,2),new e(528,7,2),new e(537,8,2),new e(544,10,2),new e(550,12,2),new e(555,15,2),new e(558,18,2),new e(560,22,2),new e(561,27,2),new e(562,33,2),new e(561,37,2),new e(559,42,2),new e(556,45,2),new e(550,48,2),new e(544,51,2),new e(538,53,2),new e(532,54,2),new e(525,55,2),new e(519,55,2),new e(513,55,2),new e(510,55,2)]},w={name:`X`,points:[new e(30,146,1),new e(106,222,1),new e(30,225,2),new e(106,146,2)]},T={name:`H`,points:[new e(188,137,1),new e(188,225,1),new e(188,180,2),new e(241,180,2),new e(241,137,3),new e(241,225,3)]},E={name:`I`,points:[new e(371,149,1),new e(371,221,1),new e(341,149,2),new e(401,149,2),new e(341,221,3),new e(401,221,3)]},D={name:`exclamation`,points:[new e(526,142,1),new e(526,204,1),new e(526,221,2)]},O={name:`line`,points:[new e(12,347,1),new e(119,347,1)]},k={name:`five-point star`,points:[new e(177,396,1),new e(223,299,1),new e(262,396,1),new e(168,332,1),new e(278,332,1),new e(184,397,1)]},A={name:`null`,points:[new e(382,310,1),new e(377,308,1),new e(373,307,1),new e(366,307,1),new e(360,310,1),new e(356,313,1),new e(353,316,1),new e(349,321,1),new e(347,326,1),new e(344,331,1),new e(342,337,1),new e(341,343,1),new e(341,350,1),new e(341,358,1),new e(342,362,1),new e(344,366,1),new e(347,370,1),new e(351,374,1),new e(356,379,1),new e(361,382,1),new e(368,385,1),new e(374,387,1),new e(381,387,1),new e(390,387,1),new e(397,385,1),new e(404,382,1),new e(408,378,1),new e(412,373,1),new e(416,367,1),new e(418,361,1),new e(419,353,1),new e(418,346,1),new e(417,341,1),new e(416,336,1),new e(413,331,1),new e(410,326,1),new e(404,320,1),new e(400,317,1),new e(393,313,1),new e(392,312,1),new e(418,309,2),new e(337,390,2)]},j={name:`arrowhead`,points:[new e(506,349,1),new e(574,349,1),new e(525,306,2),new e(584,349,2),new e(525,388,2)]},M={name:`pitchfork`,points:[new e(38,470,1),new e(36,476,1),new e(36,482,1),new e(37,489,1),new e(39,496,1),new e(42,500,1),new e(46,503,1),new e(50,507,1),new e(56,509,1),new e(63,509,1),new e(70,508,1),new e(75,506,1),new e(79,503,1),new e(82,499,1),new e(85,493,1),new e(87,487,1),new e(88,480,1),new e(88,474,1),new e(87,468,1),new e(62,464,2),new e(62,571,2)]},N={name:`six-point star`,points:[new e(177,554,1),new e(223,476,1),new e(268,554,1),new e(183,554,1),new e(177,490,2),new e(223,568,2),new e(268,490,2),new e(183,490,2)]},P={name:`asterisk`,points:[new e(325,499,1),new e(417,557,1),new e(417,499,2),new e(325,557,2),new e(371,486,3),new e(371,571,3)]},F={name:`half-note`,points:[new e(546,465,1),new e(546,531,1),new e(540,530,2),new e(536,529,2),new e(533,528,2),new e(529,529,2),new e(524,530,2),new e(520,532,2),new e(515,535,2),new e(511,539,2),new e(508,545,2),new e(506,548,2),new e(506,554,2),new e(509,558,2),new e(512,561,2),new e(517,564,2),new e(521,564,2),new e(527,563,2),new e(531,560,2),new e(535,557,2),new e(538,553,2),new e(542,548,2),new e(544,544,2),new e(546,540,2),new e(546,536,2)]},I=[b,x,S,C,w,T,E,D,O,k,A,j,M,N,P,F],L=class{pointClouds=[];initialCount=0;constructor(e=I){this.pointClouds=e.map(e=>new h(e.name,e.points)),this.initialCount=this.pointClouds.length}recognize(e){let t=Date.now(),n=new h(``,e),r=[];for(let e of this.pointClouds){let t=_(n,e,1/0),i=t>1?1/t:1;r.push(new g(e.name,i,0))}r.sort((e,t)=>t.score-e.score);let i=Date.now()-t;return r.forEach(e=>e.time=i),r}addGesture(e,t){return this.pointClouds.push(new h(e,t)),this.pointClouds.filter(t=>t.name===e).length}deleteUserGestures(){return this.pointClouds.length=this.initialCount,this.initialCount}};exports.DEFAULT_GESTURES=I,exports.GESTURE_ARROWHEAD=j,exports.GESTURE_ASTERISK=P,exports.GESTURE_D=S,exports.GESTURE_EXCLAMATION=D,exports.GESTURE_H=T,exports.GESTURE_HALF_NOTE=F,exports.GESTURE_I=E,exports.GESTURE_LINE=O,exports.GESTURE_N=x,exports.GESTURE_NULL=A,exports.GESTURE_P=C,exports.GESTURE_PITCHFORK=M,exports.GESTURE_STAR_5=k,exports.GESTURE_STAR_6=N,exports.GESTURE_T=b,exports.GESTURE_X=w,exports.LUT_SCALE_FACTOR=a,exports.LUT_SIZE=i,exports.MAX_INT_COORD=r,exports.NUM_POINTS=t,exports.ORIGIN=n,exports.Point=e,exports.PointCloud=h,exports.QDollarRecognizer=L,exports.Result=g;
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","names":[],"sources":["../src/models/Point.ts","../src/constants/configurations.ts","../src/utilities/math.ts","../src/utilities/transform.ts","../src/models/PointCloud.ts","../src/models/Result.ts","../src/utilities/cloudMatch.ts","../src/constants/gestures.ts","../src/core/QDollarRecognizer.ts"],"sourcesContent":["export class Point {\r\n x: number;\r\n y: number;\r\n id: number;\r\n intX: number = 0;\r\n intY: number = 0;\r\n\r\n constructor(x: number, y: number, id: number) {\r\n this.x = x;\r\n this.y = y;\r\n this.id = id;\r\n }\r\n}\r\n","import { Point } from \"../models/Point\";\r\n\r\nexport const NUM_POINTS = 32;\r\nexport const ORIGIN = new Point(0, 0, 0);\r\nexport const MAX_INT_COORD = 1024;\r\nexport const LUT_SIZE = 64;\r\nexport const LUT_SCALE_FACTOR = MAX_INT_COORD / LUT_SIZE;\r\n","import { Point } from \"../models/Point\";\r\n\r\nexport function sqrEuclideanDistance(pt1: Point, pt2: Point): number {\r\n const dx = pt2.x - pt1.x;\r\n const dy = pt2.y - pt1.y;\r\n return dx * dx + dy * dy;\r\n}\r\n\r\nexport function euclideanDistance(pt1: Point, pt2: Point): number {\r\n return Math.sqrt(sqrEuclideanDistance(pt1, pt2));\r\n}\r\n","import { Point } from \"../models/Point\";\r\nimport {\r\n MAX_INT_COORD,\r\n LUT_SCALE_FACTOR,\r\n LUT_SIZE,\r\n} from \"../constants/configurations\";\r\nimport { euclideanDistance } from \"./math\";\r\n\r\nexport function resample(points: Point[], n: number): Point[] {\r\n const iLen = pathLength(points) / (n - 1);\r\n let dVal = 0.0;\r\n const newPoints: Point[] = [points[0]];\r\n const tempPoints = [...points];\r\n\r\n for (let i = 1; i < tempPoints.length; i++) {\r\n if (tempPoints[i].id === tempPoints[i - 1].id) {\r\n const d = euclideanDistance(tempPoints[i - 1], tempPoints[i]);\r\n if (dVal + d >= iLen) {\r\n const qx =\r\n tempPoints[i - 1].x +\r\n ((iLen - dVal) / d) * (tempPoints[i].x - tempPoints[i - 1].x);\r\n const qy =\r\n tempPoints[i - 1].y +\r\n ((iLen - dVal) / d) * (tempPoints[i].y - tempPoints[i - 1].y);\r\n const q = new Point(qx, qy, tempPoints[i].id);\r\n newPoints.push(q);\r\n tempPoints.splice(i, 0, q);\r\n dVal = 0.0;\r\n } else {\r\n dVal += d;\r\n }\r\n }\r\n }\r\n if (newPoints.length === n - 1) {\r\n newPoints.push(\r\n new Point(\r\n tempPoints[tempPoints.length - 1].x,\r\n tempPoints[tempPoints.length - 1].y,\r\n tempPoints[tempPoints.length - 1].id,\r\n ),\r\n );\r\n }\r\n return newPoints;\r\n}\r\n\r\nexport function scale(points: Point[]): Point[] {\r\n let minX = +Infinity;\r\n let maxX = -Infinity;\r\n let minY = +Infinity;\r\n let maxY = -Infinity;\r\n for (const p of points) {\r\n minX = Math.min(minX, p.x);\r\n minY = Math.min(minY, p.y);\r\n maxX = Math.max(maxX, p.x);\r\n maxY = Math.max(maxY, p.y);\r\n }\r\n const size = Math.max(maxX - minX, maxY - minY);\r\n return points.map(\r\n (p) => new Point((p.x - minX) / size, (p.y - minY) / size, p.id),\r\n );\r\n}\r\n\r\nexport function translateTo(points: Point[], pt: Point): Point[] {\r\n const c = centroid(points);\r\n return points.map((p) => new Point(p.x + pt.x - c.x, p.y + pt.y - c.y, p.id));\r\n}\r\n\r\nexport function makeIntCoords(points: Point[]): Point[] {\r\n for (const p of points) {\r\n p.intX = Math.round(((p.x + 1.0) / 2.0) * (MAX_INT_COORD - 1));\r\n p.intY = Math.round(((p.y + 1.0) / 2.0) * (MAX_INT_COORD - 1));\r\n }\r\n return points;\r\n}\r\n\r\nexport function computeLUT(points: Point[]): number[][] {\r\n const lut: number[][] = Array.from(\r\n { length: LUT_SIZE },\r\n () => new Array(LUT_SIZE),\r\n );\r\n for (let x = 0; x < LUT_SIZE; x++) {\r\n for (let y = 0; y < LUT_SIZE; y++) {\r\n let u = -1;\r\n let b = +Infinity;\r\n for (let i = 0; i < points.length; i++) {\r\n const row = Math.round(points[i].intX / LUT_SCALE_FACTOR);\r\n const col = Math.round(points[i].intY / LUT_SCALE_FACTOR);\r\n const d = (row - x) * (row - x) + (col - y) * (col - y);\r\n if (d < b) {\r\n b = d;\r\n u = i;\r\n }\r\n }\r\n lut[x][y] = u;\r\n }\r\n }\r\n return lut;\r\n}\r\n\r\nfunction pathLength(points: Point[]): number {\r\n let d = 0.0;\r\n for (let i = 1; i < points.length; i++) {\r\n if (points[i].id === points[i - 1].id) {\r\n d += euclideanDistance(points[i - 1], points[i]);\r\n }\r\n }\r\n return d;\r\n}\r\n\r\nfunction centroid(points: Point[]): Point {\r\n let x = 0.0;\r\n let y = 0.0;\r\n for (const p of points) {\r\n x += p.x;\r\n y += p.y;\r\n }\r\n return new Point(x / points.length, y / points.length, 0);\r\n}\r\n","import { Point } from \"./Point\";\r\nimport { NUM_POINTS, ORIGIN } from \"../constants/configurations\";\r\nimport {\r\n resample,\r\n scale,\r\n translateTo,\r\n makeIntCoords,\r\n computeLUT,\r\n} from \"../utilities/transform\";\r\n\r\nexport class PointCloud {\r\n name: string;\r\n points: Point[];\r\n lut: number[][];\r\n\r\n constructor(name: string, points: Point[]) {\r\n this.name = name;\r\n this.points = resample(points, NUM_POINTS);\r\n this.points = scale(this.points);\r\n this.points = translateTo(this.points, ORIGIN);\r\n this.points = makeIntCoords(this.points);\r\n this.lut = computeLUT(this.points);\r\n }\r\n}\r\n","export class Result {\r\n name: string;\r\n score: number;\r\n time: number;\r\n\r\n constructor(name: string, score: number, ms: number) {\r\n this.name = name;\r\n this.score = score;\r\n this.time = ms;\r\n }\r\n}\r\n","import { Point } from \"../models/Point\";\r\nimport { sqrEuclideanDistance } from \"./math\";\r\nimport { LUT_SCALE_FACTOR } from \"../constants/configurations\";\r\n\r\nexport function cloudMatch(\r\n candidate: { points: Point[]; lut: number[][] },\r\n template: { points: Point[]; lut: number[][] },\r\n minSoFar: number,\r\n): number {\r\n const n = candidate.points.length;\r\n const step = Math.floor(Math.pow(n, 0.5));\r\n const lb1 = computeLowerBound(\r\n candidate.points,\r\n template.points,\r\n step,\r\n template.lut,\r\n );\r\n const lb2 = computeLowerBound(\r\n template.points,\r\n candidate.points,\r\n step,\r\n candidate.lut,\r\n );\r\n\r\n for (let i = 0, j = 0; i < n; i += step, j++) {\r\n if (lb1[j] < minSoFar) {\r\n minSoFar = Math.min(\r\n minSoFar,\r\n cloudDistance(candidate.points, template.points, i, minSoFar),\r\n );\r\n }\r\n if (lb2[j] < minSoFar) {\r\n minSoFar = Math.min(\r\n minSoFar,\r\n cloudDistance(template.points, candidate.points, i, minSoFar),\r\n );\r\n }\r\n }\r\n return minSoFar;\r\n}\r\n\r\nfunction cloudDistance(\r\n pts1: Point[],\r\n pts2: Point[],\r\n start: number,\r\n minSoFar: number,\r\n): number {\r\n const n = pts1.length;\r\n const unmatched = Array.from({ length: n }, (_, j) => j);\r\n let i = start;\r\n let weight = n;\r\n let sum = 0.0;\r\n do {\r\n let u = -1;\r\n let b = +Infinity;\r\n for (let j = 0; j < unmatched.length; j++) {\r\n const d = sqrEuclideanDistance(pts1[i], pts2[unmatched[j]]);\r\n if (d < b) {\r\n b = d;\r\n u = j;\r\n }\r\n }\r\n unmatched.splice(u, 1);\r\n sum += weight * b;\r\n if (sum >= minSoFar) return sum;\r\n weight--;\r\n i = (i + 1) % n;\r\n } while (i !== start);\r\n return sum;\r\n}\r\n\r\nfunction computeLowerBound(\r\n pts1: Point[],\r\n pts2: Point[],\r\n step: number,\r\n lut: number[][],\r\n): number[] {\r\n const n = pts1.length;\r\n const lb: number[] = new Array(Math.floor(n / step) + 1).fill(0.0);\r\n const sat: number[] = new Array(n);\r\n lb[0] = 0.0;\r\n for (let i = 0; i < n; i++) {\r\n const x = Math.round(pts1[i].intX / LUT_SCALE_FACTOR);\r\n const y = Math.round(pts1[i].intY / LUT_SCALE_FACTOR);\r\n const index = lut[x][y];\r\n const d = sqrEuclideanDistance(pts1[i], pts2[index]);\r\n sat[i] = i === 0 ? d : sat[i - 1] + d;\r\n lb[0] += (n - i) * d;\r\n }\r\n for (let i = step, j = 1; i < n; i += step, j++) {\r\n lb[j] = lb[0] + i * sat[n - 1] - n * sat[i - 1];\r\n }\r\n return lb;\r\n}\r\n","import { Point } from \"../models/Point\";\r\n\r\nexport const GESTURE_T = {\r\n name: \"T\",\r\n points: [\r\n new Point(30, 7, 1),\r\n new Point(103, 7, 1),\r\n new Point(66, 7, 2),\r\n new Point(66, 87, 2),\r\n ],\r\n};\r\nexport const GESTURE_N = {\r\n name: \"N\",\r\n points: [\r\n new Point(177, 92, 1),\r\n new Point(177, 2, 1),\r\n new Point(182, 1, 2),\r\n new Point(246, 95, 2),\r\n new Point(247, 87, 3),\r\n new Point(247, 1, 3),\r\n ],\r\n};\r\nexport const GESTURE_D = {\r\n name: \"D\",\r\n points: [\r\n new Point(345, 9, 1),\r\n new Point(345, 87, 1),\r\n new Point(351, 8, 2),\r\n new Point(363, 8, 2),\r\n new Point(372, 9, 2),\r\n new Point(380, 11, 2),\r\n new Point(386, 14, 2),\r\n new Point(391, 17, 2),\r\n new Point(394, 22, 2),\r\n new Point(397, 28, 2),\r\n new Point(399, 34, 2),\r\n new Point(400, 42, 2),\r\n new Point(400, 50, 2),\r\n new Point(400, 56, 2),\r\n new Point(399, 61, 2),\r\n new Point(397, 66, 2),\r\n new Point(394, 70, 2),\r\n new Point(391, 74, 2),\r\n new Point(386, 78, 2),\r\n new Point(382, 81, 2),\r\n new Point(377, 83, 2),\r\n new Point(372, 85, 2),\r\n new Point(367, 87, 2),\r\n new Point(360, 87, 2),\r\n new Point(355, 88, 2),\r\n new Point(349, 87, 2),\r\n ],\r\n};\r\nexport const GESTURE_P = {\r\n name: \"P\",\r\n points: [\r\n new Point(507, 8, 1),\r\n new Point(507, 87, 1),\r\n new Point(513, 7, 2),\r\n new Point(528, 7, 2),\r\n new Point(537, 8, 2),\r\n new Point(544, 10, 2),\r\n new Point(550, 12, 2),\r\n new Point(555, 15, 2),\r\n new Point(558, 18, 2),\r\n new Point(560, 22, 2),\r\n new Point(561, 27, 2),\r\n new Point(562, 33, 2),\r\n new Point(561, 37, 2),\r\n new Point(559, 42, 2),\r\n new Point(556, 45, 2),\r\n new Point(550, 48, 2),\r\n new Point(544, 51, 2),\r\n new Point(538, 53, 2),\r\n new Point(532, 54, 2),\r\n new Point(525, 55, 2),\r\n new Point(519, 55, 2),\r\n new Point(513, 55, 2),\r\n new Point(510, 55, 2),\r\n ],\r\n};\r\nexport const GESTURE_X = {\r\n name: \"X\",\r\n points: [\r\n new Point(30, 146, 1),\r\n new Point(106, 222, 1),\r\n new Point(30, 225, 2),\r\n new Point(106, 146, 2),\r\n ],\r\n};\r\nexport const GESTURE_H = {\r\n name: \"H\",\r\n points: [\r\n new Point(188, 137, 1),\r\n new Point(188, 225, 1),\r\n new Point(188, 180, 2),\r\n new Point(241, 180, 2),\r\n new Point(241, 137, 3),\r\n new Point(241, 225, 3),\r\n ],\r\n};\r\nexport const GESTURE_I = {\r\n name: \"I\",\r\n points: [\r\n new Point(371, 149, 1),\r\n new Point(371, 221, 1),\r\n new Point(341, 149, 2),\r\n new Point(401, 149, 2),\r\n new Point(341, 221, 3),\r\n new Point(401, 221, 3),\r\n ],\r\n};\r\nexport const GESTURE_EXCLAMATION = {\r\n name: \"exclamation\",\r\n points: [\r\n new Point(526, 142, 1),\r\n new Point(526, 204, 1),\r\n new Point(526, 221, 2),\r\n ],\r\n};\r\nexport const GESTURE_LINE = {\r\n name: \"line\",\r\n points: [new Point(12, 347, 1), new Point(119, 347, 1)],\r\n};\r\nexport const GESTURE_STAR_5 = {\r\n name: \"five-point star\",\r\n points: [\r\n new Point(177, 396, 1),\r\n new Point(223, 299, 1),\r\n new Point(262, 396, 1),\r\n new Point(168, 332, 1),\r\n new Point(278, 332, 1),\r\n new Point(184, 397, 1),\r\n ],\r\n};\r\nexport const GESTURE_NULL = {\r\n name: \"null\",\r\n points: [\r\n new Point(382, 310, 1),\r\n new Point(377, 308, 1),\r\n new Point(373, 307, 1),\r\n new Point(366, 307, 1),\r\n new Point(360, 310, 1),\r\n new Point(356, 313, 1),\r\n new Point(353, 316, 1),\r\n new Point(349, 321, 1),\r\n new Point(347, 326, 1),\r\n new Point(344, 331, 1),\r\n new Point(342, 337, 1),\r\n new Point(341, 343, 1),\r\n new Point(341, 350, 1),\r\n new Point(341, 358, 1),\r\n new Point(342, 362, 1),\r\n new Point(344, 366, 1),\r\n new Point(347, 370, 1),\r\n new Point(351, 374, 1),\r\n new Point(356, 379, 1),\r\n new Point(361, 382, 1),\r\n new Point(368, 385, 1),\r\n new Point(374, 387, 1),\r\n new Point(381, 387, 1),\r\n new Point(390, 387, 1),\r\n new Point(397, 385, 1),\r\n new Point(404, 382, 1),\r\n new Point(408, 378, 1),\r\n new Point(412, 373, 1),\r\n new Point(416, 367, 1),\r\n new Point(418, 361, 1),\r\n new Point(419, 353, 1),\r\n new Point(418, 346, 1),\r\n new Point(417, 341, 1),\r\n new Point(416, 336, 1),\r\n new Point(413, 331, 1),\r\n new Point(410, 326, 1),\r\n new Point(404, 320, 1),\r\n new Point(400, 317, 1),\r\n new Point(393, 313, 1),\r\n new Point(392, 312, 1),\r\n new Point(418, 309, 2),\r\n new Point(337, 390, 2),\r\n ],\r\n};\r\nexport const GESTURE_ARROWHEAD = {\r\n name: \"arrowhead\",\r\n points: [\r\n new Point(506, 349, 1),\r\n new Point(574, 349, 1),\r\n new Point(525, 306, 2),\r\n new Point(584, 349, 2),\r\n new Point(525, 388, 2),\r\n ],\r\n};\r\nexport const GESTURE_PITCHFORK = {\r\n name: \"pitchfork\",\r\n points: [\r\n new Point(38, 470, 1),\r\n new Point(36, 476, 1),\r\n new Point(36, 482, 1),\r\n new Point(37, 489, 1),\r\n new Point(39, 496, 1),\r\n new Point(42, 500, 1),\r\n new Point(46, 503, 1),\r\n new Point(50, 507, 1),\r\n new Point(56, 509, 1),\r\n new Point(63, 509, 1),\r\n new Point(70, 508, 1),\r\n new Point(75, 506, 1),\r\n new Point(79, 503, 1),\r\n new Point(82, 499, 1),\r\n new Point(85, 493, 1),\r\n new Point(87, 487, 1),\r\n new Point(88, 480, 1),\r\n new Point(88, 474, 1),\r\n new Point(87, 468, 1),\r\n new Point(62, 464, 2),\r\n new Point(62, 571, 2),\r\n ],\r\n};\r\nexport const GESTURE_STAR_6 = {\r\n name: \"six-point star\",\r\n points: [\r\n new Point(177, 554, 1),\r\n new Point(223, 476, 1),\r\n new Point(268, 554, 1),\r\n new Point(183, 554, 1),\r\n new Point(177, 490, 2),\r\n new Point(223, 568, 2),\r\n new Point(268, 490, 2),\r\n new Point(183, 490, 2),\r\n ],\r\n};\r\nexport const GESTURE_ASTERISK = {\r\n name: \"asterisk\",\r\n points: [\r\n new Point(325, 499, 1),\r\n new Point(417, 557, 1),\r\n new Point(417, 499, 2),\r\n new Point(325, 557, 2),\r\n new Point(371, 486, 3),\r\n new Point(371, 571, 3),\r\n ],\r\n};\r\nexport const GESTURE_HALF_NOTE = {\r\n name: \"half-note\",\r\n points: [\r\n new Point(546, 465, 1),\r\n new Point(546, 531, 1),\r\n new Point(540, 530, 2),\r\n new Point(536, 529, 2),\r\n new Point(533, 528, 2),\r\n new Point(529, 529, 2),\r\n new Point(524, 530, 2),\r\n new Point(520, 532, 2),\r\n new Point(515, 535, 2),\r\n new Point(511, 539, 2),\r\n new Point(508, 545, 2),\r\n new Point(506, 548, 2),\r\n new Point(506, 554, 2),\r\n new Point(509, 558, 2),\r\n new Point(512, 561, 2),\r\n new Point(517, 564, 2),\r\n new Point(521, 564, 2),\r\n new Point(527, 563, 2),\r\n new Point(531, 560, 2),\r\n new Point(535, 557, 2),\r\n new Point(538, 553, 2),\r\n new Point(542, 548, 2),\r\n new Point(544, 544, 2),\r\n new Point(546, 540, 2),\r\n new Point(546, 536, 2),\r\n ],\r\n};\r\n\r\nexport const DEFAULT_GESTURES = [\r\n GESTURE_T,\r\n GESTURE_N,\r\n GESTURE_D,\r\n GESTURE_P,\r\n GESTURE_X,\r\n GESTURE_H,\r\n GESTURE_I,\r\n GESTURE_EXCLAMATION,\r\n GESTURE_LINE,\r\n GESTURE_STAR_5,\r\n GESTURE_NULL,\r\n GESTURE_ARROWHEAD,\r\n GESTURE_PITCHFORK,\r\n GESTURE_STAR_6,\r\n GESTURE_ASTERISK,\r\n GESTURE_HALF_NOTE,\r\n];\r\n","import { Point } from \"../models/Point\";\r\nimport { PointCloud } from \"../models/PointCloud\";\r\nimport { Result } from \"../models/Result\";\r\nimport { cloudMatch } from \"../utilities/cloudMatch\";\r\nimport { DEFAULT_GESTURES } from \"../constants/gestures\";\r\n\r\nexport class QDollarRecognizer {\r\n public pointClouds: PointCloud[] = [];\r\n private initialCount: number = 0;\r\n\r\n constructor(\r\n initialData: { name: string; points: Point[] }[] = DEFAULT_GESTURES,\r\n ) {\r\n this.pointClouds = initialData.map(\r\n (data) => new PointCloud(data.name, data.points),\r\n );\r\n this.initialCount = this.pointClouds.length;\r\n }\r\n\r\n public recognize(points: Point[]): Result[] {\r\n const t0 = Date.now();\r\n const candidate = new PointCloud(\"\", points);\r\n const results: Result[] = [];\r\n\r\n for (const template of this.pointClouds) {\r\n const d = cloudMatch(candidate, template, +Infinity);\r\n const score = d > 1.0 ? 1.0 / d : 1.0;\r\n results.push(new Result(template.name, score, 0));\r\n }\r\n\r\n results.sort((a, b) => b.score - a.score);\r\n\r\n const totalTime = Date.now() - t0;\r\n results.forEach((r) => (r.time = totalTime));\r\n\r\n return results;\r\n }\r\n\r\n public addGesture(name: string, points: Point[]): number {\r\n this.pointClouds.push(new PointCloud(name, points));\r\n return this.pointClouds.filter((p) => p.name === name).length;\r\n }\r\n\r\n public deleteUserGestures(): number {\r\n this.pointClouds.length = this.initialCount;\r\n return this.initialCount;\r\n }\r\n}\r\n"],"mappings":"mEAAA,IAAa,EAAb,KAAmB,CACjB,EACA,EACA,GACA,KAAe,EACf,KAAe,EAEf,YAAY,EAAW,EAAW,EAAY,CAC5C,KAAK,EAAI,EACT,KAAK,EAAI,EACT,KAAK,GAAK,CACZ,CACF,ECVa,EAAa,GACb,EAAS,IAAI,EAAM,EAAG,EAAG,CAAC,EAC1B,EAAgB,KAChB,EAAW,GACX,EAAmB,EAAA,GCJhC,SAAgB,EAAqB,EAAY,EAAoB,CACnE,IAAM,EAAK,EAAI,EAAI,EAAI,EACjB,EAAK,EAAI,EAAI,EAAI,EACvB,OAAO,EAAK,EAAK,EAAK,CACxB,CAEA,SAAgB,EAAkB,EAAY,EAAoB,CAChE,OAAO,KAAK,KAAK,EAAqB,EAAK,CAAG,CAAC,CACjD,CCFA,SAAgB,EAAS,EAAiB,EAAoB,CAC5D,IAAM,EAA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Magrofuoco
|
|
7
|
+
* Universite Catholique de Louvain
|
|
8
|
+
* Louvain-la-Neuve, Belgium
|
|
9
|
+
* nathan.magrofuoco@uclouvain.be
|
|
10
|
+
*
|
|
11
|
+
* Original $Q authors (C# version):
|
|
12
|
+
*
|
|
13
|
+
* Radu-Daniel Vatavu, Ph.D.
|
|
14
|
+
* University Stefan cel Mare of Suceava
|
|
15
|
+
* Suceava 720229, Romania
|
|
16
|
+
* radu.vatavu@usm.ro
|
|
17
|
+
*
|
|
18
|
+
* Lisa Anthony, Ph.D.
|
|
19
|
+
* Department of CISE
|
|
20
|
+
* University of Florida
|
|
21
|
+
* Gainesville, FL, USA 32611
|
|
22
|
+
* lanthony@cise.ufl.edu
|
|
23
|
+
*
|
|
24
|
+
* Jacob O. Wobbrock, Ph.D.
|
|
25
|
+
* The Information School | DUB Group
|
|
26
|
+
* University of Washington
|
|
27
|
+
* Seattle, WA, USA 98195-2840
|
|
28
|
+
* wobbrock@uw.edu
|
|
29
|
+
*
|
|
30
|
+
* The academic publication for the $Q recognizer, and what should be
|
|
31
|
+
* used to cite it, is:
|
|
32
|
+
*
|
|
33
|
+
* Vatavu, R.-D., Anthony, L. and Wobbrock, J.O. (2018). $Q: A super-quick,
|
|
34
|
+
* articulation-invariant stroke-gesture recognizer for low-resource devices.
|
|
35
|
+
* Proceedings of the ACM Conference on Human-Computer Interaction with Mobile
|
|
36
|
+
* Devices and Services (MobileHCI '18). Barcelona, Spain (September 3-6, 2018).
|
|
37
|
+
* New York: ACM Press. Article No. 23.
|
|
38
|
+
* https://dl.acm.org/citation.cfm?id=3229434.3229465
|
|
39
|
+
*
|
|
40
|
+
* This software is distributed under the "New BSD License" agreement:
|
|
41
|
+
*
|
|
42
|
+
* Copyright (c) 2018-2019, Nathan Magrofuoco, Jacob O. Wobbrock, Radu-Daniel Vatavu,
|
|
43
|
+
* and Lisa Anthony. All rights reserved.
|
|
44
|
+
*
|
|
45
|
+
* Redistribution and use in source and binary forms, with or without
|
|
46
|
+
* modification, are permitted provided that the following conditions are met:
|
|
47
|
+
* * Redistributions of source code must retain the above copyright
|
|
48
|
+
* notice, this list of conditions and the following disclaimer.
|
|
49
|
+
* * Redistributions in binary form must reproduce the above copyright
|
|
50
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
51
|
+
* documentation and/or other materials provided with the distribution.
|
|
52
|
+
* * Neither the names of the University Stefan cel Mare of Suceava,
|
|
53
|
+
* University of Washington, nor University of Florida, nor the names of its
|
|
54
|
+
* contributors may be used to endorse or promote products derived from this
|
|
55
|
+
* software without specific prior written permission.
|
|
56
|
+
*
|
|
57
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
58
|
+
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
59
|
+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
60
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Radu-Daniel Vatavu OR Lisa Anthony
|
|
61
|
+
* OR Jacob O. Wobbrock BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
62
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
63
|
+
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
64
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
65
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
66
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
67
|
+
* SUCH DAMAGE.
|
|
68
|
+
**/
|
|
69
|
+
export { Point } from './models/Point';
|
|
70
|
+
export { PointCloud } from './models/PointCloud';
|
|
71
|
+
export { Result } from './models/Result';
|
|
72
|
+
export { QDollarRecognizer } from './core/QDollarRecognizer';
|
|
73
|
+
export * from './constants/configurations';
|
|
74
|
+
export * from './constants/gestures';
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
//#region src/models/Point.ts
|
|
2
|
+
var e = class {
|
|
3
|
+
x;
|
|
4
|
+
y;
|
|
5
|
+
id;
|
|
6
|
+
intX = 0;
|
|
7
|
+
intY = 0;
|
|
8
|
+
constructor(e, t, n) {
|
|
9
|
+
this.x = e, this.y = t, this.id = n;
|
|
10
|
+
}
|
|
11
|
+
}, t = 32, n = new e(0, 0, 0), r = 1024, i = 64, a = r / 64;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/utilities/math.ts
|
|
14
|
+
function o(e, t) {
|
|
15
|
+
let n = t.x - e.x, r = t.y - e.y;
|
|
16
|
+
return n * n + r * r;
|
|
17
|
+
}
|
|
18
|
+
function s(e, t) {
|
|
19
|
+
return Math.sqrt(o(e, t));
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/utilities/transform.ts
|
|
23
|
+
function c(t, n) {
|
|
24
|
+
let r = p(t) / (n - 1), i = 0, a = [t[0]], o = [...t];
|
|
25
|
+
for (let t = 1; t < o.length; t++) if (o[t].id === o[t - 1].id) {
|
|
26
|
+
let n = s(o[t - 1], o[t]);
|
|
27
|
+
if (i + n >= r) {
|
|
28
|
+
let s = new e(o[t - 1].x + (r - i) / n * (o[t].x - o[t - 1].x), o[t - 1].y + (r - i) / n * (o[t].y - o[t - 1].y), o[t].id);
|
|
29
|
+
a.push(s), o.splice(t, 0, s), i = 0;
|
|
30
|
+
} else i += n;
|
|
31
|
+
}
|
|
32
|
+
return a.length === n - 1 && a.push(new e(o[o.length - 1].x, o[o.length - 1].y, o[o.length - 1].id)), a;
|
|
33
|
+
}
|
|
34
|
+
function l(t) {
|
|
35
|
+
let n = Infinity, r = -Infinity, i = Infinity, a = -Infinity;
|
|
36
|
+
for (let e of t) n = Math.min(n, e.x), i = Math.min(i, e.y), r = Math.max(r, e.x), a = Math.max(a, e.y);
|
|
37
|
+
let o = Math.max(r - n, a - i);
|
|
38
|
+
return t.map((t) => new e((t.x - n) / o, (t.y - i) / o, t.id));
|
|
39
|
+
}
|
|
40
|
+
function u(t, n) {
|
|
41
|
+
let r = m(t);
|
|
42
|
+
return t.map((t) => new e(t.x + n.x - r.x, t.y + n.y - r.y, t.id));
|
|
43
|
+
}
|
|
44
|
+
function d(e) {
|
|
45
|
+
for (let t of e) t.intX = Math.round((t.x + 1) / 2 * (r - 1)), t.intY = Math.round((t.y + 1) / 2 * (r - 1));
|
|
46
|
+
return e;
|
|
47
|
+
}
|
|
48
|
+
function f(e) {
|
|
49
|
+
let t = Array.from({ length: 64 }, () => Array(64));
|
|
50
|
+
for (let n = 0; n < 64; n++) for (let r = 0; r < 64; r++) {
|
|
51
|
+
let i = -1, a = Infinity;
|
|
52
|
+
for (let t = 0; t < e.length; t++) {
|
|
53
|
+
let o = Math.round(e[t].intX / 16), s = Math.round(e[t].intY / 16), c = (o - n) * (o - n) + (s - r) * (s - r);
|
|
54
|
+
c < a && (a = c, i = t);
|
|
55
|
+
}
|
|
56
|
+
t[n][r] = i;
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
}
|
|
60
|
+
function p(e) {
|
|
61
|
+
let t = 0;
|
|
62
|
+
for (let n = 1; n < e.length; n++) e[n].id === e[n - 1].id && (t += s(e[n - 1], e[n]));
|
|
63
|
+
return t;
|
|
64
|
+
}
|
|
65
|
+
function m(t) {
|
|
66
|
+
let n = 0, r = 0;
|
|
67
|
+
for (let e of t) n += e.x, r += e.y;
|
|
68
|
+
return new e(n / t.length, r / t.length, 0);
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/models/PointCloud.ts
|
|
72
|
+
var h = class {
|
|
73
|
+
name;
|
|
74
|
+
points;
|
|
75
|
+
lut;
|
|
76
|
+
constructor(e, t) {
|
|
77
|
+
this.name = e, this.points = c(t, 32), this.points = l(this.points), this.points = u(this.points, n), this.points = d(this.points), this.lut = f(this.points);
|
|
78
|
+
}
|
|
79
|
+
}, g = class {
|
|
80
|
+
name;
|
|
81
|
+
score;
|
|
82
|
+
time;
|
|
83
|
+
constructor(e, t, n) {
|
|
84
|
+
this.name = e, this.score = t, this.time = n;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/utilities/cloudMatch.ts
|
|
89
|
+
function _(e, t, n) {
|
|
90
|
+
let r = e.points.length, i = Math.floor(r ** .5), a = y(e.points, t.points, i, t.lut), o = y(t.points, e.points, i, e.lut);
|
|
91
|
+
for (let s = 0, c = 0; s < r; s += i, c++) a[c] < n && (n = Math.min(n, v(e.points, t.points, s, n))), o[c] < n && (n = Math.min(n, v(t.points, e.points, s, n)));
|
|
92
|
+
return n;
|
|
93
|
+
}
|
|
94
|
+
function v(e, t, n, r) {
|
|
95
|
+
let i = e.length, a = Array.from({ length: i }, (e, t) => t), s = n, c = i, l = 0;
|
|
96
|
+
do {
|
|
97
|
+
let n = -1, u = Infinity;
|
|
98
|
+
for (let r = 0; r < a.length; r++) {
|
|
99
|
+
let i = o(e[s], t[a[r]]);
|
|
100
|
+
i < u && (u = i, n = r);
|
|
101
|
+
}
|
|
102
|
+
if (a.splice(n, 1), l += c * u, l >= r) return l;
|
|
103
|
+
c--, s = (s + 1) % i;
|
|
104
|
+
} while (s !== n);
|
|
105
|
+
return l;
|
|
106
|
+
}
|
|
107
|
+
function y(e, t, n, r) {
|
|
108
|
+
let i = e.length, a = Array(Math.floor(i / n) + 1).fill(0), s = Array(i);
|
|
109
|
+
a[0] = 0;
|
|
110
|
+
for (let n = 0; n < i; n++) {
|
|
111
|
+
let c = Math.round(e[n].intX / 16), l = Math.round(e[n].intY / 16), u = r[c][l], d = o(e[n], t[u]);
|
|
112
|
+
s[n] = n === 0 ? d : s[n - 1] + d, a[0] += (i - n) * d;
|
|
113
|
+
}
|
|
114
|
+
for (let e = n, t = 1; e < i; e += n, t++) a[t] = a[0] + e * s[i - 1] - i * s[e - 1];
|
|
115
|
+
return a;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/constants/gestures.ts
|
|
119
|
+
var b = {
|
|
120
|
+
name: "T",
|
|
121
|
+
points: [
|
|
122
|
+
new e(30, 7, 1),
|
|
123
|
+
new e(103, 7, 1),
|
|
124
|
+
new e(66, 7, 2),
|
|
125
|
+
new e(66, 87, 2)
|
|
126
|
+
]
|
|
127
|
+
}, x = {
|
|
128
|
+
name: "N",
|
|
129
|
+
points: [
|
|
130
|
+
new e(177, 92, 1),
|
|
131
|
+
new e(177, 2, 1),
|
|
132
|
+
new e(182, 1, 2),
|
|
133
|
+
new e(246, 95, 2),
|
|
134
|
+
new e(247, 87, 3),
|
|
135
|
+
new e(247, 1, 3)
|
|
136
|
+
]
|
|
137
|
+
}, S = {
|
|
138
|
+
name: "D",
|
|
139
|
+
points: [
|
|
140
|
+
new e(345, 9, 1),
|
|
141
|
+
new e(345, 87, 1),
|
|
142
|
+
new e(351, 8, 2),
|
|
143
|
+
new e(363, 8, 2),
|
|
144
|
+
new e(372, 9, 2),
|
|
145
|
+
new e(380, 11, 2),
|
|
146
|
+
new e(386, 14, 2),
|
|
147
|
+
new e(391, 17, 2),
|
|
148
|
+
new e(394, 22, 2),
|
|
149
|
+
new e(397, 28, 2),
|
|
150
|
+
new e(399, 34, 2),
|
|
151
|
+
new e(400, 42, 2),
|
|
152
|
+
new e(400, 50, 2),
|
|
153
|
+
new e(400, 56, 2),
|
|
154
|
+
new e(399, 61, 2),
|
|
155
|
+
new e(397, 66, 2),
|
|
156
|
+
new e(394, 70, 2),
|
|
157
|
+
new e(391, 74, 2),
|
|
158
|
+
new e(386, 78, 2),
|
|
159
|
+
new e(382, 81, 2),
|
|
160
|
+
new e(377, 83, 2),
|
|
161
|
+
new e(372, 85, 2),
|
|
162
|
+
new e(367, 87, 2),
|
|
163
|
+
new e(360, 87, 2),
|
|
164
|
+
new e(355, 88, 2),
|
|
165
|
+
new e(349, 87, 2)
|
|
166
|
+
]
|
|
167
|
+
}, C = {
|
|
168
|
+
name: "P",
|
|
169
|
+
points: [
|
|
170
|
+
new e(507, 8, 1),
|
|
171
|
+
new e(507, 87, 1),
|
|
172
|
+
new e(513, 7, 2),
|
|
173
|
+
new e(528, 7, 2),
|
|
174
|
+
new e(537, 8, 2),
|
|
175
|
+
new e(544, 10, 2),
|
|
176
|
+
new e(550, 12, 2),
|
|
177
|
+
new e(555, 15, 2),
|
|
178
|
+
new e(558, 18, 2),
|
|
179
|
+
new e(560, 22, 2),
|
|
180
|
+
new e(561, 27, 2),
|
|
181
|
+
new e(562, 33, 2),
|
|
182
|
+
new e(561, 37, 2),
|
|
183
|
+
new e(559, 42, 2),
|
|
184
|
+
new e(556, 45, 2),
|
|
185
|
+
new e(550, 48, 2),
|
|
186
|
+
new e(544, 51, 2),
|
|
187
|
+
new e(538, 53, 2),
|
|
188
|
+
new e(532, 54, 2),
|
|
189
|
+
new e(525, 55, 2),
|
|
190
|
+
new e(519, 55, 2),
|
|
191
|
+
new e(513, 55, 2),
|
|
192
|
+
new e(510, 55, 2)
|
|
193
|
+
]
|
|
194
|
+
}, w = {
|
|
195
|
+
name: "X",
|
|
196
|
+
points: [
|
|
197
|
+
new e(30, 146, 1),
|
|
198
|
+
new e(106, 222, 1),
|
|
199
|
+
new e(30, 225, 2),
|
|
200
|
+
new e(106, 146, 2)
|
|
201
|
+
]
|
|
202
|
+
}, T = {
|
|
203
|
+
name: "H",
|
|
204
|
+
points: [
|
|
205
|
+
new e(188, 137, 1),
|
|
206
|
+
new e(188, 225, 1),
|
|
207
|
+
new e(188, 180, 2),
|
|
208
|
+
new e(241, 180, 2),
|
|
209
|
+
new e(241, 137, 3),
|
|
210
|
+
new e(241, 225, 3)
|
|
211
|
+
]
|
|
212
|
+
}, E = {
|
|
213
|
+
name: "I",
|
|
214
|
+
points: [
|
|
215
|
+
new e(371, 149, 1),
|
|
216
|
+
new e(371, 221, 1),
|
|
217
|
+
new e(341, 149, 2),
|
|
218
|
+
new e(401, 149, 2),
|
|
219
|
+
new e(341, 221, 3),
|
|
220
|
+
new e(401, 221, 3)
|
|
221
|
+
]
|
|
222
|
+
}, D = {
|
|
223
|
+
name: "exclamation",
|
|
224
|
+
points: [
|
|
225
|
+
new e(526, 142, 1),
|
|
226
|
+
new e(526, 204, 1),
|
|
227
|
+
new e(526, 221, 2)
|
|
228
|
+
]
|
|
229
|
+
}, O = {
|
|
230
|
+
name: "line",
|
|
231
|
+
points: [new e(12, 347, 1), new e(119, 347, 1)]
|
|
232
|
+
}, k = {
|
|
233
|
+
name: "five-point star",
|
|
234
|
+
points: [
|
|
235
|
+
new e(177, 396, 1),
|
|
236
|
+
new e(223, 299, 1),
|
|
237
|
+
new e(262, 396, 1),
|
|
238
|
+
new e(168, 332, 1),
|
|
239
|
+
new e(278, 332, 1),
|
|
240
|
+
new e(184, 397, 1)
|
|
241
|
+
]
|
|
242
|
+
}, A = {
|
|
243
|
+
name: "null",
|
|
244
|
+
points: [
|
|
245
|
+
new e(382, 310, 1),
|
|
246
|
+
new e(377, 308, 1),
|
|
247
|
+
new e(373, 307, 1),
|
|
248
|
+
new e(366, 307, 1),
|
|
249
|
+
new e(360, 310, 1),
|
|
250
|
+
new e(356, 313, 1),
|
|
251
|
+
new e(353, 316, 1),
|
|
252
|
+
new e(349, 321, 1),
|
|
253
|
+
new e(347, 326, 1),
|
|
254
|
+
new e(344, 331, 1),
|
|
255
|
+
new e(342, 337, 1),
|
|
256
|
+
new e(341, 343, 1),
|
|
257
|
+
new e(341, 350, 1),
|
|
258
|
+
new e(341, 358, 1),
|
|
259
|
+
new e(342, 362, 1),
|
|
260
|
+
new e(344, 366, 1),
|
|
261
|
+
new e(347, 370, 1),
|
|
262
|
+
new e(351, 374, 1),
|
|
263
|
+
new e(356, 379, 1),
|
|
264
|
+
new e(361, 382, 1),
|
|
265
|
+
new e(368, 385, 1),
|
|
266
|
+
new e(374, 387, 1),
|
|
267
|
+
new e(381, 387, 1),
|
|
268
|
+
new e(390, 387, 1),
|
|
269
|
+
new e(397, 385, 1),
|
|
270
|
+
new e(404, 382, 1),
|
|
271
|
+
new e(408, 378, 1),
|
|
272
|
+
new e(412, 373, 1),
|
|
273
|
+
new e(416, 367, 1),
|
|
274
|
+
new e(418, 361, 1),
|
|
275
|
+
new e(419, 353, 1),
|
|
276
|
+
new e(418, 346, 1),
|
|
277
|
+
new e(417, 341, 1),
|
|
278
|
+
new e(416, 336, 1),
|
|
279
|
+
new e(413, 331, 1),
|
|
280
|
+
new e(410, 326, 1),
|
|
281
|
+
new e(404, 320, 1),
|
|
282
|
+
new e(400, 317, 1),
|
|
283
|
+
new e(393, 313, 1),
|
|
284
|
+
new e(392, 312, 1),
|
|
285
|
+
new e(418, 309, 2),
|
|
286
|
+
new e(337, 390, 2)
|
|
287
|
+
]
|
|
288
|
+
}, j = {
|
|
289
|
+
name: "arrowhead",
|
|
290
|
+
points: [
|
|
291
|
+
new e(506, 349, 1),
|
|
292
|
+
new e(574, 349, 1),
|
|
293
|
+
new e(525, 306, 2),
|
|
294
|
+
new e(584, 349, 2),
|
|
295
|
+
new e(525, 388, 2)
|
|
296
|
+
]
|
|
297
|
+
}, M = {
|
|
298
|
+
name: "pitchfork",
|
|
299
|
+
points: [
|
|
300
|
+
new e(38, 470, 1),
|
|
301
|
+
new e(36, 476, 1),
|
|
302
|
+
new e(36, 482, 1),
|
|
303
|
+
new e(37, 489, 1),
|
|
304
|
+
new e(39, 496, 1),
|
|
305
|
+
new e(42, 500, 1),
|
|
306
|
+
new e(46, 503, 1),
|
|
307
|
+
new e(50, 507, 1),
|
|
308
|
+
new e(56, 509, 1),
|
|
309
|
+
new e(63, 509, 1),
|
|
310
|
+
new e(70, 508, 1),
|
|
311
|
+
new e(75, 506, 1),
|
|
312
|
+
new e(79, 503, 1),
|
|
313
|
+
new e(82, 499, 1),
|
|
314
|
+
new e(85, 493, 1),
|
|
315
|
+
new e(87, 487, 1),
|
|
316
|
+
new e(88, 480, 1),
|
|
317
|
+
new e(88, 474, 1),
|
|
318
|
+
new e(87, 468, 1),
|
|
319
|
+
new e(62, 464, 2),
|
|
320
|
+
new e(62, 571, 2)
|
|
321
|
+
]
|
|
322
|
+
}, N = {
|
|
323
|
+
name: "six-point star",
|
|
324
|
+
points: [
|
|
325
|
+
new e(177, 554, 1),
|
|
326
|
+
new e(223, 476, 1),
|
|
327
|
+
new e(268, 554, 1),
|
|
328
|
+
new e(183, 554, 1),
|
|
329
|
+
new e(177, 490, 2),
|
|
330
|
+
new e(223, 568, 2),
|
|
331
|
+
new e(268, 490, 2),
|
|
332
|
+
new e(183, 490, 2)
|
|
333
|
+
]
|
|
334
|
+
}, P = {
|
|
335
|
+
name: "asterisk",
|
|
336
|
+
points: [
|
|
337
|
+
new e(325, 499, 1),
|
|
338
|
+
new e(417, 557, 1),
|
|
339
|
+
new e(417, 499, 2),
|
|
340
|
+
new e(325, 557, 2),
|
|
341
|
+
new e(371, 486, 3),
|
|
342
|
+
new e(371, 571, 3)
|
|
343
|
+
]
|
|
344
|
+
}, F = {
|
|
345
|
+
name: "half-note",
|
|
346
|
+
points: [
|
|
347
|
+
new e(546, 465, 1),
|
|
348
|
+
new e(546, 531, 1),
|
|
349
|
+
new e(540, 530, 2),
|
|
350
|
+
new e(536, 529, 2),
|
|
351
|
+
new e(533, 528, 2),
|
|
352
|
+
new e(529, 529, 2),
|
|
353
|
+
new e(524, 530, 2),
|
|
354
|
+
new e(520, 532, 2),
|
|
355
|
+
new e(515, 535, 2),
|
|
356
|
+
new e(511, 539, 2),
|
|
357
|
+
new e(508, 545, 2),
|
|
358
|
+
new e(506, 548, 2),
|
|
359
|
+
new e(506, 554, 2),
|
|
360
|
+
new e(509, 558, 2),
|
|
361
|
+
new e(512, 561, 2),
|
|
362
|
+
new e(517, 564, 2),
|
|
363
|
+
new e(521, 564, 2),
|
|
364
|
+
new e(527, 563, 2),
|
|
365
|
+
new e(531, 560, 2),
|
|
366
|
+
new e(535, 557, 2),
|
|
367
|
+
new e(538, 553, 2),
|
|
368
|
+
new e(542, 548, 2),
|
|
369
|
+
new e(544, 544, 2),
|
|
370
|
+
new e(546, 540, 2),
|
|
371
|
+
new e(546, 536, 2)
|
|
372
|
+
]
|
|
373
|
+
}, I = [
|
|
374
|
+
b,
|
|
375
|
+
x,
|
|
376
|
+
S,
|
|
377
|
+
C,
|
|
378
|
+
w,
|
|
379
|
+
T,
|
|
380
|
+
E,
|
|
381
|
+
D,
|
|
382
|
+
O,
|
|
383
|
+
k,
|
|
384
|
+
A,
|
|
385
|
+
j,
|
|
386
|
+
M,
|
|
387
|
+
N,
|
|
388
|
+
P,
|
|
389
|
+
F
|
|
390
|
+
], L = class {
|
|
391
|
+
pointClouds = [];
|
|
392
|
+
initialCount = 0;
|
|
393
|
+
constructor(e = I) {
|
|
394
|
+
this.pointClouds = e.map((e) => new h(e.name, e.points)), this.initialCount = this.pointClouds.length;
|
|
395
|
+
}
|
|
396
|
+
recognize(e) {
|
|
397
|
+
let t = Date.now(), n = new h("", e), r = [];
|
|
398
|
+
for (let e of this.pointClouds) {
|
|
399
|
+
let t = _(n, e, Infinity), i = t > 1 ? 1 / t : 1;
|
|
400
|
+
r.push(new g(e.name, i, 0));
|
|
401
|
+
}
|
|
402
|
+
r.sort((e, t) => t.score - e.score);
|
|
403
|
+
let i = Date.now() - t;
|
|
404
|
+
return r.forEach((e) => e.time = i), r;
|
|
405
|
+
}
|
|
406
|
+
addGesture(e, t) {
|
|
407
|
+
return this.pointClouds.push(new h(e, t)), this.pointClouds.filter((t) => t.name === e).length;
|
|
408
|
+
}
|
|
409
|
+
deleteUserGestures() {
|
|
410
|
+
return this.pointClouds.length = this.initialCount, this.initialCount;
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
//#endregion
|
|
414
|
+
export { I as DEFAULT_GESTURES, j as GESTURE_ARROWHEAD, P as GESTURE_ASTERISK, S as GESTURE_D, D as GESTURE_EXCLAMATION, T as GESTURE_H, F as GESTURE_HALF_NOTE, E as GESTURE_I, O as GESTURE_LINE, x as GESTURE_N, A as GESTURE_NULL, C as GESTURE_P, M as GESTURE_PITCHFORK, k as GESTURE_STAR_5, N as GESTURE_STAR_6, b as GESTURE_T, w as GESTURE_X, a as LUT_SCALE_FACTOR, i as LUT_SIZE, r as MAX_INT_COORD, t as NUM_POINTS, n as ORIGIN, e as Point, h as PointCloud, L as QDollarRecognizer, g as Result };
|
|
415
|
+
|
|
416
|
+
//# sourceMappingURL=index.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","names":[],"sources":["../src/models/Point.ts","../src/constants/configurations.ts","../src/utilities/math.ts","../src/utilities/transform.ts","../src/models/PointCloud.ts","../src/models/Result.ts","../src/utilities/cloudMatch.ts","../src/constants/gestures.ts","../src/core/QDollarRecognizer.ts"],"sourcesContent":["export class Point {\r\n x: number;\r\n y: number;\r\n id: number;\r\n intX: number = 0;\r\n intY: number = 0;\r\n\r\n constructor(x: number, y: number, id: number) {\r\n this.x = x;\r\n this.y = y;\r\n this.id = id;\r\n }\r\n}\r\n","import { Point } from \"../models/Point\";\r\n\r\nexport const NUM_POINTS = 32;\r\nexport const ORIGIN = new Point(0, 0, 0);\r\nexport const MAX_INT_COORD = 1024;\r\nexport const LUT_SIZE = 64;\r\nexport const LUT_SCALE_FACTOR = MAX_INT_COORD / LUT_SIZE;\r\n","import { Point } from \"../models/Point\";\r\n\r\nexport function sqrEuclideanDistance(pt1: Point, pt2: Point): number {\r\n const dx = pt2.x - pt1.x;\r\n const dy = pt2.y - pt1.y;\r\n return dx * dx + dy * dy;\r\n}\r\n\r\nexport function euclideanDistance(pt1: Point, pt2: Point): number {\r\n return Math.sqrt(sqrEuclideanDistance(pt1, pt2));\r\n}\r\n","import { Point } from \"../models/Point\";\r\nimport {\r\n MAX_INT_COORD,\r\n LUT_SCALE_FACTOR,\r\n LUT_SIZE,\r\n} from \"../constants/configurations\";\r\nimport { euclideanDistance } from \"./math\";\r\n\r\nexport function resample(points: Point[], n: number): Point[] {\r\n const iLen = pathLength(points) / (n - 1);\r\n let dVal = 0.0;\r\n const newPoints: Point[] = [points[0]];\r\n const tempPoints = [...points];\r\n\r\n for (let i = 1; i < tempPoints.length; i++) {\r\n if (tempPoints[i].id === tempPoints[i - 1].id) {\r\n const d = euclideanDistance(tempPoints[i - 1], tempPoints[i]);\r\n if (dVal + d >= iLen) {\r\n const qx =\r\n tempPoints[i - 1].x +\r\n ((iLen - dVal) / d) * (tempPoints[i].x - tempPoints[i - 1].x);\r\n const qy =\r\n tempPoints[i - 1].y +\r\n ((iLen - dVal) / d) * (tempPoints[i].y - tempPoints[i - 1].y);\r\n const q = new Point(qx, qy, tempPoints[i].id);\r\n newPoints.push(q);\r\n tempPoints.splice(i, 0, q);\r\n dVal = 0.0;\r\n } else {\r\n dVal += d;\r\n }\r\n }\r\n }\r\n if (newPoints.length === n - 1) {\r\n newPoints.push(\r\n new Point(\r\n tempPoints[tempPoints.length - 1].x,\r\n tempPoints[tempPoints.length - 1].y,\r\n tempPoints[tempPoints.length - 1].id,\r\n ),\r\n );\r\n }\r\n return newPoints;\r\n}\r\n\r\nexport function scale(points: Point[]): Point[] {\r\n let minX = +Infinity;\r\n let maxX = -Infinity;\r\n let minY = +Infinity;\r\n let maxY = -Infinity;\r\n for (const p of points) {\r\n minX = Math.min(minX, p.x);\r\n minY = Math.min(minY, p.y);\r\n maxX = Math.max(maxX, p.x);\r\n maxY = Math.max(maxY, p.y);\r\n }\r\n const size = Math.max(maxX - minX, maxY - minY);\r\n return points.map(\r\n (p) => new Point((p.x - minX) / size, (p.y - minY) / size, p.id),\r\n );\r\n}\r\n\r\nexport function translateTo(points: Point[], pt: Point): Point[] {\r\n const c = centroid(points);\r\n return points.map((p) => new Point(p.x + pt.x - c.x, p.y + pt.y - c.y, p.id));\r\n}\r\n\r\nexport function makeIntCoords(points: Point[]): Point[] {\r\n for (const p of points) {\r\n p.intX = Math.round(((p.x + 1.0) / 2.0) * (MAX_INT_COORD - 1));\r\n p.intY = Math.round(((p.y + 1.0) / 2.0) * (MAX_INT_COORD - 1));\r\n }\r\n return points;\r\n}\r\n\r\nexport function computeLUT(points: Point[]): number[][] {\r\n const lut: number[][] = Array.from(\r\n { length: LUT_SIZE },\r\n () => new Array(LUT_SIZE),\r\n );\r\n for (let x = 0; x < LUT_SIZE; x++) {\r\n for (let y = 0; y < LUT_SIZE; y++) {\r\n let u = -1;\r\n let b = +Infinity;\r\n for (let i = 0; i < points.length; i++) {\r\n const row = Math.round(points[i].intX / LUT_SCALE_FACTOR);\r\n const col = Math.round(points[i].intY / LUT_SCALE_FACTOR);\r\n const d = (row - x) * (row - x) + (col - y) * (col - y);\r\n if (d < b) {\r\n b = d;\r\n u = i;\r\n }\r\n }\r\n lut[x][y] = u;\r\n }\r\n }\r\n return lut;\r\n}\r\n\r\nfunction pathLength(points: Point[]): number {\r\n let d = 0.0;\r\n for (let i = 1; i < points.length; i++) {\r\n if (points[i].id === points[i - 1].id) {\r\n d += euclideanDistance(points[i - 1], points[i]);\r\n }\r\n }\r\n return d;\r\n}\r\n\r\nfunction centroid(points: Point[]): Point {\r\n let x = 0.0;\r\n let y = 0.0;\r\n for (const p of points) {\r\n x += p.x;\r\n y += p.y;\r\n }\r\n return new Point(x / points.length, y / points.length, 0);\r\n}\r\n","import { Point } from \"./Point\";\r\nimport { NUM_POINTS, ORIGIN } from \"../constants/configurations\";\r\nimport {\r\n resample,\r\n scale,\r\n translateTo,\r\n makeIntCoords,\r\n computeLUT,\r\n} from \"../utilities/transform\";\r\n\r\nexport class PointCloud {\r\n name: string;\r\n points: Point[];\r\n lut: number[][];\r\n\r\n constructor(name: string, points: Point[]) {\r\n this.name = name;\r\n this.points = resample(points, NUM_POINTS);\r\n this.points = scale(this.points);\r\n this.points = translateTo(this.points, ORIGIN);\r\n this.points = makeIntCoords(this.points);\r\n this.lut = computeLUT(this.points);\r\n }\r\n}\r\n","export class Result {\r\n name: string;\r\n score: number;\r\n time: number;\r\n\r\n constructor(name: string, score: number, ms: number) {\r\n this.name = name;\r\n this.score = score;\r\n this.time = ms;\r\n }\r\n}\r\n","import { Point } from \"../models/Point\";\r\nimport { sqrEuclideanDistance } from \"./math\";\r\nimport { LUT_SCALE_FACTOR } from \"../constants/configurations\";\r\n\r\nexport function cloudMatch(\r\n candidate: { points: Point[]; lut: number[][] },\r\n template: { points: Point[]; lut: number[][] },\r\n minSoFar: number,\r\n): number {\r\n const n = candidate.points.length;\r\n const step = Math.floor(Math.pow(n, 0.5));\r\n const lb1 = computeLowerBound(\r\n candidate.points,\r\n template.points,\r\n step,\r\n template.lut,\r\n );\r\n const lb2 = computeLowerBound(\r\n template.points,\r\n candidate.points,\r\n step,\r\n candidate.lut,\r\n );\r\n\r\n for (let i = 0, j = 0; i < n; i += step, j++) {\r\n if (lb1[j] < minSoFar) {\r\n minSoFar = Math.min(\r\n minSoFar,\r\n cloudDistance(candidate.points, template.points, i, minSoFar),\r\n );\r\n }\r\n if (lb2[j] < minSoFar) {\r\n minSoFar = Math.min(\r\n minSoFar,\r\n cloudDistance(template.points, candidate.points, i, minSoFar),\r\n );\r\n }\r\n }\r\n return minSoFar;\r\n}\r\n\r\nfunction cloudDistance(\r\n pts1: Point[],\r\n pts2: Point[],\r\n start: number,\r\n minSoFar: number,\r\n): number {\r\n const n = pts1.length;\r\n const unmatched = Array.from({ length: n }, (_, j) => j);\r\n let i = start;\r\n let weight = n;\r\n let sum = 0.0;\r\n do {\r\n let u = -1;\r\n let b = +Infinity;\r\n for (let j = 0; j < unmatched.length; j++) {\r\n const d = sqrEuclideanDistance(pts1[i], pts2[unmatched[j]]);\r\n if (d < b) {\r\n b = d;\r\n u = j;\r\n }\r\n }\r\n unmatched.splice(u, 1);\r\n sum += weight * b;\r\n if (sum >= minSoFar) return sum;\r\n weight--;\r\n i = (i + 1) % n;\r\n } while (i !== start);\r\n return sum;\r\n}\r\n\r\nfunction computeLowerBound(\r\n pts1: Point[],\r\n pts2: Point[],\r\n step: number,\r\n lut: number[][],\r\n): number[] {\r\n const n = pts1.length;\r\n const lb: number[] = new Array(Math.floor(n / step) + 1).fill(0.0);\r\n const sat: number[] = new Array(n);\r\n lb[0] = 0.0;\r\n for (let i = 0; i < n; i++) {\r\n const x = Math.round(pts1[i].intX / LUT_SCALE_FACTOR);\r\n const y = Math.round(pts1[i].intY / LUT_SCALE_FACTOR);\r\n const index = lut[x][y];\r\n const d = sqrEuclideanDistance(pts1[i], pts2[index]);\r\n sat[i] = i === 0 ? d : sat[i - 1] + d;\r\n lb[0] += (n - i) * d;\r\n }\r\n for (let i = step, j = 1; i < n; i += step, j++) {\r\n lb[j] = lb[0] + i * sat[n - 1] - n * sat[i - 1];\r\n }\r\n return lb;\r\n}\r\n","import { Point } from \"../models/Point\";\r\n\r\nexport const GESTURE_T = {\r\n name: \"T\",\r\n points: [\r\n new Point(30, 7, 1),\r\n new Point(103, 7, 1),\r\n new Point(66, 7, 2),\r\n new Point(66, 87, 2),\r\n ],\r\n};\r\nexport const GESTURE_N = {\r\n name: \"N\",\r\n points: [\r\n new Point(177, 92, 1),\r\n new Point(177, 2, 1),\r\n new Point(182, 1, 2),\r\n new Point(246, 95, 2),\r\n new Point(247, 87, 3),\r\n new Point(247, 1, 3),\r\n ],\r\n};\r\nexport const GESTURE_D = {\r\n name: \"D\",\r\n points: [\r\n new Point(345, 9, 1),\r\n new Point(345, 87, 1),\r\n new Point(351, 8, 2),\r\n new Point(363, 8, 2),\r\n new Point(372, 9, 2),\r\n new Point(380, 11, 2),\r\n new Point(386, 14, 2),\r\n new Point(391, 17, 2),\r\n new Point(394, 22, 2),\r\n new Point(397, 28, 2),\r\n new Point(399, 34, 2),\r\n new Point(400, 42, 2),\r\n new Point(400, 50, 2),\r\n new Point(400, 56, 2),\r\n new Point(399, 61, 2),\r\n new Point(397, 66, 2),\r\n new Point(394, 70, 2),\r\n new Point(391, 74, 2),\r\n new Point(386, 78, 2),\r\n new Point(382, 81, 2),\r\n new Point(377, 83, 2),\r\n new Point(372, 85, 2),\r\n new Point(367, 87, 2),\r\n new Point(360, 87, 2),\r\n new Point(355, 88, 2),\r\n new Point(349, 87, 2),\r\n ],\r\n};\r\nexport const GESTURE_P = {\r\n name: \"P\",\r\n points: [\r\n new Point(507, 8, 1),\r\n new Point(507, 87, 1),\r\n new Point(513, 7, 2),\r\n new Point(528, 7, 2),\r\n new Point(537, 8, 2),\r\n new Point(544, 10, 2),\r\n new Point(550, 12, 2),\r\n new Point(555, 15, 2),\r\n new Point(558, 18, 2),\r\n new Point(560, 22, 2),\r\n new Point(561, 27, 2),\r\n new Point(562, 33, 2),\r\n new Point(561, 37, 2),\r\n new Point(559, 42, 2),\r\n new Point(556, 45, 2),\r\n new Point(550, 48, 2),\r\n new Point(544, 51, 2),\r\n new Point(538, 53, 2),\r\n new Point(532, 54, 2),\r\n new Point(525, 55, 2),\r\n new Point(519, 55, 2),\r\n new Point(513, 55, 2),\r\n new Point(510, 55, 2),\r\n ],\r\n};\r\nexport const GESTURE_X = {\r\n name: \"X\",\r\n points: [\r\n new Point(30, 146, 1),\r\n new Point(106, 222, 1),\r\n new Point(30, 225, 2),\r\n new Point(106, 146, 2),\r\n ],\r\n};\r\nexport const GESTURE_H = {\r\n name: \"H\",\r\n points: [\r\n new Point(188, 137, 1),\r\n new Point(188, 225, 1),\r\n new Point(188, 180, 2),\r\n new Point(241, 180, 2),\r\n new Point(241, 137, 3),\r\n new Point(241, 225, 3),\r\n ],\r\n};\r\nexport const GESTURE_I = {\r\n name: \"I\",\r\n points: [\r\n new Point(371, 149, 1),\r\n new Point(371, 221, 1),\r\n new Point(341, 149, 2),\r\n new Point(401, 149, 2),\r\n new Point(341, 221, 3),\r\n new Point(401, 221, 3),\r\n ],\r\n};\r\nexport const GESTURE_EXCLAMATION = {\r\n name: \"exclamation\",\r\n points: [\r\n new Point(526, 142, 1),\r\n new Point(526, 204, 1),\r\n new Point(526, 221, 2),\r\n ],\r\n};\r\nexport const GESTURE_LINE = {\r\n name: \"line\",\r\n points: [new Point(12, 347, 1), new Point(119, 347, 1)],\r\n};\r\nexport const GESTURE_STAR_5 = {\r\n name: \"five-point star\",\r\n points: [\r\n new Point(177, 396, 1),\r\n new Point(223, 299, 1),\r\n new Point(262, 396, 1),\r\n new Point(168, 332, 1),\r\n new Point(278, 332, 1),\r\n new Point(184, 397, 1),\r\n ],\r\n};\r\nexport const GESTURE_NULL = {\r\n name: \"null\",\r\n points: [\r\n new Point(382, 310, 1),\r\n new Point(377, 308, 1),\r\n new Point(373, 307, 1),\r\n new Point(366, 307, 1),\r\n new Point(360, 310, 1),\r\n new Point(356, 313, 1),\r\n new Point(353, 316, 1),\r\n new Point(349, 321, 1),\r\n new Point(347, 326, 1),\r\n new Point(344, 331, 1),\r\n new Point(342, 337, 1),\r\n new Point(341, 343, 1),\r\n new Point(341, 350, 1),\r\n new Point(341, 358, 1),\r\n new Point(342, 362, 1),\r\n new Point(344, 366, 1),\r\n new Point(347, 370, 1),\r\n new Point(351, 374, 1),\r\n new Point(356, 379, 1),\r\n new Point(361, 382, 1),\r\n new Point(368, 385, 1),\r\n new Point(374, 387, 1),\r\n new Point(381, 387, 1),\r\n new Point(390, 387, 1),\r\n new Point(397, 385, 1),\r\n new Point(404, 382, 1),\r\n new Point(408, 378, 1),\r\n new Point(412, 373, 1),\r\n new Point(416, 367, 1),\r\n new Point(418, 361, 1),\r\n new Point(419, 353, 1),\r\n new Point(418, 346, 1),\r\n new Point(417, 341, 1),\r\n new Point(416, 336, 1),\r\n new Point(413, 331, 1),\r\n new Point(410, 326, 1),\r\n new Point(404, 320, 1),\r\n new Point(400, 317, 1),\r\n new Point(393, 313, 1),\r\n new Point(392, 312, 1),\r\n new Point(418, 309, 2),\r\n new Point(337, 390, 2),\r\n ],\r\n};\r\nexport const GESTURE_ARROWHEAD = {\r\n name: \"arrowhead\",\r\n points: [\r\n new Point(506, 349, 1),\r\n new Point(574, 349, 1),\r\n new Point(525, 306, 2),\r\n new Point(584, 349, 2),\r\n new Point(525, 388, 2),\r\n ],\r\n};\r\nexport const GESTURE_PITCHFORK = {\r\n name: \"pitchfork\",\r\n points: [\r\n new Point(38, 470, 1),\r\n new Point(36, 476, 1),\r\n new Point(36, 482, 1),\r\n new Point(37, 489, 1),\r\n new Point(39, 496, 1),\r\n new Point(42, 500, 1),\r\n new Point(46, 503, 1),\r\n new Point(50, 507, 1),\r\n new Point(56, 509, 1),\r\n new Point(63, 509, 1),\r\n new Point(70, 508, 1),\r\n new Point(75, 506, 1),\r\n new Point(79, 503, 1),\r\n new Point(82, 499, 1),\r\n new Point(85, 493, 1),\r\n new Point(87, 487, 1),\r\n new Point(88, 480, 1),\r\n new Point(88, 474, 1),\r\n new Point(87, 468, 1),\r\n new Point(62, 464, 2),\r\n new Point(62, 571, 2),\r\n ],\r\n};\r\nexport const GESTURE_STAR_6 = {\r\n name: \"six-point star\",\r\n points: [\r\n new Point(177, 554, 1),\r\n new Point(223, 476, 1),\r\n new Point(268, 554, 1),\r\n new Point(183, 554, 1),\r\n new Point(177, 490, 2),\r\n new Point(223, 568, 2),\r\n new Point(268, 490, 2),\r\n new Point(183, 490, 2),\r\n ],\r\n};\r\nexport const GESTURE_ASTERISK = {\r\n name: \"asterisk\",\r\n points: [\r\n new Point(325, 499, 1),\r\n new Point(417, 557, 1),\r\n new Point(417, 499, 2),\r\n new Point(325, 557, 2),\r\n new Point(371, 486, 3),\r\n new Point(371, 571, 3),\r\n ],\r\n};\r\nexport const GESTURE_HALF_NOTE = {\r\n name: \"half-note\",\r\n points: [\r\n new Point(546, 465, 1),\r\n new Point(546, 531, 1),\r\n new Point(540, 530, 2),\r\n new Point(536, 529, 2),\r\n new Point(533, 528, 2),\r\n new Point(529, 529, 2),\r\n new Point(524, 530, 2),\r\n new Point(520, 532, 2),\r\n new Point(515, 535, 2),\r\n new Point(511, 539, 2),\r\n new Point(508, 545, 2),\r\n new Point(506, 548, 2),\r\n new Point(506, 554, 2),\r\n new Point(509, 558, 2),\r\n new Point(512, 561, 2),\r\n new Point(517, 564, 2),\r\n new Point(521, 564, 2),\r\n new Point(527, 563, 2),\r\n new Point(531, 560, 2),\r\n new Point(535, 557, 2),\r\n new Point(538, 553, 2),\r\n new Point(542, 548, 2),\r\n new Point(544, 544, 2),\r\n new Point(546, 540, 2),\r\n new Point(546, 536, 2),\r\n ],\r\n};\r\n\r\nexport const DEFAULT_GESTURES = [\r\n GESTURE_T,\r\n GESTURE_N,\r\n GESTURE_D,\r\n GESTURE_P,\r\n GESTURE_X,\r\n GESTURE_H,\r\n GESTURE_I,\r\n GESTURE_EXCLAMATION,\r\n GESTURE_LINE,\r\n GESTURE_STAR_5,\r\n GESTURE_NULL,\r\n GESTURE_ARROWHEAD,\r\n GESTURE_PITCHFORK,\r\n GESTURE_STAR_6,\r\n GESTURE_ASTERISK,\r\n GESTURE_HALF_NOTE,\r\n];\r\n","import { Point } from \"../models/Point\";\r\nimport { PointCloud } from \"../models/PointCloud\";\r\nimport { Result } from \"../models/Result\";\r\nimport { cloudMatch } from \"../utilities/cloudMatch\";\r\nimport { DEFAULT_GESTURES } from \"../constants/gestures\";\r\n\r\nexport class QDollarRecognizer {\r\n public pointClouds: PointCloud[] = [];\r\n private initialCount: number = 0;\r\n\r\n constructor(\r\n initialData: { name: string; points: Point[] }[] = DEFAULT_GESTURES,\r\n ) {\r\n this.pointClouds = initialData.map(\r\n (data) => new PointCloud(data.name, data.points),\r\n );\r\n this.initialCount = this.pointClouds.length;\r\n }\r\n\r\n public recognize(points: Point[]): Result[] {\r\n const t0 = Date.now();\r\n const candidate = new PointCloud(\"\", points);\r\n const results: Result[] = [];\r\n\r\n for (const template of this.pointClouds) {\r\n const d = cloudMatch(candidate, template, +Infinity);\r\n const score = d > 1.0 ? 1.0 / d : 1.0;\r\n results.push(new Result(template.name, score, 0));\r\n }\r\n\r\n results.sort((a, b) => b.score - a.score);\r\n\r\n const totalTime = Date.now() - t0;\r\n results.forEach((r) => (r.time = totalTime));\r\n\r\n return results;\r\n }\r\n\r\n public addGesture(name: string, points: Point[]): number {\r\n this.pointClouds.push(new PointCloud(name, points));\r\n return this.pointClouds.filter((p) => p.name === name).length;\r\n }\r\n\r\n public deleteUserGestures(): number {\r\n this.pointClouds.length = this.initialCount;\r\n return this.initialCount;\r\n }\r\n}\r\n"],"mappings":";AAAA,IAAa,IAAb,MAAmB;CACjB;CACA;CACA;CACA,OAAe;CACf,OAAe;CAEf,YAAY,GAAW,GAAW,GAAY;EAG5C,AAFA,KAAK,IAAI,GACT,KAAK,IAAI,GACT,KAAK,KAAK;CACZ;AACF,GCVa,IAAa,IACb,IAAS,IAAI,EAAM,GAAG,GAAG,CAAC,GAC1B,IAAgB,MAChB,IAAW,IACX,IAAmB,IAAA;;;ACJhC,SAAgB,EAAqB,GAAY,GAAoB;CACnE,IAAM,IAAK,EAAI,IAAI,EAAI,GACjB,IAAK,EAAI,IAAI,EAAI;CACvB,OAAO,IAAK,IAAK,IAAK;AACxB;AAEA,SAAgB,EAAkB,GAAY,GAAoB;CAChE,OAAO,KAAK,KAAK,EAAqB,GAAK,CAAG,CAAC;AACjD;;;ACFA,SAAgB,EAAS,GAAiB,GAAoB;CAC5D,IAAM,IAAO,EAAW,CAAM,KAAK,IAAI,IACnC,IAAO,GACL,IAAqB,CAAC,EAAO,EAAE,GAC/B,IAAa,CAAC,GAAG,CAAM;CAE7B,KAAK,IAAI,IAAI,GAAG,IAAI,EAAW,QAAQ,KACrC,IAAI,EAAW,EAAE,CAAC,OAAO,EAAW,IAAI,EAAE,CAAC,IAAI;EAC7C,IAAM,IAAI,EAAkB,EAAW,IAAI,IAAI,EAAW,EAAE;EAC5D,IAAI,IAAO,KAAK,GAAM;GAOpB,IAAM,IAAI,IAAI,EALZ,EAAW,IAAI,EAAE,CAAC,KAChB,IAAO,KAAQ,KAAM,EAAW,EAAE,CAA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W,EAAK,MAAM,EAAK,MAAM,CACjD,GACA,KAAK,eAAe,KAAK,YAAY;CACvC;CAEA,UAAiB,GAA2B;EAC1C,IAAM,IAAK,KAAK,IAAI,GACd,IAAY,IAAI,EAAW,IAAI,CAAM,GACrC,IAAoB,CAAC;EAE3B,KAAK,IAAM,KAAY,KAAK,aAAa;GACvC,IAAM,IAAI,EAAW,GAAW,GAAU,QAAS,GAC7C,IAAQ,IAAI,IAAM,IAAM,IAAI;GAClC,EAAQ,KAAK,IAAI,EAAO,EAAS,MAAM,GAAO,CAAC,CAAC;EAClD;EAEA,EAAQ,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;EAExC,IAAM,IAAY,KAAK,IAAI,IAAI;EAG/B,OAFA,EAAQ,SAAS,MAAO,EAAE,OAAO,CAAU,GAEpC;CACT;CAEA,WAAkB,GAAc,GAAyB;EAEvD,OADA,KAAK,YAAY,KAAK,IAAI,EAAW,GAAM,CAAM,CAAC,GAC3C,KAAK,YAAY,QAAQ,MAAM,EAAE,SAAS,CAAI,CAAC,CAAC;CACzD;CAEA,qBAAoC;EAElC,OADA,KAAK,YAAY,SAAS,KAAK,cACxB,KAAK;CACd;AACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Point } from '../models/Point';
|
|
2
|
+
export declare function resample(points: Point[], n: number): Point[];
|
|
3
|
+
export declare function scale(points: Point[]): Point[];
|
|
4
|
+
export declare function translateTo(points: Point[], pt: Point): Point[];
|
|
5
|
+
export declare function makeIntCoords(points: Point[]): Point[];
|
|
6
|
+
export declare function computeLUT(points: Point[]): number[][];
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "qdollar-super-quick-recognizer",
|
|
3
|
+
"description": "A modern, strongly-typed TypeScript implementation of the $Q Super-Quick Recognizer.",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"test": "vitest",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/kaminorse/qdollar-super-quick-recognizer.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/kaminorse/qdollar-super-quick-recognizer/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/kaminorse/qdollar-super-quick-recognizer#readme",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"main": "./dist/index.cjs.js",
|
|
23
|
+
"module": "./dist/index.es.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.es.js",
|
|
29
|
+
"require": "./dist/index.cjs.js"
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^25.6.0",
|
|
35
|
+
"glob": "^13.0.6",
|
|
36
|
+
"typescript": "~6.0.2",
|
|
37
|
+
"vite": "^8.0.4",
|
|
38
|
+
"vite-plugin-dts": "^4.5.4",
|
|
39
|
+
"vitest": "^4.1.4"
|
|
40
|
+
}
|
|
41
|
+
}
|