1 """Tracking target example of the PST SDK 3 This example shows how to work with tracking targets using the PST SDK. 4 Note that at this moment tracking targets can not be trained or 5 imported using the PST SDK. In order to add new tracking targets, please 6 use the PST Client together with the pstech.pstsdk.tracker.Tracker.enable_shared_memory() 7 function, or use the stand-alone PST Server to configure the tracking targets. 9 Copyright PS-Tech B.V. All Rights Reserved. 26 """Implementation of a tracker callback function 28 Implementation of a tracker callback function. The callback_function 29 receives the data as soon as it becomes available. 32 tracker_data: Object containing tracking information retrieved from tracker 33 status_message: Status message reported by the tracker. 36 pstech.pstdk.trackerdata.TrackerData 37 pstech.pstsdk.errors.EStatusMessage 39 def callback_function(tracker_data, status_message):
44 if samples >= max_samples:
47 for target_pose
in tracker_data.targetlist:
48 print(
"Detected " + target_pose.name)
52 """Helper function to register the exit handler with the application""" 53 def register_exit_handler():
54 if sys.platform.startswith(
"linux"):
56 signal.signal(signal.SIGTERM, exit_handler)
57 signal.signal(signal.SIGHUP, exit_handler)
58 signal.signal(signal.SIGQUIT, exit_handler)
59 signal.signal(signal.SIGINT, exit_handler)
60 elif sys.platform.startswith(
"win"):
62 win32api.SetConsoleCtrlHandler(exit_handler,
True)
64 """Implement the exit handler to shut-down the PST Tracker connection on application termination.""" 65 def exit_handler(*args):
67 pst.Tracker.shutdown()
72 if(len(sys.argv) < 2):
73 print(
"\nConfiguration Error: A camera configuration file needs to be specified. This file can be found in the Redist folder of your installation. " 74 "See the documentation of the Python bindings for more information.")
78 register_exit_handler()
83 with pst.Tracker(
"",
"",
"", sys.argv[1])
as tracker:
86 print(
"Running PST Server version " + tracker.get_version_info())
89 tracker.add_tracker_listener(callback_function)
91 print(
"Put the Reference card in front of the PST in order to see tracking results.\n")
97 print(
"System check: " + str(tracker.system_check()))
100 targets = tracker.get_target_list()
101 print(
"Found " + str(len(targets)) +
" tracking targets:")
102 for target_status
in targets:
103 print(target_status.name +
"\t" + str(target_status.status))
108 tracker.set_target_status(
"Reference",
True)
112 markers_list = tracker.get_target_markers(
"Reference")
113 print(
"3D marker positions making up the Reference target:")
114 for marker
in markers_list:
115 print(
"x: " + str(marker[0]) +
"\ty: " + str(marker[1]) +
"\tz: " + str(marker[2]))
122 except psterrors.TrackerError
as err:
126 if __name__ ==
"__main__":