fix: ToF example colorization flicker - #1906
Conversation
Map depth-to-color interpolation from the fixed minDepth/maxDepth log range instead of each frame's own min/max, so a given depth always maps to the same color instead of flickering as the per-frame range shifts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughToF examples now use fixed logarithmic ChangesToF depth visualization
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant tof_align
participant Alignment
participant Sync
participant Windows
User->>tof_align: Select camera and adjust RGB weight
tof_align->>Alignment: Run host alignment
Alignment->>Sync: Send aligned depth
tof_align->>Sync: Send RGB
Sync->>tof_align: Return synchronized frames
tof_align->>Windows: Display depth and blended overlay
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
JakubFara
left a comment
There was a problem hiding this comment.
Fix also C++ examples
Map depth-to-color interpolation from the fixed minDepth/maxDepth log range instead of each frame's own min/max, matching the Python examples, so a given depth always maps to the same color instead of flickering. Also rewrites tof_align.cpp to match tof_align.py: drops the ToFDepthConfidenceFilter block and its extra window, builds the ToF node with CameraBoardSocket::AUTO instead of a hardcoded socket, and adds a --camera left|right flag to pick the align target camera. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
06c52ef to
a8d1538
Compare
Bring all ToF examples (C++ and Python) to a consistent 30 FPS, add RVC2/RVC4 output-queue detection to tof_all_queues.cpp to match the Python version, and remove leftover comments/typos.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/ToF/tof_align.cpp`:
- Line 11: Align the synchronization threshold units used by the C++ tof_align
example at FPS and the Python tof_align example, using one shared millisecond or
frame-count convention so both retain the same effective margin. Update
examples/cpp/ToF/tof_align.cpp:11 and examples/python/ToF/tof_align.py:17
consistently; adjust the threshold calculations in the synchronization logic
without changing unrelated behavior.
🪄 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: 19fa5544-1358-413e-b860-e40a6fed0eb1
📒 Files selected for processing (7)
examples/cpp/ToF/tof_align.cppexamples/cpp/ToF/tof_all_queues.cppexamples/cpp/ToF/tof_minimal.cppexamples/python/ToF/tof_align.pyexamples/python/ToF/tof_all_queues.pyexamples/python/ToF/tof_minimal.pyexamples/python/ToF/tof_pointcloud.py
📜 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/ToF/tof_minimal.pyexamples/python/ToF/tof_pointcloud.pyexamples/cpp/ToF/tof_minimal.cppexamples/cpp/ToF/tof_all_queues.cppexamples/python/ToF/tof_align.pyexamples/python/ToF/tof_all_queues.pyexamples/cpp/ToF/tof_align.cpp
🔇 Additional comments (8)
examples/python/ToF/tof_pointcloud.py (1)
9-9: LGTM!Also applies to: 21-21, 30-30
examples/cpp/ToF/tof_align.cpp (1)
17-43: LGTM!Also applies to: 45-51, 53-72, 73-85, 89-103, 104-130
examples/cpp/ToF/tof_all_queues.cpp (1)
2-9: LGTM!Also applies to: 11-37, 45-68
examples/cpp/ToF/tof_minimal.cpp (1)
6-7: LGTM!Also applies to: 25-27, 40-45
examples/python/ToF/tof_align.py (2)
5-6: LGTM!
24-37: LGTM!examples/python/ToF/tof_all_queues.py (1)
14-14: LGTM!Also applies to: 17-30, 40-48, 61-62
examples/python/ToF/tof_minimal.py (1)
14-14: LGTM!Also applies to: 17-30, 41-44
Use double-precision seconds converted to nanoseconds instead of truncating to whole milliseconds, matching the exact half-frame-period margin used by the Python tof_align example. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
@JakubFara up to you to confirm & merge. Thanks. |
Summary
Summary by CodeRabbit