diff --git a/depthai-core b/depthai-core index 2e824de00..587821c6f 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit 2e824de00f76478034f797877ef4bf344f8809e9 +Subproject commit 587821c6f49504ac9de1c220268492b754da2127 diff --git a/examples/Camera/camera_undistort.py b/examples/Camera/camera_undistort.py old mode 100644 new mode 100755 index 0d78f1d9e..965d3cef0 --- a/examples/Camera/camera_undistort.py +++ b/examples/Camera/camera_undistort.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai import cv2 diff --git a/examples/Camera/thermal_cam.py b/examples/Camera/thermal_cam.py old mode 100644 new mode 100755 index 51a6d62ef..d6f7384ce --- a/examples/Camera/thermal_cam.py +++ b/examples/Camera/thermal_cam.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai import cv2 import numpy as np diff --git a/examples/Cast/cast_blur.py b/examples/Cast/cast_blur.py old mode 100644 new mode 100755 index 733a491dd..68c988e46 --- a/examples/Cast/cast_blur.py +++ b/examples/Cast/cast_blur.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai import cv2 from pathlib import Path diff --git a/examples/Cast/cast_concat.py b/examples/Cast/cast_concat.py old mode 100644 new mode 100755 index e4e3bcbb8..decbb5b08 --- a/examples/Cast/cast_concat.py +++ b/examples/Cast/cast_concat.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import numpy as np import cv2 import depthai as dai diff --git a/examples/Cast/cast_diff.py b/examples/Cast/cast_diff.py old mode 100644 new mode 100755 index aaaaf750d..471f05fea --- a/examples/Cast/cast_diff.py +++ b/examples/Cast/cast_diff.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import cv2 import depthai as dai from pathlib import Path diff --git a/examples/ColorCamera/rgb_scene.py b/examples/ColorCamera/rgb_scene.py index 7bd550b1d..1815b7db7 100755 --- a/examples/ColorCamera/rgb_scene.py +++ b/examples/ColorCamera/rgb_scene.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import cv2 import depthai as dai from itertools import cycle diff --git a/examples/ColorCamera/rgb_undistort.py b/examples/ColorCamera/rgb_undistort.py index 97e71b184..f617f180f 100755 --- a/examples/ColorCamera/rgb_undistort.py +++ b/examples/ColorCamera/rgb_undistort.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import cv2 import depthai as dai import numpy as np diff --git a/examples/CrashReport/capture_diagnostic.py b/examples/CrashReport/capture_diagnostic.py old mode 100644 new mode 100755 index 5962406f0..363d40e4c --- a/examples/CrashReport/capture_diagnostic.py +++ b/examples/CrashReport/capture_diagnostic.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai import zipfile from json import dump, JSONEncoder diff --git a/examples/FeatureTracker/feature_motion_estimation.py b/examples/FeatureTracker/feature_motion_estimation.py old mode 100644 new mode 100755 index ae0162f9c..efbdfc24f --- a/examples/FeatureTracker/feature_motion_estimation.py +++ b/examples/FeatureTracker/feature_motion_estimation.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import numpy as np import cv2 from collections import deque diff --git a/examples/ImageAlign/depth_align.py b/examples/ImageAlign/depth_align.py old mode 100644 new mode 100755 index 9e13fcf58..dddfab913 --- a/examples/ImageAlign/depth_align.py +++ b/examples/ImageAlign/depth_align.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import numpy as np import cv2 import depthai as dai diff --git a/examples/ImageAlign/image_align.py b/examples/ImageAlign/image_align.py old mode 100644 new mode 100755 index 2d257e61b..c3c08ad0f --- a/examples/ImageAlign/image_align.py +++ b/examples/ImageAlign/image_align.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import cv2 import depthai as dai from datetime import timedelta diff --git a/examples/ImageAlign/thermal_align.py b/examples/ImageAlign/thermal_align.py old mode 100644 new mode 100755 index c353f2e9a..f4523e424 --- a/examples/ImageAlign/thermal_align.py +++ b/examples/ImageAlign/thermal_align.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import cv2 import depthai as dai import numpy as np diff --git a/examples/ImageAlign/tof_align.py b/examples/ImageAlign/tof_align.py old mode 100644 new mode 100755 index e4d0664be..d9ec664ac --- a/examples/ImageAlign/tof_align.py +++ b/examples/ImageAlign/tof_align.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import numpy as np import cv2 import depthai as dai diff --git a/examples/NeuralNetwork/thermal_nnet.py b/examples/NeuralNetwork/thermal_nnet.py old mode 100644 new mode 100755 index bdca65c5d..5293f37d5 --- a/examples/NeuralNetwork/thermal_nnet.py +++ b/examples/NeuralNetwork/thermal_nnet.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai import cv2 from pathlib import Path diff --git a/examples/PointCloud/pointcloud_control.py b/examples/PointCloud/pointcloud_control.py old mode 100644 new mode 100755 index 6ebe5b9a5..c03154223 --- a/examples/PointCloud/pointcloud_control.py +++ b/examples/PointCloud/pointcloud_control.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai import numpy as np import cv2 diff --git a/examples/PointCloud/visualize_pointcloud.py b/examples/PointCloud/visualize_pointcloud.py old mode 100644 new mode 100755 index 564329e4f..c2655eff9 --- a/examples/PointCloud/visualize_pointcloud.py +++ b/examples/PointCloud/visualize_pointcloud.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai from time import sleep import numpy as np diff --git a/examples/Script/script_emmc_access.py b/examples/Script/script_emmc_access.py old mode 100644 new mode 100755 index a93485976..37d85dd1b --- a/examples/Script/script_emmc_access.py +++ b/examples/Script/script_emmc_access.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai import cv2 diff --git a/examples/Script/script_read_calibration.py b/examples/Script/script_read_calibration.py old mode 100644 new mode 100755 diff --git a/examples/Script/script_uart.py b/examples/Script/script_uart.py old mode 100644 new mode 100755 diff --git a/examples/StereoDepth/stereo_depth_custom_mesh.py b/examples/StereoDepth/stereo_depth_custom_mesh.py old mode 100644 new mode 100755 diff --git a/examples/StereoDepth/stereo_runtime_calibration_update.py b/examples/StereoDepth/stereo_runtime_calibration_update.py new file mode 100755 index 000000000..4053336f2 --- /dev/null +++ b/examples/StereoDepth/stereo_runtime_calibration_update.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 + +import cv2 +import depthai as dai +import numpy as np + +# Create pipeline +pipeline = dai.Pipeline() + +# Define sources and outputs +monoLeft = pipeline.create(dai.node.MonoCamera) +monoRight = pipeline.create(dai.node.MonoCamera) +stereo = pipeline.create(dai.node.StereoDepth) +xout = pipeline.create(dai.node.XLinkOut) +xoutLeft = pipeline.create(dai.node.XLinkOut) + +xout.setStreamName("disparity") +xoutLeft.setStreamName("left") + +# Properties +monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P) +monoLeft.setCamera("left") +monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P) +monoRight.setCamera("right") + +stereo.enableDistortionCorrection(True) + +# Linking +monoLeft.out.link(stereo.left) +monoRight.out.link(stereo.right) +stereo.disparity.link(xout.input) +stereo.rectifiedLeft.link(xoutLeft.input) + +cvColorMap = cv2.applyColorMap(np.arange(256, dtype=np.uint8), cv2.COLORMAP_JET) +cvColorMap[0] = [0, 0, 0] + +# Connect to device and start pipeline +with dai.Device(pipeline) as device: + + try: + calibration = device.readCalibration() + except: + print("Device is not calibrated!") + exit() + + print("Press 'u' to update distortion coefficients with random values") + + # Output queue will be used to get the disparity frames from the outputs defined above + q = device.getOutputQueue(name="disparity", maxSize=4, blocking=False) + qLeft = device.getOutputQueue(name="left", maxSize=4, blocking=False) + + while True: + inDisparity = q.get() # blocking call, will wait until a new data has arrived + frame = inDisparity.getFrame() + # Normalization for better visualization + frame = (frame * (255 / stereo.initialConfig.getMaxDisparity())).astype(np.uint8) + + cv2.imshow("disparity", frame) + + frame = cv2.applyColorMap(frame, cvColorMap) + cv2.imshow("disparity_color", frame) + + inLeft = qLeft.get() + frame = inLeft.getCvFrame() + cv2.imshow("rectified left", frame) + + key = cv2.waitKey(1) + if key == ord('q'): + break + elif key == ord('u'): + randomDistortionCoeffs = np.random.rand(14) + calibration.setDistortionCoefficients(dai.CameraBoardSocket.LEFT, randomDistortionCoeffs) + try: + device.setCalibration(calibration) + except: + print("Failed to update calibration!") + try: + updatedCalib = device.getCalibration() + distortionCoeffs = updatedCalib.getDistortionCoefficients(dai.CameraBoardSocket.LEFT) + print("Updated distortion coefficients: ", distortionCoeffs) + except: + pass + diff --git a/examples/Sync/demux_message_group.py b/examples/Sync/demux_message_group.py old mode 100644 new mode 100755 diff --git a/examples/Sync/depth_video_synced.py b/examples/Sync/depth_video_synced.py old mode 100644 new mode 100755 diff --git a/examples/Sync/imu_video_synced.py b/examples/Sync/imu_video_synced.py old mode 100644 new mode 100755 diff --git a/examples/Sync/sync_scripts.py b/examples/Sync/sync_scripts.py old mode 100644 new mode 100755 diff --git a/examples/ToF/tof_depth.py b/examples/ToF/tof_depth.py old mode 100644 new mode 100755 diff --git a/examples/UVC/uvc_disparity.py b/examples/UVC/uvc_disparity.py old mode 100644 new mode 100755 diff --git a/examples/UVC/uvc_mono.py b/examples/UVC/uvc_mono.py old mode 100644 new mode 100755 diff --git a/examples/device/device_all_boot_bootloader.py b/examples/device/device_all_boot_bootloader.py index 4c2e9a56b..4ac04cb4e 100755 --- a/examples/device/device_all_boot_bootloader.py +++ b/examples/device/device_all_boot_bootloader.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai devices = dai.Device.getAllConnectedDevices() diff --git a/examples/device/device_boot_non_exclusive.py b/examples/device/device_boot_non_exclusive.py index 898b292f6..3a89acea7 100755 --- a/examples/device/device_boot_non_exclusive.py +++ b/examples/device/device_boot_non_exclusive.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai import time diff --git a/examples/mixed/collision_avoidance.py b/examples/mixed/collision_avoidance.py old mode 100644 new mode 100755 index c5683cb8a..d0df84ba3 --- a/examples/mixed/collision_avoidance.py +++ b/examples/mixed/collision_avoidance.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import depthai as dai import cv2 import numpy as np diff --git a/src/DeviceBindings.cpp b/src/DeviceBindings.cpp index 6c27b4d6a..7f94027d1 100644 --- a/src/DeviceBindings.cpp +++ b/src/DeviceBindings.cpp @@ -504,6 +504,8 @@ void DeviceBindings::bind(pybind11::module& m, void* pCallstack){ .def("getProfilingData", [](DeviceBase& d) { py::gil_scoped_release release; return d.getProfilingData(); }, DOC(dai, DeviceBase, getProfilingData)) .def("readCalibration", [](DeviceBase& d) { py::gil_scoped_release release; return d.readCalibration(); }, DOC(dai, DeviceBase, readCalibration)) .def("flashCalibration", [](DeviceBase& d, CalibrationHandler calibrationDataHandler) { py::gil_scoped_release release; return d.flashCalibration(calibrationDataHandler); }, py::arg("calibrationDataHandler"), DOC(dai, DeviceBase, flashCalibration)) + .def("setCalibration", [](DeviceBase& d, CalibrationHandler calibrationDataHandler) { py::gil_scoped_release release; return d.setCalibration(calibrationDataHandler); }, py::arg("calibrationDataHandler"), DOC(dai, DeviceBase, setCalibration)) + .def("getCalibration", [](DeviceBase& d) { py::gil_scoped_release release; return d.getCalibration(); }, DOC(dai, DeviceBase, getCalibration)) .def("setXLinkChunkSize", [](DeviceBase& d, int s) { py::gil_scoped_release release; d.setXLinkChunkSize(s); }, py::arg("sizeBytes"), DOC(dai, DeviceBase, setXLinkChunkSize)) .def("getXLinkChunkSize", [](DeviceBase& d) { py::gil_scoped_release release; return d.getXLinkChunkSize(); }, DOC(dai, DeviceBase, getXLinkChunkSize)) .def("setIrLaserDotProjectorBrightness", [](DeviceBase& d, float mA, int mask) {