1"""Minimal example of the PST SDK
2
3This is a bare minimum example showing how to connect to the PST SDK and how to
4register a listener to receive data.
5
6In order to be able to run this example, the PST Tracker has to be initialized first.
7This can be done by starting the PST-Server and the PST-Client application and making
8sure the calibration files have been downloaded and a tracking target is available.
9The tracking target can be the default Reference target or a newly trained or imported
10target. For more information, please see the Initialization section of the PST SDK manual
11or check the PST Manual.
12
13Copyright PS-Tech B.V. All Rights Reserved.
14"""
15import context
16import time
17import sys
20
21"""Implementation of the pst.Listener class to receive tracking data and mode changes."""
22class MyListener(pst.Listener):
23
24 """Implementation of a tracker data callback function
25
26 Implementation of a tracker data callback function. The on_tracker_data
27 function receives the data as soon as it becomes available.
28
29 Args:
30 tracker_data: Object containing tracking information retrieved from tracker
31 status_message: Status message reported by the tracker.
32
33 See Also:
34 pstech.pstdk.trackerdata.TrackerData
35 pstech.pstsdk.errors.EStatusMessage
36 """
37 def on_tracker_data(self, tracker_data, status_message):
38
39 pass
40
41def main():
42 if(len(sys.argv) < 2):
43 print("\nConfiguration Error: A camera configuration file needs to be specified. This file can be found in the Redist folder of your installation. "
44 "See the documentation of the Python bindings for more information.")
45 exit(0)
46
47 try:
48
49
50 with pst.Tracker("", "","", sys.argv[1]) as tracker:
51
52
53 listener = MyListener()
54
55
56 tracker.add_tracker_listener(listener)
57
58
59 tracker.start()
60
61
62 time.sleep(10)
63 except psterrors.TrackerError as err:
64
65 print(err.message)
66
67if __name__ == "__main__":
68 main()
Module containing all error related classes and functions.
Definition errors.py:1
Module containing all tracker related classes and functions.
Definition tracker.py:1