-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1043 from luxonis/develop
DepthAI SDK 1.11.0
- Loading branch information
Showing
42 changed files
with
1,128 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
[submodule "depthai_sdk/src/depthai_sdk/integrations/depthai_pipeline_graph"] | ||
path = depthai_sdk/src/depthai_sdk/integrations/depthai_pipeline_graph | ||
url = https://github.com/luxonis/depthai_pipeline_graph | ||
[submodule "resources/depthai_boards"] | ||
path = resources/depthai_boards | ||
url = https://github.com/luxonis/depthai-boards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Automatic IR power control | ||
========================== | ||
|
||
.. note:: This feature is only available on OAK devices with IR lights. | ||
|
||
.. note:: This feature is experimental, please report any issues you encounter | ||
to the Luxonis team. | ||
|
||
**Automatic IR power control** is a feature that allows the device to automatically | ||
adjust the IR power based on the scene. This is useful for applications where | ||
the scene is not always the same, for example when the camera is used in an | ||
outdoor environment. | ||
|
||
To enable automatic IR power control, you need to use :meth:`auto_ir <depthai_sdk.StereoComponent.auto_ir>` method | ||
that accepts two parameters: | ||
|
||
- ``auto_mode`` - ``True`` to enable automatic IR power control, ``False`` to disable it. | ||
- ``continuous_mode`` - ``True`` to enable continuous mode, ``False`` otherwise. Requires ``auto_mode`` to be enabled. | ||
|
||
When **automatic mode** is enabled, the device will automatically adjust the IR power after the startup. | ||
The disparity map will be analyzed with different dot projector and illumination settings, | ||
and once the best settings are found, the device will use them for the rest of the session. | ||
The whole process takes around **25 seconds**. | ||
|
||
If **continuous mode** is enabled, the device will continue to search for better settings. | ||
In case the scene changes and disparity map quality drops below a certain threshold, | ||
the device will automatically adjust the IR power again. | ||
|
||
Usage | ||
----- | ||
|
||
The following example shows how to enable automatic IR power control in continuous mode: | ||
|
||
.. literalinclude:: ../../../examples/StereoComponent/stereo_auto_ir.py | ||
:language: python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from depthai_sdk import OakCamera | ||
from depthai_sdk.classes.packets import IMUPacket | ||
import rerun as rr | ||
import subprocess | ||
import depthai as dai | ||
|
||
def callback(packet: IMUPacket): | ||
for d in packet.data: | ||
gyro: dai.IMUReportGyroscope = d.gyroscope | ||
accel: dai.IMUReportAccelerometer = d.acceleroMeter | ||
mag: dai.IMUReportMagneticField = d.magneticField | ||
rot: dai.IMUReportRotationVectorWAcc = d.rotationVector | ||
print(accel.x, accel.y, accel.z) | ||
rr.log_scalar('world/accel_x', accel.x, color=(255,0,0)) | ||
rr.log_scalar('world/accel_y', accel.y, color=(0,255,0)) | ||
rr.log_scalar('world/accel_z', accel.z, color=(0,0,255)) | ||
|
||
|
||
with OakCamera() as oak: | ||
subprocess.Popen(["rerun", "--memory-limit", "200MB"]) | ||
rr.init("Rerun ", spawn=False) | ||
rr.connect() | ||
|
||
|
||
imu = oak.create_imu() | ||
imu.config_imu(report_rate=10, batch_report_threshold=2) | ||
print(oak.device.getConnectedIMU()) | ||
oak.callback(imu, callback=callback) | ||
oak.start(blocking=True) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import cv2 | ||
from depthai_sdk import OakCamera | ||
from depthai_sdk.classes.packets import PointcloudPacket, FramePacket | ||
import rerun as rr | ||
import subprocess | ||
subprocess.Popen(["rerun", "--memory-limit", "200MB"]) | ||
rr.init("Rerun ", spawn=False) | ||
rr.connect() | ||
def callback(packet: PointcloudPacket): | ||
colors = packet.color_frame.getCvFrame()[..., ::-1] # BGR to RGB | ||
rr.log_image('Color Image', colors) | ||
points = packet.points.reshape(-1, 3) | ||
rr.log_points("Pointcloud", points, colors=colors.reshape(-1, 3)) | ||
|
||
with OakCamera() as oak: | ||
pcl = oak.create_pointcloud() | ||
oak.callback(pcl, callback=callback) | ||
oak.start(blocking=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from depthai_sdk import OakCamera | ||
|
||
with OakCamera() as oak: | ||
left = oak.create_camera('left') | ||
right = oak.create_camera('right') | ||
stereo = oak.create_stereo(left=left, right=right) | ||
|
||
# Automatically estimate IR brightness and adjust it continuously | ||
stereo.set_auto_ir(auto_mode=True, continuous_mode=True) | ||
|
||
oak.visualize([stereo.out.disparity, left]) | ||
oak.start(blocking=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from depthai_sdk import OakCamera | ||
from depthai_sdk.visualize.configs import StereoColor | ||
from depthai_sdk.classes.packets import DepthPacket | ||
import math | ||
import depthai as dai | ||
import cv2 | ||
|
||
# User-defined constants | ||
WARNING = 1000 # 1m, orange | ||
CRITICAL = 500 # 50cm, red | ||
|
||
slc_data = [] | ||
|
||
def cb(packet: DepthPacket): | ||
global slc_data | ||
fontType = cv2.FONT_HERSHEY_TRIPLEX | ||
|
||
depthFrameColor = packet.visualizer.draw(packet.frame) | ||
|
||
for depthData in slc_data: | ||
roi = depthData.config.roi | ||
roi = roi.denormalize(width=depthFrameColor.shape[1], height=depthFrameColor.shape[0]) | ||
|
||
xmin = int(roi.topLeft().x) | ||
ymin = int(roi.topLeft().y) | ||
xmax = int(roi.bottomRight().x) | ||
ymax = int(roi.bottomRight().y) | ||
|
||
coords = depthData.spatialCoordinates | ||
distance = math.sqrt(coords.x ** 2 + coords.y ** 2 + coords.z ** 2) | ||
|
||
if distance == 0: # Invalid | ||
continue | ||
|
||
if distance < CRITICAL: | ||
color = (0, 0, 255) | ||
cv2.rectangle(depthFrameColor, (xmin, ymin), (xmax, ymax), color, thickness=4) | ||
cv2.putText(depthFrameColor, "{:.1f}m".format(distance/1000), (xmin + 10, ymin + 20), fontType, 0.5, color) | ||
elif distance < WARNING: | ||
color = (0, 140, 255) | ||
cv2.rectangle(depthFrameColor, (xmin, ymin), (xmax, ymax), color, thickness=2) | ||
cv2.putText(depthFrameColor, "{:.1f}m".format(distance/1000), (xmin + 10, ymin + 20), fontType, 0.5, color) | ||
|
||
cv2.imshow('0_depth', depthFrameColor) | ||
|
||
with OakCamera() as oak: | ||
stereo = oak.create_stereo('720p') | ||
# We don't need high fill rate, just very accurate depth, that's why we enable some filters, and | ||
# set the confidence threshold to 50 | ||
config = stereo.node.initialConfig.get() | ||
config.postProcessing.brightnessFilter.minBrightness = 0 | ||
config.postProcessing.brightnessFilter.maxBrightness = 255 | ||
stereo.node.initialConfig.set(config) | ||
stereo.config_postprocessing(colorize=StereoColor.RGBD, colormap=cv2.COLORMAP_BONE) | ||
stereo.config_stereo(confidence=50, lr_check=True, extended=True) | ||
|
||
oak.visualize([stereo], fps=True, callback=cb) | ||
|
||
oak.build() | ||
|
||
slc = oak.pipeline.create(dai.node.SpatialLocationCalculator) | ||
for x in range(15): | ||
for y in range(9): | ||
config = dai.SpatialLocationCalculatorConfigData() | ||
config.depthThresholds.lowerThreshold = 200 | ||
config.depthThresholds.upperThreshold = 10000 | ||
config.roi = dai.Rect(dai.Point2f((x+0.5)*0.0625, (y+0.5)*0.1), dai.Point2f((x+1.5)*0.0625, (y+1.5)*0.1)) | ||
# TODO: change from median to 10th percentile once supported | ||
config.calculationAlgorithm = dai.SpatialLocationCalculatorAlgorithm.MEDIAN | ||
slc.initialConfig.addROI(config) | ||
|
||
stereo.depth.link(slc.inputDepth) | ||
|
||
slc_out = oak.pipeline.create(dai.node.XLinkOut) | ||
slc_out.setStreamName('slc') | ||
slc.out.link(slc_out.input) | ||
|
||
oak.start() # Start the pipeline (upload it to the OAK) | ||
|
||
q = oak.device.getOutputQueue('slc') # Create output queue after calling start() | ||
while oak.running(): | ||
if q.has(): | ||
slc_data = q.get().getSpatialLocations() | ||
oak.poll() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.