documentation

VisionLib Tracking Events
Level: Intermediate

In Unity, you can listen to several events that are emitted by VisionLib to react to them.
For example, the VLLogEventsBehaviour on the VLNotifications GameObject in the AdvancedModelTracking example scene uses those kind of events and logs them to the screen or the console.

List of available events

Event Parameters

Description

VLWorkerBehaviour.OnTrackerInitializing Event which will be emitted once after calling the StartTracking function.
VLWorkerBehaviour.OnTrackerInitialized bool success Event which will be emitted after the tracking configuration was loaded. Success is true, if the tracking configuration was loaded successfully; false, otherwise.
VLWorkerBehaviour.OnTrackerInitializedWithIssues VLTrackingIssues errors, VLTrackingIssues warnings Event which will be emitted after the tracking configuration was loaded. Holds a "warnings" and "errors" list of VLTrackingIssues.
VLWorkerBehaviour.OnTrackerRunning bool success Event which will be emitted once after the tracking was stopped or paused and is now running again.
VLWorkerBehaviour.OnTrackerRanOnce bool success Event which will be emitted once after the tracking was explicitly ran once.
VLWorkerBehaviour.OnTrackerPaused bool success Event which will be emitted after the tracking was paused.
VLWorkerBehaviour.OnTrackerStopped bool success Event which will be emitted after the tracking was stopped.
VLWorkerBehaviour.OnTrackerResetSoft bool success Event which will be emitted after a soft reset was executed.
VLWorkerBehaviour.OnTrackerResetHard bool success Event which will be emitted after a hard reset was executed.
VLWorkerBehaviour.OnTrackingStates VLTrackingState state Event with the current tracking state of all tracked objects. This event will be emitted for each tracking frame. See also Tracking States in Unity.
VLWorkerBehaviour.OnPerformanceInfo VLPerformanceInfo state Event with the current tracking performance. This Event will be emitted for each tracking frame.
VLWorkerBehaviour.OnImage VLImageWrapper image Event with the current tracking image. This Event will be emitted for each tracking frame.
VLWorkerBehaviour.OnExtrinsicData VLExtrinsicDataWrapper extrinsicData Event with the current extrinsic data. This Event will be emitted for each tracking frame.
VLWorkerBehaviour.OnIntrinsicData VLIntrinsicDataWrapper intrinsicData Event with the current intrinsic data. This Event will be emitted for each tracking frame.
VLModelTrackerBehaviour_v1.OnReadInitData bool success Event which will be emitted after the initialization data has been loaded from an uri. See also Initialization: Fast Init & Re-initialization.
VLModelTrackerBehaviour_v1.OnWriteInitData bool success Event which will be emitted after the initialization data has been written to disk. See also Initialization: Fast Init & Re-initialization.
VLModelTrackerBehaviour_v1.OnResetInitData bool success Event which will be emitted after the initialization data has been reset. See also Initialization: Fast Init & Re-initialization.

Register to events in code

To react to VisionLib events in your own Monobehaviour script, register to them like seen below:

void OnEnable()
{
VLWorkerBehaviour.OnTrackerInitialized += HandleTrackingInitialized;
}
void OnDisable()
{
VLWorkerBehaviour.OnTrackerInitialized -= HandleTrackingInitialized;
}
private void HandleTrackingInitialized(bool success)
{
if (success)
{
// do something
}
}