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 a tracker callback function 26 Implementation of a tracker callback function. The callback_function 27 receives the data as soon as it becomes available. 30 tracker_data: Object containing tracking information retrieved from tracker 31 status_message: Status message reported by the tracker. 34 pstech.pstdk.trackerdata.TrackerData 35 pstech.pstsdk.errors.EStatusMessage 37 def callback_function(tracker_data, status_message):
41 if samples >= max_samples:
47 """Helper function to register the exit handler with the application""" 48 def register_exit_handler():
49 if sys.platform.startswith(
"linux"):
51 signal.signal(signal.SIGTERM, exit_handler)
52 signal.signal(signal.SIGHUP, exit_handler)
53 signal.signal(signal.SIGQUIT, exit_handler)
54 signal.signal(signal.SIGINT, exit_handler)
55 elif sys.platform.startswith(
"win"):
57 win32api.SetConsoleCtrlHandler(exit_handler,
True)
60 """Implement the exit handler to shut-down the PST Tracker connection on application termination.""" 61 def exit_handler(*args):
63 pst.Tracker.shutdown()
68 if(len(sys.argv) < 2):
69 print(
"\nConfiguration Error: A camera configuration file needs to be specified. This file can be found in the Redist folder of your installation. " 70 "See the documentation of the Python bindings for more information.")
74 register_exit_handler()
79 with pst.Tracker(
"",
"",
"", sys.argv[1])
as tracker:
82 print(
"Running PST Server version " + tracker.get_version_info())
85 tracker.add_tracker_listener(callback_function)
91 print(
"System check: " + str(tracker.system_check()))
92 print(
"***************************\n")
95 tracker.set_framerate(30)
99 print(
"Frame rate set to: " + str(tracker.get_framerate()) +
" Hz\n")
102 min, max = tracker.get_exposure_range()
103 print(
"Exposure range: " + str(min) +
" s - " + str(max) +
" s")
104 print(
"Set Exposure to " + str(max))
105 tracker.set_exposure(max)
106 print(
"Check new exposure: " + str(tracker.get_exposure()) +
" s")
107 print(
"***************************\n")
112 print(
"Set frame rate to 60 Hz")
113 tracker.set_framerate(60)
114 print(
"Frame rate set to: " + str(tracker.get_framerate()) +
" Hz\n")
115 print(
"Check exposure: " + str(tracker.get_exposure()) +
" s")
118 min, max = tracker.get_exposure_range()
119 print(
"New exposure range: " + str(min) +
" s - " + str(max) +
" s")
120 print(
"***************************\n")
123 exposure_half = min + (max - min) / 2.0
124 print(
"Set exposure half way: " + str(exposure_half) +
" s")
125 tracker.set_exposure(exposure_half)
126 print(
"Check new exposure: " + str(tracker.get_exposure()) +
" s")
127 print(
"***************************\n")
132 except psterrors.TrackerError
as err:
136 if __name__ ==
"__main__":