Main PST SDK class implementing tracker communication. More...
Public Member Functions | |
| __init__ (self, path="", config_file="", db_file="", grabber_name="") | |
| Tracker constructor. | |
| __enter__ (self) | |
| __del__ (self) | |
| __exit__ (self, ex_type, ex_value, ex_traceback) | |
| load_calibration_from_local_path (self, path) | |
| Load calibration information from a given path. | |
| get_connected_camera_urls (self, silent=False) | |
| Get URLs of the calibration information for the connected PST Tracker. | |
| get_uncalibrated_camera_urls (self, silent=False) | |
| Check if cameras of the connected PST Tracker are calibrated. | |
| get_version_info (self) | |
| Get version information of the SDK. | |
| get_config_path (self) | |
| Get the path to the current configuration directory. | |
| get_single_measurement (self) | |
| Retrieve latest TrackerData available from the connected PST Tracker. | |
| add_tracker_listener (self, Listener listener) | |
| Add a listener for receiving tracker data and tracking mode updates. | |
| remove_tracker_listener (self, Listener listener) | |
| Remove a listener for receiving tracker data and tracking mode updates. | |
| start (self) | |
| Start tracking. | |
| pause (self) | |
| Pause tracking. | |
| system_check (self) | |
| Check if the tracker is running correctly. | |
| set_framerate (self, float framerate) | |
| Set tracker frame rate. | |
| get_framerate (self) | |
| Get current frame rate. | |
| get_supported_framerates (self) | |
| Get vector of available frame rates. | |
| set_exposure (self, exposure) | |
| Set the exposure time. | |
| get_exposure (self) | |
| Get the current exposure time. | |
| get_exposure_range (self) | |
| Get the allowed exposure range. | |
| enable_filtering (self) | |
| Enable filtering of the tracking results. | |
| disable_filtering (self) | |
| Disable filtering of the tracking results. | |
| set_position_filter (self, value) | |
| Set the strength of the position filter. | |
| set_orientation_filter (self, value) | |
| Set the strength of the orientation filter. | |
| enable_tremor_filter (self) | |
| Enable the tremor filter. | |
| disable_tremor_filter (self) | |
| Disable the tremor filter. | |
| enable_image_transfer (self) | |
| Enable image transfer from the PST Tracker. | |
| disable_image_transfer (self) | |
| Disable image transfer from the PST Tracker. | |
| get_image (self) | |
| Retrieve images from the connected PST Tracker. | |
| get_target_list (self) | |
| Get TargetStatuses object containing all tracking targets and their status. | |
| get_target_info (self, name) | |
| Get basic tracking target information. | |
| set_target_status (self, target_name, active) | |
| Set status of a single tracking Target. | |
| get_target_status (self, name) | |
| Get status of a single tracking Target. | |
| get_target_markers (self, target_name) | |
| Get 3D marker positions of stored tracking Target. | |
| set_target_id (self, name, target_id) | |
| Set the id of the tracking target. | |
| set_reference (self, reference, relative=False) | |
| Set the reference system in which tracking results are reported. | |
| set_default_reference (self) | |
| Reset the reference system to the default reference system. | |
| get_reference (self) | |
| Gets the transformation matrix for the current reference system. | |
| get_connected_camera_info (self, silent=True) | |
| Get camera information for connected PST Trackers. | |
| import_json_model (self, json_model) | |
| Import a tracking target model into the target model database. | |
| export_json_model (self, model_name) | |
| Export a tracking target model as a JSON-formatted string. | |
| remove_target_model (self, model_name) | |
| Remove a tracking target model from the target model database. | |
| set_marker_detection_region (self, ETrackingRegion detection_region) | |
| Sets the region of the tracking working space where markers are reported. | |
| get_marker_detection_region (self) | |
| Gets the region of the tracking working space where markers are reported. | |
| supports_detection_region_pruning (self) | |
| Check if the connected PST tracker supports pruning markers by tracking region. | |
Static Public Member Functions | |
| enable_shared_memory () | |
| Enable shared memory communication layer. | |
| disable_shared_memory () | |
| Disable shared memory communication layer. | |
| enable_rest_server (address="localhost", port="7278", event_stream_retry_timeout=3000) | |
| Enable a REST Server using the HTTP protocol on a local area network. | |
| disable_rest_server () | |
| Disable the REST server communication layer. | |
| shutdown () | |
| Shutdown the tracking system, stopping tracking. | |
Protected Attributes | |
| list | _listeners = [] |
| _on_tracker_data_cfunc = None | |
| _on_tracker_mode_cfunc = None | |
| _tracker = Tracker._CTracker() | |
| bool | _is_cleaned_up = False |
Main PST SDK class implementing tracker communication.
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.__init__ | ( | self, | |
| path = "", | |||
| config_file = "", | |||
| db_file = "", | |||
| grabber_name = "" ) |
Tracker constructor.
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.
| 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) |
| config_file | Name of the server configuration file. Use "" for default. (default: "server.cfg") |
| db_file | Name of the tracking target database file. Use "" for default. (default: "models.db") |
| 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") |
| NotInitializedError | Unable to initialize Tracker |
| TrackerError | Tracker was not initialized correctly |
| pstech.pstsdk.tracker.Tracker.__del__ | ( | self | ) |
| pstech.pstsdk.tracker.Tracker.__enter__ | ( | self | ) |
| pstech.pstsdk.tracker.Tracker.__exit__ | ( | self, | |
| ex_type, | |||
| ex_value, | |||
| ex_traceback ) |
| pstech.pstsdk.tracker.Tracker.add_tracker_listener | ( | self, | |
| Listener | listener ) |
Add a listener for receiving tracker data and tracking mode updates.
Register a listener to receive tracking information and tracking modes from the connected PST Tracker. The use of this method requires an implementation of the Listener class to be made.
| listener | Listener object implementing the callback functions to receive tracker data and/or tracker mode updates |
| pstech.pstsdk.tracker.Tracker.disable_filtering | ( | self | ) |
Disable filtering of the tracking results.
Switch off filtering of the tracking results using the double exponential-based prediction filter (DESP).
| pstech.pstsdk.tracker.Tracker.disable_image_transfer | ( | self | ) |
Disable image transfer from the PST Tracker.
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.
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.disable_rest_server() does nothing.
|
static |
Disable shared memory communication layer.
Disable the shared memory-based communication layer. The PST-Client application will no longer be able to connect to the PST Tracker.
| pstech.pstsdk.tracker.Tracker.disable_tremor_filter | ( | self | ) |
Disable the tremor filter.
Disables the tremor filter. The tremor filter will no longer be used to filter the estimated target pose.
| pstech.pstsdk.tracker.Tracker.enable_filtering | ( | self | ) |
Enable filtering of the tracking results.
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.
| pstech.pstsdk.tracker.Tracker.enable_image_transfer | ( | self | ) |
Enable image transfer from the PST Tracker.
Enable transferring grayscale image data from the PST Tracker. After enabling image transfer, call Tracker.get_image() in order to receive the captured images. When no calls are made to Tracker.get_image() 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 using the HTTP protocol on a local area network.
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 already running, calling Tracker.enable_rest_server() 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.
| address | The IP address on which the REST server should be accessible (default: localhost). |
| port | The port number on which the REST server should be accessible (default:7278). |
| event_stream_retry_timeout | Timeout in milliseconds before an eventstream attempt to reconnect to the server automatically (default:3000). |
| HTTPError | The REST server failed to initialize properly. A possible cause could be an invalid IP address or port number. |
| NotInitializedError | A Tracker object must have been initialized before enabling the REST server. |
|
static |
Enable shared memory communication layer.
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.
| NotInitializedError | A Tracker object must have been initialized before enabling shared memory. |
| pstech.pstsdk.tracker.Tracker.enable_tremor_filter | ( | self | ) |
Enable the tremor filter.
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.
| pstech.pstsdk.tracker.Tracker.export_json_model | ( | self, | |
| model_name ) |
Export a tracking target model as a JSON-formatted string.
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.
| model_name | The name of the target model to be exported. |
| NotFoundError | The requested model was not found in the database. |
| pstech.pstsdk.tracker.Tracker.get_config_path | ( | self | ) |
Get the path to the current configuration directory.
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.
| pstech.pstsdk.tracker.Tracker.get_connected_camera_info | ( | self, | |
| silent = True ) |
Get camera information for connected PST Trackers.
This function returns a array containing a CameraInfo entry for each camera in the connected PST Trackers. Each entry provides the unique camera identifier and calibration verification details. For detailed information about the fields and verification process, refer to the documentation of CameraInfo.
| silent | Set to False in order to enable printing of calibration information. (default: True) |
| pstech.pstsdk.tracker.Tracker.get_connected_camera_urls | ( | self, | |
| silent = False ) |
Get URLs of the calibration information for the connected PST Tracker.
Returns and prints the URLs to download the calibration information for the cameras in the connected PST Tracker.
| silent | Set to True in order to disable printing of calibration information. (default: False) |
| pstech.pstsdk.tracker.Tracker.get_exposure | ( | self | ) |
Get the current exposure time.
Get the current exposure time as set on the PST Tracker.
| pstech.pstsdk.tracker.Tracker.get_exposure_range | ( | self | ) |
Get the allowed exposure range.
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.
| pstech.pstsdk.tracker.Tracker.get_framerate | ( | self | ) |
Get current frame rate.
Get the current frame rate as set on the PST Tracker.
| pstech.pstsdk.tracker.Tracker.get_image | ( | self | ) |
Retrieve images from the connected PST Tracker.
Retrieve images from the PST Tracker when image transfer has been enabled. When image transfer has not been enabled by calling Tracker.enable_image_transfer() before calling this method, Image.images will be an empty list. Note that image transfer will be automatically disabled when no call to this method is made for 4 seconds.
| pstech.pstsdk.tracker.Tracker.get_marker_detection_region | ( | self | ) |
Gets the region of the tracking working space where markers are reported.
Gets the region of the tracking working space in which detected markers are currently being reported. Markers can either be in the high-precision ETrackingRegion.OPTIMAL region or in the ETrackingRegion.FULL region where accuracy is not guaranteed.
| pstech.pstsdk.OutOfRangeError | Internal error. |
| pstech.pstsdk.tracker.Tracker.get_reference | ( | self | ) |
Gets the transformation matrix for the current reference system.
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.
| pstech.pstsdk.tracker.Tracker.get_single_measurement | ( | self | ) |
Retrieve latest TrackerData available from the connected PST Tracker.
Retrieve the latest TrackerData available from the PST Tracker. If the PST Tracker has not been started with start(), the TrackerData will be empty.
| pstech.pstsdk.tracker.Tracker.get_supported_framerates | ( | self | ) |
Get vector of available frame rates.
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.set_framerate() 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.set_framerate().
| pstech.pstsdk.tracker.Tracker.get_target_info | ( | self, | |
| name ) |
Get basic tracking target information.
Retrieves the name, uuid and id for the requested tracking target.
| name | The name of the tracking target. |
| NotFoundError | Target name could not be found. |
| pstech.pstsdk.tracker.Tracker.get_target_list | ( | self | ) |
Get TargetStatuses object containing all tracking targets and their status.
Retrieves the list of all tracking targets defined in the tracking target database and returns them as a list of TargetStatus objects.
| pstech.pstsdk.tracker.Tracker.get_target_markers | ( | self, | |
| target_name ) |
Get 3D marker positions of stored tracking Target.
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.
| target_name | Name of the tracking Target to get the marker positions of. |
| NotFoundError | Target name could not be found. |
| pstech.pstsdk.tracker.Tracker.get_target_status | ( | self, | |
| name ) |
Get status of a single tracking Target.
Retrieves the status of a single tracking Target. Tracking targets can be either active (true) or inactive (false).
| name | The name of the tracking Target to get the status of. |
| NotFoundError | Target name could not be found. |
| pstech.pstsdk.tracker.Tracker.get_uncalibrated_camera_urls | ( | self, | |
| silent = False ) |
Check if cameras of the connected PST Tracker are calibrated.
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.
| silent | Set to True in order to disable printing of missing calibration information. (default: False) |
| pstech.pstsdk.tracker.Tracker.get_version_info | ( | self | ) |
Get version information of the SDK.
Retrieves version information of the PST Server used by the SDK.
| pstech.pstsdk.tracker.Tracker.import_json_model | ( | self, | |
| json_model ) |
Import a tracking target model into the target model database.
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.
| json_model | A JSON-formatted string representing the tracking target model. |
| InvalidDataError | Data provided did not match the requirements. |
| AlreadyExistsError | The request could not be executed because a model with the same name already exists in the database. |
| JSONError | The JSON string could not be parsed correctly. |
| pstech.pstsdk.tracker.Tracker.load_calibration_from_local_path | ( | self, | |
| path ) |
Load calibration information from a given 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.
| path | Path to the local directory where the calibration information for all connected cameras is stored. |
| NotFoundError | Calibration information not found for one or more of the connected cameras. |
| InvalidDataError | The provided data is not valid. |
| pstech.pstsdk.tracker.Tracker.pause | ( | self | ) |
Pause tracking.
Pause the tracking system, stop producing tracking results and enter low-power mode. Tracking can be resumed with a subsequent call to start().
| pstech.pstsdk.tracker.Tracker.remove_target_model | ( | self, | |
| model_name ) |
Remove a tracking target model from the target model database.
Remove a tracking target model from the target model database.
| model_name | The name of the tracking target model to be removed. |
| NotFoundError | The tracking target model to be removed was not found in the target model database. |
| pstech.pstsdk.tracker.Tracker.remove_tracker_listener | ( | self, | |
| Listener | listener ) |
Remove a listener for receiving tracker data and tracking mode updates.
Remove a listener receiving tracking information and tracking modes from the connected PST Tracker.
| listener | Listener object that was previously added through Tracker.add_tracker_listener(). |
| pstech.pstsdk.tracker.Tracker.set_default_reference | ( | self | ) |
Reset the reference system to the default reference system.
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.
| pstech.pstsdk.tracker.Tracker.set_exposure | ( | self, | |
| exposure ) |
Set the exposure 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.
| exposure | Exposure time in seconds. |
| OutOfRangeError | The value supplied is not within the allowed range. |
| NotSupportedError | Exposure could not be set on the Tracker. |
| pstech.pstsdk.tracker.Tracker.set_framerate | ( | self, | |
| float | framerate ) |
| pstech.pstsdk.tracker.Tracker.set_marker_detection_region | ( | self, | |
| ETrackingRegion | detection_region ) |
Sets the region of the tracking working space where markers are reported.
The tracker will report markers detected in the selected region. When the region is set to ETrackingRegion.FULL, all detected markers are reported. When the region is set to ETrackingRegion.OPTIMAL, only markers detected in the predetermined optimal region of the tracker used are reported. Markers are pruned based on their distance to the tracker as well as how far they are to the edges of the field of view.
| detection_region | The detection region that should be used during tracking. |
| pstech.pstsdk.OutOfRangeError | The supplied detection_region cannot be internally converted. |
| pstech.pstsdk.NotSupportedError | ETrackingRegion.OPTIMAL was requested but the connected PST tracker does not support tracking region based pruning. The detection region has been set to ETrackingRegion.FULL. |
| pstech.pstsdk.tracker.Tracker.set_orientation_filter | ( | self, | |
| value ) |
Set the strength of the orientation filter.
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).
| value | Filtering strength to be used in range [0, 0.99] |
| pstech.pstsdk.tracker.Tracker.set_position_filter | ( | self, | |
| value ) |
Set the strength of the position filter.
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).
| value | Filtering strength to be used in range [0, 0.99] |
| pstech.pstsdk.tracker.Tracker.set_reference | ( | self, | |
| reference, | |||
| relative = False ) |
Set the reference system in which tracking results are reported.
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 TrackerError 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.
| reference | The transformation matrix for the new reference system. |
| relative | When set to true, the current transformation matrix is transformed using the supplied transformation matrix. |
| TrackerError | The supplied reference matrix is either non-homogeneous or the rotation component is non-orthonormal. |
| pstech.pstsdk.tracker.Tracker.set_target_id | ( | self, | |
| name, | |||
| target_id ) |
Set the id of the tracking target.
This function changes the id of the tracking target. This id is mainly used when connecting to the PST Tracker through VRPN.
| name | The name of the tracking target to change the id of. |
| target_id | The new id of the tracking target. |
| NotFoundError | Target name could not be found. |
| pstech.pstsdk.tracker.Tracker.set_target_status | ( | self, | |
| target_name, | |||
| active ) |
|
static |
Shutdown the tracking system, stopping tracking.
Fully shutdown the tracking system, disconnecting from the PST Tracker. 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.
| pstech.pstsdk.tracker.Tracker.start | ( | self | ) |
| pstech.pstsdk.tracker.Tracker.supports_detection_region_pruning | ( | self | ) |
Check if the connected PST tracker supports pruning markers by tracking region.
Determines whether the currently connected PST tracker supports pruning detected markers based on the tracking region in which they are detected. When this function returns True, setting the detection region to ETrackingRegion.OPTIMAL via Tracker.set_marker_detection_region() will prune markers that fall outside the optimal zone.
| pstech.pstsdk.tracker.Tracker.system_check | ( | self | ) |
Check if the tracker is running correctly.
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.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |