@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.
Files changed (2) hide show
  1. package/README.md +133 -48
  2. 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) compiler toolkit for **Node.js** and **Browser** environments. It provides an ultra-fast offline compiler for image targets.
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
- Built with performance in mind, this package features a **pure JavaScript offline compiler** that requires **no TensorFlow** for compilation, generating high-quality `.mind` files in record time.
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
- - ๐Ÿ–ผ๏ธ **Ultra-Fast Offline Compiler**: Pure JavaScript compiler that generates `.mind` target files in **~1.3s per image**.
12
- - โšก **Zero TensorFlow for Compilation**: The offline compiler uses optimized pure JS algorithms - no TensorFlow installation required.
13
- - ๐Ÿงต **Multi-threaded Engine**: Truly parallel processing using Node.js `worker_threads` for bulk image compilation.
14
- - ๐Ÿš€ **Serverless Ready**: Lightweight compiler with minimal dependencies, perfect for Vercel, AWS Lambda, and Netlify.
15
- - ๐Ÿ“ฆ **Protocol V3 (Columnar Binary)**: Industry-leading performance with zero-copy loading and 80%+ smaller files.
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
- ## ๐Ÿ–ผ๏ธ High-Performance Compiler (Protocol V3)
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
- ### โšก Industry-Leading Benchmarks
36
-
37
- | Metric | Official MindAR | TapTapp AR (v3) | Improvement |
29
+ | Metric | Official MindAR | TapTapp AR | Improvement |
38
30
  | :--- | :--- | :--- | :--- |
39
- | **Compilation Time** | ~23.50s | **~1.71s** | ๐Ÿš€ **13.7x Faster** |
31
+ | **Compilation Time** | ~23.50s | **~0.89s** | ๐Ÿš€ **26x Faster** |
40
32
  | **Output Size (.mind)** | ~770 KB | **~127 KB** | ๐Ÿ“‰ **83.5% Smaller** |
41
- | **Loading Latency** | >100ms | **2.6ms** | โšก **Zero-Copy** |
42
- | **Memory Footprint** | Heavy (JSON Objects) | **Minimal (Binary)** | ๐Ÿง  **CPU-Aligned** |
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
- ### ๐Ÿš€ Key Technical Breakthroughs
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
- ### ๐Ÿ–ฅ๏ธ Usage (Node.js & Serverless)
38
+ ## ๐Ÿ–ผ๏ธ Compiler Usage (Node.js & Web)
54
39
 
55
- Optimized for server-side compilation with multi-core parallelism:
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
- const compiledData = await compiler.compileImageTargets(
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 Protocol V3 binary format
69
- const binaryBuffer = compiler.exportData(); // Yields a much smaller .mind file
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
- ### ๐ŸŒ Frontend (Zero-Latency Loading)
76
+ ### 2. High-Performance Three.js Wrapper
77
+ For custom Three.js applications:
73
78
 
74
79
  ```javascript
75
- import { OfflineCompiler } from '@srsergio/taptapp-ar';
80
+ import { MindARThree } from '@srsergio/taptapp-ar';
76
81
 
77
- const compiler = new OfflineCompiler();
78
- // Loading 127KB instead of 800KB saves bandwidth and CPU parsing time
79
- compiler.importData(binaryBuffer);
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
- ## ๐Ÿ— Development
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
- ```bash
87
- # Install dependencies
88
- npm install
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
- # Build the package
91
- npm run build
154
+ if (targetIndex !== -1) {
155
+ // Found a match! Use modelViewTransform for initial pose estimation
156
+ }
92
157
  ```
93
158
 
94
- The package uses **TypeScript** and exports both ESM and CJS compatible builds located in the `dist` folder.
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
- ## ๐Ÿ“„ License
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srsergio/taptapp-ar",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "AR Compiler for Node.js and Browser",
5
5
  "repository": {
6
6
  "type": "git",