Skip to content

Monolook Image API

Import

js
import { MonolookImage } from 'monolook/image'

Constructor

js
const tracker = new MonolookImage({
  licenseKey: '<IMAGE_LICENSE_KEY>'
})

Options

OptionTypeRequiredDefault
licenseKeystringYes-
useFlannMatcherbooleanNofalse
videoElementHTMLVideoElementNonull
cameraConstraintsMediaStreamConstraintsNoRear camera, 640x480 ideal

Methods

MethodReturnsDescription
init()Promise<void>Validates license and loads WASM
start()Promise<void>Opens camera and starts tracking
stop()voidStops tracking and camera
addTarget(id, image)Promise<boolean>Adds target
removeTarget(id)voidRemoves target
clearTargets()voidRemoves all targets
isTracking(id)booleanWhether a target is active
getTrackedTargets()string[]Currently detected targets
setActiveTargets(targetIds)voidActivates only selected targets
setMatcherType(useFlann)voidChanges matcher
getVideo()HTMLVideoElement | nullCamera video
getVideoCanvas()HTMLCanvasElement | nullVideo canvas
createVideoBackground(container?)HTMLCanvasElementInserts video background
getCameraDimensions(){ width, height } | nullCamera dimensions
getFOV()numberFOV for adapters
on(event, callback)() => voidSubscribes to event
off(event, callback)voidUnsubscribes event
destroy()voidFull cleanup

Events

EventPayload
foundstring
loststring
pose{ targetId, position, forward, up, rotationMatrix }
frame{ time }
errorError

Adapters

AdapterImport
Three.jsimport { ThreeAdapter } from 'monolook/image/three'
A-Frameimport { AFrameAdapter } from 'monolook/image/aframe'
Babylon.jsimport { BabylonAdapter } from 'monolook/image/babylon'