Skip to content

MiniTrackAR

Main class of the Image Tracking tracker.

Constructor

javascript
const tracker = new MiniTrackAR({
  licenseKey: 'YOUR_LICENSE_KEY',  // Required
  useFlannMatcher: false,          // Optional - use FLANN instead of BFMatcher
  cameraConstraints: { ... }       // Optional - custom camera constraints
})
ParameterTypeRequiredDescription
licenseKeystringYesYour Monolook license key
useFlannMatcherbooleanNoUse FLANN matcher (default: false)
cameraConstraintsobjectNoMediaTrackConstraints for the camera

Methods

Initialization

async init()

Initializes the WASM module and validates the license against the Monolook server.

javascript
await tracker.init()

Possible errors:

  • "Monolook license key required"
  • "License validation failed: License expired"
  • "License validation failed: Domain not allowed"
  • "Build version 0001PR is not authorized"

Target management

async addTarget(id, imageElement)

Adds an image as a tracking target.

javascript
const img = new Image()
img.src = './marker.jpg'
await new Promise(r => { img.onload = r })
await tracker.addTarget('myMarker', img)
ParameterTypeDescription
idstringUnique identifier for the target
imageElementHTMLImageElementMarker image

removeTarget(id)

Removes a target and frees its data.

javascript
tracker.removeTarget('myMarker')

clearTargets()

Removes all targets.

javascript
tracker.clearTargets()

setActiveTargets(targetIds)

Sets which targets are active for detection. Inactive targets remain in memory but are not searched for. See Selective Tracking.

javascript
tracker.setActiveTargets(['marker1', 'marker3'])
ParameterTypeDescription
targetIdsstring[]IDs of targets to activate

State

isTracking(id)

Checks if a specific target is being tracked.

javascript
if (tracker.isTracking('myMarker')) {
  // The marker is visible
}

getTrackedTargets()

Returns the list of IDs of currently tracked targets.

javascript
const active = tracker.getTrackedTargets()
// ['marker1', 'marker3']

Control

async start()

Activates the camera and begins tracking.

javascript
await tracker.start()

stop()

Stops tracking.

javascript
tracker.stop()

setMatcherType(useFlann)

Switches between BFMatcher and FLANN at runtime.

javascript
tracker.setMatcherType(true)  // Use FLANN
tracker.setMatcherType(false) // Use BFMatcher

destroy()

Stops tracking, releases all resources, and cleans up the WASM.

javascript
tracker.destroy()

Events

on(event, callback)

Subscribes to an event. Returns a function to unsubscribe.

javascript
const unsub = tracker.on('found', (id) => {
  console.log('Found:', id)
})

// Unsubscribe
unsub()

off(event, callback)

Unsubscribes from an event.

javascript
tracker.off('found', myHandler)

Available events

EventCallbackDescription
'found'(id: string)Marker detected
'lost'(id: string)Marker lost
'pose'(pose: object)Pose update
'frame'()Each frame
'error'(error)Error

Pose object

javascript
tracker.on('pose', (pose) => {
  pose.position       // { x, y, z }
  pose.forward         // Direction vector
  pose.up              // Up vector
  pose.rotationMatrix  // Rotation matrix
})