@srsergio/taptapp-ar 1.0.88 → 1.0.90
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/README.md +17 -10
- package/dist/compiler/offline-compiler.js +16 -4
- package/dist/core/detector/detector-lite.d.ts +1 -0
- package/dist/core/detector/detector-lite.js +31 -15
- package/dist/core/estimation/estimate.d.ts +7 -0
- package/dist/core/estimation/estimate.js +13 -48
- package/dist/core/estimation/morph-refinement.d.ts +8 -0
- package/dist/core/estimation/morph-refinement.js +116 -0
- package/dist/core/estimation/pnp-solver.d.ts +5 -0
- package/dist/core/estimation/pnp-solver.js +109 -0
- package/dist/core/input-loader.js +19 -2
- package/dist/core/matching/hdc.d.ts +27 -0
- package/dist/core/matching/hdc.js +102 -0
- package/dist/core/matching/hierarchical-clustering.d.ts +1 -3
- package/dist/core/matching/hierarchical-clustering.js +30 -29
- package/dist/core/matching/hough.js +12 -11
- package/dist/core/matching/matcher.d.ts +4 -0
- package/dist/core/matching/matcher.js +23 -8
- package/dist/core/matching/matching.d.ts +22 -2
- package/dist/core/matching/matching.js +169 -39
- package/dist/core/matching/ransacHomography.js +3 -6
- package/dist/core/protocol.d.ts +5 -3
- package/dist/core/protocol.js +28 -6
- package/dist/runtime/controller.js +19 -14
- package/dist/runtime/controller.worker.js +4 -1
- package/package.json +3 -2
- package/src/compiler/offline-compiler.ts +17 -4
- package/src/core/detector/detector-lite.js +32 -15
- package/src/core/estimation/estimate.js +14 -63
- package/src/core/estimation/morph-refinement.js +139 -0
- package/src/core/estimation/pnp-solver.js +131 -0
- package/src/core/input-loader.js +21 -2
- package/src/core/matching/hdc.ts +117 -0
- package/src/core/matching/hierarchical-clustering.js +30 -29
- package/src/core/matching/hough.js +12 -11
- package/src/core/matching/matcher.js +27 -9
- package/src/core/matching/matching.js +192 -39
- package/src/core/matching/ransacHomography.js +3 -6
- package/src/core/protocol.ts +26 -6
- package/src/runtime/controller.ts +20 -14
- package/src/runtime/controller.worker.js +4 -1
package/src/core/protocol.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as msgpack from "@msgpack/msgpack";
|
|
2
2
|
|
|
3
|
-
export const CURRENT_VERSION =
|
|
3
|
+
export const CURRENT_VERSION = 9; // Bumped for HDC support
|
|
4
|
+
export const HDC_SEED = 0x1337BEEF; // Default system seed
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Morton Order calculation for spatial sorting
|
|
@@ -59,13 +60,19 @@ export function unpack4Bit(packed: Uint8Array, width: number, height: number): U
|
|
|
59
60
|
/**
|
|
60
61
|
* Columnarizes point data for efficient storage and transfer
|
|
61
62
|
*/
|
|
62
|
-
export function columnarize(points: any[], tree: any, width: number, height: number) {
|
|
63
|
+
export function columnarize(points: any[], tree: any, width: number, height: number, useHDC: boolean = false) {
|
|
63
64
|
const count = points.length;
|
|
64
65
|
const x = new Uint16Array(count);
|
|
65
66
|
const y = new Uint16Array(count);
|
|
66
67
|
const angle = new Int16Array(count);
|
|
67
68
|
const scale = new Uint8Array(count);
|
|
68
|
-
|
|
69
|
+
|
|
70
|
+
let descriptors: any;
|
|
71
|
+
if (useHDC) {
|
|
72
|
+
descriptors = new Uint32Array(count); // HDC Signatures (32-bit)
|
|
73
|
+
} else {
|
|
74
|
+
descriptors = new Uint32Array(count * 2); // Raw Descriptors (64-bit)
|
|
75
|
+
}
|
|
69
76
|
|
|
70
77
|
for (let i = 0; i < count; i++) {
|
|
71
78
|
x[i] = Math.round((points[i].x / width) * 65535);
|
|
@@ -74,8 +81,15 @@ export function columnarize(points: any[], tree: any, width: number, height: num
|
|
|
74
81
|
scale[i] = Math.round(Math.log2(points[i].scale || 1));
|
|
75
82
|
|
|
76
83
|
if (points[i].descriptors && points[i].descriptors.length >= 2) {
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
if (useHDC) {
|
|
85
|
+
// For HDC, we'd normally call project + compress here
|
|
86
|
+
// But protocol.ts should be agnostic of the generator.
|
|
87
|
+
// We'll assume points[i].hdcSignature exists if pre-calculated
|
|
88
|
+
descriptors[i] = points[i].hdcSignature || 0;
|
|
89
|
+
} else {
|
|
90
|
+
descriptors[i * 2] = points[i].descriptors[0];
|
|
91
|
+
descriptors[(i * 2) + 1] = points[i].descriptors[1];
|
|
92
|
+
}
|
|
79
93
|
}
|
|
80
94
|
}
|
|
81
95
|
|
|
@@ -85,6 +99,7 @@ export function columnarize(points: any[], tree: any, width: number, height: num
|
|
|
85
99
|
a: angle,
|
|
86
100
|
s: scale,
|
|
87
101
|
d: descriptors,
|
|
102
|
+
hdc: useHDC ? 1 : 0, // HDC Flag (renamed from h to avoid collision with height)
|
|
88
103
|
t: compactTree(tree.rootNode),
|
|
89
104
|
};
|
|
90
105
|
}
|
|
@@ -209,7 +224,12 @@ export function decodeTaar(buffer: ArrayBuffer | Uint8Array) {
|
|
|
209
224
|
}
|
|
210
225
|
|
|
211
226
|
if (col.d instanceof Uint8Array) {
|
|
212
|
-
|
|
227
|
+
// Check if it's HDC (Uint32) or Raw (Uint32 x 2)
|
|
228
|
+
if (col.hdc === 1) {
|
|
229
|
+
col.d = new Uint32Array(col.d.buffer.slice(col.d.byteOffset, col.d.byteOffset + col.d.byteLength));
|
|
230
|
+
} else {
|
|
231
|
+
col.d = new Uint32Array(col.d.buffer.slice(col.d.byteOffset, col.d.byteOffset + col.d.byteLength));
|
|
232
|
+
}
|
|
213
233
|
}
|
|
214
234
|
}
|
|
215
235
|
}
|
|
@@ -102,7 +102,10 @@ class Controller {
|
|
|
102
102
|
if (this.worker) this._setupWorkerListener();
|
|
103
103
|
|
|
104
104
|
// Moonshot: Full frame detector for better sensitivity
|
|
105
|
-
this.fullDetector = new DetectorLite(this.inputWidth, this.inputHeight, {
|
|
105
|
+
this.fullDetector = new DetectorLite(this.inputWidth, this.inputHeight, {
|
|
106
|
+
useLSH: true,
|
|
107
|
+
maxFeaturesPerBucket: 24 // Increased from 12 for better small target density
|
|
108
|
+
});
|
|
106
109
|
|
|
107
110
|
this.featureManager.init({
|
|
108
111
|
inputWidth: this.inputWidth,
|
|
@@ -111,9 +114,9 @@ class Controller {
|
|
|
111
114
|
debugMode: this.debugMode
|
|
112
115
|
});
|
|
113
116
|
|
|
114
|
-
const near =
|
|
115
|
-
const far =
|
|
116
|
-
const fovy = (
|
|
117
|
+
const near = 1.0;
|
|
118
|
+
const far = 10000;
|
|
119
|
+
const fovy = (60.0 * Math.PI) / 180;
|
|
117
120
|
const f = this.inputHeight / 2 / Math.tan(fovy / 2);
|
|
118
121
|
|
|
119
122
|
this.projectionTransform = [
|
|
@@ -323,10 +326,12 @@ class Controller {
|
|
|
323
326
|
}
|
|
324
327
|
}
|
|
325
328
|
|
|
326
|
-
//
|
|
327
|
-
const
|
|
329
|
+
// 🚀 WARMUP FIX: If we just started tracking (less than 15 frames), we are much more relaxed
|
|
330
|
+
const isWarmup = state.trackCount < 15;
|
|
331
|
+
const numTracked = finalWorldCoords.length;
|
|
332
|
+
const minPoints = isWarmup ? 4 : 5; // Start with 4, then require 5
|
|
328
333
|
|
|
329
|
-
if (
|
|
334
|
+
if (numTracked < minPoints) {
|
|
330
335
|
return {
|
|
331
336
|
modelViewTransform: null,
|
|
332
337
|
screenCoords: finalScreenCoords,
|
|
@@ -335,6 +340,8 @@ class Controller {
|
|
|
335
340
|
};
|
|
336
341
|
}
|
|
337
342
|
|
|
343
|
+
state.trackCount++;
|
|
344
|
+
|
|
338
345
|
const modelViewTransform = await this._workerTrackUpdate(lastModelViewTransform, {
|
|
339
346
|
worldCoords: finalWorldCoords,
|
|
340
347
|
screenCoords: finalWorldCoords.map((_, i) => {
|
|
@@ -670,15 +677,14 @@ class Controller {
|
|
|
670
677
|
}
|
|
671
678
|
|
|
672
679
|
_glModelViewMatrix(modelViewTransform: number[][], targetIndex: number) {
|
|
673
|
-
|
|
680
|
+
// Transformation to map Computer Vision coordinates (Y-down, Z-forward)
|
|
681
|
+
// to OpenGL coordinates (Y-up, Z-backward).
|
|
682
|
+
// We negate the 2nd and 3rd rows of the pose matrix.
|
|
674
683
|
return [
|
|
675
684
|
modelViewTransform[0][0], -modelViewTransform[1][0], -modelViewTransform[2][0], 0,
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
modelViewTransform[0][1]
|
|
679
|
-
-(modelViewTransform[1][1] * height + modelViewTransform[1][3]),
|
|
680
|
-
-(modelViewTransform[2][1] * height + modelViewTransform[2][3]),
|
|
681
|
-
1,
|
|
685
|
+
modelViewTransform[0][1], -modelViewTransform[1][1], -modelViewTransform[2][1], 0,
|
|
686
|
+
modelViewTransform[0][2], -modelViewTransform[1][2], -modelViewTransform[2][2], 0,
|
|
687
|
+
modelViewTransform[0][3], -modelViewTransform[1][3], -modelViewTransform[2][3], 1,
|
|
682
688
|
];
|
|
683
689
|
}
|
|
684
690
|
|
|
@@ -31,7 +31,10 @@ onmessage = (msg) => {
|
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
detector = new DetectorLite(data.inputWidth, data.inputHeight, {
|
|
34
|
+
detector = new DetectorLite(data.inputWidth, data.inputHeight, {
|
|
35
|
+
useLSH: true,
|
|
36
|
+
maxFeaturesPerBucket: 24
|
|
37
|
+
});
|
|
35
38
|
break;
|
|
36
39
|
|
|
37
40
|
case "match":
|