mgonzs13 / yolo_ros

Ultralytics YOLOv8, YOLOv9, YOLOv10, YOLOv11 for ROS 2
GNU General Public License v3.0
336 stars 89 forks source link

Realsense fix #13

Closed adamwhats closed 1 year ago

adamwhats commented 1 year ago

This PR changes how the 3D bounding box and keypoint markers are calculated in detect_3d_node.

The depth image and depth camera info messages are used to produce the 3D data, rather than extracting it directly from the PointCloud2 message. This is because different RGB-D camera's / ROS drivers handle the pointcloud in different ways. This change hopefully makes the package work with a broader range and cameras, as the depth image should be more consistent between manufacturers.

Initial testing results: image

mgonzs13 commented 1 year ago

Sorry for the delay. I have been testing this and I have found a minor error in the mask_z that makes 3D bb appear behind the object. This should fix it:

        center_point = depth_image[int(center_y)][int(center_x)] / self.depth_image_units_divisor
        z_diff = np.abs(roi - center_point)
        mask_z = z_diff <= self.maximum_detection_threshold
adamwhats commented 1 year ago

Ah good spot, that line was left over from an earlier version where I handled the z_min and z_max differently