Skip to content

Add sync subnode for FrameCropper inputs#303

Open
tadeas0 wants to merge 1 commit into
mainfrom
feat/frame-cropper-input-sync
Open

Add sync subnode for FrameCropper inputs#303
tadeas0 wants to merge 1 commit into
mainfrom
feat/frame-cropper-input-sync

Conversation

@tadeas0

@tadeas0 tadeas0 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Purpose

Add Sync subnode in front of FrameCropper inputs. This enables non-blocking queue usage earlier in the pipeline and makes the FrameCropper node more robust.

Specification

None / not applicable

Dependencies & Potential Impact

None / not applicable

Deployment Plan

None / not applicable

Testing & Validation

All oak-examples using FrameCropper work same as before after this change.

AI Usage

Assisted-by: Pi Coding Agent:GPT-5.5

Submitted code was reviewed by a human: YES

The author is taking the responsibility for the contribution: YES

Summary by CodeRabbit

  • New Features

    • Added optional timestamp synchronization thresholds for frame cropping when pairing frames with detections or manipulation configs.
    • Improved support for waiting on config data so frame processing can stay tightly synchronized with incoming inputs.
  • Bug Fixes

    • Made input handling more reliable by using synchronized input groups, reducing mismatches between frames and related metadata.

@tadeas0 tadeas0 requested a review from PetrNovota July 1, 2026 12:50
@github-actions github-actions Bot added the enhancement New feature or request label Jul 1, 2026
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

FrameCropper's Script-based cropping pipeline is refactored to synchronize frame and detection/config inputs using dai.node.Sync with a configurable syncThreshold. Script content consumes synchronized groups instead of separate ports, WAIT_FOR_CFG gating is removed, and node construction now uses createSubnode.

Changes

FrameCropper synchronized cropping pipeline

Layer / File(s) Summary
Init and subnode construction
depthai_nodes/node/frame_cropper.py
Adds cast import, initializes _sync and _sync_threshold fields, and constructs ImageManip via createSubnode.
Script content for synced inputs
depthai_nodes/node/frame_cropper.py
IMG_DETECTIONS_SCRIPT_CONTENT and MANIP_CONFIGS_SCRIPT_CONTENT read from a synchronized group input instead of separate ports; removes WAIT_FOR_CFG gating in favor of tryGet()-based config updates.
Public syncThreshold API
depthai_nodes/node/frame_cropper.py
fromImgDetections(...) and fromManipConfigs(...) accept syncThreshold: timedelta = timedelta(milliseconds=10), document synchronization behavior, and store it into _sync_threshold.
Pipeline wiring with Sync node
depthai_nodes/node/frame_cropper.py
_build_detections_cropper uses createSubnode with assertions; _build_manip_configs_cropper wires a dai.node.Sync (using _sync_threshold) linking image and detections/configs into a synced group feeding the Script, switching between synced and non-synced script content based on _wait_for_cfg.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ImageManip
  participant Sync
  participant Script

  ImageManip->>Sync: inputImage
  ImageManip->>Sync: detections/configs
  Sync->>Script: synced group (frame + detections/configs) within syncThreshold
  Script->>Script: crop/process using synced data
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a Sync subnode for FrameCropper inputs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/frame-cropper-input-sync

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

Choose a reason for hiding this comment

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

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 `@depthai_nodes/node/frame_cropper.py`:
- Around line 201-209: The docstring for the FrameCropper configuration method
should explicitly note the timestamp requirement when waitForConfig=True. Update
the text near inputManipConfigs/syncThreshold to say that the MessageGroup must
carry a timestamp aligned with inputImage because dai.node.Sync uses it to pair
config groups with frames; mention that untimestamped groups will not
synchronize. Keep the existing explanation of reuse behavior when
waitForConfig=False, and reference the FrameCropper method and waitForConfig
branch so the change is easy to locate.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 24191cb7-9ea0-4afe-af23-53f85db3faec

📥 Commits

Reviewing files that changed from the base of the PR and between d98ce6d and f179a35.

📒 Files selected for processing (1)
  • depthai_nodes/node/frame_cropper.py

Comment thread depthai_nodes/node/frame_cropper.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant