1 """Exposure example of the PST SDK 3 This example shows how to adjust exposure settings using the PST SDK. It shows how to 4 change exposure settings based on frame rate and the available exposure range for a 5 certain PST Tracker at a certain frame rate. 7 Copyright PS-Tech B.V. All Rights Reserved. 24 """Implementation of the pst.Listener class to receive tracking data.""" 25 class MyListener(pst.Listener):
27 """Implementation of a tracker data callback function 29 Implementation of a tracker data callback function. The on_tracker_data 30 function receives the data as soon as it becomes available. 33 tracker_data: Object containing tracking information retrieved from tracker 34 status_message: Status message reported by the tracker. 37 pstech.pstdk.trackerdata.TrackerData 38 pstech.pstsdk.errors.EStatusMessage 40 def on_tracker_data(self, tracker_data, status_message):
44 if samples >= max_samples:
50 """Helper function to register the exit handler with the application""" 51 def register_exit_handler():
52 if sys.platform.startswith(
"linux"):
54 signal.signal(signal.SIGTERM, exit_handler)
55 signal.signal(signal.SIGHUP, exit_handler)
56 signal.signal(signal.SIGQUIT, exit_handler)
57 signal.signal(signal.SIGINT, exit_handler)
58 elif sys.platform.startswith(
"win"):
60 win32api.SetConsoleCtrlHandler(exit_handler,
True)
63 """Implement the exit handler to shut-down the PST Tracker connection on application termination.""" 64 def exit_handler(*args):
66 pst.Tracker.shutdown()
71 if(len(sys.argv) < 2):
72 print(
"\nConfiguration Error: A camera configuration file needs to be specified. This file can be found in the Redist folder of your installation. " 73 "See the documentation of the Python bindings for more information.")
77 register_exit_handler()
82 with pst.Tracker(
"",
"",
"", sys.argv[1])
as tracker:
85 print(
"Running PST Server version " + tracker.get_version_info())
88 listener = MyListener()
91 tracker.add_tracker_listener(listener)
97 print(
"System check: " + str(tracker.system_check()))
98 print(
"***************************\n")
101 tracker.set_framerate(30)
105 print(
"Frame rate set to: " + str(tracker.get_framerate()) +
" Hz\n")
108 min, max = tracker.get_exposure_range()
109 print(
"Exposure range: " + str(min) +
" s - " + str(max) +
" s")
110 print(
"Set Exposure to " + str(max))
111 tracker.set_exposure(max)
112 print(
"Check new exposure: " + str(tracker.get_exposure()) +
" s")
113 print(
"***************************\n")
118 print(
"Set frame rate to 60 Hz")
119 tracker.set_framerate(60)
120 print(
"Frame rate set to: " + str(tracker.get_framerate()) +
" Hz\n")
121 print(
"Check exposure: " + str(tracker.get_exposure()) +
" s")
124 min, max = tracker.get_exposure_range()
125 print(
"New exposure range: " + str(min) +
" s - " + str(max) +
" s")
126 print(
"***************************\n")
129 exposure_half = min + (max - min) / 2.0
130 print(
"Set exposure half way: " + str(exposure_half) +
" s")
131 tracker.set_exposure(exposure_half)
132 print(
"Check new exposure: " + str(tracker.get_exposure()) +
" s")
133 print(
"***************************\n")
138 except psterrors.TrackerError
as err:
142 if __name__ ==
"__main__":