@srsergio/taptapp-ar 1.0.61 → 1.0.62

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.
@@ -9,6 +9,7 @@ export class DetectorLite {
9
9
  useGPU: any;
10
10
  useLSH: any;
11
11
  numOctaves: number;
12
+ maxFeaturesPerBucket: any;
12
13
  /**
13
14
  * Detecta características en una imagen en escala de grises
14
15
  * @param {Float32Array|Uint8Array} imageData - Datos de imagen (width * height)
@@ -15,7 +15,6 @@ import { computeLSH64, computeFullFREAK, packLSHIntoDescriptor } from "../utils/
15
15
  const PYRAMID_MIN_SIZE = 4; // Restored to 4 for better small-scale detection
16
16
  // PYRAMID_MAX_OCTAVE ya no es necesario, el límite lo da PYRAMID_MIN_SIZE
17
17
  const NUM_BUCKETS_PER_DIMENSION = 10;
18
- const MAX_FEATURES_PER_BUCKET = 30; // Maximized to ensure robustness in Moonshot mode
19
18
  const ORIENTATION_NUM_BINS = 36;
20
19
  const FREAK_EXPANSION_FACTOR = 7.0;
21
20
  // Global GPU mode flag
@@ -48,6 +47,9 @@ export class DetectorLite {
48
47
  break;
49
48
  }
50
49
  this.numOctaves = options.maxOctaves !== undefined ? Math.min(numOctaves, options.maxOctaves) : numOctaves;
50
+ // 🚀 SMART BITRATE (VBR): Internal logic to decide feature density based on scale
51
+ const scale = options.scale !== undefined ? options.scale : 1.0;
52
+ this.maxFeaturesPerBucket = options.maxFeaturesPerBucket || Math.max(4, Math.floor(12 * Math.sqrt(scale)));
51
53
  }
52
54
  /**
53
55
  * Detecta características en una imagen en escala de grises
@@ -305,7 +307,7 @@ export class DetectorLite {
305
307
  */
306
308
  _applyPrune(extremas) {
307
309
  const nBuckets = NUM_BUCKETS_PER_DIMENSION;
308
- const nFeatures = MAX_FEATURES_PER_BUCKET;
310
+ const nFeatures = this.maxFeaturesPerBucket;
309
311
  // Agrupar por buckets
310
312
  const buckets = [];
311
313
  for (let i = 0; i < nBuckets * nBuckets; i++) {
@@ -4,7 +4,7 @@ import { resize } from "./utils/images.js";
4
4
  * Un valor más bajo permite detectar imágenes más pequeñas pero aumenta el tiempo de procesamiento
5
5
  * @constant {number}
6
6
  */
7
- const MIN_IMAGE_PIXEL_SIZE = 32;
7
+ const MIN_IMAGE_PIXEL_SIZE = 40; // Increased to 40 to skip extremely small, noisy layers and reduce size
8
8
  /**
9
9
  * Construye una lista de imágenes con diferentes escalas para detección de características
10
10
  * @param {Object} inputImage - Imagen de entrada con propiedades width, height y data
@@ -16,9 +16,8 @@ const buildImageList = (inputImage) => {
16
16
  let c = minScale;
17
17
  while (true) {
18
18
  scaleList.push(c);
19
- // Optimization: Paso balanceado (aprox 1.5)
20
- // Mejor cobertura que 2.0, pero mucho más ligero que 1.41 o 1.26
21
- c *= Math.pow(2.0, 0.6);
19
+ // Optimization: More aggressive step (pow(2, 0.75) approx 1.68) for smaller exports
20
+ c *= Math.pow(2.0, 0.75);
22
21
  if (c >= 0.95) {
23
22
  c = 1;
24
23
  break;
@@ -70,8 +70,12 @@ parentPort.on('message', async (msg) => {
70
70
  const keyframes = [];
71
71
  for (let i = 0; i < imageList.length; i++) {
72
72
  const image = imageList[i];
73
- // Disable internal pyramid (maxOctaves: 1) as we are already processing a scale list
74
- const detector = new DetectorLite(image.width, image.height, { useLSH: true, maxOctaves: 1 });
73
+ // 🚀 SMART BITRATE (VBR): Now handled internally by DetectorLite via 'scale'
74
+ const detector = new DetectorLite(image.width, image.height, {
75
+ useLSH: true,
76
+ maxOctaves: 1,
77
+ scale: image.scale
78
+ });
75
79
  const { featurePoints: ps } = detector.detect(image.data);
76
80
  const sortedPs = sortPoints(ps);
77
81
  const maximaPoints = sortedPs.filter((p) => p.maxima);
@@ -126,8 +126,12 @@ export class OfflineCompiler {
126
126
  const percentPerImageScale = percentPerImage / imageList.length;
127
127
  const keyframes = [];
128
128
  for (const image of imageList) {
129
- // Disabling internal pyramid (maxOctaves: 1) as we are already processing a scale list
130
- const detector = new DetectorLite(image.width, image.height, { useLSH: true, maxOctaves: 1 });
129
+ // 🚀 SMART BITRATE (VBR): Internalized in DetectorLite
130
+ const detector = new DetectorLite(image.width, image.height, {
131
+ useLSH: true,
132
+ maxOctaves: 1,
133
+ scale: image.scale
134
+ });
131
135
  const { featurePoints: ps } = detector.detect(image.data);
132
136
  const maximaPoints = ps.filter((p) => p.maxima);
133
137
  const minimaPoints = ps.filter((p) => !p.maxima);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srsergio/taptapp-ar",
3
- "version": "1.0.61",
3
+ "version": "1.0.62",
4
4
  "author": "Sergio Lazaro <srsergiolazaro@gmail.com>",
5
5
  "license": "GPL-3.0",
6
6
  "description": "Ultra-fast, lightweight Augmented Reality Image Tracking SDK for the web. Features an optimized offline compiler, React components, and compatibility with Three.js/A-Frame. No heavy ML frameworks required.",
@@ -19,7 +19,6 @@ const PYRAMID_MIN_SIZE = 4; // Restored to 4 for better small-scale detection
19
19
 
20
20
 
21
21
  const NUM_BUCKETS_PER_DIMENSION = 10;
22
- const MAX_FEATURES_PER_BUCKET = 30; // Maximized to ensure robustness in Moonshot mode
23
22
 
24
23
 
25
24
  const ORIENTATION_NUM_BINS = 36;
@@ -58,6 +57,10 @@ export class DetectorLite {
58
57
  }
59
58
 
60
59
  this.numOctaves = options.maxOctaves !== undefined ? Math.min(numOctaves, options.maxOctaves) : numOctaves;
60
+
61
+ // 🚀 SMART BITRATE (VBR): Internal logic to decide feature density based on scale
62
+ const scale = options.scale !== undefined ? options.scale : 1.0;
63
+ this.maxFeaturesPerBucket = options.maxFeaturesPerBucket || Math.max(4, Math.floor(12 * Math.sqrt(scale)));
61
64
  }
62
65
 
63
66
  /**
@@ -350,7 +353,7 @@ export class DetectorLite {
350
353
  */
351
354
  _applyPrune(extremas) {
352
355
  const nBuckets = NUM_BUCKETS_PER_DIMENSION;
353
- const nFeatures = MAX_FEATURES_PER_BUCKET;
356
+ const nFeatures = this.maxFeaturesPerBucket;
354
357
 
355
358
  // Agrupar por buckets
356
359
  const buckets = [];
@@ -5,7 +5,7 @@ import { resize } from "./utils/images.js";
5
5
  * Un valor más bajo permite detectar imágenes más pequeñas pero aumenta el tiempo de procesamiento
6
6
  * @constant {number}
7
7
  */
8
- const MIN_IMAGE_PIXEL_SIZE = 32;
8
+ const MIN_IMAGE_PIXEL_SIZE = 40; // Increased to 40 to skip extremely small, noisy layers and reduce size
9
9
 
10
10
 
11
11
 
@@ -21,9 +21,8 @@ const buildImageList = (inputImage) => {
21
21
  let c = minScale;
22
22
  while (true) {
23
23
  scaleList.push(c);
24
- // Optimization: Paso balanceado (aprox 1.5)
25
- // Mejor cobertura que 2.0, pero mucho más ligero que 1.41 o 1.26
26
- c *= Math.pow(2.0, 0.6);
24
+ // Optimization: More aggressive step (pow(2, 0.75) approx 1.68) for smaller exports
25
+ c *= Math.pow(2.0, 0.75);
27
26
  if (c >= 0.95) {
28
27
  c = 1;
29
28
  break;
@@ -78,8 +78,13 @@ parentPort.on('message', async (msg) => {
78
78
 
79
79
  for (let i = 0; i < imageList.length; i++) {
80
80
  const image = imageList[i];
81
- // Disable internal pyramid (maxOctaves: 1) as we are already processing a scale list
82
- const detector = new DetectorLite(image.width, image.height, { useLSH: true, maxOctaves: 1 });
81
+
82
+ // 🚀 SMART BITRATE (VBR): Now handled internally by DetectorLite via 'scale'
83
+ const detector = new DetectorLite(image.width, image.height, {
84
+ useLSH: true,
85
+ maxOctaves: 1,
86
+ scale: image.scale
87
+ });
83
88
  const { featurePoints: ps } = detector.detect(image.data);
84
89
 
85
90
  const sortedPs = sortPoints(ps);
@@ -155,8 +155,12 @@ export class OfflineCompiler {
155
155
  const keyframes = [];
156
156
 
157
157
  for (const image of imageList as any[]) {
158
- // Disabling internal pyramid (maxOctaves: 1) as we are already processing a scale list
159
- const detector = new DetectorLite(image.width, image.height, { useLSH: true, maxOctaves: 1 });
158
+ // 🚀 SMART BITRATE (VBR): Internalized in DetectorLite
159
+ const detector = new DetectorLite(image.width, image.height, {
160
+ useLSH: true,
161
+ maxOctaves: 1,
162
+ scale: image.scale
163
+ });
160
164
  const { featurePoints: ps } = detector.detect(image.data);
161
165
 
162
166
  const maximaPoints = ps.filter((p: any) => p.maxima);