Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main_2025.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
for target tracking
"""
import pathlib

import pathlib


CONFIG_FILE_PATH = pathlib.Path("config.yaml")
Expand Down
49 changes: 49 additions & 0 deletions modules/target_tracking/stereo_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""
Module for initializing and configuring the StereoDepth node.
This setup aligns the depth map to the RGB camera for spatial logic.
"""

import depthai as dai


def create_stereo_depth(pipeline: dai.Pipeline) -> dai.node.StereoDepth:
"""
Creates the StereoDepth node and links it to the Mono cameras.

Args:
pipeline (dai.Pipeline): The DepthAI pipeline object.

Returns:
dai.node.StereoDepth: The configured stereo node.
"""
# --- 1. Define Sources ---
mono_left = pipeline.create(dai.node.MonoCamera)
mono_right = pipeline.create(dai.node.MonoCamera)

# Configure the hardware sockets (Left vs Right)
mono_left.setBoardSocket(dai.CameraBoardSocket.LEFT)
mono_right.setBoardSocket(dai.CameraBoardSocket.RIGHT)

# Set Resolution (400p is standard)
# Breaking line to satisfy flake8 line length limit
mono_left.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
mono_right.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)

# --- 2. Define the Processor ---
stereo = pipeline.create(dai.node.StereoDepth)

# --- 3. Configuration ---
# CRITICAL: Align depth to RGB (bc mono cams are 20 pixels off)
stereo.setDepthAlign(dai.CameraBoardSocket.RGB)

# Improve quality
stereo.setSubpixel(True)
stereo.setLeftRightCheck(True) # Removes ghost pixels at edges
# Change to True if <50cm need tracking needed
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

The comment has a grammatical error with redundant wording. The phrase "need tracking needed" should be revised to either "tracking is needed" or "tracking needed" for clarity.

Suggested change
# Change to True if <50cm need tracking needed
# Change to True if tracking is needed for distances <50cm

Copilot uses AI. Check for mistakes.
stereo.setExtendedDisparity(False)

# --- 4. Linking ---
mono_left.out.link(stereo.left)
mono_right.out.link(stereo.right)

return stereo
4 changes: 4 additions & 0 deletions requirements-pytorch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Runtime dependencies for target tracking pipeline

depthai>=2.24.0
pymavlink>=2.4.40