documentation

Visometry.VisionLib.SDK.Core.API.Native.Worker Class Reference

The Worker is a wrapper for an Worker object. The Worker object manages the tracking thread. More...

Inherits IDisposable.

Public Member Functions

 Worker (bool syncWorker=false)
 Constructor of Worker.
 
bool AddCalibratedImageListener (CalibratedImageWrapperCallback listener, IntPtr clientData, VLSDK.ImageFormat format)
 Registers a listener for calibrated image events of a specific format. More...
 
bool AddCameraCalibrationDB (string uri)
 Adds a custom camera calibration database file. More...
 
bool AddDebugImageListener (ImageWrapperCallback listener, IntPtr clientData)
 Registers a listener for debug image events. DebugImageListeners are removed automatically, whenever the tracker gets destroyed. More...
 
bool AddExtrinsicDataListener (ExtrinsicDataWrapperCallback listener, IntPtr clientData)
 Registers a listener for extrinsic data events. More...
 
bool AddImageListener (ImageWrapperCallback listener, IntPtr clientData)
 Registers a listener for image events. More...
 
bool AddIntrinsicDataListener (IntrinsicDataWrapperCallback listener, IntPtr clientData)
 Registers a listener for intrinsic data events. More...
 
bool AddPerformanceInfoListener (StringCallback listener, IntPtr clientData)
 Registers a listener for performance information events. More...
 
bool AddTrackingStateListener (StringCallback listener, IntPtr clientData)
 Registers a listener for tracking state events. More...
 
bool AddWorldFromAnchorTransformListener (string anchorName, SimilarityTransformWrapperCallback listener, IntPtr clientData)
 Registers a listener for anchor to world transform events. More...
 
bool AddWorldFromCameraTransformListener (ExtrinsicDataWrapperCallback listener, IntPtr clientData)
 Registers a listener for world to camera transform events. More...
 
delegate void BoolCallback (bool data, IntPtr clientData)
 
delegate void CalibratedImageWrapperCallback (IntPtr handle, IntPtr clientData)
 
void Dispose ()
 Explicitly releases references to unmanaged resources. More...
 
delegate void ExtrinsicDataWrapperCallback (IntPtr handle, IntPtr clientData)
 
DeviceInfo GetDeviceInfo ()
 Retrieves the device info object from the Worker. More...
 
bool GetDisposed ()
 
Image GetImageSync ()
 Returns a pointer to the camera image. More...
 
LicenseInformation GetLicenseInformation ()
 Retrieves the license information object. More...
 
ExtrinsicData GetNodeExtrinsicDataSync (string node, string key)
 
Image GetNodeImageSync (string node, string key)
 
IntrinsicData GetNodeIntrinsicDataSync (string node, string key)
 
SimilarityTransform GetNodeSimilarityTransformSync (string node, string key)
 
TrackingState GetNodeTrackingStateSync (string node)
 
delegate void ImageWrapperCallback (IntPtr handle, IntPtr clientData)
 
delegate void IntrinsicDataWrapperCallback (IntPtr handle, IntPtr clientData)
 
bool IsRunning ()
 Returns whether the thread is currently running or not. More...
 
delegate void JsonStringAndBinaryCallback ([MarshalAs(UnmanagedType.LPStr)] string error, [MarshalAs(UnmanagedType.LPStr)] string result, IntPtr data, System.UInt32 dataSize, IntPtr clientData)
 
delegate void JsonStringCallback ([MarshalAs(UnmanagedType.LPStr)] string errorJson, [MarshalAs(UnmanagedType.LPStr)] string dataJson, IntPtr clientData)
 
bool LoadPlugin (string pluginName)
 Loads the Plugin with the given name. More...
 
bool PollEvents ()
 Calls the registered listeners for the enqueued events. More...
 
bool ProcessCallbacks ()
 Executes all enqueued callbacks. More...
 
bool PushCommand (WorkerCommands.CommandBase cmd, JsonStringCallback callback, IntPtr clientData)
 Enqueues a command for the tracking thread. More...
 
bool PushCommand (WorkerCommands.JsonAndBinaryCommandBase cmd, JsonStringAndBinaryCallback callback, IntPtr clientData)
 Enqueues a command for the tracking thread using a JSON string and binary data - THIS FUNCTION IS CONSIDERED AS BETA AND MAY BE MATTER OF CHANGE. More...
 
bool RemoveCalibratedImageListener (CalibratedImageWrapperCallback listener, IntPtr clientData, VLSDK.ImageFormat format)
 Unregisters a listener from calibrated image events. More...
 
bool RemoveDebugImageListener (ImageWrapperCallback listener, IntPtr clientData)
 Unregisters a listener from debug image events. More...
 
bool RemoveExtrinsicDataListener (ExtrinsicDataWrapperCallback listener, IntPtr clientData)
 Unregisters a listener from extrinsic data events. More...
 
bool RemoveImageListener (ImageWrapperCallback listener, IntPtr clientData)
 Unregisters a listener from image events. More...
 
bool RemoveIntrinsicDataListener (IntrinsicDataWrapperCallback listener, IntPtr clientData)
 Unregisters a listener from intrinsic data events. More...
 
bool RemovePerformanceInfoListener (StringCallback listener, IntPtr clientData)
 Unregisters a listener from performance info events. More...
 
bool RemoveTrackingStateListener (StringCallback listener, IntPtr clientData)
 Unregisters a listener from tracking state events. More...
 
bool RemoveWorldFromAnchorTransformListener (string anchorName, SimilarityTransformWrapperCallback listener, IntPtr clientData)
 Unregisters a listener from anchor to world transform events. More...
 
bool RemoveWorldFromCameraTransformListener (ExtrinsicDataWrapperCallback listener, IntPtr clientData)
 Unregisters a listener from world to camera transform events. More...
 
bool RunOnceSync ()
 Processes the enqueued commands and the tracking once. More...
 
bool SetLicenseFileData (string licenseFileData)
 Allows to inject the license data from memory More...
 
bool SetLicenseFilePath (string licenseFilePath)
 Sets the path of the license file in the system. More...
 
bool SetNodeExtrinsicDataSync (ExtrinsicData extrinsicData, string node, string key)
 
bool SetNodeImageSync (Image image, string node, string key)
 
bool SetNodeIntrinsicDataSync (IntrinsicData intrinsicData, string node, string key)
 
bool SetNodeSimilarityTransformSync (SimilarityTransform similarityTransform, string node, string key)
 
delegate void SimilarityTransformWrapperCallback (IntPtr handle, IntPtr clientData)
 
bool Start ()
 Starts the tracking thread. More...
 
bool Stop ()
 Stops the tracking thread. More...
 
delegate void StringCallback ([MarshalAs(UnmanagedType.LPStr)] string message, IntPtr clientData)
 
bool WaitEvents (uint timeout)
 Waits for enqueued events and calls the registered listeners. More...
 

Detailed Description

The Worker is a wrapper for an Worker object. The Worker object manages the tracking thread.

Member Function Documentation

◆ AddCalibratedImageListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.AddCalibratedImageListener ( CalibratedImageWrapperCallback  listener,
IntPtr  clientData,
VLSDK.ImageFormat  format 
)
inline

Registers a listener for calibrated image events of a specific format.

Parameters
listenerListener which will be notified during the event processing, if a calibrated image event occurred.
clientDataThe listener function will be called with the given pointer value as argument.
formatThe image format for which the listener is receiving events.
Returns
true, if the listener was registered successfully; false otherwise.
See also
CalibratedImage

◆ AddCameraCalibrationDB()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.AddCameraCalibrationDB ( string  uri)
inline

Adds a custom camera calibration database file.

The calibration database must be added before loading a tracking configuration.

Returns
true, if the camera calibration database URI was added successfully; false otherwise. false will also be returned, if the URI was added already.
Parameters
uriURI to the camera calibration database file

◆ AddDebugImageListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.AddDebugImageListener ( ImageWrapperCallback  listener,
IntPtr  clientData 
)
inline

Registers a listener for debug image events. DebugImageListeners are removed automatically, whenever the tracker gets destroyed.

Parameters
listenerListener which will be notified during the event processing, if an debug image event occurred.
clientDataThe listener function will be called with the given pointer value as parameter.
Returns
true, if the listener was registered successfully; false otherwise.
See also
Image

◆ AddExtrinsicDataListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.AddExtrinsicDataListener ( ExtrinsicDataWrapperCallback  listener,
IntPtr  clientData 
)
inline

Registers a listener for extrinsic data events.

Parameters
listenerListener which will be notified during the event processing, if an extrinsic data event occurred.
clientDataThe listener function will be called with the given pointer value as parameter.
Returns
true, if the listener was registered successfully; false otherwise.
See also
ExtrinsicData

◆ AddImageListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.AddImageListener ( ImageWrapperCallback  listener,
IntPtr  clientData 
)
inline

Registers a listener for image events.

Parameters
listenerListener which will be notified during the event processing, if an image event occurred.
clientDataThe listener function will be called with the given pointer value as parameter.
Returns
true, if the listener was registered successfully; false otherwise.
See also
Image

◆ AddIntrinsicDataListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.AddIntrinsicDataListener ( IntrinsicDataWrapperCallback  listener,
IntPtr  clientData 
)
inline

Registers a listener for intrinsic data events.

Parameters
listenerListener which will be notified during the event processing, if an intrinsic data event occurred.
clientDataThe listener function will be called with the given pointer value as argument.
Returns
true, if the listener was registered successfully; false otherwise.
See also
IntrinsicData

◆ AddPerformanceInfoListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.AddPerformanceInfoListener ( StringCallback  listener,
IntPtr  clientData 
)
inline

Registers a listener for performance information events.

Parameters
listenerListener which will be notified during the event processing, if a performance info state event occurred.
clientDataThe listener function will be called with the given pointer value as parameter.
Returns
true, if the listener was registered successfully; false otherwise.

◆ AddTrackingStateListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.AddTrackingStateListener ( StringCallback  listener,
IntPtr  clientData 
)
inline

Registers a listener for tracking state events.

Parameters
listenerListener which will be notified during the event processing, if an tracking state event occurred.
clientDataThe listener function will be called with the given pointer value as parameter.
Returns
true, if the listener was registered successfully; false otherwise.

◆ AddWorldFromAnchorTransformListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.AddWorldFromAnchorTransformListener ( string  anchorName,
SimilarityTransformWrapperCallback  listener,
IntPtr  clientData 
)
inline

Registers a listener for anchor to world transform events.

Parameters
anchorNameName of the anchor which the listener should be getting the similarity transform from.
listenerListener which will be notified during the event processing, if an similarity transform event occurred.
clientDataThe listener function will be called with the given pointer value as parameter.
Returns
true, if the listener was registered successfully; false otherwise.
See also
SimilarityTransform

◆ AddWorldFromCameraTransformListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.AddWorldFromCameraTransformListener ( ExtrinsicDataWrapperCallback  listener,
IntPtr  clientData 
)
inline

Registers a listener for world to camera transform events.

Parameters
listenerListener which will be notified during the event processing, if an world to camera transform event occurred.
clientDataThe listener function will be called with the given pointer value as parameter.
Returns
true, if the listener was registered successfully; false otherwise.
See also
ExtrinsicData

◆ Dispose()

void Visometry.VisionLib.SDK.Core.API.Native.Worker.Dispose ( )
inline

Explicitly releases references to unmanaged resources.

Call Dispose when you are finished using the Worker. The Dispose method leaves the Worker in an unusable state. After calling Dispose, you must release all references to the Worker so the garbage collector can reclaim the memory that the Worker was occupying.

◆ GetDeviceInfo()

DeviceInfo Visometry.VisionLib.SDK.Core.API.Native.Worker.GetDeviceInfo ( )
inline

Retrieves the device info object from the Worker.

Returns
DeviceInfo, if the device info was acquired successfully; null otherwise.

◆ GetImageSync()

Image Visometry.VisionLib.SDK.Core.API.Native.Worker.GetImageSync ( )
inline

Returns a pointer to the camera image.

This function only works, if the Worker was created as synchronous instance.

NOTICE: This functions is experimental and might get removed in future.

Returns
VLImageWrapper, on success; null, otherwise.

◆ GetLicenseInformation()

LicenseInformation Visometry.VisionLib.SDK.Core.API.Native.Worker.GetLicenseInformation ( )
inline

Retrieves the license information object.

Returns
LicenseInformation, if the license information was acquired successfully; null otherwise.

◆ IsRunning()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.IsRunning ( )
inline

Returns whether the thread is currently running or not.

Returns
true, if the thread is running; false otherwise.

◆ LoadPlugin()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.LoadPlugin ( string  pluginName)
inline

Loads the Plugin with the given name.

Parameters
pluginNameThe name of the plugin to load
Returns
true, on success; false otherwise.

◆ PollEvents()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.PollEvents ( )
inline

Calls the registered listeners for the enqueued events.

Listeners aren't called immediately from the tracking thread in order to avoid synchronization problems. Instead this method should be called regularly from the main thread.

Returns
true, if the events where processed successfully; false otherwise.
See also
AddImageListener, AddExtrinsicDataListener, AddIntrinsicDataListener

◆ ProcessCallbacks()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.ProcessCallbacks ( )
inline

Executes all enqueued callbacks.

Callbacks aren't called immediately from the tracking thread in order to avoid synchronization problems. Instead this method should be called regularly from the main thread.

Returns
true, if the command was enqueue successfully; false otherwise.
See also
PushCommand

◆ PushCommand() [1/2]

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.PushCommand ( WorkerCommands.CommandBase  cmd,
JsonStringCallback  callback,
IntPtr  clientData 
)
inline

Enqueues a command for the tracking thread.

A callback will called once after the processing has finished.

The different commands are defined inside the WorkerCommands namespace.

Parameters
cmdThe command object.
callbackCallback, which will be called inside ProcessCallbacks after the command was processed.
clientDataThe callback function will be called with the given pointer value.
Returns
true, if the command was enqueue successfully; false otherwise.

◆ PushCommand() [2/2]

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.PushCommand ( WorkerCommands.JsonAndBinaryCommandBase  cmd,
JsonStringAndBinaryCallback  callback,
IntPtr  clientData 
)
inline

Enqueues a command for the tracking thread using a JSON string and binary data - THIS FUNCTION IS CONSIDERED AS BETA AND MAY BE MATTER OF CHANGE.

The command gets processed asynchronously by the tracking thread and a callback will called once after the processing has finished. Since the memory is pinned until the callback is called in order to prevent multiple copies, the static FreeBinaryMemory() function should be called from the callback, in order to free allocated memory, which has eventually being passed to the function.

Parameters
cmdA command containing a JSON string describing the binary data, the binary data itself and the size of the binary data.
callbackCallback, which will be called inside ProcessCallbacks after the command was processed.
clientDataThe callback function will be called with the given pointer value.
Returns
true, if the command was enqueue successfully; false otherwise (usually some JSON syntax error).

◆ RemoveCalibratedImageListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.RemoveCalibratedImageListener ( CalibratedImageWrapperCallback  listener,
IntPtr  clientData,
VLSDK.ImageFormat  format 
)
inline

Unregisters a listener from calibrated image events.

Parameters
listenerListener which should be unregistered.
clientDataPointer value used as parameter during the registration of the listener.
formatThe image format for which the listener has been registered.
Returns
true, if the listener was unregistered successfully; false otherwise.
See also
CalibratedImage

◆ RemoveDebugImageListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.RemoveDebugImageListener ( ImageWrapperCallback  listener,
IntPtr  clientData 
)
inline

Unregisters a listener from debug image events.

Parameters
listenerListener which should be unregistered.
clientDataPointer value used as parameter during the registration of the listener.
Returns
true, if the listener was unregistered successfully; false otherwise.
See also
Image

◆ RemoveExtrinsicDataListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.RemoveExtrinsicDataListener ( ExtrinsicDataWrapperCallback  listener,
IntPtr  clientData 
)
inline

Unregisters a listener from extrinsic data events.

Parameters
listenerListener which should be unregistered.
clientDataPointer value used as parameter during the registration of the listener.
Returns
true, if the listener was unregistered successfully; false otherwise.
See also
Image

◆ RemoveImageListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.RemoveImageListener ( ImageWrapperCallback  listener,
IntPtr  clientData 
)
inline

Unregisters a listener from image events.

Parameters
listenerListener which should be unregistered.
clientDataPointer value used as parameter during the registration of the listener.
Returns
true, if the listener was unregistered successfully; false otherwise.
See also
Image

◆ RemoveIntrinsicDataListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.RemoveIntrinsicDataListener ( IntrinsicDataWrapperCallback  listener,
IntPtr  clientData 
)
inline

Unregisters a listener from intrinsic data events.

Parameters
listenerListener which should be unregistered.
clientDataPointer value used as parameter during the registration of the listener.
Returns
true, if the listener was unregistered successfully; false otherwise.
See also
Image

◆ RemovePerformanceInfoListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.RemovePerformanceInfoListener ( StringCallback  listener,
IntPtr  clientData 
)
inline

Unregisters a listener from performance info events.

Parameters
listenerListener which should be unregistered.
clientDataPointer value used as parameter during the registration of the listener.
Returns
true, if the listener was unregistered successfully; false otherwise.
See also
Image

◆ RemoveTrackingStateListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.RemoveTrackingStateListener ( StringCallback  listener,
IntPtr  clientData 
)
inline

Unregisters a listener from tracking state events.

Parameters
listenerListener which should be unregistered.
clientDataPointer value used as parameter during the registration of the listener.
Returns
true, if the listener was unregistered successfully; false otherwise.
See also
Image

◆ RemoveWorldFromAnchorTransformListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.RemoveWorldFromAnchorTransformListener ( string  anchorName,
SimilarityTransformWrapperCallback  listener,
IntPtr  clientData 
)
inline

Unregisters a listener from anchor to world transform events.

Parameters
anchorNameName of the anchor from which the listener should be removed.
listenerListener which should be unregistered.
clientDataPointer value used as parameter during the registration of the listener.
Returns
true, if the listener was unregistered successfully; false otherwise.
See also
SimilarityTransform

◆ RemoveWorldFromCameraTransformListener()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.RemoveWorldFromCameraTransformListener ( ExtrinsicDataWrapperCallback  listener,
IntPtr  clientData 
)
inline

Unregisters a listener from world to camera transform events.

Parameters
listenerListener which should be unregistered.
clientDataPointer value used as parameter during the registration of the listener.
Returns
true, if the listener was unregistered successfully; false otherwise.
See also
ExtrinsicData

◆ RunOnceSync()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.RunOnceSync ( )
inline

Processes the enqueued commands and the tracking once.

This function only works, if the Worker was created as synchronous instance. The target number of FPS will get ignored. After calling this function you should call Worker.ProcessCallbacks and Worker.PollEvents to invoke callbacks and registered listeners.

Returns
true, on success; false otherwise.

◆ SetLicenseFileData()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.SetLicenseFileData ( string  licenseFileData)
inline

Allows to inject the license data from memory

Parameters
dataString with the license data.
Returns
true, on success; false otherwise.

◆ SetLicenseFilePath()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.SetLicenseFilePath ( string  licenseFilePath)
inline

Sets the path of the license file in the system.

Calling of this function is mandatory for starting the tracking configuration.

Parameters
pathThe absolute location of the file.
Returns
true, on success; false otherwise.

◆ Start()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.Start ( )
inline

Starts the tracking thread.

Returns
true, if the thread was started successfully; false otherwise.

◆ Stop()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.Stop ( )
inline

Stops the tracking thread.

Returns
true, if the thread was stopped successfully; false otherwise.

◆ WaitEvents()

bool Visometry.VisionLib.SDK.Core.API.Native.Worker.WaitEvents ( uint  timeout)
inline

Waits for enqueued events and calls the registered listeners.

Listeners aren't called immediately from the tracking thread in order to avoid synchronization problems. Instead this method should be called regularly from the main thread.

Parameters
timeoutNumber of milliseconds before stopping to wait. Under normal circumstances this shouldn't happen, but in case something went wrong, we don't want to wait indefinitely.
Returns
true, on success or false, if there was an error while waiting for events. false is also returned, if the tracking is enabled, but the timeout elapsed without an event arriving.
See also
AddImageListener, AddExtrinsicDataListener, AddIntrinsicDataListener