1 """Shared memory example of the PST SDK 3 This example shows how to activate the shared memory communication pipeline 4 that enables communication of the PST Client application through the PST SDK. 5 Note that for the shared memory pipeline to function, the application has to 6 run with elevated access (administrator rights). After enabling shared memory, 7 the PST Client application can be used to download calibration information and 8 manage tracking targets. 10 Copyright PS-Tech B.V. All Rights Reserved. 19 """Helper function to register the exit handler with the application""" 20 def register_exit_handler():
21 if sys.platform.startswith(
"linux"):
23 signal.signal(signal.SIGTERM, exit_handler)
24 signal.signal(signal.SIGHUP, exit_handler)
25 signal.signal(signal.SIGQUIT, exit_handler)
26 signal.signal(signal.SIGINT, exit_handler)
27 elif sys.platform.startswith(
"win"):
29 win32api.SetConsoleCtrlHandler(exit_handler,
True)
31 """Implement the exit handler to shut-down the PST Tracker connection on application termination.""" 32 def exit_handler(*args):
33 pst.Tracker.disable_shared_memory()
34 pst.Tracker.shutdown()
36 """Check if user is an admin.""" 38 if sys.platform.startswith(
"win"):
40 return ctypes.windll.shell32.IsUserAnAdmin()
43 elif sys.platform.startswith(
"linux"):
48 if(len(sys.argv) < 2):
49 print(
"\nConfiguration Error: A camera configuration file needs to be specified. This file can be found in the Redist folder of your installation. " 50 "See the documentation of the Python bindings for more information.")
54 register_exit_handler()
59 with pst.Tracker(
"",
"",
"", sys.argv[1])
as tracker:
64 tracker.enable_shared_memory()
66 print(
"Shared memory server initialized. Start the PST Client application to create a connection.\n")
73 tracker.disable_shared_memory()
74 except psterrors.TrackerError
as err:
79 ctypes.windll.shell32.ShellExecuteW(
None,
"runas", sys.executable,
" ".join(sys.argv),
None, 1)
81 if __name__ ==
"__main__":