@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.
- package/README.md +102 -26
- package/dist/compiler/aframe.js +0 -3
- package/dist/compiler/compiler-base.d.ts +3 -7
- package/dist/compiler/compiler-base.js +28 -14
- package/dist/compiler/compiler.js +1 -1
- package/dist/compiler/compiler.worker.js +1 -1
- package/dist/compiler/controller.js +4 -5
- package/dist/compiler/controller.worker.js +0 -2
- package/dist/compiler/detector/crop-detector.js +0 -2
- package/dist/compiler/detector/detector-lite.d.ts +73 -0
- package/dist/compiler/detector/detector-lite.js +430 -0
- package/dist/compiler/detector/detector.js +236 -243
- package/dist/compiler/detector/kernels/cpu/binomialFilter.js +0 -1
- package/dist/compiler/detector/kernels/cpu/computeLocalization.js +0 -4
- package/dist/compiler/detector/kernels/cpu/computeOrientationHistograms.js +0 -18
- package/dist/compiler/detector/kernels/cpu/fakeShader.js +1 -1
- package/dist/compiler/detector/kernels/cpu/prune.d.ts +7 -1
- package/dist/compiler/detector/kernels/cpu/prune.js +1 -42
- package/dist/compiler/detector/kernels/webgl/upsampleBilinear.js +2 -2
- package/dist/compiler/estimation/refine-estimate.js +0 -1
- package/dist/compiler/estimation/utils.d.ts +1 -1
- package/dist/compiler/estimation/utils.js +1 -14
- package/dist/compiler/image-list.js +4 -4
- package/dist/compiler/input-loader.js +2 -2
- package/dist/compiler/matching/hamming-distance.js +13 -13
- package/dist/compiler/matching/hierarchical-clustering.js +1 -1
- package/dist/compiler/matching/matching.d.ts +20 -4
- package/dist/compiler/matching/matching.js +67 -41
- package/dist/compiler/matching/ransacHomography.js +1 -2
- package/dist/compiler/node-worker.d.ts +1 -0
- package/dist/compiler/node-worker.js +84 -0
- package/dist/compiler/offline-compiler.d.ts +171 -6
- package/dist/compiler/offline-compiler.js +303 -421
- package/dist/compiler/tensorflow-setup.js +27 -1
- package/dist/compiler/three.js +3 -5
- package/dist/compiler/tracker/extract.d.ts +1 -0
- package/dist/compiler/tracker/extract.js +200 -244
- package/dist/compiler/tracker/tracker.d.ts +1 -1
- package/dist/compiler/tracker/tracker.js +13 -18
- package/dist/compiler/utils/cumsum.d.ts +4 -2
- package/dist/compiler/utils/cumsum.js +17 -19
- package/dist/compiler/utils/gpu-compute.d.ts +57 -0
- package/dist/compiler/utils/gpu-compute.js +262 -0
- package/dist/compiler/utils/images.d.ts +4 -4
- package/dist/compiler/utils/images.js +67 -53
- package/dist/compiler/utils/worker-pool.d.ts +14 -0
- package/dist/compiler/utils/worker-pool.js +84 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/package.json +19 -13
- package/src/compiler/aframe.js +2 -4
- package/src/compiler/compiler-base.js +29 -14
- package/src/compiler/compiler.js +1 -1
- package/src/compiler/compiler.worker.js +1 -1
- package/src/compiler/controller.js +4 -5
- package/src/compiler/controller.worker.js +0 -2
- package/src/compiler/detector/crop-detector.js +0 -2
- package/src/compiler/detector/detector-lite.js +494 -0
- package/src/compiler/detector/detector.js +1052 -1063
- package/src/compiler/detector/kernels/cpu/binomialFilter.js +0 -1
- package/src/compiler/detector/kernels/cpu/computeLocalization.js +0 -4
- package/src/compiler/detector/kernels/cpu/computeOrientationHistograms.js +0 -17
- package/src/compiler/detector/kernels/cpu/fakeShader.js +1 -1
- package/src/compiler/detector/kernels/cpu/prune.js +1 -37
- package/src/compiler/detector/kernels/webgl/upsampleBilinear.js +2 -2
- package/src/compiler/estimation/refine-estimate.js +0 -1
- package/src/compiler/estimation/utils.js +9 -24
- package/src/compiler/image-list.js +4 -4
- package/src/compiler/input-loader.js +2 -2
- package/src/compiler/matching/hamming-distance.js +11 -15
- package/src/compiler/matching/hierarchical-clustering.js +1 -1
- package/src/compiler/matching/matching.js +72 -42
- package/src/compiler/matching/ransacHomography.js +0 -2
- package/src/compiler/node-worker.js +93 -0
- package/src/compiler/offline-compiler.js +339 -504
- package/src/compiler/tensorflow-setup.js +29 -1
- package/src/compiler/three.js +3 -5
- package/src/compiler/tracker/extract.js +211 -267
- package/src/compiler/tracker/tracker.js +13 -22
- package/src/compiler/utils/cumsum.js +17 -19
- package/src/compiler/utils/gpu-compute.js +303 -0
- package/src/compiler/utils/images.js +84 -53
- package/src/compiler/utils/worker-pool.js +89 -0
- package/src/index.ts +0 -2
- package/src/compiler/estimation/esimate-experiment.js +0 -316
- package/src/compiler/estimation/refine-estimate-experiment.js +0 -512
- package/src/react/AREditor.tsx +0 -394
- 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;
|
|
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 {
|
package/src/compiler/three.js
CHANGED
|
@@ -122,7 +122,7 @@ export class MindARThree {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
_startVideo() {
|
|
125
|
-
return new Promise((resolve
|
|
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
|
|
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
|
-
|
|
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;
|