@srsergio/taptapp-ar 1.0.76 → 1.0.77
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/dist/compiler/controller.js +2 -2
- package/dist/compiler/detector/crop-detector.d.ts +1 -0
- package/dist/compiler/detector/crop-detector.js +11 -14
- package/dist/compiler/tracker/tracker.js +1 -1
- package/package.json +1 -1
- package/src/compiler/controller.ts +1 -1
- package/src/compiler/detector/crop-detector.js +11 -14
- package/src/compiler/tracker/tracker.js +1 -1
|
@@ -173,8 +173,8 @@ class Controller {
|
|
|
173
173
|
}
|
|
174
174
|
async _trackAndUpdate(inputData, lastModelViewTransform, targetIndex) {
|
|
175
175
|
const { worldCoords, screenCoords } = this.tracker.track(inputData, lastModelViewTransform, targetIndex);
|
|
176
|
-
if (worldCoords.length <
|
|
177
|
-
return null; //
|
|
176
|
+
if (worldCoords.length < 8)
|
|
177
|
+
return null; // Resynced with Matcher (8 points) to allow initial detection
|
|
178
178
|
const modelViewTransform = await this._workerTrackUpdate(lastModelViewTransform, {
|
|
179
179
|
worldCoords,
|
|
180
180
|
screenCoords,
|
|
@@ -24,39 +24,36 @@ class CropDetector {
|
|
|
24
24
|
}
|
|
25
25
|
detectMoving(input) {
|
|
26
26
|
const imageData = input;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if (!this.frameCounter)
|
|
28
|
+
this.frameCounter = 0;
|
|
29
|
+
this.frameCounter++;
|
|
30
|
+
// Scan full screen every 2 frames
|
|
31
|
+
if (this.frameCounter % 2 === 0) {
|
|
31
32
|
return this._detectGlobal(imageData);
|
|
32
33
|
}
|
|
33
|
-
// Local crops
|
|
34
|
+
// Local crops: ensure we visit every single cell
|
|
34
35
|
const gridSize = 5;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const dx = idx % gridSize;
|
|
38
|
-
const dy = Math.floor(idx / gridSize);
|
|
36
|
+
const dx = this.lastRandomIndex % gridSize;
|
|
37
|
+
const dy = Math.floor(this.lastRandomIndex / gridSize);
|
|
39
38
|
const stepX = this.cropSize / 3;
|
|
40
39
|
const stepY = this.cropSize / 3;
|
|
41
40
|
let startY = Math.floor(this.height / 2 - this.cropSize / 2 + (dy - 2) * stepY);
|
|
42
41
|
let startX = Math.floor(this.width / 2 - this.cropSize / 2 + (dx - 2) * stepX);
|
|
43
42
|
startX = Math.max(0, Math.min(this.width - this.cropSize - 1, startX));
|
|
44
43
|
startY = Math.max(0, Math.min(this.height - this.cropSize - 1, startY));
|
|
45
|
-
this.lastRandomIndex = (this.lastRandomIndex + 1) %
|
|
44
|
+
this.lastRandomIndex = (this.lastRandomIndex + 1) % (gridSize * gridSize);
|
|
46
45
|
return this._detect(imageData, startX, startY);
|
|
47
46
|
}
|
|
48
47
|
_detectGlobal(imageData) {
|
|
49
48
|
const croppedData = new Float32Array(this.cropSize * this.cropSize);
|
|
50
49
|
const scaleX = this.width / this.cropSize;
|
|
51
50
|
const scaleY = this.height / this.cropSize;
|
|
52
|
-
//
|
|
51
|
+
// Use sharp sampling for better descriptors
|
|
53
52
|
for (let y = 0; y < this.cropSize; y++) {
|
|
54
53
|
const srcY = Math.floor(y * scaleY) * this.width;
|
|
55
54
|
const dstY = y * this.cropSize;
|
|
56
55
|
for (let x = 0; x < this.cropSize; x++) {
|
|
57
|
-
|
|
58
|
-
const sx = Math.floor(x * scaleX);
|
|
59
|
-
croppedData[dstY + x] = (imageData[srcY + sx] + imageData[srcY + sx + 1]) * 0.5;
|
|
56
|
+
croppedData[dstY + x] = imageData[srcY + Math.floor(x * scaleX)];
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
59
|
const { featurePoints } = this.detector.detect(croppedData);
|
|
@@ -95,7 +95,7 @@ class Tracker {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
// 2.1 Spatial distribution check: Avoid getting stuck in corners/noise
|
|
98
|
-
if (screenCoords.length >=
|
|
98
|
+
if (screenCoords.length >= 8) {
|
|
99
99
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
100
100
|
for (const p of screenCoords) {
|
|
101
101
|
if (p.x < minX)
|
package/package.json
CHANGED
|
@@ -233,7 +233,7 @@ class Controller {
|
|
|
233
233
|
lastModelViewTransform,
|
|
234
234
|
targetIndex,
|
|
235
235
|
);
|
|
236
|
-
if (worldCoords.length <
|
|
236
|
+
if (worldCoords.length < 8) return null; // Resynced with Matcher (8 points) to allow initial detection
|
|
237
237
|
const modelViewTransform = await this._workerTrackUpdate(lastModelViewTransform, {
|
|
238
238
|
worldCoords,
|
|
239
239
|
screenCoords,
|
|
@@ -32,20 +32,19 @@ class CropDetector {
|
|
|
32
32
|
|
|
33
33
|
detectMoving(input) {
|
|
34
34
|
const imageData = input;
|
|
35
|
+
if (!this.frameCounter) this.frameCounter = 0;
|
|
36
|
+
this.frameCounter++;
|
|
35
37
|
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
if (this.lastRandomIndex % 2 === 0) {
|
|
39
|
-
this.lastRandomIndex = (this.lastRandomIndex + 1) % 25;
|
|
38
|
+
// Scan full screen every 2 frames
|
|
39
|
+
if (this.frameCounter % 2 === 0) {
|
|
40
40
|
return this._detectGlobal(imageData);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// Local crops
|
|
43
|
+
// Local crops: ensure we visit every single cell
|
|
44
44
|
const gridSize = 5;
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const dy = Math.floor(idx / gridSize);
|
|
45
|
+
const dx = this.lastRandomIndex % gridSize;
|
|
46
|
+
const dy = Math.floor(this.lastRandomIndex / gridSize);
|
|
47
|
+
|
|
49
48
|
const stepX = this.cropSize / 3;
|
|
50
49
|
const stepY = this.cropSize / 3;
|
|
51
50
|
|
|
@@ -55,7 +54,7 @@ class CropDetector {
|
|
|
55
54
|
startX = Math.max(0, Math.min(this.width - this.cropSize - 1, startX));
|
|
56
55
|
startY = Math.max(0, Math.min(this.height - this.cropSize - 1, startY));
|
|
57
56
|
|
|
58
|
-
this.lastRandomIndex = (this.lastRandomIndex + 1) %
|
|
57
|
+
this.lastRandomIndex = (this.lastRandomIndex + 1) % (gridSize * gridSize);
|
|
59
58
|
return this._detect(imageData, startX, startY);
|
|
60
59
|
}
|
|
61
60
|
|
|
@@ -64,14 +63,12 @@ class CropDetector {
|
|
|
64
63
|
const scaleX = this.width / this.cropSize;
|
|
65
64
|
const scaleY = this.height / this.cropSize;
|
|
66
65
|
|
|
67
|
-
//
|
|
66
|
+
// Use sharp sampling for better descriptors
|
|
68
67
|
for (let y = 0; y < this.cropSize; y++) {
|
|
69
68
|
const srcY = Math.floor(y * scaleY) * this.width;
|
|
70
69
|
const dstY = y * this.cropSize;
|
|
71
70
|
for (let x = 0; x < this.cropSize; x++) {
|
|
72
|
-
|
|
73
|
-
const sx = Math.floor(x * scaleX);
|
|
74
|
-
croppedData[dstY + x] = (imageData[srcY + sx] + imageData[srcY + sx + 1]) * 0.5;
|
|
71
|
+
croppedData[dstY + x] = imageData[srcY + Math.floor(x * scaleX)];
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
|
|
@@ -137,7 +137,7 @@ class Tracker {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
// 2.1 Spatial distribution check: Avoid getting stuck in corners/noise
|
|
140
|
-
if (screenCoords.length >=
|
|
140
|
+
if (screenCoords.length >= 8) {
|
|
141
141
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
142
142
|
for (const p of screenCoords) {
|
|
143
143
|
if (p.x < minX) minX = p.x; if (p.y < minY) minY = p.y;
|