PST SDK
6.0.0.0-272350a
|
Main PST SDK class implementing tracker communication. More...
#include <pstsdk_cpp.h>
Public Member Functions | |
Tracker (const Utils::PstString &path="", const Utils::PstString &config_file="server.cfg", const Utils::PstString &db_file="models.db", const Utils::PstString &grabber_name="default") | |
Tracker constructor. More... | |
~Tracker () | |
void | LoadCalibrationFromLocalPath (const Utils::PstString &path) |
Load calibration information from a given path. More... | |
TrackerData | GetSingleMeasurement () const |
Retrieve the latest TrackerData available from the connected PST Tracker. More... | |
Utils::PstVector< Utils::PstString > | GetConnectedCameraUrls (bool silent=false) const |
Get URLs of the calibration information for the connected PST Tracker. More... | |
Utils::PstVector< Utils::PstString > | GetUncalibratedCameraUrls (bool silent=false) |
Check if cameras of the connected PST Tracker are calibrated. More... | |
Utils::PstString | GetVersionInfo () const |
Get version information of the SDK. More... | |
Utils::PstString | GetConfigPath () const |
Get the path to the current configuration directory. More... | |
void | AddTrackerListener (Listener *listener) |
Add a listener for receiving tracker data and tracking mode updates. More... | |
void | RemoveTrackerListener (Listener *listener) |
Remove a listener for receiving tracker data and tracking mode updates. More... | |
void | Start () |
Start tracking. More... | |
void | Pause () |
Pause tracking. More... | |
StatusMessage | Systemcheck () const |
Check if the tracker is running correctly. More... | |
void | SetFramerate (double fps) |
Set tracker frame rate. More... | |
double | GetFramerate () const |
Get current frame rate. More... | |
Utils::PstVector< float > | GetSupportedFramerates () const |
Get vector of available frame rates. More... | |
void | SetExposure (double time) |
Set the exposure time. More... | |
double | GetExposure () const |
Get the current exposure time. More... | |
void | GetExposureRange (double &min, double &max) const |
Get the allowed exposure range. More... | |
void | EnableFiltering () |
Enable filtering of the tracking results. More... | |
void | DisableFiltering () |
Disable filtering of the tracking results. More... | |
void | SetPositionFilter (double value) |
Set the strength of the position filter. More... | |
void | SetOrientationFilter (double value) |
Set the strength of the orientation filter. More... | |
void | EnableTremorFilter () |
Enable the tremor filter. More... | |
void | DisableTremorFilter () |
Disable the tremor filter. More... | |
void | EnableImageTransfer () |
Enable image transfer from the PST Tracker. More... | |
void | DisableImageTransfer () |
Disable image transfer from the PST Tracker. More... | |
bool | GetImage (Image &image) const |
Retrieve images from the connected PST Tracker. More... | |
TargetStatuses | GetTargetList () const |
Get TargetStatuses object containing all tracking targets and their status. More... | |
Target | GetTargetInfo (const Utils::PstString &name) const |
Get basic tracking target information. More... | |
void | SetTargetStatus (const Utils::PstString &name, bool active) |
Set status of a single tracking Target. More... | |
bool | GetTargetStatus (const Utils::PstString &name) const |
Get status of a single tracking Target. More... | |
MarkerList | GetTargetMarkers (const Utils::PstString &name) const |
Get 3D marker positions of stored tracking Target. More... | |
void | SetTargetId (const Utils::PstString &name, int id) |
Set the id of the tracking target. More... | |
void | SetReference (const Utils::PstArray< float, 16 > &reference, bool relative=false) |
Set the reference system in which tracking results are reported. More... | |
void | SetDefaultReference () |
Reset the reference system to the default reference system. More... | |
Utils::PstArray< float, 16 > | GetReference () const |
Gets the transformation matrix for the current reference system. More... | |
void | ImportJSONModel (const Utils::PstString &json_model) |
Import a tracking target model into the target model database. More... | |
Utils::PstString | ExportJSONModel (const Utils::PstString &model_name) const |
Export a tracking target model as a JSON-formatted string. More... | |
void | RemoveTargetModel (const Utils::PstString &model_name) |
Remove a tracking target model from the target model database. More... | |
Static Public Member Functions | |
static void | Shutdown () |
Shutdown the tracking system, stopping tracking. More... | |
static void | EnableSharedMemory () |
Enable shared memory communication layer. More... | |
static void | DisableSharedMemory () |
Disable shared memory communication layer. More... | |
static void | EnableRestServer (const Utils::PstString &server_address, const Utils::PstString &server_port, int eventStream_retry_timeout_ms=3000) |
Enable a REST Server using the HTTP protocol on a local area network. More... | |
static void | DisableRestServer () |
Disable the REST server communication layer. More... | |
This class implements the main PST SDK functionality. Examples on how to use this class and how to get data from the PST Tracker can be found in the Examples section.
PSTech::pstsdk::Tracker::Tracker | ( | const Utils::PstString & | path = "" , |
const Utils::PstString & | config_file = "server.cfg" , |
||
const Utils::PstString & | db_file = "models.db" , |
||
const Utils::PstString & | grabber_name = "default" |
||
) |
Construct Tracker object and initialize connected PST tracker. Camera calibration information is checked during initialization. When calibration files for the connected tracker can not be found, a message with download links will be printed to the command line.
[in] | path | Path to the configuration directory to be used for storing camera calibrations, target database and configuration files. Use "" for default. (default: "%PROGRAMDATA%\PS-Tech\PST Iris" on Windows or ~/.pstiris on Linux) |
[in] | config_file | Name of the server configuration file. Use "" for default. (default: "server.cfg") |
[in] | db_file | Name of the tracking target database file. Use "" for default. (default: "models.db") |
[in] | grabber_name | Name of the grabber plugin to be used. Can contain absolute or relative path to xml config file. Set to "default" to use auto-detect. (default: "default") |
PSTech::TrackerException | Unable to initialize Tracker |
PSTech::NotInitializedException | Tracker was not initialized correctly |
PSTech::pstsdk::Tracker::~Tracker | ( | ) |
void PSTech::pstsdk::Tracker::AddTrackerListener | ( | Listener * | listener | ) |
Register a listener to receive tracking information and tracking mode updates from the connected PST Tracker. The use of this method requires an implementation of the Listener class to be made.
[in] | listener | A pointer to an implementation of the Listener class to function as a callback. |
void PSTech::pstsdk::Tracker::DisableFiltering | ( | ) |
Switch off filtering of the tracking results using the double exponential-based prediction filter (DESP).
void PSTech::pstsdk::Tracker::DisableImageTransfer | ( | ) |
Disable transferring grayscale image data from the PST Tracker. When using a standard PST Iris or PST Base tracker, the frame rate of the tracker will be restored to the frame rate that was set before enabling image transfer.
|
static |
Disable the REST server communication layer. If a REST server is running, the connections will be closed and the REST server will be destroyed. If no REST server is running a call to Tracker::DisableRestServer() does nothing.
|
static |
Disable the shared memory-based communication layer. The PST-Client application will no longer be able to connect to the PST Tracker.
void PSTech::pstsdk::Tracker::DisableTremorFilter | ( | ) |
Disables the tremor filter. The tremor filter will no longer be used to filter the estimated target pose.
void PSTech::pstsdk::Tracker::EnableFiltering | ( | ) |
Switch on filtering of the tracker results using a double exponential-based prediction filter (DESP). This will result in smoother tracking with less noise. It can have a small impact on tracker accuracy.
void PSTech::pstsdk::Tracker::EnableImageTransfer | ( | ) |
Enable transferring grayscale image data from the PST Tracker. After enabling image transfer, call Tracker::GetImage() in order to receive the captured images. When no calls are made to Tracker::GetImage() for more than 4 seconds, image transfer will be automatically disabled. Note that for the standard PST Iris and standard PST Base trackers, enabling image transfer will result in a reduced framerate of 30 fps. The frame rate will be restored to the original setting after image transfer is disabled.
|
static |
Enable a REST Server that uses the HTTP protocol to enable access to the PST Tracker over a local area network. Parameters from the tracker can be accessed using GET requests. Tracking results and image can be streamed using an Event-stream based communication pipeline. The state of the tracker and parameters can be set through POST calls. If a REST server is aleady running, calling Tracker::EnableRestServer() will terminate the current server and restart it with the new parameters. More information on how to use the REST server can be found in the REST documentation.
[in] | server_address | The IP address on which the REST server should be accessible. |
[in] | server_port | The port number on which the REST server should be accessible. |
[in] | eventStream_retry_timeout_ms | Timeout in milliseconds before an eventstream attempt to reconnect to the server automatically. |
PSTech::NotInitializedException | A Tracker object must have been initialized before enabling the REST server. |
PSTech::HttpException | The REST server failed to initialize properly. A possible cause could be an invalid IP address or port number. |
|
static |
Enable a shared memory-based communication layer. Enabling shared memory will allow the PST-Client application to connect to the SDK. This will allow receiving tracking data and setting parameters using the PST-Client application. Note that a PST-Client that is connected in this way will not be updated when settings are changed through the SDK. This could cause instabilities in the PST software. It is recommended to only use this function when setting up a PST Tracker (e.g. adding tracking targets or retrieving calibration data). When using a tracker in normal operation, it is recommended to choose to use either the PST-Client application or the SDK and not mix usage.
PSTech::NotInitializedException | A Tracker object must have been initialized before enabling shared memory. |
void PSTech::pstsdk::Tracker::EnableTremorFilter | ( | ) |
Enables the tremor filter. This filter greatly reduces the noise levels of the estimated target pose. However, using the filter introduces latency to the tracking results received and lowers tracking accuracy. This filter is mainly useful when using the PST Tracker in an interaction-type setting. When the PST Tracker is used for measurement purposes, enabling the tremor filter is not recommended.
Utils::PstString PSTech::pstsdk::Tracker::ExportJSONModel | ( | const Utils::PstString & | model_name | ) | const |
Export a tracking target model from the target model database as a JSON-formatted string. The string will be formatted according to the specification found in Appendix A of the PST Manual.
[in] | model_name | The name of the target model to be exported. |
PSTech::NotFoundException | The requested model was not found in the database. |
Utils::PstString PSTech::pstsdk::Tracker::GetConfigPath | ( | ) | const |
Retrieves the full path to the configuration directory currently being used by the PST Tracker. The default path is "%PROGRAMDATA%\PS-Tech\PST Iris" on Windows or ~/.pstiris on Linux. The configuration directory contains the target model database, server configuration, reference file and tracker calibration information.
Utils::PstVector<Utils::PstString> PSTech::pstsdk::Tracker::GetConnectedCameraUrls | ( | bool | silent = false | ) | const |
Returns and prints the URLs to download the calibration information for the cameras in the connected PST Tracker.
[in] | silent | Set to true in order to disable printing of calibration information. (default: false) |
double PSTech::pstsdk::Tracker::GetExposure | ( | ) | const |
Get the current exposure time as set on the PST Tracker.
void PSTech::pstsdk::Tracker::GetExposureRange | ( | double & | min, |
double & | max | ||
) | const |
Get the minimum and maximum exposure value that can be set with the current frame rate. The maximum exposure value differs for different frame rates and PST Trackers. In general, lower frame rates allow for higher exposures and higher frame rates have a lower maximum exposure value. After changing the frame rate it is advised to check the currently allowed range before changing exposure values.
[out] | min | The minimum exposure value that can be set. |
[out] | max | The maximum exposure value that can be set. |
double PSTech::pstsdk::Tracker::GetFramerate | ( | ) | const |
Get the current frame rate as set on the PST Tracker.
bool PSTech::pstsdk::Tracker::GetImage | ( | Image & | image | ) | const |
Retrieve images from the PST Tracker when image transfer has been enabled. When image transfer has not been enabled by calling Tracker::EnableImageTransfer() before calling this method, Image.image will be an empty vector. Note that image transfer will be disabled automatically when no call to this method is made for 4 seconds.
[out] | image | The image information retrieved from the PST Tracker. |
Utils::PstArray<float, 16> PSTech::pstsdk::Tracker::GetReference | ( | ) | const |
Tracking results are reported relative to a predefined right-handed Cartesian coordinate system, called the reference system. The default reference system is located at 1 meter from the PST Tracker. It is oriented such that the Z-axis points away from the PST tracker and the X-axis is parallel to the PST tracker. The transformation matrix defining the reference system is a row-major 4x4 homogeneous transformation matrix.
TrackerData PSTech::pstsdk::Tracker::GetSingleMeasurement | ( | ) | const |
Retrieve the latest TrackerData available from the connected PST Tracker. If this function is called before the tracking system is started with Tracker::Start(), the resulting TrackerData object will be empty.
Utils::PstVector<float> PSTech::pstsdk::Tracker::GetSupportedFramerates | ( | ) | const |
Get a vector containing all frame rates that are available for the currently connected PST Tracker. The range of available frame rates differs for different types of PST Trackers. When using Tracker::SetFramerate() to set a new frame rate, the frame rate of the PST Tracker will be set to the value provided by this function nearest to the value supplied to Tracker::SetFramerate().
Target PSTech::pstsdk::Tracker::GetTargetInfo | ( | const Utils::PstString & | name | ) | const |
Retrieves the name, uuid and id for the requested tracking target.
[in] | name | The name of the tracking target. |
PSTech::NotFoundException | Target name could not be found. |
TargetStatuses PSTech::pstsdk::Tracker::GetTargetList | ( | ) | const |
Retrieves the list of all tracking targets defined in the tracking target database and returns them as a TargetStatuses object.
MarkerList PSTech::pstsdk::Tracker::GetTargetMarkers | ( | const Utils::PstString & | name | ) | const |
Gets a list of the 3D positions of the markers making up the specified tracking Target. The returned positions are relative to the tracking Target origin.
[in] | name | Name of the tracking Target to get the marker positions of. |
PSTech::NotFoundException | Target name could not be found. |
bool PSTech::pstsdk::Tracker::GetTargetStatus | ( | const Utils::PstString & | name | ) | const |
Retrieves the status of a single tracking Target. Tracking targets can be either active (true) or inactive (false).
[in] | name | The name of the tracking Target to get the status of. |
PSTech::NotFoundException | Target name could not be found. |
Utils::PstVector<Utils::PstString> PSTech::pstsdk::Tracker::GetUncalibratedCameraUrls | ( | bool | silent = false | ) |
Check for calibration information of the cameras of the connected PST Tracker. When not all calibration information can be retrieved, download urls for the uncalibrated cameras will be returned. Furthermore, a message will be shown at the command line specifying which files are missing and where they can be downloaded.
[in] | silent | Set to true in order to disable printing of missing calibration information. (default: false) |
Utils::PstString PSTech::pstsdk::Tracker::GetVersionInfo | ( | ) | const |
Retrieves version information of the PST Server used by the SDK. This version can differ from the SDK version retrieved using GetSdkVersion().
void PSTech::pstsdk::Tracker::ImportJSONModel | ( | const Utils::PstString & | json_model | ) |
Import a JSON-formatted string representing a tracking target model into the target model database. The JSON string should be formatted according to the instructions found in Appendix A of the PST Manual. After successfully importing the model it can be tracked by the PST Tracker.
[in] | json_model | A JSON-formatted string representing the tracking target model. |
PSTech::InvalidDataException | Data provided did not match the requirements. |
PSTech::AlreadyExistsException | The request could not be executed because a model with the same name already exists in the database. |
PSTech::JSONException | The JSON string could not be parsed correctly. |
void PSTech::pstsdk::Tracker::LoadCalibrationFromLocalPath | ( | const Utils::PstString & | path | ) |
Load the calibration information for each of the cameras in the connected PST Tracker from the specified local path. This function will overwrite any calibration information for the currently connected trackers available in the current configuration folder. Calibration information will only be loaded and placed in the configuration folder when calibration information is found and valid for all connected cameras.
[in] | path | Path to the local directory where the calibration information for all connected cameras is stored. |
PSTech::NotFoundException | Not all the required files could be found in the specified location. |
PSTech::InvalidDataException | Calibration file contains invalid data. |
void PSTech::pstsdk::Tracker::Pause | ( | ) |
Pause the tracking system, stop producing tracking results and enter low-power mode. Tracking can be resumed with a subsequent call to Tracker::Start().
void PSTech::pstsdk::Tracker::RemoveTargetModel | ( | const Utils::PstString & | model_name | ) |
Remove a tracking target model from the target model database.
[in] | model_name | The name of the tracking target model to be removed. |
PSTech::NotFoundException | The tracking target model to be removed was not found in the target model database. |
void PSTech::pstsdk::Tracker::RemoveTrackerListener | ( | Listener * | listener | ) |
Remove a listener receiving tracking information and tracking mode updates from the connected PST Tracker.
[in] | listener | A pointer to an implementation of the Listener class which has previously been added using Tracker::AddTrackerListener(). |
void PSTech::pstsdk::Tracker::SetDefaultReference | ( | ) |
Resets the currently set reference system to the default reference system. The default system is defined by a 4x4 identity matrix. This places the origin of the reference system 1 meter away from the PST Tracker. It is oriented such that the Z-axis points away from the PST tracker and the X-axis is parallel to the PST tracker.
void PSTech::pstsdk::Tracker::SetExposure | ( | double | time | ) |
Set the PST Tracker exposure time to the supplied time. This adjusts both the shutter speed of the PST Tracker and the time the IR illumination panel will be turned on.
[in] | time | Exposure time in seconds. |
PSTech::OutOfRangeException | The value supplied is not within the allowed range. |
PSTech::NotSupportedException | Exposure could not be set on the Tracker. |
void PSTech::pstsdk::Tracker::SetFramerate | ( | double | fps | ) |
Set the PST Tracker frame rate to the value available for the connected PST Tracker nearest to the supplied value.
[in] | fps | The new frame rate to be set. |
PSTech::NotSupportedException | Supplied frame rate could not be set on the Tracker. |
void PSTech::pstsdk::Tracker::SetOrientationFilter | ( | double | value | ) |
Set the strength of the double exponential-based prediction filter (DESP) that filters the estimated orientation of the tracked tracking targets. The supplied filtering value should be between 0 (no filtering) and 0.99 (maximum filtering).
[in] | value | Filtering strength to be used in range [0, 0.99] |
void PSTech::pstsdk::Tracker::SetPositionFilter | ( | double | value | ) |
Set the strength of the double exponential-based prediction filter (DESP) that filters the estimated positions of the tracked tracking targets. The supplied filtering value should be between 0 (no filtering) and 0.99 (maximum filtering).
[in] | value | Filtering strength to be used in range [0, 0.99] |
void PSTech::pstsdk::Tracker::SetReference | ( | const Utils::PstArray< float, 16 > & | reference, |
bool | relative = false |
||
) |
Sets the reference system relative to which tracking results are reported. The reference system is defined by a homogeneous transformation matrix (a row-major 4x4 matrix) representing a right-handed Cartesian coordinate system. The function checks if the rotation component of the supplied transformation matrix is orthonormal and if the supplied transformation matrix is homogeneous (i.e. the final row of the matrix is [0 0 0 1]). If either one of these conditions is not true, a PSTech::TrackerException is thrown. As an optional parameter, the reference system can be set relative to the current reference system. When this option is used, the current reference system is transformed using the supplied transformation matrix. Otherwise, the current reference system is replaced by the supplied reference system.
[in] | reference | The transformation matrix for the new reference system. |
[in] | relative | When set to true, the current transformation matrix is transformed using the supplied transformation matrix. |
PSTech::TrackerException | The supplied reference matrix is either non-homogeneous or the rotation component is non-orthonormal. |
void PSTech::pstsdk::Tracker::SetTargetId | ( | const Utils::PstString & | name, |
int | id | ||
) |
This function changes the id of the tracking target. This id is mainly used when connecting to the PST Tracker through VRPN.
[in] | name | The name of the tracking target to change the id of. |
[in] | id | The new id of the tracking target. |
PSTech::NotFoundException | Target name could not be found. |
void PSTech::pstsdk::Tracker::SetTargetStatus | ( | const Utils::PstString & | name, |
bool | active | ||
) |
Sets the status of a single tracking Target to active (true) or inactive (false).
[in] | name | The name of the tracking Target to set the status of. |
[in] | active | New status of the tracking Target. |
PSTech::NotFoundException | Target name could not be found. |
|
static |
Fully shutdown the tracking system, disconnecting from the PST Tracker and rendering the Tracker object useless. When the shared memory interface or the REST server have been enabled these will be disabled as well. In order to restart the tracker, a new instance of the Tracker class has to be created.
void PSTech::pstsdk::Tracker::Start | ( | ) |
Start the tracking system and produce tracking results.
StatusMessage PSTech::pstsdk::Tracker::Systemcheck | ( | ) | const |
Perform a system check, checking if the PST Tracker has been initialized correctly and if the system is running properly. In order to get continuous feedback on the status of the PST Tracker it is recommended to implement regular polling of this function. This way, issues that will not cause the software to crash (e.g. a camera disconnect) can be handled.