Monolook Image API
Import
js
import { MonolookImage } from 'monolook/image'Constructor
js
const tracker = new MonolookImage({
licenseKey: '<IMAGE_LICENSE_KEY>'
})Opciones
| Opción | Tipo | Requerido | Default |
|---|---|---|---|
licenseKey | string | Sí | - |
useFlannMatcher | boolean | No | false |
videoElement | HTMLVideoElement | No | null |
cameraConstraints | MediaStreamConstraints | No | Cámara trasera 640x480 ideal |
Métodos
| Método | Devuelve | Descripción |
|---|---|---|
init() | Promise<void> | Valida licencia y carga WASM |
start() | Promise<void> | Abre cámara y empieza tracking |
stop() | void | Detiene tracking y cámara |
addTarget(id, image) | Promise<boolean> | Añade target |
removeTarget(id) | void | Elimina target |
clearTargets() | void | Elimina todos los targets |
isTracking(id) | boolean | Indica si un target está activo |
getTrackedTargets() | string[] | Targets detectados actualmente |
setActiveTargets(targetIds) | void | Activa solo ciertos targets |
setMatcherType(useFlann) | void | Cambia matcher |
getVideo() | HTMLVideoElement | null | Vídeo de cámara |
getVideoCanvas() | HTMLCanvasElement | null | Canvas de vídeo |
createVideoBackground(container?) | HTMLCanvasElement | Inserta fondo de vídeo |
getCameraDimensions() | { width, height } | null | Dimensiones de cámara |
getFOV() | number | FOV para adapters |
on(event, callback) | () => void | Suscribe evento |
off(event, callback) | void | Desuscribe evento |
destroy() | void | Limpieza completa |
Eventos
| Evento | Payload |
|---|---|
found | string |
lost | string |
pose | { targetId, position, forward, up, rotationMatrix } |
frame | { time } |
error | Error |
Adapters
| Adapter | Import |
|---|---|
| Three.js | import { ThreeAdapter } from 'monolook/image/three' |
| A-Frame | import { AFrameAdapter } from 'monolook/image/aframe' |
| Babylon.js | import { BabylonAdapter } from 'monolook/image/babylon' |