@srsergio/taptapp-ar 1.0.2 → 1.0.4
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 +47 -45
- 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.d.ts +4 -4
- package/dist/compiler/controller.js +4 -5
- package/dist/compiler/controller.worker.js +0 -2
- package/dist/compiler/detector/crop-detector.d.ts +12 -12
- 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.d.ts +20 -21
- package/dist/compiler/detector/detector.js +236 -243
- package/dist/compiler/detector/kernels/cpu/binomialFilter.js +0 -1
- package/dist/compiler/detector/kernels/cpu/computeExtremaAngles.d.ts +1 -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.d.ts +1 -1
- 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.d.ts +4 -5
- 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.d.ts +0 -1
- package/dist/compiler/tensorflow-setup.js +27 -1
- package/dist/compiler/three.d.ts +7 -12
- 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 +9 -17
- 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 +13 -0
- package/dist/compiler/utils/worker-pool.js +84 -0
- package/package.json +12 -14
- 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/dist/compiler/estimation/esimate-experiment.d.ts +0 -5
- package/dist/compiler/estimation/esimate-experiment.js +0 -267
- package/dist/compiler/estimation/refine-estimate-experiment.d.ts +0 -6
- package/dist/compiler/estimation/refine-estimate-experiment.js +0 -429
- package/dist/react/AREditor.d.ts +0 -5
- package/dist/react/AREditor.js +0 -159
- package/dist/react/ProgressDialog.d.ts +0 -13
- package/dist/react/ProgressDialog.js +0 -57
- package/src/compiler/estimation/esimate-experiment.js +0 -316
- package/src/compiler/estimation/refine-estimate-experiment.js +0 -512
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Node.js para compilación de imágenes AR
|
|
3
|
+
*
|
|
4
|
+
* OPTIMIZADO: Sin TensorFlow para evitar bloqueos de inicialización.
|
|
5
|
+
* Usa JavaScript puro para máxima velocidad.
|
|
6
|
+
*/
|
|
7
|
+
import { parentPort } from 'node:worker_threads';
|
|
8
|
+
import { extractTrackingFeatures } from './tracker/extract-utils.js';
|
|
9
|
+
import { buildTrackingImageList, buildImageList } from './image-list.js';
|
|
10
|
+
import { DetectorLite } from './detector/detector-lite.js';
|
|
11
|
+
import { build as hierarchicalClusteringBuild } from './matching/hierarchical-clustering.js';
|
|
12
|
+
if (!parentPort) {
|
|
13
|
+
throw new Error('This file must be run as a worker thread.');
|
|
14
|
+
}
|
|
15
|
+
parentPort.on('message', async (msg) => {
|
|
16
|
+
if (msg.type === 'compile') {
|
|
17
|
+
const { targetImage, percentPerImage, basePercent } = msg;
|
|
18
|
+
try {
|
|
19
|
+
const imageList = buildTrackingImageList(targetImage);
|
|
20
|
+
const percentPerAction = percentPerImage / imageList.length;
|
|
21
|
+
let localPercent = 0;
|
|
22
|
+
const trackingData = extractTrackingFeatures(imageList, (index) => {
|
|
23
|
+
localPercent += percentPerAction;
|
|
24
|
+
parentPort.postMessage({
|
|
25
|
+
type: 'progress',
|
|
26
|
+
percent: basePercent + localPercent
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
parentPort.postMessage({
|
|
30
|
+
type: 'compileDone',
|
|
31
|
+
trackingData
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
parentPort.postMessage({
|
|
36
|
+
type: 'error',
|
|
37
|
+
error: error.message
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else if (msg.type === 'match') {
|
|
42
|
+
const { targetImage, percentPerImage, basePercent } = msg;
|
|
43
|
+
try {
|
|
44
|
+
const imageList = buildImageList(targetImage);
|
|
45
|
+
const percentPerAction = percentPerImage / imageList.length;
|
|
46
|
+
let localPercent = 0;
|
|
47
|
+
const keyframes = [];
|
|
48
|
+
for (let i = 0; i < imageList.length; i++) {
|
|
49
|
+
const image = imageList[i];
|
|
50
|
+
const detector = new DetectorLite(image.width, image.height);
|
|
51
|
+
// Detectar features usando JS puro (sin TensorFlow)
|
|
52
|
+
const { featurePoints: ps } = detector.detect(image.data);
|
|
53
|
+
const maximaPoints = ps.filter((p) => p.maxima);
|
|
54
|
+
const minimaPoints = ps.filter((p) => !p.maxima);
|
|
55
|
+
const maximaPointsCluster = hierarchicalClusteringBuild({ points: maximaPoints });
|
|
56
|
+
const minimaPointsCluster = hierarchicalClusteringBuild({ points: minimaPoints });
|
|
57
|
+
keyframes.push({
|
|
58
|
+
maximaPoints,
|
|
59
|
+
minimaPoints,
|
|
60
|
+
maximaPointsCluster,
|
|
61
|
+
minimaPointsCluster,
|
|
62
|
+
width: image.width,
|
|
63
|
+
height: image.height,
|
|
64
|
+
scale: image.scale,
|
|
65
|
+
});
|
|
66
|
+
localPercent += percentPerAction;
|
|
67
|
+
parentPort.postMessage({
|
|
68
|
+
type: 'progress',
|
|
69
|
+
percent: basePercent + localPercent
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
parentPort.postMessage({
|
|
73
|
+
type: 'matchDone',
|
|
74
|
+
matchingData: keyframes
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
parentPort.postMessage({
|
|
79
|
+
type: 'error',
|
|
80
|
+
error: error.message
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
@@ -1,10 +1,175 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Compilador offline optimizado sin TensorFlow
|
|
3
|
+
*/
|
|
4
|
+
export class OfflineCompiler {
|
|
5
|
+
data: any;
|
|
6
|
+
workerPool: import("./utils/worker-pool.js").WorkerPool | null;
|
|
7
|
+
_initNodeWorkers(): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Compila una lista de imágenes objetivo
|
|
10
|
+
* @param {Array} images - Lista de imágenes {width, height, data}
|
|
11
|
+
* @param {Function} progressCallback - Callback de progreso (0-100)
|
|
12
|
+
* @returns {Promise<Array>} Datos compilados
|
|
13
|
+
*/
|
|
14
|
+
compileImageTargets(images: any[], progressCallback: Function): Promise<any[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Compila datos de matching usando DetectorLite (JS puro)
|
|
17
|
+
*/
|
|
18
|
+
_compileMatch(targetImages: any, progressCallback: any): Promise<{
|
|
19
|
+
maximaPoints: any[];
|
|
20
|
+
minimaPoints: any[];
|
|
21
|
+
maximaPointsCluster: {
|
|
22
|
+
rootNode: {
|
|
23
|
+
centerPointIndex: any;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
minimaPointsCluster: {
|
|
27
|
+
rootNode: {
|
|
28
|
+
centerPointIndex: any;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
width: any;
|
|
32
|
+
height: any;
|
|
33
|
+
scale: any;
|
|
34
|
+
}[][]>;
|
|
35
|
+
/**
|
|
36
|
+
* Compila datos de tracking usando extractTrackingFeatures (JS puro)
|
|
37
|
+
*/
|
|
38
|
+
_compileTrack(targetImages: any, progressCallback: any): Promise<Object[][]>;
|
|
39
|
+
/**
|
|
40
|
+
* Método público para compilar tracking (compatibilidad con API anterior)
|
|
41
|
+
* @param {Object} options - Opciones de compilación
|
|
42
|
+
* @param {Function} options.progressCallback - Callback de progreso
|
|
43
|
+
* @param {Array} options.targetImages - Lista de imágenes objetivo
|
|
44
|
+
* @param {number} options.basePercent - Porcentaje base
|
|
45
|
+
* @returns {Promise<Array>} Datos de tracking
|
|
46
|
+
*/
|
|
4
47
|
compileTrack({ progressCallback, targetImages, basePercent }: {
|
|
48
|
+
progressCallback: Function;
|
|
49
|
+
targetImages: any[];
|
|
50
|
+
basePercent: number;
|
|
51
|
+
}): Promise<any[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Método público para compilar matching (compatibilidad con API anterior)
|
|
54
|
+
*/
|
|
55
|
+
compileMatch({ progressCallback, targetImages, basePercent }: {
|
|
5
56
|
progressCallback: any;
|
|
6
57
|
targetImages: any;
|
|
7
|
-
basePercent
|
|
8
|
-
}): Promise<
|
|
58
|
+
basePercent?: number | undefined;
|
|
59
|
+
}): Promise<{
|
|
60
|
+
maximaPoints: any[];
|
|
61
|
+
minimaPoints: any[];
|
|
62
|
+
maximaPointsCluster: {
|
|
63
|
+
rootNode: {
|
|
64
|
+
centerPointIndex: any;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
minimaPointsCluster: {
|
|
68
|
+
rootNode: {
|
|
69
|
+
centerPointIndex: any;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
width: any;
|
|
73
|
+
height: any;
|
|
74
|
+
scale: any;
|
|
75
|
+
}[][]>;
|
|
76
|
+
/**
|
|
77
|
+
* Exporta datos compilados en formato binario columnar optimizado
|
|
78
|
+
*/
|
|
79
|
+
exportData(): any;
|
|
80
|
+
_packKeyframe(kf: any): {
|
|
81
|
+
w: any;
|
|
82
|
+
h: any;
|
|
83
|
+
s: any;
|
|
84
|
+
max: {
|
|
85
|
+
x: Float32Array<any>;
|
|
86
|
+
y: Float32Array<any>;
|
|
87
|
+
a: Float32Array<any>;
|
|
88
|
+
d: Uint8Array<ArrayBuffer>;
|
|
89
|
+
t: any[];
|
|
90
|
+
};
|
|
91
|
+
min: {
|
|
92
|
+
x: Float32Array<any>;
|
|
93
|
+
y: Float32Array<any>;
|
|
94
|
+
a: Float32Array<any>;
|
|
95
|
+
d: Uint8Array<ArrayBuffer>;
|
|
96
|
+
t: any[];
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
_columnarize(points: any, tree: any): {
|
|
100
|
+
x: Float32Array<any>;
|
|
101
|
+
y: Float32Array<any>;
|
|
102
|
+
a: Float32Array<any>;
|
|
103
|
+
d: Uint8Array<ArrayBuffer>;
|
|
104
|
+
t: any[];
|
|
105
|
+
};
|
|
106
|
+
_compactTree(node: any): any[];
|
|
107
|
+
/**
|
|
108
|
+
* Importa datos - Mantiene el formato columnar para máximo rendimiento (Zero-copy)
|
|
109
|
+
*/
|
|
110
|
+
importData(buffer: any): any;
|
|
111
|
+
_unpackKeyframe(kf: any): {
|
|
112
|
+
width: any;
|
|
113
|
+
height: any;
|
|
114
|
+
scale: any;
|
|
115
|
+
maximaPoints: {
|
|
116
|
+
x: any;
|
|
117
|
+
y: any;
|
|
118
|
+
angle: any;
|
|
119
|
+
descriptors: any;
|
|
120
|
+
}[];
|
|
121
|
+
minimaPoints: {
|
|
122
|
+
x: any;
|
|
123
|
+
y: any;
|
|
124
|
+
angle: any;
|
|
125
|
+
descriptors: any;
|
|
126
|
+
}[];
|
|
127
|
+
maximaPointsCluster: {
|
|
128
|
+
rootNode: {
|
|
129
|
+
leaf: boolean;
|
|
130
|
+
centerPointIndex: any;
|
|
131
|
+
pointIndexes: any;
|
|
132
|
+
children?: undefined;
|
|
133
|
+
} | {
|
|
134
|
+
leaf: boolean;
|
|
135
|
+
centerPointIndex: any;
|
|
136
|
+
children: any;
|
|
137
|
+
pointIndexes?: undefined;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
minimaPointsCluster: {
|
|
141
|
+
rootNode: {
|
|
142
|
+
leaf: boolean;
|
|
143
|
+
centerPointIndex: any;
|
|
144
|
+
pointIndexes: any;
|
|
145
|
+
children?: undefined;
|
|
146
|
+
} | {
|
|
147
|
+
leaf: boolean;
|
|
148
|
+
centerPointIndex: any;
|
|
149
|
+
children: any;
|
|
150
|
+
pointIndexes?: undefined;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
_decolumnarize(col: any): {
|
|
155
|
+
x: any;
|
|
156
|
+
y: any;
|
|
157
|
+
angle: any;
|
|
158
|
+
descriptors: any;
|
|
159
|
+
}[];
|
|
160
|
+
_expandTree(node: any): {
|
|
161
|
+
leaf: boolean;
|
|
162
|
+
centerPointIndex: any;
|
|
163
|
+
pointIndexes: any;
|
|
164
|
+
children?: undefined;
|
|
165
|
+
} | {
|
|
166
|
+
leaf: boolean;
|
|
167
|
+
centerPointIndex: any;
|
|
168
|
+
children: any;
|
|
169
|
+
pointIndexes?: undefined;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Destruye el pool de workers
|
|
173
|
+
*/
|
|
174
|
+
destroy(): Promise<void>;
|
|
9
175
|
}
|
|
10
|
-
import { CompilerBase } from "./compiler-base.js";
|