Monolook Image API
Import
js
import { MonolookImage } from 'monolook/image'Constructor
js
const tracker = new MonolookImage({
licenseKey: '<IMAGE_LICENSE_KEY>'
})Options
| Option | Type | Required | Default |
|---|---|---|---|
licenseKey | string | Yes | - |
useFlannMatcher | boolean | No | false |
videoElement | HTMLVideoElement | No | null |
cameraConstraints | MediaStreamConstraints | No | Rear camera, 640x480 ideal |
Methods
| Method | Returns | Description |
|---|---|---|
init() | Promise<void> | Validates license and loads WASM |
start() | Promise<void> | Opens camera and starts tracking |
stop() | void | Stops tracking and camera |
addTarget(id, image) | Promise<boolean> | Adds target |
removeTarget(id) | void | Removes target |
clearTargets() | void | Removes all targets |
isTracking(id) | boolean | Whether a target is active |
getTrackedTargets() | string[] | Currently detected targets |
setActiveTargets(targetIds) | void | Activates only selected targets |
setMatcherType(useFlann) | void | Changes matcher |
getVideo() | HTMLVideoElement | null | Camera video |
getVideoCanvas() | HTMLCanvasElement | null | Video canvas |
createVideoBackground(container?) | HTMLCanvasElement | Inserts video background |
getCameraDimensions() | { width, height } | null | Camera dimensions |
getFOV() | number | FOV for adapters |
on(event, callback) | () => void | Subscribes to event |
off(event, callback) | void | Unsubscribes event |
destroy() | void | Full cleanup |
Events
| Event | 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' |