Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescale detections to input image #606

Open
wants to merge 8 commits into
base: iron
Choose a base branch
from

Conversation

MRo47
Copy link

@MRo47 MRo47 commented Sep 30, 2024

Overview

Author: Myron Rodrigues

Issue

Issue link (if present): #604
Issue description: Currently the NN detection output is not to scale with the input image,
I've also passed the socket parameter in nn_wrapper.cpp the default is correct but if supplied by user through constructor this might be incorrectly set

Changes

ROS distro: iron
List of changes:

  • Add a bool paramater to <sensor>_nn nodes that rescales the detection to its original input: i_desqueeze_output: false(default)
  • Pass the input image dimensions to ImgDetectionConverter in depthai-ros/depthai_ros_driver/include/depthai_ros_driver/dai_nodes/nn/detection.hpp if parameter is set.

Testing

Hardware used: OAK-D Pro Wide
Depthai library version: 2.28.0
Depthai ros version: cf5d2aaee9117298ea1632c98ffd36a5d7d535ac a commit behind iron

Visuals from testing on RGB socket

camera.yaml

/**:
  ros__parameters:
    camera:
      i_enable_imu: true
      i_enable_ir: true
      i_nn_type: RGB
      i_pipeline_type: RGB
    nn:
      i_nn_config_path: depthai_ros_driver/yolo
      i_desqueeze_output: true

complete launch file: here

camera.launch.py

detection_viz_node = ComposableNode(
    package="depthai_filters",
    plugin="depthai_filters::Detection2DOverlay",
    parameters=[
        {"label_map": detection_labels},
    ],
    remappings=[
        ("rgb/preview/image_raw", "/oak/rgb/image_raw"),
        ("nn/detections", "/oak/nn/detections"),
    ],
)

Not setting nn.i_desqueeze_output ie. default (false)

image

Setting nn.i_desqueeze_output: true

Screenshot from 2024-09-30 14-47-43

Visuals from testing on mono left socket

camera.launch.py

detection_viz_node = ComposableNode(
    package="depthai_filters",
    plugin="depthai_filters::Detection2DOverlay",
    parameters=[
        {"label_map": detection_labels},
    ],
    remappings=[
        ("rgb/preview/image_raw", "/oak/left/image_raw"),
        ("nn/detections", "/oak/left_nn/detections"),
    ],
)

camera.yaml

/**:
  ros__parameters:
    camera:
      i_enable_imu: true
      i_enable_ir: true
      i_nn_type: RGB
      i_pipeline_type: Depth
    left:
      i_publish_topic: true
      i_enable_nn: true
      i_disable_node: false
      i_resolution: '720P'
    left_nn:
      i_board_socket_id: 1
      i_nn_config_path: depthai_ros_driver/yolo
      i_desqueeze_output: true

Setting left_nn.i_desqueeze_output: true

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant