documentation

 
Loading...
Searching...
No Matches
Visometry.VisionLib.SDK.Core.TrackingManager Class Referenceabstract

The base class for all types of TrackingManager. More...

Inherits MonoBehaviour, Visometry.VisionLib.SDK.Core.IParameterHandler, and Visometry.VisionLib.SDK.Core.Details.ISceneValidationCheck.

Inherited by Visometry.VisionLib.SDK.Core.AsynchronousTrackingManager, and Visometry.VisionLib.SDK.Core.SynchronousTrackingManager.

Data Structures

class  WorkerNotFoundException
 

Public Types

enum  ImageStream
 

Public Member Functions

bool ActiveInBackend ()
 
bool AddCameraCalibrationDB (string uri)
 Adds the camera calibration DataBase using the URI. It will not be loaded at this point but only the possibility to add it will be checked. The loading of the actual database happens when starting the tracking pipe! More...
 
delegate void CalibratedImageAction (CalibratedImage calibratedImage)
 Delegate for OnCalibratedImage events. More...
 
delegate void ExtrinsicDataAction (ExtrinsicData extrinsicData)
 Delegate for OnExtrinsicData events. More...
 
DeviceInfo GetDeviceInfo ()
 Returns the device info, when the worker object has been initialized. You can call this function in order to get useful system information before starting the tracking pipe You might use this structure for retrieving the available cameras in the system. More...
 
string GetDeviceType ()
 Returns the type of the loaded device pipeline. Works for tracking configurations loaded from a vl-file or vl-string. More...
 
LicenseInformation GetLicenseInformation ()
 
async Task< T > GetParameterAsync< T > (string parameterName)
 
Texture2D GetStreamTexture (ImageStream streamType)
 
bool GetTrackerInitialized ()
 This variable stores the state of the trackerInitialized variable before it is Disabled. More...
 
TrackerRuntimeParameters GetTrackerRuntimeParameters ()
 
string GetTrackerType ()
 Returns the type of the loaded tracking pipeline. Works for tracking configurations loaded from a vl-file or vl-string. More...
 
bool GetTrackerType (out string trackerType)
 Returns the type of the loaded tracking pipeline. Works for tracking configurations loaded from a vl-file or vl-string. More...
 
bool GetTrackingRunning ()
 
Worker GetWorker ()
 Returns the owned Worker object. More...
 
bool HasWorker ()
 Check if the Worker has already been created. If you depend on the Worker, you can register to the OnWorkerCreated event, if this function returns false. More...
 
delegate void ImageAction (Image image)
 Delegate for OnImage events. More...
 
delegate void IntrinsicDataAction (IntrinsicData intrinsicData)
 Delegate for OnIntrinsicData events. More...
 
delegate void IssueTriggeredAction (Issue issue)
 Delegate for OnIssueTriggered events. More...
 
void PauseTracking ()
 Pause the tracking. More...
 
async Task PauseTrackingAsync ()
 Pause the tracking.
 
delegate void PerformanceInfoAction (PerformanceInfo state)
 Delegate for OnPerformanceInfo events. More...
 
void ResetAnchorTransformListener (string anchorName)
 
void ResetTrackingHard ()
 Reset the tracking and all key frames. More...
 
void ResetTrackingSoft ()
 Reset the tracking. More...
 
void ResumeTracking ()
 Resume the tracking. More...
 
async Task ResumeTrackingAsync ()
 Resume the tracking.
 
void SetFPS (int newFPS)
 Sets the frame rate of the tracking algorithm. This might limit the performance consumed by VisionLib. More...
 
async Task SetFPSAsync (int newFPS)
 Sets target number of frames per second for the tracking thread.
 
void SetImageSourceEnabled (bool newValue)
 
Task< WorkerCommands.CommandWarningsSetParameterAsync (string parameterName, string parameterValue)
 
void SetWaitForEvents (bool wait)
 Set waitForEvents to the given value. More...
 
virtual void StartTracking (string filename)
 Start the tracking using a vl-file. More...
 
void StartTrackingFromString (string trackingConfig, string projectDir, string overrideParameter=null)
 Start the tracking using a tracking configuration as string. More...
 
virtual void StopTracking ()
 Stop the tracking (releases all tracking resources). More...
 
delegate void TrackingStatesAction (TrackingState state)
 Delegate for OnTrackingStates events. More...
 
bool ActiveInBackend ()
 
Task< T > GetParameterAsync< T > (string parameterName)
 
Task< WorkerCommands.CommandWarningsSetParameterAsync (string parameterName, string parameterValue)
 

Static Public Member Functions

static EventWrapper< SimilarityTransformAnchorTransform (string anchorName)
 
static async void CatchCommandErrors (Task task, MonoBehaviour caller=null)
 This function should be used when awaiting a Task created anywhere within the vlUnitySDK. It will await the Task while treating all VisionLib specific errors which might arise from calling a command. Using this function also preserves the call stack, so you will still be able to identify the function which causes the logged error. More...
 
static async void CatchCommandErrors (Task< WorkerCommands.CommandWarnings > task, MonoBehaviour caller=null)
 This function should be used when awaiting a Task created anywhere within the vlUnitySDK. It will await the Task while treating all VisionLib specific errors which might arise from calling a command. Using this function also preserves the call stack, so you will still be able to identify the function which causes the logged error. More...
 
static bool DoesTrackerExistAndIsInitialized ()
 Returns true if the tracker is initialized. If no instance of the tracking manager exists (yet / anymore) this will More...
 
static bool DoesTrackerExistAndIsRunning ()
 Returns true if the tracker is running. If no instance of the tracking manager exists (yet / anymore) this will More...
 
static void EmitEvents (Frame frame)
 
static void InvokeOnTrackerResetHard ()
 
static void InvokeOnTrackerResetSoft ()
 

Data Fields

string calibrationDataBaseURI
 
LicenseFile licenseFile
 Path to the license file.
 
VLSDK.LogLevel logLevel = VLSDK.LogLevel.Warning
 VisionLib log level. More...
 
int targetFPS = 30
 Target number of frames per second for the tracking thread. More...
 
bool waitForEvents = false
 Whether to wait for tracking events. More...
 

Protected Member Functions

virtual void Awake ()
 
void CreateLogger ()
 
abstract void CreateWorker ()
 
virtual void Initialize ()
 
virtual void OnDestroy ()
 
virtual void OnDisable ()
 
virtual void OnEnable ()
 
void PauseTrackingInternal ()
 Pause the tracking. Does not modify the trackingRunning variable. More...
 
abstract void RegisterListeners ()
 
abstract void RegisterTrackerListeners ()
 
async Task ResetTrackingHardAsync ()
 
async Task ResetTrackingSoftAsync ()
 
abstract bool ShouldShowMark ()
 
abstract bool TryAddDebugImageListener ()
 
abstract bool TryRemoveDebugImageListener ()
 
void UnregisterAllAnchorTransformListeners ()
 
abstract void UnregisterListeners ()
 
abstract void UnregisterTrackerListeners ()
 
virtual void Update ()
 
abstract void UpdateAnchorTransformListeners ()
 

Static Protected Member Functions

static void EmitOnCalibratedDepthImageWhenValid (CalibratedImage calibratedImage)
 
static void EmitOnCameraTransform (ExtrinsicData extrinsicData)
 
static void EmitOnDebugImage (Image debugImage)
 
static void EmitOnExtrinsicData (ExtrinsicData extrinsicData)
 
static void EmitOnImage (Image image)
 
static void EmitOnIntrinsicData (IntrinsicData intrinsicData)
 
static void EmitOnPerformanceInfo (PerformanceInfo performanceInfo)
 
static void EmitOnTrackingStatesWhenValid (TrackingState state)
 
static void TriggerIssue (Issue issue)
 
static void TriggerWarnings (WorkerCommands.CommandWarnings warnings, MonoBehaviour caller=null)
 

Protected Attributes

Dictionary< string, IDisposable > anchorTransformListeners
 
bool trackerInitialized = false
 
Worker worker = null
 
object workerLock = new object()
 
bool worldFromCameraTransformListenerRegistered = false
 

Static Protected Attributes

static SingletonObjectReference< TrackingManagerinstance
 

Properties

static TrackingManager Instance [get]
 Get a reference to the TrackingManager in the scene. More...
 
Worker Worker [get]
 Get a reference to the Worker owned by a TrackingManager. More...
 

Events

static CalibratedImageAction OnCalibratedDepthImage
 Event with the current calibrated depth image. This Event will be emitted for each tracking frame.
 
static ExtrinsicDataAction OnCameraTransform
 Event with the current extrinsic data slam. This Event will be emitted for each tracking frame.
 
static ImageAction OnDebugImage
 Event with the current debug image. This Event will be emitted for each tracking frame, if debugLevel is at least 1
 
static ExtrinsicDataAction OnExtrinsicData
 Event with the current extrinsic data. This Event will be emitted for each tracking frame.
 
static ImageAction OnImage
 Event with the current tracking image. This Event will be emitted for each tracking frame.
 
static IntrinsicDataAction OnIntrinsicData
 Event with the current intrinsic data. This Event will be emitted for each tracking frame.
 
static IssueTriggeredAction OnIssueTriggered
 Event which will be emitted if an Issue was triggered
 
static PerformanceInfoAction OnPerformanceInfo
 Event with the current tracking performance. This Event will be emitted for each tracking frame.
 
static VLSDK.VoidDelegate OnTrackerInitialized
 Event which will be emitted after the tracking configuration was loaded.
 
static VLSDK.VoidDelegate OnTrackerInitializing
 Event which will be emitted once after calling the StartTracking function.
 
static VLSDK.VoidDelegate OnTrackerPaused
 Event which will be emitted after the tracking was paused.
 
static VLSDK.VoidDelegate OnTrackerResetHard
 Event which will be emitted after a hard reset was executed.
 
static VLSDK.VoidDelegate OnTrackerResetSoft
 Event which will be emitted after a soft reset was executed.
 
static VLSDK.VoidDelegate OnTrackerRunning
 Event which will be emitted once after the tracking was stopped or paused and is now running again.
 
static VLSDK.VoidDelegate OnTrackerStopped
 Event which will be emitted after the tracking was stopped or the initialization of the tracker has failed.
 
static TrackingStatesAction OnTrackingStates
 Event with the current tracking state of all tracked objects. This Event will be emitted for each tracking frame.
 
static VLSDK.VoidDelegate OnWorkerCreated
 Event which will be emitted once after the worker has been created.
 

Detailed Description

The base class for all types of TrackingManager.

Member Function Documentation

◆ ActiveInBackend()

bool Visometry.VisionLib.SDK.Core.TrackingManager.ActiveInBackend ( )
inline

◆ AddCameraCalibrationDB()

bool Visometry.VisionLib.SDK.Core.TrackingManager.AddCameraCalibrationDB ( string  uri)
inline

Adds the camera calibration DataBase using the URI. It will not be loaded at this point but only the possibility to add it will be checked. The loading of the actual database happens when starting the tracking pipe!

Returns
true, if camera calibration DB was added, false otherwise.
Parameters
uriURI pointing to the camera calibration to be merged.

◆ CalibratedImageAction()

delegate void Visometry.VisionLib.SDK.Core.TrackingManager.CalibratedImageAction ( CalibratedImage  calibratedImage)

Delegate for OnCalibratedImage events.

Parameters
calibratedImageCalibratedImage.

◆ CatchCommandErrors() [1/2]

static async void Visometry.VisionLib.SDK.Core.TrackingManager.CatchCommandErrors ( Task  task,
MonoBehaviour  caller = null 
)
inlinestatic

This function should be used when awaiting a Task created anywhere within the vlUnitySDK. It will await the Task while treating all VisionLib specific errors which might arise from calling a command. Using this function also preserves the call stack, so you will still be able to identify the function which causes the logged error.

Parameters
taskTask which should be awaited.
callerMonoBehaviour which should be referenced, when selecting error message in the log.

◆ CatchCommandErrors() [2/2]

static async void Visometry.VisionLib.SDK.Core.TrackingManager.CatchCommandErrors ( Task< WorkerCommands.CommandWarnings task,
MonoBehaviour  caller = null 
)
inlinestatic

This function should be used when awaiting a Task created anywhere within the vlUnitySDK. It will await the Task while treating all VisionLib specific errors which might arise from calling a command. Using this function also preserves the call stack, so you will still be able to identify the function which causes the logged error.

Parameters
taskTask which should be awaited.
callerMonoBehaviour which should be referenced, when selecting error message in the log.

◆ DoesTrackerExistAndIsInitialized()

static bool Visometry.VisionLib.SDK.Core.TrackingManager.DoesTrackerExistAndIsInitialized ( )
inlinestatic

Returns true if the tracker is initialized. If no instance of the tracking manager exists (yet / anymore) this will

also return false and not throw an exception.

◆ DoesTrackerExistAndIsRunning()

static bool Visometry.VisionLib.SDK.Core.TrackingManager.DoesTrackerExistAndIsRunning ( )
inlinestatic

Returns true if the tracker is running. If no instance of the tracking manager exists (yet / anymore) this will

also return false and not throw an exception.

◆ ExtrinsicDataAction()

delegate void Visometry.VisionLib.SDK.Core.TrackingManager.ExtrinsicDataAction ( ExtrinsicData  extrinsicData)

Delegate for OnExtrinsicData events.

Parameters
extrinsicDataExtrinsicData.

◆ GetDeviceInfo()

DeviceInfo Visometry.VisionLib.SDK.Core.TrackingManager.GetDeviceInfo ( )
inline

Returns the device info, when the worker object has been initialized. You can call this function in order to get useful system information before starting the tracking pipe You might use this structure for retrieving the available cameras in the system.

Returns
The device info object or null.

◆ GetDeviceType()

string Visometry.VisionLib.SDK.Core.TrackingManager.GetDeviceType ( )
inline

Returns the type of the loaded device pipeline. Works for tracking configurations loaded from a vl-file or vl-string.

Returns
loaded device type

◆ GetParameterAsync< T >()

async Task< T > Visometry.VisionLib.SDK.Core.TrackingManager.GetParameterAsync< T > ( string  parameterName)
inline

◆ GetTrackerInitialized()

bool Visometry.VisionLib.SDK.Core.TrackingManager.GetTrackerInitialized ( )
inline

This variable stores the state of the trackerInitialized variable before it is Disabled.

Some MonoBehaviours request the trackerInitialized state in their OnEnable function. If OnEnable is called for several GameObjects, the execution order can not be influenced. This is especially the case when recompiling during play mode. For this reason, we store the trackerInitialized state in this variable and set trackerInitialized to false in OnDisable. In OnEnable, we reset the value of trackerInitialized back to the original value. This way, any MonoBehaviour re-enabled before the TrackingManager will assume the TrackingManager as uninitialized. At the moment, if the scripts are recompiled, TrackingManager will be uninitialized afterwards.

◆ GetTrackerType() [1/2]

string Visometry.VisionLib.SDK.Core.TrackingManager.GetTrackerType ( )
inline

Returns the type of the loaded tracking pipeline. Works for tracking configurations loaded from a vl-file or vl-string.

Returns
loaded tracker type

◆ GetTrackerType() [2/2]

bool Visometry.VisionLib.SDK.Core.TrackingManager.GetTrackerType ( out string  trackerType)
inline

Returns the type of the loaded tracking pipeline. Works for tracking configurations loaded from a vl-file or vl-string.

Parameters
trackerTypeloaded tracker type
Returns
returns true on success; false otherwise.

◆ GetWorker()

Worker Visometry.VisionLib.SDK.Core.TrackingManager.GetWorker ( )
inline

Returns the owned Worker object.

Returns
Worker object or null, if the Worker wasn't initialized yet.

◆ HasWorker()

bool Visometry.VisionLib.SDK.Core.TrackingManager.HasWorker ( )
inline

Check if the Worker has already been created. If you depend on the Worker, you can register to the OnWorkerCreated event, if this function returns false.

Returns
true, if the Worker can be used, false otherwise.

◆ ImageAction()

delegate void Visometry.VisionLib.SDK.Core.TrackingManager.ImageAction ( Image  image)

Delegate for OnImage events.

Parameters
imageAPI.Native.Image.

◆ IntrinsicDataAction()

delegate void Visometry.VisionLib.SDK.Core.TrackingManager.IntrinsicDataAction ( IntrinsicData  intrinsicData)

Delegate for OnIntrinsicData events.

Parameters
intrinsicDataIntrinsicData.

◆ IssueTriggeredAction()

delegate void Visometry.VisionLib.SDK.Core.TrackingManager.IssueTriggeredAction ( Issue  issue)

Delegate for OnIssueTriggered events.

Parameters
issueIssue

◆ PauseTracking()

void Visometry.VisionLib.SDK.Core.TrackingManager.PauseTracking ( )
inline

Pause the tracking.

This function will be performed asynchronously.

◆ PauseTrackingInternal()

void Visometry.VisionLib.SDK.Core.TrackingManager.PauseTrackingInternal ( )
inlineprotected

Pause the tracking. Does not modify the trackingRunning variable.

This function will be performed asynchronously.

◆ PerformanceInfoAction()

delegate void Visometry.VisionLib.SDK.Core.TrackingManager.PerformanceInfoAction ( PerformanceInfo  state)

Delegate for OnPerformanceInfo events.

Parameters
statePerformanceInfo with information about the performance.

◆ ResetTrackingHard()

void Visometry.VisionLib.SDK.Core.TrackingManager.ResetTrackingHard ( )
inline

Reset the tracking and all key frames.

This function will be performed asynchronously.

◆ ResetTrackingSoft()

void Visometry.VisionLib.SDK.Core.TrackingManager.ResetTrackingSoft ( )
inline

Reset the tracking.

This function will be performed asynchronously.

◆ ResumeTracking()

void Visometry.VisionLib.SDK.Core.TrackingManager.ResumeTracking ( )
inline

Resume the tracking.

This function will be performed asynchronously.

◆ SetFPS()

void Visometry.VisionLib.SDK.Core.TrackingManager.SetFPS ( int  newFPS)
inline

Sets the frame rate of the tracking algorithm. This might limit the performance consumed by VisionLib.

This function will be performed asynchronously.

Parameters
newFPSNumber of frames per second

◆ SetParameterAsync()

Task< WorkerCommands.CommandWarnings > Visometry.VisionLib.SDK.Core.TrackingManager.SetParameterAsync ( string  parameterName,
string  parameterValue 
)
inline

◆ SetWaitForEvents()

void Visometry.VisionLib.SDK.Core.TrackingManager.SetWaitForEvents ( bool  wait)
inline

Set waitForEvents to the given value.

See waitForEvents for further information.

◆ StartTracking()

virtual void Visometry.VisionLib.SDK.Core.TrackingManager.StartTracking ( string  filename)
inlinevirtual

Start the tracking using a vl-file.

The type of the tracker will be derived from the vl-file.

Reimplemented in Visometry.VisionLib.SDK.Core.SynchronousTrackingManager.

◆ StartTrackingFromString()

void Visometry.VisionLib.SDK.Core.TrackingManager.StartTrackingFromString ( string  trackingConfig,
string  projectDir,
string  overrideParameter = null 
)
inline

Start the tracking using a tracking configuration as string.

Parameters
trackingConfigTracking configuration as string
projectDirDirectory
overrideParameter

◆ StopTracking()

virtual void Visometry.VisionLib.SDK.Core.TrackingManager.StopTracking ( )
inlinevirtual

Stop the tracking (releases all tracking resources).

Reimplemented in Visometry.VisionLib.SDK.Core.SynchronousTrackingManager.

◆ TrackingStatesAction()

delegate void Visometry.VisionLib.SDK.Core.TrackingManager.TrackingStatesAction ( TrackingState  state)

Delegate for OnTrackingStates events.

Parameters
stateTrackingState with information about the currently tracked objects.

Field Documentation

◆ anchorTransformListeners

Dictionary<string, IDisposable> Visometry.VisionLib.SDK.Core.TrackingManager.anchorTransformListeners
protected
Initial value:
=
new Dictionary<string, IDisposable>()

◆ instance

SingletonObjectReference<TrackingManager> Visometry.VisionLib.SDK.Core.TrackingManager.instance
staticprotected
Initial value:
=
new SingletonObjectReference<TrackingManager>()

◆ logLevel

VLSDK.LogLevel Visometry.VisionLib.SDK.Core.TrackingManager.logLevel = VLSDK.LogLevel.Warning

VisionLib log level.

Available log levels:

  • 0: Mute
  • 1: Fatal
  • 2: Warning
  • 3: Notice
  • 4: Info
  • 5: Debug

Log level N will disable all log messages with a level > N.

◆ targetFPS

int Visometry.VisionLib.SDK.Core.TrackingManager.targetFPS = 30

Target number of frames per second for the tracking thread.

The tracking will run as fast as possible, if the value is zero or less.

Higher values will result in a smoother tracking experience, but the battery will be drained faster.

◆ waitForEvents

bool Visometry.VisionLib.SDK.Core.TrackingManager.waitForEvents = false

Whether to wait for tracking events.

If true, the Update member function will wait until there is at least one tracking event. This will limit the speed of the Unity update cycler to the speed of the tracking, but the tracking will feel more smooth, because the camera image will be shown with less delay.

If false, the speed of the tracking and the Unity update cycle are largely separate. Due to the out of sync update rates, the camera might be shown with a slight delay.

Property Documentation

◆ Instance

TrackingManager Visometry.VisionLib.SDK.Core.TrackingManager.Instance
staticget

Get a reference to the TrackingManager in the scene.

Usage:

var thisScenesTrackingManager = TrackingManager.Instance;

◆ Worker

Worker Visometry.VisionLib.SDK.Core.TrackingManager.Worker
get

Get a reference to the Worker owned by a TrackingManager.

Usage for direct access to the Worker in the current scene via the TrackingManager's static Instance property:

var thisScenesWorker = TrackingManager.Instance.Worker;

Usage for access via a reference to a specific TrackingManager:

var worker = someTrackingManager.Worker;