Skip to content

Commit 5af35ba

Browse files
committed
rgb_uvc.py: Windows fixes: change SIGKILL->SIGTERM, set env var before depthai import
1 parent 0f20d8d commit 5af35ba

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

examples/ColorCamera/rgb_uvc.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python3
22

3-
import depthai as dai
43
import time
54
import argparse
65

@@ -10,6 +9,14 @@
109
parser.add_argument('-l', '--load-and-exit', default=False, action="store_true")
1110
args = parser.parse_args()
1211

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+
1320
def getPipeline():
1421
enable_4k = True # Will downscale 4K -> 1080p
1522

@@ -68,17 +75,14 @@ def flash(pipeline=None):
6875
quit()
6976

7077
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"
7478
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.
7983
# (TODO add depthai API to be able to cleanly exit without closing device)
8084
import signal
81-
os.kill(os.getpid(),signal.SIGKILL)
85+
os.kill(os.getpid(), signal.SIGTERM)
8286

8387
# Standard UVC load with depthai
8488
with dai.Device(getPipeline()) as device:

0 commit comments

Comments
 (0)