ObjectTrackingConfig
Object Tracking Configuration
The ObjectTrackingConfig is a singleton object that provides centralized configuration for the MultiSet SDK object tracking behavior. It controls how the ObjectTrackingActivity detects and tracks pre-registered physical objects in AR.
Description
This configuration object allows you to customize object tracking behavior before launching ObjectTrackingActivity. Settings include object code registration, auto-tracking triggers, background tracking intervals, confidence thresholds, and image quality. All settings can be modified at runtime and validated using the validate() method.
Properties
Object Codes
objectCodes
Array<String>
emptyArray()
List of object codes to track. Set before launching ObjectTrackingActivity. Maximum 10 codes. Object codes are assigned when registering objects in the MultiSet platform.
ObjectTrackingConfig.objectCodes = arrayOf("OBJ_001", "OBJ_002")Tracking Behavior
autoTracking
Boolean
true
Whether to automatically start tracking when the AR session begins. If false, the user must tap the capture button manually.
backgroundTracking
Boolean
true
Whether to continue tracking in the background after first success. Keeps the object pose updated over time.
bgTrackingDurationSeconds
Float
15f
Interval between background tracking attempts in seconds. Valid range: 5 – 30 seconds.
restartTracking
Boolean
true
Whether to restart tracking when AR tracking state is lost (PAUSED or STOPPED).
firstTrackingUntilSuccess
Boolean
true
Keep retrying silently until the first tracking attempt succeeds. Failed results will not be reported to onObjectTrackingFailure until at least one success has occurred.
captureDelayMs
Long
1000L
Delay in milliseconds before capturing a frame after a tracking trigger. Allows the device camera to stabilize.
Confidence Settings
confidenceCheck
Boolean
true
Whether to check the confidence threshold before accepting a tracking result. Results below the threshold are discarded and retried.
confidenceThreshold
Float
0.3f
Minimum confidence score required to accept a tracking result. Valid range: 0.2 – 0.8.
UI Settings
showAlerts
Boolean
true
Whether to show toast messages for tracking status (success, failure).
Image Quality Settings
imageQuality
Int
80
JPEG quality for frames sent to the tracking API. Higher quality improves accuracy but increases upload size. Valid range: 50 – 100.
Methods
resetToDefaults()
Resets all settings to their default values.
Declaration:
Description: Calling this method resets all configuration properties to factory defaults. Useful to ensure a clean state before customizing specific settings.
Example:
validate()
Applies validated bounds to all numeric settings.
Declaration:
Description: Clamps all numeric properties to their valid ranges and truncates objectCodes to a maximum of 10 entries. Call this after modifying any settings and before launching ObjectTrackingActivity.
Validation Rules:
bgTrackingDurationSeconds
5 – 30
coerceIn(5f, 30f)
confidenceThreshold
0.2 – 0.8
coerceIn(0.2f, 0.8f)
imageQuality
50 – 100
coerceIn(50, 100)
objectCodes
max 10 entries
first 10 retained
Example:
Configuration Flow
Best Practices
Always call
validate()after modifying settings to ensure values are within valid ranges.Keep
firstTrackingUntilSuccess = truefor the best first-time user experience. The activity will silently retry until a confident result is obtained.Tune
confidenceThresholdbased on your environment:Start with
0.3f(default)Increase to
0.5f – 0.6ffor environments with many similar objectsDecrease toward
0.2ffor difficult lighting conditions
Use
bgTrackingDurationSecondsof 10–20 seconds for most use cases. Lower values give more frequent updates but consume more battery and network.Set
objectCodesfrommultiset.propertiesviaBuildConfigrather than hardcoding them in your app, to keep object codes configurable per environment.Register your objects on the MultiSet platform before using their codes. Unregistered codes will result in tracking failures.
Related
Last updated