@srsergio/taptapp-ar 1.0.11 → 1.0.12
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 +66 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,27 +95,87 @@ renderer.setAnimationLoop(() => {
|
|
|
95
95
|
});
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
### 3. Raw Controller (Custom
|
|
99
|
-
|
|
98
|
+
### 3. Raw Controller (Advanced & Custom Engines)
|
|
99
|
+
The `Controller` is the core engine of TapTapp AR. You can use it to build your own AR components or integrate tracking into custom 3D engines.
|
|
100
|
+
|
|
101
|
+
#### ⚙️ Controller Configuration
|
|
102
|
+
| Property | Default | Description |
|
|
103
|
+
| :--- | :--- | :--- |
|
|
104
|
+
| `inputWidth` | **Required** | The width of the video or image source. |
|
|
105
|
+
| `inputHeight` | **Required** | The height of the video or image source. |
|
|
106
|
+
| `maxTrack` | `1` | Max number of images to track simultaneously. |
|
|
107
|
+
| `warmupTolerance` | `5` | Frames of consistent detection needed to "lock" a target. |
|
|
108
|
+
| `missTolerance` | `5` | Frames of missed detection before considering the target "lost". |
|
|
109
|
+
| `filterMinCF` | `0.001` | Min cutoff frequency for the OneEuroFilter (reduces jitter). |
|
|
110
|
+
| `filterBeta` | `1000` | Filter beta parameter (higher = more responsive, lower = smoother). |
|
|
111
|
+
| `onUpdate` | `null` | Callback for tracking events (Found, Lost, ProcessDone). |
|
|
112
|
+
| `debugMode` | `false` | If true, returns extra debug data (cropped images, feature points). |
|
|
113
|
+
| `worker` | `null` | Pass a custom worker instance if using a specialized environment. |
|
|
114
|
+
|
|
115
|
+
#### 🚀 Example: Tracking a Video Stream
|
|
116
|
+
Ideal for real-time AR apps in the browser:
|
|
100
117
|
|
|
101
118
|
```javascript
|
|
102
119
|
import { Controller } from '@srsergio/taptapp-ar';
|
|
103
120
|
|
|
104
121
|
const controller = new Controller({
|
|
105
|
-
inputWidth:
|
|
106
|
-
inputHeight:
|
|
122
|
+
inputWidth: video.videoWidth,
|
|
123
|
+
inputHeight: video.videoHeight,
|
|
107
124
|
onUpdate: (data) => {
|
|
108
125
|
if (data.type === 'updateMatrix') {
|
|
109
|
-
// worldMatrix found! Apply to your 3D engine
|
|
110
126
|
const { targetIndex, worldMatrix } = data;
|
|
127
|
+
if (worldMatrix) {
|
|
128
|
+
console.log(`Target ${targetIndex} detected! Matrix:`, worldMatrix);
|
|
129
|
+
// Apply worldMatrix (Float32Array[16]) to your 3D object
|
|
130
|
+
} else {
|
|
131
|
+
console.log(`Target ${targetIndex} lost.`);
|
|
132
|
+
}
|
|
111
133
|
}
|
|
112
134
|
}
|
|
113
135
|
});
|
|
114
136
|
|
|
115
137
|
await controller.addImageTargets('./targets.mind');
|
|
116
|
-
controller.processVideo(videoElement);
|
|
138
|
+
controller.processVideo(videoElement); // Starts the internal RAF loop
|
|
117
139
|
```
|
|
118
140
|
|
|
141
|
+
#### 📸 Example: One-shot Image Matching
|
|
142
|
+
Use this for "Snap and Detect" features without a continuous video loop:
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
const controller = new Controller({ inputWidth: 1024, inputHeight: 1024 });
|
|
146
|
+
await controller.addImageTargets('./targets.mind');
|
|
147
|
+
|
|
148
|
+
// 1. Detect features in a static image
|
|
149
|
+
const { featurePoints } = await controller.detect(canvasElement);
|
|
150
|
+
|
|
151
|
+
// 2. Attempt to match against a specific target index
|
|
152
|
+
const { targetIndex, modelViewTransform } = await controller.match(featurePoints, 0);
|
|
153
|
+
|
|
154
|
+
if (targetIndex !== -1) {
|
|
155
|
+
// Found a match! Use modelViewTransform for initial pose estimation
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### 🛠️ Life-cycle Management
|
|
160
|
+
Properly management is crucial to avoid memory leaks:
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
// Stop the video loop
|
|
164
|
+
controller.stopProcessVideo();
|
|
165
|
+
|
|
166
|
+
// Clean up workers and internal buffers
|
|
167
|
+
controller.dispose();
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 🏗️ Protocol V3 (Columnar Binary Format)
|
|
173
|
+
TapTapp AR uses a proprietary columnar binary format that is significantly more efficient than standard JSON-based formats.
|
|
174
|
+
|
|
175
|
+
- **Zero-Copy Restoration**: Binary buffers are mapped directly to TypedArrays.
|
|
176
|
+
- **Cache Locality**: Performance is optimized for modern CPUs by keeping coordinates and descriptors adjacent in memory.
|
|
177
|
+
- **Alignment Safe**: Automatically handles `ArrayBuffer` alignment for predictable behavior across all browsers.
|
|
178
|
+
|
|
119
179
|
---
|
|
120
180
|
|
|
121
181
|
## 📄 License & Credits
|