Skip to content

Commit c7bea3f

Browse files
committed
Merge branch 'develop' into main
2 parents c8faece + 4cdaa66 commit c7bea3f

38 files changed

+1762
-506
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
runs-on: windows-latest
109109
strategy:
110110
matrix:
111-
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
111+
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
112112
python-architecture: [x64, x86]
113113
steps:
114114
- name: Cache .hunter folder
@@ -159,7 +159,7 @@ jobs:
159159
runs-on: macos-latest
160160
strategy:
161161
matrix:
162-
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
162+
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
163163
steps:
164164
- name: Cache .hunter folder
165165
uses: actions/cache@v2
@@ -259,7 +259,7 @@ jobs:
259259
/opt/python/cp38-cp38/bin/python3.8 setup.py sdist --formats=gztar
260260
mv dist/* wheelhouse/audited/
261261
- name: Build wheels
262-
run: for PYBIN in /opt/python/cp3*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/ --verbose; done
262+
run: for PYBIN in /opt/python/cp3{6..10}*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/ --verbose; done
263263
- name: Audit wheels
264264
run: for whl in wheelhouse/*.whl; do auditwheel repair "$whl" --plat $PLAT -w wheelhouse/audited/; done
265265
- name: Archive wheel artifacts
@@ -316,7 +316,7 @@ jobs:
316316
if: startsWith(github.ref, 'refs/tags/v') != true
317317
run: echo "BUILD_COMMIT_HASH=${{github.sha}}" >> $GITHUB_ENV
318318
- name: Building wheels
319-
run: for PYBIN in /opt/python/cp3*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/ --verbose; done
319+
run: for PYBIN in /opt/python/cp3{6..10}*/bin; do "${PYBIN}/pip" wheel . -w ./wheelhouse/ --verbose; done
320320
- name: Auditing wheels
321321
run: for whl in wheelhouse/*.whl; do auditwheel repair "$whl" --plat $PLAT -w wheelhouse/audited/; done
322322
- name: Archive wheel artifacts

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ find_package(pybind11 CONFIG REQUIRED)
8383
# Add files for python module
8484
pybind11_add_module(${TARGET_NAME}
8585
src/py_bindings.cpp
86-
src/XLinkConnectionBindings.cpp
86+
src/XLinkBindings.cpp
8787
src/DeviceBindings.cpp
8888
src/CalibrationHandlerBindings.cpp
8989
src/DeviceBootloaderBindings.cpp
@@ -157,6 +157,7 @@ target_link_libraries(${TARGET_NAME}
157157
pybind11::pybind11
158158
depthai::core # Use non-opencv target as we use opencv-python in bindings
159159
hedley
160+
pybind11_json
160161
)
161162

162163
# Find Git

ci/build-wheels.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ yum install -y libusb1-devel
77
#yum remove -y libusb1
88

99
# Compile wheels
10-
for PYBIN in /opt/python/cp3*/bin; do
10+
for PYBIN in /opt/python/cp3{6..10}*/bin; do
1111
#"${PYBIN}/pip" install -r /io/requirements.txt
1212
"${PYBIN}/pip" wheel /io/ -w wheelhouse/
1313
done

depthai-core

Submodule depthai-core updated 66 files

docs/source/components/nodes/script.rst

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,34 @@ Usage
9191
Interfacing with GPIOs
9292
######################
9393

94-
In the script node you can interface with GPIOs of the VPU. Currently supported functions are:
94+
In the script node you can interface with GPIOs of the VPU using module GPIO. Currently supported functions are:
9595

9696
.. code-block:: python
9797
98-
import GPIO # module
99-
GPIO.read(pin)
100-
GPIO.write(pin, value)
101-
GPIO.setPwm(pin, highCount, lowCount, repeat=0) # repeat == 0 means indefinite
102-
GPIO.enablePwm(pin, enable)
98+
# Module
99+
import GPIO
100+
101+
# General
102+
GPIO.setup(gpio, dir, pud, exclusive)
103+
GPIO.release(gpio)
104+
GPIO.write(gpio, value)
105+
GPIO.read(gpio)
106+
107+
# Interrupts
108+
GPIO.waitInterruptEvent(gpio = -1) # blocks until any interrupt or interrupt by specified gpio is fired. Interrupts with callbacks are ignored here
109+
GPIO.hasInterruptEvent(gpio = -1) # returns whether interrupt happened on any or specfied gpio. Interrupts with callbacks are ignored here
110+
GPIO.setInterrupt(gpio, edge, priority, callback = None) # adds interrupt to specified pin
111+
GPIO.clearInterrupt(gpio) # clears interrupt of specified pin
112+
113+
# PWM
114+
GPIO.setPwm(gpio, highCount, lowCount, repeat=0) # repeat == 0 means indefinite
115+
GPIO.enablePwm(gpio, enable)
116+
117+
# Enumerations
118+
GPIO.Direction: GPIO.IN, GPIO.OUT
119+
GPIO.State: GPIO.LOW, GPIO.HIGH
120+
GPIO.PullDownUp: GPIO.PULL_NONE, GPIO.PULL_DOWN, GPIO.PULL_UP
121+
GPIO.Edge: GPIO.RISING, GPIO.FALLING, GPIO.LEVEL_HIGH, GPIO.LEVEL_LOW
103122
104123
Using DepthAI :ref:`Messages <components_messages>`
105124
###################################################

examples/bootloader_config.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python3
2+
3+
import depthai as dai
4+
import sys
5+
6+
usage = False
7+
read = True
8+
clear = False
9+
path = ''
10+
if len(sys.argv) >= 2:
11+
op = sys.argv[1]
12+
if op == 'read':
13+
read = True
14+
elif op == 'flash':
15+
read = False
16+
if len(sys.argv) >= 3:
17+
path = sys.argv[2]
18+
elif op == 'clear':
19+
clear = True
20+
read = False
21+
else:
22+
usage = True
23+
else:
24+
usage = True
25+
26+
if usage:
27+
print(f'Usage: {sys.argv[0]} [read/flash/clear] [flash: path/to/config/json]')
28+
exit(-1)
29+
30+
(res, info) = dai.DeviceBootloader.getFirstAvailableDevice()
31+
32+
if res:
33+
print(f'Found device with name: {info.desc.name}');
34+
with dai.DeviceBootloader(info) as bl:
35+
if read:
36+
print('Current flashed configuration')
37+
print(f'{bl.readConfigData()}')
38+
else:
39+
success = None
40+
error = None
41+
if clear:
42+
(success, error) = bl.flashConfigClear()
43+
else:
44+
if path == '':
45+
(success, error) = bl.flashConfig(dai.DeviceBootloader.Config())
46+
else:
47+
(success, error) = bl.flashConfigFile(path)
48+
if success:
49+
print('Successfully flashed bootloader configuration')
50+
else:
51+
print(f'Error flashing bootloader configuration: {error}')
52+
else:
53+
print('No devices found')

examples/bootloader_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
(res, info) = dai.DeviceBootloader.getFirstAvailableDevice()
66

77
if res == True:
8-
print(f'Found device with name: {info.desc.name}');
8+
print(f'Found device with name: {info.desc.name}')
99
bl = dai.DeviceBootloader(info)
10-
print(f'Version: {bl.getVersion()}');
10+
print(f'Version: {bl.getVersion()}')
1111
else:
1212
print('No devices found')

examples/depth_preview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
inDepth = q.get() # blocking call, will wait until a new data has arrived
5252
frame = inDepth.getFrame()
5353
# Normalization for better visualization
54-
frame = (frame * (255 / depth.getMaxDisparity())).astype(np.uint8)
54+
frame = (frame * (255 / depth.initialConfig.getMaxDisparity())).astype(np.uint8)
5555

5656
cv2.imshow("disparity", frame)
5757

examples/flash_bootloader.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python3
2+
3+
import depthai as dai
4+
import sys
5+
import time
6+
7+
blType = dai.DeviceBootloader.Type.AUTO
8+
if len(sys.argv) > 1:
9+
if sys.argv[1] == 'usb':
10+
blType = dai.DeviceBootloader.Type.USB
11+
elif sys.argv[1] == 'network':
12+
blType = dai.DeviceBootloader.Type.NETWORK
13+
else:
14+
print("Specify either 'usb' or 'network' bootloader type")
15+
exit()
16+
17+
(found, info) = dai.DeviceBootloader.getFirstAvailableDevice()
18+
if not found:
19+
print("No device found to flash. Exiting.")
20+
exit(-1)
21+
22+
hasBootloader = (info.state == dai.XLinkDeviceState.X_LINK_BOOTLOADER)
23+
if hasBootloader:
24+
print("Warning! Flashing bootloader can potentially soft brick your device and should be done with caution.")
25+
print("Do not unplug your device while the bootloader is flashing.")
26+
print("Type 'y' and press enter to proceed, otherwise exits: ")
27+
if input() != 'y':
28+
print("Prompt declined, exiting...")
29+
exit(-1)
30+
31+
# Open DeviceBootloader and allow flashing bootloader
32+
print(f"Booting latest bootloader first, will take a tad longer...")
33+
with dai.DeviceBootloader(info, allowFlashingBootloader=True) as bl:
34+
currentBlType = bl.getType()
35+
36+
if blType == dai.DeviceBootloader.Type.AUTO:
37+
blType = currentBlType
38+
39+
# Check if bootloader type is the same, if already booted by bootloader (not in USB recovery mode)
40+
if currentBlType != blType and hasBootloader:
41+
print(f"Are you sure you want to flash '{blType.name}' bootloader over current '{currentBlType.name}' bootloader?")
42+
print(f"Type 'y' and press enter to proceed, otherwise exits: ")
43+
if input() != 'y':
44+
print("Prompt declined, exiting...")
45+
exit(-1)
46+
47+
# Create a progress callback lambda
48+
progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
49+
50+
print(f"Flashing {blType.name} bootloader...")
51+
startTime = time.monotonic()
52+
(res, message) = bl.flashBootloader(dai.DeviceBootloader.Memory.FLASH, blType, progress)
53+
if res:
54+
print("Flashing successful. Took", time.monotonic() - startTime, "seconds")
55+
else:
56+
print("Flashing failed:", message)

examples/mono_depth_mobilenetssd.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
labelMap = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow",
2020
"diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]
2121

22-
flipRectified = True
23-
2422
# Create pipeline
2523
pipeline = dai.Pipeline()
2624

@@ -97,7 +95,7 @@ def show(name, frame):
9795
# Show the frame
9896
cv2.imshow(name, frame)
9997

100-
disparityMultiplier = 255 / stereo.getMaxDisparity()
98+
disparityMultiplier = 255 / stereo.initialConfig.getMaxDisparity()
10199

102100
while True:
103101
# Instead of get (blocking), we use tryGet (nonblocking) which will return the available data or None otherwise
@@ -107,16 +105,6 @@ def show(name, frame):
107105

108106
if inRight is not None:
109107
rightFrame = inRight.getCvFrame()
110-
if flipRectified:
111-
rightFrame = cv2.flip(rightFrame, 1)
112-
113-
if inDet is not None:
114-
detections = inDet.detections
115-
if flipRectified:
116-
for detection in detections:
117-
swap = detection.xmin
118-
detection.xmin = 1 - detection.xmax
119-
detection.xmax = 1 - swap
120108

121109
if inDisparity is not None:
122110
# Frame is transformed, normalized, and color map will be applied to highlight the depth info

examples/rgb_depth_aligned.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383
if latestPacket["depth"] is not None:
8484
frameDepth = latestPacket["depth"].getFrame()
85-
maxDisparity = stereo.getMaxDisparity()
85+
maxDisparity = stereo.initialConfig.getMaxDisparity()
8686
# Optional, extend range 0..95 -> 0..255, for a better visualisation
8787
if 1: frameDepth = (frameDepth * 255. / maxDisparity).astype(np.uint8)
8888
# Optional, apply false colorization

examples/rgb_encoding_mono_mobilenet_depth.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
labelMap = ["background", "aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow",
2020
"diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]
2121

22-
flipRectified = True
23-
2422
# Create pipeline
2523
pipeline = dai.Pipeline()
2624

@@ -54,9 +52,7 @@
5452
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
5553
videoEncoder.setDefaultProfilePreset(1920, 1080, 30, dai.VideoEncoderProperties.Profile.H265_MAIN)
5654

57-
# Note: the rectified streams are horizontally mirrored by default
5855
depth.initialConfig.setConfidenceThreshold(255)
59-
depth.setRectifyMirrorFrame(False)
6056
depth.setRectifyEdgeFillColor(0) # Black, to better see the cutout
6157

6258
nn.setConfidenceThreshold(0.5)
@@ -81,7 +77,7 @@
8177
nn.out.link(nnOut.input)
8278

8379
# Disparity range is used for normalization
84-
disparityMultiplier = 255 / depth.getMaxDisparity()
80+
disparityMultiplier = 255 / depth.initialConfig.getMaxDisparity()
8581

8682
# Connect to device and start pipeline
8783
with dai.Device(pipeline) as device:
@@ -126,10 +122,8 @@ def frameNorm(frame, bbox):
126122
frameManip = inManip.getCvFrame()
127123

128124
if inDisparity is not None:
129-
# Flip disparity frame, normalize it and apply color map for better visualization
125+
# Apply color map for better visualization
130126
frameDisparity = inDisparity.getCvFrame()
131-
if flipRectified:
132-
frameDisparity = cv2.flip(frameDisparity, 1)
133127
frameDisparity = (frameDisparity*disparityMultiplier).astype(np.uint8)
134128
frameDisparity = cv2.applyColorMap(frameDisparity, cv2.COLORMAP_JET)
135129

examples/rgb_preview.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
# Linking
2121
camRgb.preview.link(xoutRgb.input)
2222

23-
# Connect to device and start pipeline
24-
with dai.Device(pipeline) as device:
25-
23+
# Connect to the device
24+
with dai.Device(pipeline, dai.UsbSpeed.SUPER) as device:
25+
# Print out available cameras
2626
print('Connected cameras: ', device.getConnectedCameras())
2727
# Print out usb speed
2828
print('Usb speed: ', device.getUsbSpeed().name)
@@ -31,7 +31,7 @@
3131
qRgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
3232

3333
while True:
34-
inRgb = qRgb.get() # blocking call, will wait until a new data has arrived
34+
inRgb = qRgb.get() # blocking call, will wait until a new data has arrived
3535

3636
# Retrieve 'bgr' (opencv format) frame
3737
cv2.imshow("rgb", inRgb.getCvFrame())

examples/spatial_location_calculator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125

126126
if newConfig:
127127
config.roi = dai.Rect(topLeft, bottomRight)
128+
config.calculationAlgorithm = dai.SpatialLocationCalculatorAlgorithm.AVERAGE
128129
cfg = dai.SpatialLocationCalculatorConfig()
129130
cfg.addROI(config)
130131
spatialCalcConfigInQueue.send(cfg)

examples/spatial_mobilenet_mono.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]
2929

3030
syncNN = True
31-
flipRectified = True
3231

3332
# Create pipeline
3433
pipeline = dai.Pipeline()
@@ -118,8 +117,6 @@
118117
startTime = currentTime
119118

120119
rectifiedRight = inRectified.getCvFrame()
121-
if flipRectified:
122-
rectifiedRight = cv2.flip(rectifiedRight, 1)
123120

124121
depthFrame = inDepth.getFrame()
125122
depthFrameColor = cv2.normalize(depthFrame, None, 255, 0, cv2.NORM_INF, cv2.CV_8UC1)
@@ -146,10 +143,6 @@
146143
height = rectifiedRight.shape[0]
147144
width = rectifiedRight.shape[1]
148145
for detection in detections:
149-
if flipRectified:
150-
swap = detection.xmin
151-
detection.xmin = 1 - detection.xmax
152-
detection.xmax = 1 - swap
153146
# Denormalize bounding box
154147
x1 = int(detection.xmin * width)
155148
x2 = int(detection.xmax * width)

0 commit comments

Comments
 (0)