|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 |
|
3 |
| -import depthai as dai |
4 | 3 | import time
|
5 | 4 | import argparse
|
6 | 5 |
|
|
10 | 9 | parser.add_argument('-l', '--load-and-exit', default=False, action="store_true")
|
11 | 10 | args = parser.parse_args()
|
12 | 11 |
|
| 12 | +if args.load_and_exit: |
| 13 | + import os |
| 14 | + # Disabling device watchdog, so it doesn't need the host to ping periodically. |
| 15 | + # Note: this is done before importing `depthai` |
| 16 | + os.environ["DEPTHAI_WATCHDOG"] = "0" |
| 17 | + |
| 18 | +import depthai as dai |
| 19 | + |
13 | 20 | def getPipeline():
|
14 | 21 | enable_4k = True # Will downscale 4K -> 1080p
|
15 | 22 |
|
@@ -68,17 +75,14 @@ def flash(pipeline=None):
|
68 | 75 | quit()
|
69 | 76 |
|
70 | 77 | if args.load_and_exit:
|
71 |
| - import os |
72 |
| - # Disabling device watchdog, so it doesn't need the host to ping periodically |
73 |
| - os.environ["DEPTHAI_WATCHDOG"] = "0" |
74 | 78 | device = dai.Device(getPipeline())
|
75 |
| - print("\nDevice started, open a UVC viewer to check the camera stream.") |
76 |
| - print("Attempting to force-quit this process...") |
77 |
| - print("To reconnect with depthai, a device power-cycle may be required") |
78 |
| - # We do not want the device to be closed, so kill the process. |
| 79 | + print("\nDevice started. Attempting to force-terminate this process...") |
| 80 | + print("Open an UVC viewer to check the camera stream.") |
| 81 | + print("To reconnect with depthai, a device power-cycle may be required in some cases") |
| 82 | + # We do not want the device to be closed, so terminate the process uncleanly. |
79 | 83 | # (TODO add depthai API to be able to cleanly exit without closing device)
|
80 | 84 | import signal
|
81 |
| - os.kill(os.getpid(),signal.SIGKILL) |
| 85 | + os.kill(os.getpid(), signal.SIGTERM) |
82 | 86 |
|
83 | 87 | # Standard UVC load with depthai
|
84 | 88 | with dai.Device(getPipeline()) as device:
|
|
0 commit comments