@srsergio/taptapp-ar 1.0.75 → 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 +4 -4
- package/dist/compiler/detector/crop-detector.d.ts +1 -3
- package/dist/compiler/detector/crop-detector.js +10 -14
- package/dist/compiler/tracker/tracker.js +1 -1
- package/dist/react/TaptappAR.js +0 -3
- package/package.json +1 -1
- package/src/compiler/controller.ts +3 -3
- package/src/compiler/detector/crop-detector.js +9 -16
- package/src/compiler/tracker/tracker.js +1 -1
- package/src/react/TaptappAR.tsx +0 -3
|
@@ -20,8 +20,8 @@ const getControllerWorker = async () => {
|
|
|
20
20
|
ControllerWorker = await getControllerWorker();
|
|
21
21
|
const DEFAULT_FILTER_CUTOFF = 0.5;
|
|
22
22
|
const DEFAULT_FILTER_BETA = 0.1;
|
|
23
|
-
const DEFAULT_WARMUP_TOLERANCE =
|
|
24
|
-
const DEFAULT_MISS_TOLERANCE =
|
|
23
|
+
const DEFAULT_WARMUP_TOLERANCE = 2; // Instant detection
|
|
24
|
+
const DEFAULT_MISS_TOLERANCE = 5; // More grace when partially hidden
|
|
25
25
|
class Controller {
|
|
26
26
|
inputWidth;
|
|
27
27
|
inputHeight;
|
|
@@ -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,
|
|
@@ -22,9 +22,7 @@ export class CropDetector {
|
|
|
22
22
|
projectedImage?: undefined;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
* Scans the ENTIRE frame by downsampling it to cropSize
|
|
27
|
-
*/
|
|
25
|
+
frameCounter: number | undefined;
|
|
28
26
|
_detectGlobal(imageData: any): {
|
|
29
27
|
featurePoints: any[];
|
|
30
28
|
debugExtra: {
|
|
@@ -24,35 +24,31 @@ class CropDetector {
|
|
|
24
24
|
}
|
|
25
25
|
detectMoving(input) {
|
|
26
26
|
const imageData = input;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
if (!this.frameCounter)
|
|
28
|
+
this.frameCounter = 0;
|
|
29
|
+
this.frameCounter++;
|
|
30
|
+
// Scan full screen every 2 frames
|
|
31
|
+
if (this.frameCounter % 2 === 0) {
|
|
32
32
|
return this._detectGlobal(imageData);
|
|
33
33
|
}
|
|
34
|
-
//
|
|
34
|
+
// Local crops: ensure we visit every single cell
|
|
35
35
|
const gridSize = 5;
|
|
36
|
-
const
|
|
37
|
-
const
|
|
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
|
-
/**
|
|
49
|
-
* Scans the ENTIRE frame by downsampling it to cropSize
|
|
50
|
-
*/
|
|
51
47
|
_detectGlobal(imageData) {
|
|
52
48
|
const croppedData = new Float32Array(this.cropSize * this.cropSize);
|
|
53
49
|
const scaleX = this.width / this.cropSize;
|
|
54
50
|
const scaleY = this.height / this.cropSize;
|
|
55
|
-
//
|
|
51
|
+
// Use sharp sampling for better descriptors
|
|
56
52
|
for (let y = 0; y < this.cropSize; y++) {
|
|
57
53
|
const srcY = Math.floor(y * scaleY) * this.width;
|
|
58
54
|
const dstY = y * this.cropSize;
|
|
@@ -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/dist/react/TaptappAR.js
CHANGED
|
@@ -92,9 +92,6 @@ export const TaptappAR = ({ config, className = "", showScanningOverlay = true,
|
|
|
92
92
|
display: block;
|
|
93
93
|
width: 100%;
|
|
94
94
|
height: auto;
|
|
95
|
-
will-change: transform;
|
|
96
|
-
/* Visual interpolation to smooth out frame gaps */
|
|
97
|
-
transition: transform 0.1s linear, opacity 0.3s ease;
|
|
98
95
|
}
|
|
99
96
|
` })] }));
|
|
100
97
|
};
|
package/package.json
CHANGED
|
@@ -21,8 +21,8 @@ ControllerWorker = await getControllerWorker();
|
|
|
21
21
|
|
|
22
22
|
const DEFAULT_FILTER_CUTOFF = 0.5;
|
|
23
23
|
const DEFAULT_FILTER_BETA = 0.1;
|
|
24
|
-
const DEFAULT_WARMUP_TOLERANCE =
|
|
25
|
-
const DEFAULT_MISS_TOLERANCE =
|
|
24
|
+
const DEFAULT_WARMUP_TOLERANCE = 2; // Instant detection
|
|
25
|
+
const DEFAULT_MISS_TOLERANCE = 5; // More grace when partially hidden
|
|
26
26
|
|
|
27
27
|
export interface ControllerOptions {
|
|
28
28
|
inputWidth: number;
|
|
@@ -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,18 @@ 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
|
-
// Every 3 frames, we do a full screen downsampled scan.
|
|
39
|
-
if (this.lastRandomIndex % 3 === 0) {
|
|
40
|
-
this.lastRandomIndex = (this.lastRandomIndex + 1) % 25;
|
|
38
|
+
// Scan full screen every 2 frames
|
|
39
|
+
if (this.frameCounter % 2 === 0) {
|
|
41
40
|
return this._detectGlobal(imageData);
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
//
|
|
43
|
+
// Local crops: ensure we visit every single cell
|
|
45
44
|
const gridSize = 5;
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const dy = Math.floor(idx / gridSize);
|
|
45
|
+
const dx = this.lastRandomIndex % gridSize;
|
|
46
|
+
const dy = Math.floor(this.lastRandomIndex / gridSize);
|
|
49
47
|
|
|
50
48
|
const stepX = this.cropSize / 3;
|
|
51
49
|
const stepY = this.cropSize / 3;
|
|
@@ -56,20 +54,16 @@ class CropDetector {
|
|
|
56
54
|
startX = Math.max(0, Math.min(this.width - this.cropSize - 1, startX));
|
|
57
55
|
startY = Math.max(0, Math.min(this.height - this.cropSize - 1, startY));
|
|
58
56
|
|
|
59
|
-
this.lastRandomIndex = (this.lastRandomIndex + 1) %
|
|
60
|
-
|
|
57
|
+
this.lastRandomIndex = (this.lastRandomIndex + 1) % (gridSize * gridSize);
|
|
61
58
|
return this._detect(imageData, startX, startY);
|
|
62
59
|
}
|
|
63
60
|
|
|
64
|
-
/**
|
|
65
|
-
* Scans the ENTIRE frame by downsampling it to cropSize
|
|
66
|
-
*/
|
|
67
61
|
_detectGlobal(imageData) {
|
|
68
62
|
const croppedData = new Float32Array(this.cropSize * this.cropSize);
|
|
69
63
|
const scaleX = this.width / this.cropSize;
|
|
70
64
|
const scaleY = this.height / this.cropSize;
|
|
71
65
|
|
|
72
|
-
//
|
|
66
|
+
// Use sharp sampling for better descriptors
|
|
73
67
|
for (let y = 0; y < this.cropSize; y++) {
|
|
74
68
|
const srcY = Math.floor(y * scaleY) * this.width;
|
|
75
69
|
const dstY = y * this.cropSize;
|
|
@@ -79,7 +73,6 @@ class CropDetector {
|
|
|
79
73
|
}
|
|
80
74
|
|
|
81
75
|
const { featurePoints } = this.detector.detect(croppedData);
|
|
82
|
-
|
|
83
76
|
featurePoints.forEach((p) => {
|
|
84
77
|
p.x *= scaleX;
|
|
85
78
|
p.y *= scaleY;
|
|
@@ -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;
|
package/src/react/TaptappAR.tsx
CHANGED
|
@@ -169,9 +169,6 @@ export const TaptappAR: React.FC<TaptappARProps> = ({
|
|
|
169
169
|
display: block;
|
|
170
170
|
width: 100%;
|
|
171
171
|
height: auto;
|
|
172
|
-
will-change: transform;
|
|
173
|
-
/* Visual interpolation to smooth out frame gaps */
|
|
174
|
-
transition: transform 0.1s linear, opacity 0.3s ease;
|
|
175
172
|
}
|
|
176
173
|
`}</style>
|
|
177
174
|
</div>
|