@srsergio/taptapp-ar 1.0.10 โ 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 +133 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# @srsergio/taptapp-ar
|
|
2
2
|
|
|
3
|
-
๐ **TapTapp AR** is a high-performance Augmented Reality (AR)
|
|
3
|
+
๐ **TapTapp AR** is a high-performance Augmented Reality (AR) toolkit for **Node.js** and **Browser** environments. It provides an ultra-fast offline compiler and a lightweight runtime for image tracking.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**100% Pure JavaScript**: This package is now completely independent of **TensorFlow.js** for both compilation and real-time tracking, resulting in massive performance gains and zero-latency initialization.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## ๐ Key Features
|
|
10
10
|
|
|
11
|
-
- ๐ผ๏ธ **
|
|
12
|
-
- โก **
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
- ๐ฆ **
|
|
11
|
+
- ๐ผ๏ธ **Hyper-Fast Compiler**: Pure JavaScript compiler that generates `.mind` files in **< 0.9s per image**.
|
|
12
|
+
- โก **No TensorFlow Dependency**: No TFJS at all. Works natively in any JS environment (Node, Browser, Workers).
|
|
13
|
+
- ๐ **Protocol V3 (Columnar Binary)**: Zero-copy loading with 80%+ smaller files and CPU-cache alignment.
|
|
14
|
+
- ๐งต **Optimized Runtime**: Tracking engine with **Buffer Recycling** and **Zero-Copy** for smooth 60fps AR on low-end devices.
|
|
15
|
+
- ๐ฆ **Framework Agnostic**: Includes wrappers for **A-Frame**, **Three.js**, and a raw **Controller** for custom engines.
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
@@ -22,79 +22,164 @@ Built with performance in mind, this package features a **pure JavaScript offlin
|
|
|
22
22
|
npm install @srsergio/taptapp-ar
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
### ๐ฆ Optional Dependencies
|
|
26
|
-
|
|
27
|
-
> **Note:** TensorFlow is **NOT required** for the offline compiler. It only uses pure JavaScript.
|
|
28
|
-
|
|
29
25
|
---
|
|
30
26
|
|
|
31
|
-
##
|
|
32
|
-
|
|
33
|
-
TaptApp AR features the industry's most advanced **pure JavaScript** offline compiler. With the introduction of **Protocol V3 (Columnar Binary Format)**, it sets a new standard for AR asset management.
|
|
27
|
+
## ๐ Industry-Leading Benchmarks (v3)
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
| Metric | Official MindAR | TapTapp AR (v3) | Improvement |
|
|
29
|
+
| Metric | Official MindAR | TapTapp AR | Improvement |
|
|
38
30
|
| :--- | :--- | :--- | :--- |
|
|
39
|
-
| **Compilation Time** | ~23.50s | **~
|
|
31
|
+
| **Compilation Time** | ~23.50s | **~0.89s** | ๐ **26x Faster** |
|
|
40
32
|
| **Output Size (.mind)** | ~770 KB | **~127 KB** | ๐ **83.5% Smaller** |
|
|
41
|
-
| **
|
|
42
|
-
| **
|
|
43
|
-
|
|
44
|
-
> *Tested on 1024x1024 high-detail image target.*
|
|
33
|
+
| **Tracking Latency** | Variable (TFJS) | **Constant (Pure JS)** | โก **Stable 60fps** |
|
|
34
|
+
| **Dependency Size** | ~20MB (TFJS) | **< 100KB** | ๐ฆ **99% Smaller Bundle** |
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- **Protocol V3 (Columnar Binary)**: Uses TypedArrays to store coordinates, angles, and descriptors in a cache-aligned layout. No more thousands of slow JavaScript objects.
|
|
49
|
-
- **Zero-Copy Loading**: The runtime reads directly from the binary buffer. Initialization is now virtualy instant.
|
|
50
|
-
- **Aggressive Matching Optimization**: Tree-based hierarchical clustering compacted into a flattened binary format.
|
|
51
|
-
- **No Dependencies**: Works in Node.js and Browser with zero external requirements for the compilation core.
|
|
36
|
+
---
|
|
52
37
|
|
|
53
|
-
|
|
38
|
+
## ๐ผ๏ธ Compiler Usage (Node.js & Web)
|
|
54
39
|
|
|
55
|
-
|
|
40
|
+
The compiler is designed to run in workers (Node.js or Browser) for maximum performance.
|
|
56
41
|
|
|
57
42
|
```javascript
|
|
58
43
|
import { OfflineCompiler } from '@srsergio/taptapp-ar';
|
|
59
44
|
|
|
60
45
|
const compiler = new OfflineCompiler();
|
|
61
46
|
|
|
62
|
-
// Compile target image
|
|
63
|
-
|
|
47
|
+
// Compile target image (provide grayscale pixel data)
|
|
48
|
+
await compiler.compileImageTargets(
|
|
64
49
|
[{ width, height, data: grayscaleUint8Array }],
|
|
65
50
|
(progress) => console.log(`Compiling: ${progress}%`)
|
|
66
51
|
);
|
|
67
52
|
|
|
68
|
-
// Export to
|
|
69
|
-
const binaryBuffer = compiler.exportData();
|
|
53
|
+
// Export to high-efficiency binary format
|
|
54
|
+
const binaryBuffer = compiler.exportData();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## ๐ฅ Runtime Usage (AR Tracking)
|
|
60
|
+
|
|
61
|
+
### 1. Simple A-Frame Integration
|
|
62
|
+
The easiest way to use TapTapp AR in a web app:
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
|
|
66
|
+
<script src="path/to/@srsergio/taptapp-ar/dist/index.js"></script>
|
|
67
|
+
|
|
68
|
+
<a-scene mindar-image="imageTargetSrc: ./targets.mind;">
|
|
69
|
+
<a-camera position="0 0 0" look-controls="enabled: false"></a-camera>
|
|
70
|
+
<a-entity mindar-image-target="targetIndex: 0">
|
|
71
|
+
<a-plane position="0 0 0" height="0.552" width="1"></a-plane>
|
|
72
|
+
</a-entity>
|
|
73
|
+
</a-scene>
|
|
70
74
|
```
|
|
71
75
|
|
|
72
|
-
###
|
|
76
|
+
### 2. High-Performance Three.js Wrapper
|
|
77
|
+
For custom Three.js applications:
|
|
73
78
|
|
|
74
79
|
```javascript
|
|
75
|
-
import {
|
|
80
|
+
import { MindARThree } from '@srsergio/taptapp-ar';
|
|
76
81
|
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
const mindarThree = new MindARThree({
|
|
83
|
+
container: document.querySelector("#container"),
|
|
84
|
+
imageTargetSrc: './targets.mind',
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const {renderer, scene, camera} = mindarThree;
|
|
88
|
+
|
|
89
|
+
const anchor = mindarThree.addAnchor(0);
|
|
90
|
+
// Add your 3D models to anchor.group
|
|
91
|
+
|
|
92
|
+
await mindarThree.start();
|
|
93
|
+
renderer.setAnimationLoop(() => {
|
|
94
|
+
renderer.render(scene, camera);
|
|
95
|
+
});
|
|
80
96
|
```
|
|
81
97
|
|
|
82
|
-
|
|
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:
|
|
83
117
|
|
|
84
|
-
|
|
118
|
+
```javascript
|
|
119
|
+
import { Controller } from '@srsergio/taptapp-ar';
|
|
120
|
+
|
|
121
|
+
const controller = new Controller({
|
|
122
|
+
inputWidth: video.videoWidth,
|
|
123
|
+
inputHeight: video.videoHeight,
|
|
124
|
+
onUpdate: (data) => {
|
|
125
|
+
if (data.type === 'updateMatrix') {
|
|
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
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
await controller.addImageTargets('./targets.mind');
|
|
138
|
+
controller.processVideo(videoElement); // Starts the internal RAF loop
|
|
139
|
+
```
|
|
85
140
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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);
|
|
89
153
|
|
|
90
|
-
|
|
91
|
-
|
|
154
|
+
if (targetIndex !== -1) {
|
|
155
|
+
// Found a match! Use modelViewTransform for initial pose estimation
|
|
156
|
+
}
|
|
92
157
|
```
|
|
93
158
|
|
|
94
|
-
|
|
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
|
+
```
|
|
95
169
|
|
|
96
170
|
---
|
|
97
171
|
|
|
98
|
-
##
|
|
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
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## ๐ License & Credits
|
|
99
182
|
|
|
100
183
|
MIT ยฉ [srsergiolazaro](https://github.com/srsergiolazaro)
|
|
184
|
+
|
|
185
|
+
Based on the core research of MindAR, but completely re-written for high-performance binary processing and JS-only execution.
|