Skip to content

Feature/colorize depth frame - #1909

Merged
aljazkonec1 merged 8 commits into
developfrom
feature/colorize-depth-frame
Aug 11, 2026
Merged

Feature/colorize depth frame#1909
aljazkonec1 merged 8 commits into
developfrom
feature/colorize-depth-frame

Conversation

@JakubFara

@JakubFara JakubFara commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Why

  • New function colorizeDepthFrame which unifies colorization of depth images.
  • Simplify examples
  • Replace disparity with depth in some examples where depth is more suitable.

Usage

dai.colorizeDepthFrame(depthFrame, 500, 12000, cv2.COLORMAP_HOT, False).getCvFrame();

Summary by CodeRabbit

  • New Features
    • Added a shared depth colorization utility for C++ and Python with configurable minDepth, maxDepth, colormap selection, and optional log scaling.
    • Python now exposes colorizeDepthFrame, supporting DepthAI frames, with percentile auto-range when maxDepth <= minDepth.
  • Examples
    • Updated multiple depth-related C++ and Python examples to display colorized depth using the shared utility, removing ad-hoc helpers and disparity-based previews.
  • Build
    • Extended OpenCV-enabled builds to compile/link the new depth colorization implementation.

@JakubFara
JakubFara requested a review from aljazkonec1 July 27, 2026 12:37
@JakubFara
JakubFara changed the base branch from main to develop July 27, 2026 12:37
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This change adds a shared OpenCV depth-colorization API, exposes it through Python, and replaces custom depth/disparity visualization code across C++ and Python examples with the shared utility.

Changes

Depth Colorization Utility

Layer / File(s) Summary
Public API and implementation
include/depthai/utility/ColorizeDepthFrame.hpp, src/opencv/ColorizeDepthFrame.cpp, include/depthai/depthai.hpp, CMakeLists.txt
Adds ImgFrame and cv::Mat overloads with configurable ranges, colormaps, logarithmic scaling, automatic percentile ranges, and black invalid pixels.
Python binding
bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp
Adds colorizeDepthFrame support for ImgFrame and NumPy inputs when OpenCV support is enabled.
C++ examples
examples/cpp/**
Replaces local colorization logic and disparity visualization paths with shared depth colorization.
Python examples
examples/python/**
Uses the new binding, removes duplicated NumPy/OpenCV colorization helpers, and switches applicable queues from disparity to depth.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DepthFrame
  participant Example
  participant colorizeDepthFrame
  participant OpenCV
  DepthFrame->>Example: deliver depth frame
  Example->>colorizeDepthFrame: request colorized frame
  colorizeDepthFrame->>OpenCV: normalize and apply colormap
  OpenCV-->>colorizeDepthFrame: BGR output
  colorizeDepthFrame-->>Example: return display frame
Loading

Possibly related PRs

Suggested reviewers: aljazkonec, asahtik

Poem

A rabbit hops through depthy streams,
One helper paints the pixels bright.
C++ and Python share the light.
Raw frames bloom in colored cheer—
Unified depth magic is here!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.58% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a depth-frame colorization feature.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/colorize-depth-frame

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/cpp/NeuralAssistedStereo/neural_assisted_stereo.cpp`:
- Line 32: Update the NeuralAssistedStereo pipeline to create and output the
depth frame from neuralAssistedStereo->depth, then use that depth output instead
of neuralAssistedStereo->disparity in the colorizeDepthFrame call. Preserve the
existing 500.0f and 12000.0f bounds and display flow.

In `@examples/python/NeuralAssistedStereo/neural_assisted_stereo.py`:
- Around line 26-27: Update the display path around disparityQueue.get() to
consume frames from the neuralAssistedStereo.depth output queue instead, then
pass that depth-in-millimeters frame to colorizeDepthFrame while preserving the
existing 500–12000 range and Depth display.

In `@src/opencv/ColorizeDepthFrame.cpp`:
- Around line 12-22: Correct the valid-pixel collection in the bounds-building
loop anchored by nz and values: make the mask condition match the valid-pixel
count, so values.push_back(d[c]) includes valid depths rather than zero/invalid
ones. Preserve the existing reserve and iteration structure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8087ccb1-1388-440d-8e3d-c1ea3c8683b2

📥 Commits

Reviewing files that changed from the base of the PR and between 06b2050 and 9fe20da.

📒 Files selected for processing (59)
  • CMakeLists.txt
  • bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp
  • examples/cpp/AutoCalibration/auto_calibration_example.cpp
  • examples/cpp/Depth/depth_rgb_align.cpp
  • examples/cpp/Depth/unified_depth.cpp
  • examples/cpp/DetectionNetwork/detection_network_remap.cpp
  • examples/cpp/DynamicCalibration/calibration_dynamic.cpp
  • examples/cpp/DynamicCalibration/calibration_integration.cpp
  • examples/cpp/ImageAlign/depth_align.cpp
  • examples/cpp/Misc/PipelineDebugging/get_pipeline_state.cpp
  • examples/cpp/Misc/PipelineDebugging/node_pipeline_events.cpp
  • examples/cpp/NeuralAssistedStereo/neural_assisted_stereo.cpp
  • examples/cpp/NeuralDepth/neural_depth.cpp
  • examples/cpp/NeuralDepth/neural_depth_align.cpp
  • examples/cpp/NeuralDepth/neural_depth_minimal.cpp
  • examples/cpp/ObjectTracker/object_tracker_remap.cpp
  • examples/cpp/Remapping/point_remapping.cpp
  • examples/cpp/SpatialDetectionNetwork/spatial_detection.cpp
  • examples/cpp/SpatialLocationCalculator/spatial_location_calculator.cpp
  • examples/cpp/SpatialLocationCalculator/spatial_segmentation.cpp
  • examples/cpp/StereoDepth/depth_preview.cpp
  • examples/cpp/StereoDepth/stereo.cpp
  • examples/cpp/StereoDepth/stereo_depth_remap.cpp
  • examples/cpp/ToF/tof_align.cpp
  • examples/cpp/ToF/tof_all_queues.cpp
  • examples/cpp/ToF/tof_minimal.cpp
  • examples/cpp/Vpp/virtual_patern_projection.cpp
  • examples/python/AutoCalibration/auto_calibration_example.py
  • examples/python/Depth/depth_rgb_align.py
  • examples/python/Depth/unified_depth.py
  • examples/python/DetectionNetwork/detection_network_remap.py
  • examples/python/DynamicCalibration/calibration_dynamic.py
  • examples/python/DynamicCalibration/calibration_integration.py
  • examples/python/DynamicCalibration/calibration_quality_dynamic.py
  • examples/python/ImageAlign/depth_align.py
  • examples/python/Misc/PipelineDebugging/get_pipeline_state.py
  • examples/python/Misc/PipelineDebugging/node_pipeline_events.py
  • examples/python/NeuralAssistedStereo/neural_assisted_stereo.py
  • examples/python/NeuralDepth/neural_depth.py
  • examples/python/NeuralDepth/neural_depth_align.py
  • examples/python/NeuralDepth/neural_depth_minimal.py
  • examples/python/ObjectTracker/object_tracker_remap.py
  • examples/python/PointCloud/point_cloud_visualizer.py
  • examples/python/Remapping/point_remapping.py
  • examples/python/SpatialDetectionNetwork/spatial_detection.py
  • examples/python/SpatialLocationCalculator/spatial_keypoints.py
  • examples/python/SpatialLocationCalculator/spatial_location_calculator.py
  • examples/python/SpatialLocationCalculator/spatial_segmentation.py
  • examples/python/StereoDepth/stereo.py
  • examples/python/StereoDepth/stereo_depth_from_host.py
  • examples/python/StereoDepth/stereo_depth_remap.py
  • examples/python/StereoDepth/stereo_runtime_calibration_update.py
  • examples/python/ToF/tof_align.py
  • examples/python/ToF/tof_all_queues.py
  • examples/python/ToF/tof_minimal.py
  • examples/python/Vpp/virtual_patern_projection.py
  • include/depthai/depthai.hpp
  • include/depthai/utility/ColorizeDepthFrame.hpp
  • src/opencv/ColorizeDepthFrame.cpp
📜 Review details
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-05-28T13:36:26.383Z
Learnt from: moratom
Repo: luxonis/depthai-core PR: 1812
File: examples/cpp/ImageManip/image_manip_remap.cpp:51-52
Timestamp: 2026-05-28T13:36:26.383Z
Learning: In depthai-core example code, do not set `ImageManip::Backend::GPU` unconditionally. The GPU backend is only available on RVC4 (not RVC2). Prefer leaving the backend as the default, or comment out the GPU backend selection and add a clear note explaining it is RVC4-only support (so the example won’t fail or mislead on RVC2).

Applied to files:

  • examples/cpp/ObjectTracker/object_tracker_remap.cpp
  • examples/cpp/Vpp/virtual_patern_projection.cpp
  • examples/cpp/Remapping/point_remapping.cpp
  • examples/cpp/NeuralDepth/neural_depth_minimal.cpp
  • examples/python/SpatialLocationCalculator/spatial_segmentation.py
  • examples/cpp/Misc/PipelineDebugging/node_pipeline_events.cpp
  • examples/python/Remapping/point_remapping.py
  • examples/cpp/StereoDepth/stereo_depth_remap.cpp
  • examples/cpp/SpatialLocationCalculator/spatial_location_calculator.cpp
  • examples/python/SpatialLocationCalculator/spatial_location_calculator.py
  • examples/python/StereoDepth/stereo_depth_remap.py
  • examples/cpp/Misc/PipelineDebugging/get_pipeline_state.cpp
  • examples/cpp/StereoDepth/stereo.cpp
  • examples/python/SpatialLocationCalculator/spatial_keypoints.py
  • examples/python/NeuralDepth/neural_depth_minimal.py
  • examples/cpp/AutoCalibration/auto_calibration_example.cpp
  • examples/python/PointCloud/point_cloud_visualizer.py
  • examples/python/ToF/tof_all_queues.py
  • examples/python/DynamicCalibration/calibration_integration.py
  • examples/python/DynamicCalibration/calibration_quality_dynamic.py
  • examples/cpp/DynamicCalibration/calibration_dynamic.cpp
  • examples/python/ToF/tof_minimal.py
  • examples/python/Depth/unified_depth.py
  • examples/cpp/ToF/tof_all_queues.cpp
  • examples/cpp/SpatialDetectionNetwork/spatial_detection.cpp
  • examples/python/Misc/PipelineDebugging/get_pipeline_state.py
  • examples/cpp/DynamicCalibration/calibration_integration.cpp
  • examples/cpp/Depth/depth_rgb_align.cpp
  • examples/cpp/ToF/tof_align.cpp
  • examples/python/NeuralDepth/neural_depth.py
  • examples/python/Misc/PipelineDebugging/node_pipeline_events.py
  • examples/cpp/NeuralAssistedStereo/neural_assisted_stereo.cpp
  • examples/python/DynamicCalibration/calibration_dynamic.py
  • examples/python/NeuralAssistedStereo/neural_assisted_stereo.py
  • examples/cpp/ToF/tof_minimal.cpp
  • examples/cpp/NeuralDepth/neural_depth.cpp
  • examples/cpp/ImageAlign/depth_align.cpp
  • examples/cpp/Depth/unified_depth.cpp
  • examples/cpp/DetectionNetwork/detection_network_remap.cpp
  • examples/cpp/NeuralDepth/neural_depth_align.cpp
  • examples/cpp/SpatialLocationCalculator/spatial_segmentation.cpp
  • examples/python/NeuralDepth/neural_depth_align.py
  • examples/python/StereoDepth/stereo.py
  • examples/cpp/StereoDepth/depth_preview.cpp
  • examples/python/ToF/tof_align.py
  • examples/python/Vpp/virtual_patern_projection.py
  • examples/python/ObjectTracker/object_tracker_remap.py
  • examples/python/StereoDepth/stereo_runtime_calibration_update.py
  • examples/python/DetectionNetwork/detection_network_remap.py
  • examples/python/Depth/depth_rgb_align.py
  • examples/python/ImageAlign/depth_align.py
  • examples/python/StereoDepth/stereo_depth_from_host.py
  • examples/python/SpatialDetectionNetwork/spatial_detection.py
  • examples/python/AutoCalibration/auto_calibration_example.py
🪛 Cppcheck (2.21.0)
src/opencv/ColorizeDepthFrame.cpp

[error] 120-120: There is an unknown macro here somewhere. Configuration is required. If DEPTHAI_NLOHMANN_DEFINE_TYPE_INTRUSIVE is a macro then please configure it.

(unknownMacro)

🪛 Ruff (0.15.21)
examples/python/SpatialLocationCalculator/spatial_segmentation.py

[warning] 65-65: Boolean positional value in function call

(FBT003)

examples/python/Remapping/point_remapping.py

[warning] 117-117: Boolean positional value in function call

(FBT003)

examples/python/StereoDepth/stereo_depth_remap.py

[warning] 28-28: Boolean positional value in function call

(FBT003)

examples/python/SpatialLocationCalculator/spatial_keypoints.py

[warning] 102-102: Boolean positional value in function call

(FBT003)

examples/python/NeuralDepth/neural_depth_minimal.py

[warning] 24-24: Boolean positional value in function call

(FBT003)

examples/python/PointCloud/point_cloud_visualizer.py

[warning] 114-114: Boolean positional value in function call

(FBT003)

examples/python/DynamicCalibration/calibration_integration.py

[warning] 62-62: Boolean positional value in function call

(FBT003)

examples/python/DynamicCalibration/calibration_quality_dynamic.py

[warning] 60-60: Boolean positional value in function call

(FBT003)

examples/python/Misc/PipelineDebugging/get_pipeline_state.py

[warning] 29-29: Boolean positional value in function call

(FBT003)

examples/python/NeuralDepth/neural_depth.py

[warning] 56-56: Boolean positional value in function call

(FBT003)

examples/python/Misc/PipelineDebugging/node_pipeline_events.py

[warning] 31-31: Boolean positional value in function call

(FBT003)

examples/python/DynamicCalibration/calibration_dynamic.py

[warning] 66-66: Boolean positional value in function call

(FBT003)

examples/python/NeuralAssistedStereo/neural_assisted_stereo.py

[warning] 27-27: Boolean positional value in function call

(FBT003)

examples/python/StereoDepth/stereo.py

[warning] 28-28: Boolean positional value in function call

(FBT003)

examples/python/Vpp/virtual_patern_projection.py

[warning] 86-86: Boolean positional value in function call

(FBT003)

examples/python/StereoDepth/stereo_runtime_calibration_update.py

[warning] 39-39: Boolean positional value in function call

(FBT003)

examples/python/StereoDepth/stereo_depth_from_host.py

[warning] 1142-1142: Boolean positional value in function call

(FBT003)

examples/python/SpatialDetectionNetwork/spatial_detection.py

[warning] 39-39: Boolean positional value in function call

(FBT003)

examples/python/AutoCalibration/auto_calibration_example.py

[warning] 124-124: Boolean positional value in function call

(FBT003)

🔇 Additional comments (58)
include/depthai/depthai.hpp (1)

24-27: LGTM!

include/depthai/utility/ColorizeDepthFrame.hpp (1)

1-59: LGTM!

src/opencv/ColorizeDepthFrame.cpp (1)

97-118: LGTM!

CMakeLists.txt (1)

468-468: LGTM!

bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp (1)

11-11: LGTM!

Also applies to: 329-349

examples/cpp/AutoCalibration/auto_calibration_example.cpp (1)

132-132: LGTM!

examples/cpp/Depth/depth_rgb_align.cpp (1)

137-137: LGTM!

examples/cpp/Depth/unified_depth.cpp (1)

298-298: LGTM!

examples/cpp/DetectionNetwork/detection_network_remap.cpp (1)

24-24: LGTM!

Also applies to: 103-103

examples/cpp/DynamicCalibration/calibration_dynamic.cpp (1)

35-35: LGTM!

Also applies to: 57-62

examples/cpp/NeuralDepth/neural_depth.cpp (1)

43-43: LGTM!

Also applies to: 85-86

examples/cpp/NeuralDepth/neural_depth_minimal.cpp (1)

41-49: LGTM!

examples/python/Depth/unified_depth.py (1)

183-183: LGTM!

examples/python/SpatialLocationCalculator/spatial_segmentation.py (1)

65-65: LGTM!

examples/python/ToF/tof_minimal.py (1)

35-35: LGTM!

examples/cpp/DynamicCalibration/calibration_integration.cpp (1)

48-48: LGTM!

Also applies to: 66-71

examples/cpp/ImageAlign/depth_align.cpp (1)

128-128: LGTM!

examples/cpp/Misc/PipelineDebugging/get_pipeline_state.cpp (1)

25-30: LGTM!

examples/cpp/NeuralDepth/neural_depth_align.cpp (1)

114-114: LGTM!

examples/cpp/ObjectTracker/object_tracker_remap.cpp (1)

17-17: LGTM!

Also applies to: 102-102

examples/cpp/Remapping/point_remapping.cpp (1)

182-182: LGTM!

examples/cpp/SpatialLocationCalculator/spatial_segmentation.cpp (1)

132-132: LGTM!

examples/cpp/StereoDepth/stereo.cpp (1)

34-40: LGTM!

Also applies to: 52-52

examples/cpp/ToF/tof_align.cpp (1)

106-112: LGTM!

examples/cpp/ToF/tof_minimal.cpp (1)

23-23: LGTM!

examples/cpp/Vpp/virtual_patern_projection.cpp (1)

77-77: LGTM!

examples/cpp/Misc/PipelineDebugging/node_pipeline_events.cpp (1)

25-32: LGTM!

examples/cpp/StereoDepth/depth_preview.cpp (1)

38-53: LGTM!

examples/python/DynamicCalibration/calibration_dynamic.py (1)

23-31: LGTM!

Also applies to: 61-67

examples/python/Misc/PipelineDebugging/get_pipeline_state.py (1)

23-30: LGTM!

examples/python/Misc/PipelineDebugging/node_pipeline_events.py (1)

23-32: LGTM!

examples/python/NeuralDepth/neural_depth_minimal.py (1)

17-25: LGTM!

examples/python/PointCloud/point_cloud_visualizer.py (1)

114-114: LGTM!

examples/python/SpatialLocationCalculator/spatial_keypoints.py (1)

102-102: LGTM!

examples/python/StereoDepth/stereo.py (1)

21-29: LGTM!

examples/python/StereoDepth/stereo_runtime_calibration_update.py (1)

26-40: LGTM!

examples/cpp/SpatialDetectionNetwork/spatial_detection.cpp (1)

47-55: LGTM!

examples/cpp/SpatialLocationCalculator/spatial_location_calculator.cpp (1)

91-91: LGTM!

examples/cpp/StereoDepth/stereo_depth_remap.cpp (1)

34-35: LGTM!

Also applies to: 93-93

examples/python/AutoCalibration/auto_calibration_example.py (1)

124-124: LGTM!

examples/python/DynamicCalibration/calibration_integration.py (1)

37-37: LGTM!

Also applies to: 57-62, 93-93

examples/python/DynamicCalibration/calibration_quality_dynamic.py (1)

37-37: LGTM!

Also applies to: 55-61

examples/python/SpatialDetectionNetwork/spatial_detection.py (1)

39-39: LGTM!

examples/python/SpatialLocationCalculator/spatial_location_calculator.py (1)

62-62: LGTM!

examples/python/StereoDepth/stereo_depth_remap.py (1)

27-28: LGTM!

Also applies to: 61-61

examples/python/Vpp/virtual_patern_projection.py (1)

86-86: LGTM!

examples/python/StereoDepth/stereo_depth_from_host.py (1)

1140-1142: 🎯 Functional Correctness

No change needed. GRAYF16 maps cv::Mat float32 input through convertTo(CV_16FC1), and colorizeDepthFrame(CV_32F) accepts FP16 depth input before converting it internally.

			> Likely an incorrect or invalid review comment.
examples/cpp/ToF/tof_all_queues.cpp (2)

1-11: LGTM!


44-44: 🩺 Stability & Availability

No change needed.

ImgFrame::getCvFrame() is documented to return a copied cv::Mat, so the temporary ImgFrame does not keep displayFrame alive.

			> Likely an incorrect or invalid review comment.
examples/python/Depth/depth_rgb_align.py (1)

2-3: LGTM!

Also applies to: 56-57, 107-107

examples/python/DetectionNetwork/detection_network_remap.py (1)

5-6: LGTM!

Also applies to: 28-38, 83-84

examples/python/ImageAlign/depth_align.py (1)

2-5: LGTM!

Also applies to: 60-61, 108-108

examples/python/NeuralDepth/neural_depth.py (1)

20-21: LGTM!

Also applies to: 28-29, 54-56

examples/python/NeuralDepth/neural_depth_align.py (1)

2-5: LGTM!

Also applies to: 52-66, 100-100

examples/python/ObjectTracker/object_tracker_remap.py (1)

5-5: LGTM!

Also applies to: 34-44

examples/python/Remapping/point_remapping.py (1)

117-117: LGTM!

examples/python/ToF/tof_align.py (1)

14-18: LGTM!

Also applies to: 94-94

examples/python/ToF/tof_all_queues.py (1)

11-14: LGTM!

Also applies to: 60-60

Comment thread examples/cpp/NeuralAssistedStereo/neural_assisted_stereo.cpp Outdated
Comment thread examples/python/NeuralAssistedStereo/neural_assisted_stereo.py Outdated
Comment thread src/opencv/ColorizeDepthFrame.cpp
@JakubFara
JakubFara force-pushed the feature/colorize-depth-frame branch from 9fe20da to e08dd0a Compare July 27, 2026 13:18
Introduces dai::utility::colorizeDepthFrame C++ overloads (cv::Mat and
ImgFrame) plus Python bindings, supporting min/max depth, colormap and
log/linear scaling. Replaces inline cv2.applyColorMap / cv::applyColorMap
calls in C++ and Python depth examples with the new helper.
@JakubFara
JakubFara force-pushed the feature/colorize-depth-frame branch from e08dd0a to fbfd800 Compare July 27, 2026 13:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/python/AutoCalibration/auto_calibration_example.py`:
- Line 124: Update the colorizeDepthFrame calls in
examples/python/AutoCalibration/auto_calibration_example.py:124-124,
examples/python/NeuralAssistedStereo/neural_assisted_stereo.py:27-27,
examples/python/NeuralDepth/neural_depth.py:56-56, and
examples/python/Vpp/virtual_patern_projection.py:86-86 to pass the existing
False value as the explicit keyword argument useLog=False.

In `@examples/python/DynamicCalibration/calibration_dynamic.py`:
- Line 66: Replace the fifth positional argument in each dai.colorizeDepthFrame
call with the named useLog=True argument to satisfy Ruff FBT003 and make the
scaling mode explicit. Apply this change at
examples/python/DynamicCalibration/calibration_dynamic.py:66-66,
examples/python/DynamicCalibration/calibration_integration.py:62-62,
examples/python/DynamicCalibration/calibration_quality_dynamic.py:60-60,
examples/python/Misc/PipelineDebugging/get_pipeline_state.py:29-29,
examples/python/Misc/PipelineDebugging/node_pipeline_events.py:31-31,
examples/python/NeuralDepth/neural_depth_minimal.py:24-24,
examples/python/StereoDepth/stereo.py:28-28, and
examples/python/StereoDepth/stereo_runtime_calibration_update.py:39-39.

In `@examples/python/PointCloud/point_cloud_visualizer.py`:
- Line 114: Replace the final positional False argument with the explicit
useLog=False keyword in dai.colorizeDepthFrame calls at
examples/python/PointCloud/point_cloud_visualizer.py:114-114,
examples/python/Remapping/point_remapping.py:117-117,
examples/python/SpatialDetectionNetwork/spatial_detection.py:39-39,
examples/python/SpatialLocationCalculator/spatial_keypoints.py:102-102,
examples/python/SpatialLocationCalculator/spatial_segmentation.py:65-65, and
examples/python/StereoDepth/stereo_depth_remap.py:28-28, preserving the existing
linear-scaling behavior.

In `@examples/python/SpatialLocationCalculator/spatial_location_calculator.py`:
- Line 62: Update the depth colorization call in the SpatialLocationCalculator
example to pass useLog=false explicitly, preserving the previous linear depth
mapping and matching the intended C++ behavior. Keep the existing depth frame
and range arguments unchanged.

In `@src/opencv/ColorizeDepthFrame.cpp`:
- Around line 48-49: Update the invalidMask construction in the depth
colorization flow to mark every non-finite or non-positive depth as invalid, not
only values equal to zero. Ensure this mask is used to exclude those pixels from
auto-ranging and log scaling, and preserve the resulting black output for
invalid pixels.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8cf84b8a-524d-4a45-99da-aa61ee7adcbf

📥 Commits

Reviewing files that changed from the base of the PR and between 9fe20da and 154fb6c.

📒 Files selected for processing (59)
  • CMakeLists.txt
  • bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp
  • examples/cpp/AutoCalibration/auto_calibration_example.cpp
  • examples/cpp/Depth/depth_rgb_align.cpp
  • examples/cpp/Depth/unified_depth.cpp
  • examples/cpp/DetectionNetwork/detection_network_remap.cpp
  • examples/cpp/DynamicCalibration/calibration_dynamic.cpp
  • examples/cpp/DynamicCalibration/calibration_integration.cpp
  • examples/cpp/ImageAlign/depth_align.cpp
  • examples/cpp/Misc/PipelineDebugging/get_pipeline_state.cpp
  • examples/cpp/Misc/PipelineDebugging/node_pipeline_events.cpp
  • examples/cpp/NeuralAssistedStereo/neural_assisted_stereo.cpp
  • examples/cpp/NeuralDepth/neural_depth.cpp
  • examples/cpp/NeuralDepth/neural_depth_align.cpp
  • examples/cpp/NeuralDepth/neural_depth_minimal.cpp
  • examples/cpp/ObjectTracker/object_tracker_remap.cpp
  • examples/cpp/Remapping/point_remapping.cpp
  • examples/cpp/SpatialDetectionNetwork/spatial_detection.cpp
  • examples/cpp/SpatialLocationCalculator/spatial_location_calculator.cpp
  • examples/cpp/SpatialLocationCalculator/spatial_segmentation.cpp
  • examples/cpp/StereoDepth/depth_preview.cpp
  • examples/cpp/StereoDepth/stereo.cpp
  • examples/cpp/StereoDepth/stereo_depth_remap.cpp
  • examples/cpp/ToF/tof_align.cpp
  • examples/cpp/ToF/tof_all_queues.cpp
  • examples/cpp/ToF/tof_minimal.cpp
  • examples/cpp/Vpp/virtual_patern_projection.cpp
  • examples/python/AutoCalibration/auto_calibration_example.py
  • examples/python/Depth/depth_rgb_align.py
  • examples/python/Depth/unified_depth.py
  • examples/python/DetectionNetwork/detection_network_remap.py
  • examples/python/DynamicCalibration/calibration_dynamic.py
  • examples/python/DynamicCalibration/calibration_integration.py
  • examples/python/DynamicCalibration/calibration_quality_dynamic.py
  • examples/python/ImageAlign/depth_align.py
  • examples/python/Misc/PipelineDebugging/get_pipeline_state.py
  • examples/python/Misc/PipelineDebugging/node_pipeline_events.py
  • examples/python/NeuralAssistedStereo/neural_assisted_stereo.py
  • examples/python/NeuralDepth/neural_depth.py
  • examples/python/NeuralDepth/neural_depth_align.py
  • examples/python/NeuralDepth/neural_depth_minimal.py
  • examples/python/ObjectTracker/object_tracker_remap.py
  • examples/python/PointCloud/point_cloud_visualizer.py
  • examples/python/Remapping/point_remapping.py
  • examples/python/SpatialDetectionNetwork/spatial_detection.py
  • examples/python/SpatialLocationCalculator/spatial_keypoints.py
  • examples/python/SpatialLocationCalculator/spatial_location_calculator.py
  • examples/python/SpatialLocationCalculator/spatial_segmentation.py
  • examples/python/StereoDepth/stereo.py
  • examples/python/StereoDepth/stereo_depth_from_host.py
  • examples/python/StereoDepth/stereo_depth_remap.py
  • examples/python/StereoDepth/stereo_runtime_calibration_update.py
  • examples/python/ToF/tof_align.py
  • examples/python/ToF/tof_all_queues.py
  • examples/python/ToF/tof_minimal.py
  • examples/python/Vpp/virtual_patern_projection.py
  • include/depthai/depthai.hpp
  • include/depthai/utility/ColorizeDepthFrame.hpp
  • src/opencv/ColorizeDepthFrame.cpp
📜 Review details
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-05-28T13:36:26.383Z
Learnt from: moratom
Repo: luxonis/depthai-core PR: 1812
File: examples/cpp/ImageManip/image_manip_remap.cpp:51-52
Timestamp: 2026-05-28T13:36:26.383Z
Learning: In depthai-core example code, do not set `ImageManip::Backend::GPU` unconditionally. The GPU backend is only available on RVC4 (not RVC2). Prefer leaving the backend as the default, or comment out the GPU backend selection and add a clear note explaining it is RVC4-only support (so the example won’t fail or mislead on RVC2).

Applied to files:

  • examples/python/PointCloud/point_cloud_visualizer.py
  • examples/cpp/Misc/PipelineDebugging/get_pipeline_state.cpp
  • examples/cpp/SpatialLocationCalculator/spatial_location_calculator.cpp
  • examples/cpp/NeuralDepth/neural_depth_minimal.cpp
  • examples/cpp/ToF/tof_minimal.cpp
  • examples/python/ToF/tof_minimal.py
  • examples/cpp/Remapping/point_remapping.cpp
  • examples/python/Remapping/point_remapping.py
  • examples/cpp/Misc/PipelineDebugging/node_pipeline_events.cpp
  • examples/cpp/NeuralAssistedStereo/neural_assisted_stereo.cpp
  • examples/python/DynamicCalibration/calibration_quality_dynamic.py
  • examples/cpp/StereoDepth/stereo_depth_remap.cpp
  • examples/cpp/StereoDepth/stereo.cpp
  • examples/cpp/ToF/tof_all_queues.cpp
  • examples/python/Misc/PipelineDebugging/get_pipeline_state.py
  • examples/cpp/StereoDepth/depth_preview.cpp
  • examples/python/SpatialLocationCalculator/spatial_location_calculator.py
  • examples/python/StereoDepth/stereo.py
  • examples/python/ObjectTracker/object_tracker_remap.py
  • examples/python/SpatialLocationCalculator/spatial_keypoints.py
  • examples/cpp/DetectionNetwork/detection_network_remap.cpp
  • examples/python/DynamicCalibration/calibration_dynamic.py
  • examples/python/ToF/tof_all_queues.py
  • examples/cpp/AutoCalibration/auto_calibration_example.cpp
  • examples/cpp/NeuralDepth/neural_depth.cpp
  • examples/python/StereoDepth/stereo_runtime_calibration_update.py
  • examples/cpp/NeuralDepth/neural_depth_align.cpp
  • examples/python/Depth/depth_rgb_align.py
  • examples/python/SpatialDetectionNetwork/spatial_detection.py
  • examples/python/StereoDepth/stereo_depth_remap.py
  • examples/cpp/Vpp/virtual_patern_projection.cpp
  • examples/python/NeuralDepth/neural_depth.py
  • examples/cpp/SpatialDetectionNetwork/spatial_detection.cpp
  • examples/cpp/ImageAlign/depth_align.cpp
  • examples/python/NeuralDepth/neural_depth_minimal.py
  • examples/python/StereoDepth/stereo_depth_from_host.py
  • examples/python/NeuralDepth/neural_depth_align.py
  • examples/cpp/Depth/unified_depth.cpp
  • examples/cpp/Depth/depth_rgb_align.cpp
  • examples/python/Misc/PipelineDebugging/node_pipeline_events.py
  • examples/python/SpatialLocationCalculator/spatial_segmentation.py
  • examples/python/DetectionNetwork/detection_network_remap.py
  • examples/cpp/SpatialLocationCalculator/spatial_segmentation.cpp
  • examples/cpp/DynamicCalibration/calibration_integration.cpp
  • examples/cpp/ToF/tof_align.cpp
  • examples/python/ImageAlign/depth_align.py
  • examples/python/DynamicCalibration/calibration_integration.py
  • examples/python/Vpp/virtual_patern_projection.py
  • examples/python/NeuralAssistedStereo/neural_assisted_stereo.py
  • examples/cpp/DynamicCalibration/calibration_dynamic.cpp
  • examples/python/ToF/tof_align.py
  • examples/python/Depth/unified_depth.py
  • examples/cpp/ObjectTracker/object_tracker_remap.cpp
  • examples/python/AutoCalibration/auto_calibration_example.py
🪛 Cppcheck (2.21.0)
examples/cpp/ToF/tof_minimal.cpp

[error] 18-18: There is an unknown macro here somewhere. Configuration is required. If DEPTHAI_NLOHMANN_DEFINE_TYPE_INTRUSIVE is a macro then please configure it.

(unknownMacro)

src/opencv/ColorizeDepthFrame.cpp

[error] 120-120: There is an unknown macro here somewhere. Configuration is required. If DEPTHAI_NLOHMANN_DEFINE_TYPE_INTRUSIVE is a macro then please configure it.

(unknownMacro)

examples/cpp/ToF/tof_align.cpp

[error] 18-18: There is an unknown macro here somewhere. Configuration is required. If DEPTHAI_NLOHMANN_DEFINE_TYPE_INTRUSIVE is a macro then please configure it.

(unknownMacro)

🪛 Ruff (0.15.21)
examples/python/PointCloud/point_cloud_visualizer.py

[warning] 114-114: Boolean positional value in function call

(FBT003)

examples/python/Remapping/point_remapping.py

[warning] 117-117: Boolean positional value in function call

(FBT003)

examples/python/DynamicCalibration/calibration_quality_dynamic.py

[warning] 60-60: Boolean positional value in function call

(FBT003)

examples/python/Misc/PipelineDebugging/get_pipeline_state.py

[warning] 29-29: Boolean positional value in function call

(FBT003)

examples/python/StereoDepth/stereo.py

[warning] 28-28: Boolean positional value in function call

(FBT003)

examples/python/SpatialLocationCalculator/spatial_keypoints.py

[warning] 102-102: Boolean positional value in function call

(FBT003)

examples/python/DynamicCalibration/calibration_dynamic.py

[warning] 66-66: Boolean positional value in function call

(FBT003)

examples/python/StereoDepth/stereo_runtime_calibration_update.py

[warning] 39-39: Boolean positional value in function call

(FBT003)

examples/python/SpatialDetectionNetwork/spatial_detection.py

[warning] 39-39: Boolean positional value in function call

(FBT003)

examples/python/StereoDepth/stereo_depth_remap.py

[warning] 28-28: Boolean positional value in function call

(FBT003)

examples/python/NeuralDepth/neural_depth.py

[warning] 56-56: Boolean positional value in function call

(FBT003)

examples/python/NeuralDepth/neural_depth_minimal.py

[warning] 24-24: Boolean positional value in function call

(FBT003)

examples/python/StereoDepth/stereo_depth_from_host.py

[warning] 1142-1142: Boolean positional value in function call

(FBT003)

examples/python/Misc/PipelineDebugging/node_pipeline_events.py

[warning] 31-31: Boolean positional value in function call

(FBT003)

examples/python/SpatialLocationCalculator/spatial_segmentation.py

[warning] 65-65: Boolean positional value in function call

(FBT003)

examples/python/DynamicCalibration/calibration_integration.py

[warning] 62-62: Boolean positional value in function call

(FBT003)

examples/python/Vpp/virtual_patern_projection.py

[warning] 86-86: Boolean positional value in function call

(FBT003)

examples/python/NeuralAssistedStereo/neural_assisted_stereo.py

[warning] 27-27: Boolean positional value in function call

(FBT003)

examples/python/AutoCalibration/auto_calibration_example.py

[warning] 124-124: Boolean positional value in function call

(FBT003)

🔇 Additional comments (48)
include/depthai/utility/ColorizeDepthFrame.hpp (1)

1-53: LGTM!

src/opencv/ColorizeDepthFrame.cpp (1)

1-47: LGTM!

Also applies to: 50-122

include/depthai/depthai.hpp (1)

24-28: LGTM!

CMakeLists.txt (1)

468-468: LGTM!

bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp (1)

11-11: LGTM!

Also applies to: 329-350

examples/python/Depth/depth_rgb_align.py (1)

107-107: LGTM!

examples/python/Depth/unified_depth.py (1)

183-183: LGTM!

examples/python/DetectionNetwork/detection_network_remap.py (1)

28-38: LGTM!

examples/python/ImageAlign/depth_align.py (1)

108-108: LGTM!

examples/python/ObjectTracker/object_tracker_remap.py (1)

34-44: LGTM!

examples/python/DynamicCalibration/calibration_dynamic.py (1)

23-31: LGTM!

Also applies to: 61-65

examples/python/DynamicCalibration/calibration_integration.py (1)

37-37: LGTM!

Also applies to: 57-61, 93-93

examples/python/DynamicCalibration/calibration_quality_dynamic.py (1)

37-37: LGTM!

Also applies to: 55-59, 61-61

examples/python/Misc/PipelineDebugging/get_pipeline_state.py (1)

23-28: LGTM!

Also applies to: 30-30

examples/python/Misc/PipelineDebugging/node_pipeline_events.py (1)

23-30: LGTM!

Also applies to: 32-32

examples/python/NeuralDepth/neural_depth_align.py (1)

100-100: LGTM!

examples/python/NeuralDepth/neural_depth_minimal.py (1)

17-23: LGTM!

Also applies to: 25-25

examples/python/StereoDepth/stereo.py (1)

21-27: LGTM!

Also applies to: 29-29

examples/python/StereoDepth/stereo_runtime_calibration_update.py (1)

26-38: LGTM!

Also applies to: 40-40

examples/python/StereoDepth/stereo_depth_from_host.py (1)

1140-1142: 🎯 Functional Correctness

No change needed for setCvFrame() on GRAYF16.

setCvFrame() converts the input OpenCV/NumPy data to the declared type, so passing float32 data with dai.ImgFrame.Type.GRAYF16 is supported.

examples/python/ToF/tof_align.py (1)

5-15: LGTM!

Also applies to: 21-24, 96-96

examples/python/ToF/tof_all_queues.py (1)

13-17: LGTM!

Also applies to: 59-59

examples/python/ToF/tof_minimal.py (1)

13-15: LGTM!

Also applies to: 36-36

examples/cpp/AutoCalibration/auto_calibration_example.cpp (1)

132-132: LGTM!

examples/cpp/Depth/depth_rgb_align.cpp (1)

137-137: LGTM!

examples/cpp/Misc/PipelineDebugging/node_pipeline_events.cpp (1)

25-32: LGTM!

examples/cpp/NeuralDepth/neural_depth.cpp (1)

43-43: LGTM!

Also applies to: 85-86

examples/cpp/Remapping/point_remapping.cpp (1)

182-182: LGTM!

examples/cpp/SpatialDetectionNetwork/spatial_detection.cpp (1)

47-55: LGTM!

examples/cpp/SpatialLocationCalculator/spatial_location_calculator.cpp (1)

91-91: LGTM!

examples/cpp/SpatialLocationCalculator/spatial_segmentation.cpp (1)

132-132: LGTM!

examples/cpp/StereoDepth/stereo_depth_remap.cpp (1)

34-35: LGTM!

Also applies to: 93-93

examples/cpp/Depth/unified_depth.cpp (1)

298-298: LGTM!

examples/cpp/ImageAlign/depth_align.cpp (1)

128-128: LGTM!

examples/cpp/Misc/PipelineDebugging/get_pipeline_state.cpp (1)

25-30: LGTM!

examples/cpp/NeuralAssistedStereo/neural_assisted_stereo.cpp (1)

27-32: LGTM! The previously flagged disparity/depth mismatch is resolved — the output now correctly comes from neuralAssistedStereo->depth.

examples/cpp/ToF/tof_align.cpp (1)

73-96: LGTM!

examples/cpp/ToF/tof_all_queues.cpp (1)

8-13: LGTM!

Also applies to: 50-51

examples/cpp/ToF/tof_minimal.cpp (1)

5-22: LGTM!

examples/cpp/Vpp/virtual_patern_projection.cpp (1)

77-77: LGTM!

examples/cpp/DetectionNetwork/detection_network_remap.cpp (1)

24-24: LGTM!

Also applies to: 103-103, 130-130

examples/cpp/DynamicCalibration/calibration_dynamic.cpp (1)

35-35: LGTM!

Also applies to: 54-62

examples/cpp/DynamicCalibration/calibration_integration.cpp (1)

48-48: LGTM!

Also applies to: 66-71

examples/cpp/NeuralDepth/neural_depth_align.cpp (1)

114-114: LGTM!

examples/cpp/NeuralDepth/neural_depth_minimal.cpp (1)

41-49: LGTM!

examples/cpp/ObjectTracker/object_tracker_remap.cpp (1)

17-17: LGTM!

Also applies to: 102-102

examples/cpp/StereoDepth/depth_preview.cpp (1)

38-53: LGTM!

examples/cpp/StereoDepth/stereo.cpp (1)

34-40: LGTM!

Also applies to: 52-52

Comment thread examples/python/AutoCalibration/auto_calibration_example.py Outdated
Comment thread examples/python/DynamicCalibration/calibration_dynamic.py Outdated
Comment thread examples/python/PointCloud/point_cloud_visualizer.py Outdated
Comment thread examples/python/SpatialLocationCalculator/spatial_location_calculator.py Outdated
Comment thread src/opencv/ColorizeDepthFrame.cpp Outdated
@JakubFara
JakubFara force-pushed the feature/colorize-depth-frame branch from 0b79ae6 to eaace1f Compare July 28, 2026 10:17

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/opencv/ColorizeDepthFrame.cpp (2)

112-120: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Preserve metadata in the fallback frame.

The success path copies input metadata, but the exception path returns an output without timestamps, sequence information, or transformations. Call output.setMetadata(frame) before constructing the zero-filled fallback.

Proposed fix
     } catch(const std::exception&) {
         ImgFrame output;
+        output.setMetadata(frame);
         if(frame.getWidth() > 0 && frame.getHeight() > 0) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/opencv/ColorizeDepthFrame.cpp` around lines 112 - 120, Update the
exception fallback in the ColorizeDepthFrame processing method to call
output.setMetadata(frame) before constructing the zero-filled image data,
preserving timestamps, sequence information, and transformations while leaving
the existing size, type, and return behavior unchanged.

55-83: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Validate explicit depth bounds before scaling.

The maxDepth <= minDepth check does not catch NaN values, and negative minDepth values make std::log(minDepth + EPS) undefined/NaN when logarithmic scaling is enabled. Validate finite bounds before the auto-range fallback, and require non-negative bounds before logarithmic scaling.

Proposed validation
         cv::Mat depth32f;
         frame.convertTo(depth32f, CV_32F);

+        if(!std::isfinite(minDepth) || !std::isfinite(maxDepth)) {
+            return cv::Mat::zeros(frame.size(), CV_8UC3);
+        }
+
         if(maxDepth <= minDepth) {
             const auto range = computeAutoDepthRange(depth32f, invalidMask);
             minDepth = range.first;
             maxDepth = range.second;
@@
         cv::Mat scaled;
         if(useLog) {
+            if(minDepth < 0.0f || maxDepth <= 0.0f) {
+                return cv::Mat::zeros(frame.size(), CV_8UC3);
+            }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/opencv/ColorizeDepthFrame.cpp` around lines 55 - 83, Update the
depth-bound validation in the colorization flow before auto-range fallback to
reject non-finite minDepth or maxDepth values, while retaining the existing
ordering check. Before the useLog branch computes logarithms, require both
bounds to be non-negative and return the existing zero image for invalid bounds;
preserve normal scaling for valid finite ranges.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/opencv/ColorizeDepthFrame.cpp`:
- Around line 112-120: Update the exception fallback in the ColorizeDepthFrame
processing method to call output.setMetadata(frame) before constructing the
zero-filled image data, preserving timestamps, sequence information, and
transformations while leaving the existing size, type, and return behavior
unchanged.
- Around line 55-83: Update the depth-bound validation in the colorization flow
before auto-range fallback to reject non-finite minDepth or maxDepth values,
while retaining the existing ordering check. Before the useLog branch computes
logarithms, require both bounds to be non-negative and return the existing zero
image for invalid bounds; preserve normal scaling for valid finite ranges.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 304ad483-5294-4363-a9b6-a0e30743f894

📥 Commits

Reviewing files that changed from the base of the PR and between 154fb6c and 0b79ae6.

📒 Files selected for processing (12)
  • examples/cpp/NeuralDepth/neural_depth.cpp
  • examples/cpp/StereoDepth/stereo_depth_remap.cpp
  • examples/python/DynamicCalibration/calibration_dynamic.py
  • examples/python/DynamicCalibration/calibration_integration.py
  • examples/python/DynamicCalibration/calibration_quality_dynamic.py
  • examples/python/Misc/PipelineDebugging/get_pipeline_state.py
  • examples/python/Misc/PipelineDebugging/node_pipeline_events.py
  • examples/python/NeuralAssistedStereo/neural_assisted_stereo.py
  • examples/python/NeuralDepth/neural_depth_minimal.py
  • examples/python/StereoDepth/stereo.py
  • examples/python/StereoDepth/stereo_runtime_calibration_update.py
  • src/opencv/ColorizeDepthFrame.cpp
📜 Review details
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-05-28T13:36:26.383Z
Learnt from: moratom
Repo: luxonis/depthai-core PR: 1812
File: examples/cpp/ImageManip/image_manip_remap.cpp:51-52
Timestamp: 2026-05-28T13:36:26.383Z
Learning: In depthai-core example code, do not set `ImageManip::Backend::GPU` unconditionally. The GPU backend is only available on RVC4 (not RVC2). Prefer leaving the backend as the default, or comment out the GPU backend selection and add a clear note explaining it is RVC4-only support (so the example won’t fail or mislead on RVC2).

Applied to files:

  • examples/python/DynamicCalibration/calibration_quality_dynamic.py
  • examples/python/NeuralAssistedStereo/neural_assisted_stereo.py
  • examples/python/DynamicCalibration/calibration_integration.py
  • examples/python/DynamicCalibration/calibration_dynamic.py
  • examples/cpp/StereoDepth/stereo_depth_remap.cpp
  • examples/cpp/NeuralDepth/neural_depth.cpp
  • examples/python/Misc/PipelineDebugging/get_pipeline_state.py
  • examples/python/NeuralDepth/neural_depth_minimal.py
  • examples/python/StereoDepth/stereo.py
  • examples/python/Misc/PipelineDebugging/node_pipeline_events.py
  • examples/python/StereoDepth/stereo_runtime_calibration_update.py
🪛 Ruff (0.15.21)
examples/python/NeuralAssistedStereo/neural_assisted_stereo.py

[warning] 27-27: Boolean positional value in function call

(FBT003)

🔇 Additional comments (15)
src/opencv/ColorizeDepthFrame.cpp (3)

5-5: LGTM!

Also applies to: 11-54


86-99: LGTM!

Also applies to: 101-111


124-125: LGTM!

examples/cpp/NeuralDepth/neural_depth.cpp (1)

43-43: LGTM!

Also applies to: 52-52, 85-86

examples/cpp/StereoDepth/stereo_depth_remap.cpp (1)

34-35: LGTM!

Also applies to: 93-93, 127-127

examples/python/NeuralAssistedStereo/neural_assisted_stereo.py (2)

27-27: Use the named useLog argument.

The positional False triggers Ruff FBT003 and obscures the scaling mode. This repeats the existing finding; change it to useLog=False.

🧰 Proposed fix
-            cv.imshow("Depth", dai.colorizeDepthFrame(depth, 500, 12000, cv.COLORMAP_TURBO, False).getCvFrame())
+            cv.imshow("Depth", dai.colorizeDepthFrame(depth, 500, 12000, cv.COLORMAP_TURBO, useLog=False).getCvFrame())

Source: Linters/SAST tools


21-26: LGTM!

examples/python/DynamicCalibration/calibration_dynamic.py (1)

66-66: LGTM!

examples/python/DynamicCalibration/calibration_integration.py (1)

62-62: LGTM!

examples/python/DynamicCalibration/calibration_quality_dynamic.py (1)

60-60: LGTM!

examples/python/Misc/PipelineDebugging/get_pipeline_state.py (1)

29-29: LGTM!

examples/python/Misc/PipelineDebugging/node_pipeline_events.py (1)

31-31: LGTM!

examples/python/NeuralDepth/neural_depth_minimal.py (1)

24-24: LGTM!

examples/python/StereoDepth/stereo.py (1)

28-28: LGTM!

examples/python/StereoDepth/stereo_runtime_calibration_update.py (1)

39-39: LGTM!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/opencv/ColorizeDepthFrame.cpp (1)

65-81: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject invalid depth bounds before logarithmic scaling.

With useLog=True, a negative or non-finite minDepth/maxDepth makes std::log(...) return NaN. Since NaN comparisons do not trigger the logMaxDepth <= logMinDepth guard, valid pixels can be scaled as NaN and produce misleading output.

Validate finite, non-negative bounds after auto-ranging and before calculating logarithms.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/opencv/ColorizeDepthFrame.cpp` around lines 65 - 81, In the useLog branch
of the depth-colorization flow, validate the auto-ranged minDepth and maxDepth
before computing logMinDepth/logMaxDepth: both must be finite and non-negative.
For invalid bounds, return the existing zero-valued output, then retain the
current logarithmic scaling and ordering guard for valid bounds.
examples/python/StereoDepth/stereo_runtime_calibration_update.py (1)

58-58: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Do not silently swallow calibration readback failures.

except: pass hides whether calibration retrieval or coefficient access failed, making the interactive update appear successful when it was not. Catch the expected exception type and print or log the failure.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/python/StereoDepth/stereo_runtime_calibration_update.py` at line 58,
Update the exception handling around the calibration readback in the interactive
update flow: replace the bare except/pass with the expected exception type and
print or log the failure details. Preserve successful calibration retrieval and
coefficient access behavior while ensuring failures are visible.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp`:
- Around line 348-349: Update the docstring for the depth-frame colorization
binding to describe auto-range computation from finite positive pixels instead
of “non-zero” pixels. Modify only the documentation string near the
maxDepth/minDepth behavior and preserve the existing implementation.

---

Outside diff comments:
In `@examples/python/StereoDepth/stereo_runtime_calibration_update.py`:
- Line 58: Update the exception handling around the calibration readback in the
interactive update flow: replace the bare except/pass with the expected
exception type and print or log the failure details. Preserve successful
calibration retrieval and coefficient access behavior while ensuring failures
are visible.

In `@src/opencv/ColorizeDepthFrame.cpp`:
- Around line 65-81: In the useLog branch of the depth-colorization flow,
validate the auto-ranged minDepth and maxDepth before computing
logMinDepth/logMaxDepth: both must be finite and non-negative. For invalid
bounds, return the existing zero-valued output, then retain the current
logarithmic scaling and ordering guard for valid bounds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0344d0be-6519-4e5a-939b-ae526dd1642f

📥 Commits

Reviewing files that changed from the base of the PR and between 0b79ae6 and eaace1f.

📒 Files selected for processing (51)
  • bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp
  • examples/cpp/Depth/depth_rgb_align.cpp
  • examples/cpp/Depth/unified_depth.cpp
  • examples/cpp/DetectionNetwork/detection_network_remap.cpp
  • examples/cpp/DynamicCalibration/calibration_dynamic.cpp
  • examples/cpp/DynamicCalibration/calibration_integration.cpp
  • examples/cpp/ImageAlign/depth_align.cpp
  • examples/cpp/Misc/PipelineDebugging/get_pipeline_state.cpp
  • examples/cpp/Misc/PipelineDebugging/node_pipeline_events.cpp
  • examples/cpp/NeuralDepth/neural_depth.cpp
  • examples/cpp/NeuralDepth/neural_depth_align.cpp
  • examples/cpp/NeuralDepth/neural_depth_minimal.cpp
  • examples/cpp/ObjectTracker/object_tracker_remap.cpp
  • examples/cpp/SpatialLocationCalculator/spatial_location_calculator.cpp
  • examples/cpp/StereoDepth/depth_preview.cpp
  • examples/cpp/StereoDepth/stereo.cpp
  • examples/cpp/StereoDepth/stereo_depth_remap.cpp
  • examples/cpp/ToF/tof_align.cpp
  • examples/cpp/ToF/tof_all_queues.cpp
  • examples/cpp/ToF/tof_minimal.cpp
  • examples/python/AutoCalibration/auto_calibration_example.py
  • examples/python/Depth/depth_rgb_align.py
  • examples/python/Depth/unified_depth.py
  • examples/python/DetectionNetwork/detection_network_remap.py
  • examples/python/DynamicCalibration/calibration_dynamic.py
  • examples/python/DynamicCalibration/calibration_integration.py
  • examples/python/DynamicCalibration/calibration_quality_dynamic.py
  • examples/python/ImageAlign/depth_align.py
  • examples/python/Misc/PipelineDebugging/get_pipeline_state.py
  • examples/python/Misc/PipelineDebugging/node_pipeline_events.py
  • examples/python/NeuralAssistedStereo/neural_assisted_stereo.py
  • examples/python/NeuralDepth/neural_depth.py
  • examples/python/NeuralDepth/neural_depth_align.py
  • examples/python/NeuralDepth/neural_depth_minimal.py
  • examples/python/ObjectTracker/object_tracker_remap.py
  • examples/python/PointCloud/point_cloud_visualizer.py
  • examples/python/Remapping/point_remapping.py
  • examples/python/SpatialDetectionNetwork/spatial_detection.py
  • examples/python/SpatialLocationCalculator/spatial_keypoints.py
  • examples/python/SpatialLocationCalculator/spatial_location_calculator.py
  • examples/python/SpatialLocationCalculator/spatial_segmentation.py
  • examples/python/StereoDepth/stereo.py
  • examples/python/StereoDepth/stereo_depth_from_host.py
  • examples/python/StereoDepth/stereo_depth_remap.py
  • examples/python/StereoDepth/stereo_runtime_calibration_update.py
  • examples/python/ToF/tof_align.py
  • examples/python/ToF/tof_all_queues.py
  • examples/python/ToF/tof_minimal.py
  • examples/python/Vpp/virtual_patern_projection.py
  • include/depthai/utility/ColorizeDepthFrame.hpp
  • src/opencv/ColorizeDepthFrame.cpp
📜 Review details
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-05-28T13:36:26.383Z
Learnt from: moratom
Repo: luxonis/depthai-core PR: 1812
File: examples/cpp/ImageManip/image_manip_remap.cpp:51-52
Timestamp: 2026-05-28T13:36:26.383Z
Learning: In depthai-core example code, do not set `ImageManip::Backend::GPU` unconditionally. The GPU backend is only available on RVC4 (not RVC2). Prefer leaving the backend as the default, or comment out the GPU backend selection and add a clear note explaining it is RVC4-only support (so the example won’t fail or mislead on RVC2).

Applied to files:

  • examples/cpp/Misc/PipelineDebugging/get_pipeline_state.cpp
  • examples/cpp/Misc/PipelineDebugging/node_pipeline_events.cpp
  • examples/cpp/SpatialLocationCalculator/spatial_location_calculator.cpp
  • examples/python/ToF/tof_minimal.py
  • examples/cpp/NeuralDepth/neural_depth_minimal.cpp
  • examples/cpp/ToF/tof_minimal.cpp
  • examples/cpp/StereoDepth/stereo.cpp
  • examples/python/PointCloud/point_cloud_visualizer.py
  • examples/python/Remapping/point_remapping.py
  • examples/cpp/ImageAlign/depth_align.cpp
  • examples/python/DynamicCalibration/calibration_quality_dynamic.py
  • examples/cpp/NeuralDepth/neural_depth_align.cpp
  • examples/cpp/ToF/tof_align.cpp
  • examples/python/SpatialLocationCalculator/spatial_location_calculator.py
  • examples/cpp/Depth/unified_depth.cpp
  • examples/python/DynamicCalibration/calibration_dynamic.py
  • examples/python/ToF/tof_all_queues.py
  • examples/python/SpatialLocationCalculator/spatial_keypoints.py
  • examples/cpp/ToF/tof_all_queues.cpp
  • examples/python/StereoDepth/stereo_depth_remap.py
  • examples/python/Vpp/virtual_patern_projection.py
  • examples/python/Depth/depth_rgb_align.py
  • examples/python/StereoDepth/stereo.py
  • examples/python/StereoDepth/stereo_depth_from_host.py
  • examples/python/ImageAlign/depth_align.py
  • examples/python/Depth/unified_depth.py
  • examples/python/AutoCalibration/auto_calibration_example.py
  • examples/python/Misc/PipelineDebugging/get_pipeline_state.py
  • examples/cpp/NeuralDepth/neural_depth.cpp
  • examples/cpp/ObjectTracker/object_tracker_remap.cpp
  • examples/python/NeuralDepth/neural_depth_minimal.py
  • examples/python/ToF/tof_align.py
  • examples/cpp/StereoDepth/depth_preview.cpp
  • examples/python/NeuralAssistedStereo/neural_assisted_stereo.py
  • examples/python/NeuralDepth/neural_depth_align.py
  • examples/cpp/StereoDepth/stereo_depth_remap.cpp
  • examples/cpp/DynamicCalibration/calibration_dynamic.cpp
  • examples/python/SpatialDetectionNetwork/spatial_detection.py
  • examples/cpp/DetectionNetwork/detection_network_remap.cpp
  • examples/python/Misc/PipelineDebugging/node_pipeline_events.py
  • examples/python/DetectionNetwork/detection_network_remap.py
  • examples/cpp/Depth/depth_rgb_align.cpp
  • examples/python/StereoDepth/stereo_runtime_calibration_update.py
  • examples/python/DynamicCalibration/calibration_integration.py
  • examples/python/NeuralDepth/neural_depth.py
  • examples/python/ObjectTracker/object_tracker_remap.py
  • examples/cpp/DynamicCalibration/calibration_integration.cpp
  • examples/python/SpatialLocationCalculator/spatial_segmentation.py
🔇 Additional comments (51)
examples/cpp/Depth/depth_rgb_align.cpp (1)

68-69: LGTM!

Also applies to: 137-137

examples/cpp/Depth/unified_depth.cpp (1)

32-32: LGTM!

Also applies to: 298-298

examples/cpp/DetectionNetwork/detection_network_remap.cpp (1)

1-14: LGTM!

Also applies to: 24-24, 103-103, 130-130

examples/cpp/DynamicCalibration/calibration_dynamic.cpp (1)

2-2: LGTM!

Also applies to: 35-35, 54-62

examples/cpp/ObjectTracker/object_tracker_remap.cpp (1)

1-8: LGTM!

Also applies to: 17-17, 102-102

examples/cpp/StereoDepth/depth_preview.cpp (1)

38-53: LGTM!

examples/cpp/StereoDepth/stereo_depth_remap.cpp (1)

34-35: LGTM!

Also applies to: 93-93, 127-127

examples/cpp/ToF/tof_align.cpp (1)

1-13: LGTM!

Also applies to: 85-85

examples/cpp/ToF/tof_all_queues.cpp (1)

1-1: LGTM!

Also applies to: 9-13, 51-51

examples/cpp/ToF/tof_minimal.cpp (1)

1-5: LGTM!

Also applies to: 22-22

examples/cpp/DynamicCalibration/calibration_integration.cpp (1)

48-48: LGTM!

Also applies to: 57-57, 66-71

examples/cpp/ImageAlign/depth_align.cpp (1)

46-47: LGTM!

Also applies to: 128-128

examples/cpp/Misc/PipelineDebugging/get_pipeline_state.cpp (1)

25-30: LGTM!

examples/cpp/Misc/PipelineDebugging/node_pipeline_events.cpp (1)

25-32: LGTM!

examples/cpp/NeuralDepth/neural_depth.cpp (1)

43-43: LGTM!

Also applies to: 51-51, 85-86

examples/cpp/NeuralDepth/neural_depth_align.cpp (1)

42-43: LGTM!

Also applies to: 114-114

examples/cpp/NeuralDepth/neural_depth_minimal.cpp (1)

41-49: LGTM!

examples/cpp/SpatialLocationCalculator/spatial_location_calculator.cpp (1)

91-91: LGTM!

Also applies to: 198-198

examples/cpp/StereoDepth/stereo.cpp (1)

34-40: LGTM!

Also applies to: 52-52

include/depthai/utility/ColorizeDepthFrame.hpp (1)

14-31: LGTM!

Also applies to: 32-49

examples/python/AutoCalibration/auto_calibration_example.py (1)

4-5: LGTM!

Also applies to: 124-124

examples/python/Depth/depth_rgb_align.py (1)

2-3: LGTM!

Also applies to: 56-58, 107-107

examples/python/DetectionNetwork/detection_network_remap.py (1)

4-5: LGTM!

Also applies to: 28-38, 81-83

examples/python/DynamicCalibration/calibration_dynamic.py (1)

23-31: LGTM!

Also applies to: 42-42, 61-67

examples/python/DynamicCalibration/calibration_integration.py (1)

37-37: LGTM!

Also applies to: 49-49, 57-62, 93-93

examples/python/NeuralDepth/neural_depth_align.py (1)

2-2: LGTM!

Also applies to: 52-55, 100-100, 124-124

examples/python/NeuralDepth/neural_depth_minimal.py (1)

4-5: LGTM!

Also applies to: 17-25

examples/python/SpatialLocationCalculator/spatial_segmentation.py (1)

65-65: LGTM!

examples/python/StereoDepth/stereo_depth_from_host.py (1)

1127-1128: LGTM!

Also applies to: 1140-1142

src/opencv/ColorizeDepthFrame.cpp (1)

5-5: LGTM!

Also applies to: 11-64, 82-99, 101-122

bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp (1)

11-11: LGTM!

Also applies to: 328-347

examples/python/Depth/unified_depth.py (1)

36-45: LGTM!

Also applies to: 183-183

examples/python/DynamicCalibration/calibration_quality_dynamic.py (1)

37-37: LGTM!

Also applies to: 49-61

examples/python/ImageAlign/depth_align.py (1)

2-3: LGTM!

Also applies to: 60-62, 108-108

examples/python/NeuralDepth/neural_depth.py (1)

20-20: LGTM!

Also applies to: 28-29, 54-56

examples/python/PointCloud/point_cloud_visualizer.py (1)

114-114: LGTM!

examples/python/Remapping/point_remapping.py (1)

117-117: LGTM!

examples/python/SpatialDetectionNetwork/spatial_detection.py (1)

6-7: LGTM!

Also applies to: 33-39

examples/python/SpatialLocationCalculator/spatial_keypoints.py (1)

102-102: LGTM!

examples/python/StereoDepth/stereo_depth_remap.py (1)

27-28: LGTM!

Also applies to: 61-61

examples/python/Misc/PipelineDebugging/get_pipeline_state.py (1)

1-1: LGTM!

Also applies to: 23-30

examples/python/Misc/PipelineDebugging/node_pipeline_events.py (1)

2-2: LGTM!

Also applies to: 23-32

examples/python/NeuralAssistedStereo/neural_assisted_stereo.py (1)

1-5: LGTM!

Also applies to: 21-27

examples/python/ObjectTracker/object_tracker_remap.py (1)

5-5: LGTM!

Also applies to: 34-44

examples/python/SpatialLocationCalculator/spatial_location_calculator.py (1)

59-62: LGTM!

examples/python/StereoDepth/stereo.py (1)

5-5: LGTM!

Also applies to: 21-29

examples/python/StereoDepth/stereo_runtime_calibration_update.py (1)

26-57: LGTM!

examples/python/ToF/tof_align.py (1)

14-14: LGTM!

Also applies to: 21-24, 96-96

examples/python/ToF/tof_all_queues.py (1)

11-16: LGTM!

Also applies to: 59-59

examples/python/ToF/tof_minimal.py (1)

11-15: LGTM!

Also applies to: 36-36

examples/python/Vpp/virtual_patern_projection.py (1)

1-1: LGTM!

Also applies to: 14-15, 86-86

Comment thread bindings/python/src/pipeline/datatype/ImgFrameBindings.cpp Outdated
@JakubFara
JakubFara force-pushed the feature/colorize-depth-frame branch from 859cbde to ae3541b Compare July 28, 2026 11:35

@MaticTonin MaticTonin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please unify the API to be same for cpp and py since now its dai.::utility::... in CPP, in dai.colo... in python,
unify for dai.utility,colorize...

@aljazkonec1 aljazkonec1 added the testable PR is ready to be tested - run vanilla tests label Aug 11, 2026
@aljazkonec1
aljazkonec1 requested a review from MaticTonin August 11, 2026 18:02
@aljazkonec1
aljazkonec1 merged commit fcd9684 into develop Aug 11, 2026
40 of 51 checks passed
@aljazkonec1
aljazkonec1 deleted the feature/colorize-depth-frame branch August 11, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testable PR is ready to be tested - run vanilla tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants