@srsergio/taptapp-ar 1.0.0 → 1.0.3

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 (88) hide show
  1. package/README.md +102 -26
  2. package/dist/compiler/aframe.js +0 -3
  3. package/dist/compiler/compiler-base.d.ts +3 -7
  4. package/dist/compiler/compiler-base.js +28 -14
  5. package/dist/compiler/compiler.js +1 -1
  6. package/dist/compiler/compiler.worker.js +1 -1
  7. package/dist/compiler/controller.js +4 -5
  8. package/dist/compiler/controller.worker.js +0 -2
  9. package/dist/compiler/detector/crop-detector.js +0 -2
  10. package/dist/compiler/detector/detector-lite.d.ts +73 -0
  11. package/dist/compiler/detector/detector-lite.js +430 -0
  12. package/dist/compiler/detector/detector.js +236 -243
  13. package/dist/compiler/detector/kernels/cpu/binomialFilter.js +0 -1
  14. package/dist/compiler/detector/kernels/cpu/computeLocalization.js +0 -4
  15. package/dist/compiler/detector/kernels/cpu/computeOrientationHistograms.js +0 -18
  16. package/dist/compiler/detector/kernels/cpu/fakeShader.js +1 -1
  17. package/dist/compiler/detector/kernels/cpu/prune.d.ts +7 -1
  18. package/dist/compiler/detector/kernels/cpu/prune.js +1 -42
  19. package/dist/compiler/detector/kernels/webgl/upsampleBilinear.js +2 -2
  20. package/dist/compiler/estimation/refine-estimate.js +0 -1
  21. package/dist/compiler/estimation/utils.d.ts +1 -1
  22. package/dist/compiler/estimation/utils.js +1 -14
  23. package/dist/compiler/image-list.js +4 -4
  24. package/dist/compiler/input-loader.js +2 -2
  25. package/dist/compiler/matching/hamming-distance.js +13 -13
  26. package/dist/compiler/matching/hierarchical-clustering.js +1 -1
  27. package/dist/compiler/matching/matching.d.ts +20 -4
  28. package/dist/compiler/matching/matching.js +67 -41
  29. package/dist/compiler/matching/ransacHomography.js +1 -2
  30. package/dist/compiler/node-worker.d.ts +1 -0
  31. package/dist/compiler/node-worker.js +84 -0
  32. package/dist/compiler/offline-compiler.d.ts +171 -6
  33. package/dist/compiler/offline-compiler.js +303 -421
  34. package/dist/compiler/tensorflow-setup.js +27 -1
  35. package/dist/compiler/three.js +3 -5
  36. package/dist/compiler/tracker/extract.d.ts +1 -0
  37. package/dist/compiler/tracker/extract.js +200 -244
  38. package/dist/compiler/tracker/tracker.d.ts +1 -1
  39. package/dist/compiler/tracker/tracker.js +13 -18
  40. package/dist/compiler/utils/cumsum.d.ts +4 -2
  41. package/dist/compiler/utils/cumsum.js +17 -19
  42. package/dist/compiler/utils/gpu-compute.d.ts +57 -0
  43. package/dist/compiler/utils/gpu-compute.js +262 -0
  44. package/dist/compiler/utils/images.d.ts +4 -4
  45. package/dist/compiler/utils/images.js +67 -53
  46. package/dist/compiler/utils/worker-pool.d.ts +14 -0
  47. package/dist/compiler/utils/worker-pool.js +84 -0
  48. package/dist/index.d.ts +0 -2
  49. package/dist/index.js +0 -2
  50. package/package.json +19 -13
  51. package/src/compiler/aframe.js +2 -4
  52. package/src/compiler/compiler-base.js +29 -14
  53. package/src/compiler/compiler.js +1 -1
  54. package/src/compiler/compiler.worker.js +1 -1
  55. package/src/compiler/controller.js +4 -5
  56. package/src/compiler/controller.worker.js +0 -2
  57. package/src/compiler/detector/crop-detector.js +0 -2
  58. package/src/compiler/detector/detector-lite.js +494 -0
  59. package/src/compiler/detector/detector.js +1052 -1063
  60. package/src/compiler/detector/kernels/cpu/binomialFilter.js +0 -1
  61. package/src/compiler/detector/kernels/cpu/computeLocalization.js +0 -4
  62. package/src/compiler/detector/kernels/cpu/computeOrientationHistograms.js +0 -17
  63. package/src/compiler/detector/kernels/cpu/fakeShader.js +1 -1
  64. package/src/compiler/detector/kernels/cpu/prune.js +1 -37
  65. package/src/compiler/detector/kernels/webgl/upsampleBilinear.js +2 -2
  66. package/src/compiler/estimation/refine-estimate.js +0 -1
  67. package/src/compiler/estimation/utils.js +9 -24
  68. package/src/compiler/image-list.js +4 -4
  69. package/src/compiler/input-loader.js +2 -2
  70. package/src/compiler/matching/hamming-distance.js +11 -15
  71. package/src/compiler/matching/hierarchical-clustering.js +1 -1
  72. package/src/compiler/matching/matching.js +72 -42
  73. package/src/compiler/matching/ransacHomography.js +0 -2
  74. package/src/compiler/node-worker.js +93 -0
  75. package/src/compiler/offline-compiler.js +339 -504
  76. package/src/compiler/tensorflow-setup.js +29 -1
  77. package/src/compiler/three.js +3 -5
  78. package/src/compiler/tracker/extract.js +211 -267
  79. package/src/compiler/tracker/tracker.js +13 -22
  80. package/src/compiler/utils/cumsum.js +17 -19
  81. package/src/compiler/utils/gpu-compute.js +303 -0
  82. package/src/compiler/utils/images.js +84 -53
  83. package/src/compiler/utils/worker-pool.js +89 -0
  84. package/src/index.ts +0 -2
  85. package/src/compiler/estimation/esimate-experiment.js +0 -316
  86. package/src/compiler/estimation/refine-estimate-experiment.js +0 -512
  87. package/src/react/AREditor.tsx +0 -394
  88. package/src/react/ProgressDialog.tsx +0 -185
@@ -8,6 +8,24 @@ import "@tensorflow/tfjs-backend-webgl";
8
8
  import "./detector/kernels/cpu/index.js";
9
9
  import "./detector/kernels/webgl/index.js";
10
10
 
11
+ /**
12
+ * Intenta cargar el backend de Node.js si está disponible
13
+ */
14
+ const loadNodeBackend = async () => {
15
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
16
+ try {
17
+ // Usar import dinámico para evitar errores en el navegador
18
+ await import("@tensorflow/tfjs-node");
19
+ console.log("🚀 TensorFlow Node.js backend cargado correctamente");
20
+ return true;
21
+ } catch (e) {
22
+ console.warn("⚠️ No se pudo cargar @tensorflow/tfjs-node, usando fallback");
23
+ return false;
24
+ }
25
+ }
26
+ return false;
27
+ };
28
+
11
29
  /**
12
30
  * Configuración optimizada de TensorFlow para diferentes entornos
13
31
  * @returns {Promise<string>} El backend activo ('webgl', 'cpu')
@@ -16,6 +34,9 @@ export async function setupTensorFlow() {
16
34
  console.log("🔧 Iniciando configuración optimizada de TensorFlow.js...");
17
35
 
18
36
  try {
37
+ // Intentar cargar backend de Node.js primero
38
+ const nodeBackendLoaded = await loadNodeBackend();
39
+
19
40
  // Optimizaciones base para todos los backends
20
41
  tf.ENV.set("DEBUG", false);
21
42
  tf.ENV.set("WEBGL_CPU_FORWARD", false);
@@ -23,9 +44,16 @@ export async function setupTensorFlow() {
23
44
 
24
45
  // Configuración adaptativa de memoria según el entorno
25
46
  const isServerless = typeof window === "undefined";
26
- const memoryThreshold = isServerless ? 1024 * 1024 * 4 : 1024 * 1024 * 8; // 4MB en serverless, 8MB en cliente
47
+ const memoryThreshold = isServerless ? 1024 * 1024 * 4 : 1024 * 1024 * 8;
27
48
  tf.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD", memoryThreshold);
28
49
 
50
+ if (nodeBackendLoaded) {
51
+ await tf.setBackend("tensorflow");
52
+ console.log("🚀 Backend TensorFlow (Node.js) activado");
53
+ await tf.ready();
54
+ return "tensorflow";
55
+ }
56
+
29
57
  // Configuración específica para entorno serverless
30
58
  if (isServerless) {
31
59
  try {
@@ -122,7 +122,7 @@ export class MindARThree {
122
122
  }
123
123
 
124
124
  _startVideo() {
125
- return new Promise((resolve, reject) => {
125
+ return new Promise((resolve) => {
126
126
  this.video = document.createElement("video");
127
127
 
128
128
  this.video.setAttribute("autoplay", "");
@@ -176,9 +176,8 @@ export class MindARThree {
176
176
  }
177
177
 
178
178
  _startAR() {
179
- return new Promise(async (resolve, reject) => {
179
+ return new Promise(async (resolve) => {
180
180
  const video = this.video;
181
- const container = this.container;
182
181
 
183
182
  this.controller = new Controller({
184
183
  inputWidth: video.videoWidth,
@@ -268,7 +267,7 @@ export class MindARThree {
268
267
  this.postMatrixs.push(postMatrix);
269
268
  }
270
269
 
271
- await this.controller.dummyRun(this.video);
270
+ this.controller.dummyRun(this.video);
272
271
  this.ui.hideLoading();
273
272
  this.ui.showScanning();
274
273
 
@@ -323,7 +322,6 @@ export class MindARThree {
323
322
  const fov = (2 * Math.atan((1 / proj[5]) * fovAdjust) * 180) / Math.PI; // vertical fov
324
323
  const near = proj[14] / (proj[10] - 1.0);
325
324
  const far = proj[14] / (proj[10] + 1.0);
326
- const ratio = proj[5] / proj[0]; // (r-l) / (t-b)
327
325
 
328
326
  camera.fov = fov;
329
327
  camera.near = near;