ros-perception / image_pipeline

An image processing pipeline for ROS.
Other
792 stars 727 forks source link

image_view crashes with encoding yuv422_yuy2 #1021

Open christianrauch opened 2 months ago

christianrauch commented 2 months ago

Using the image_view / image_view::ImageViewNode with image encoding yuv422_yuy2 causes exception:

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.6.0) ./modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<3, 4>; VDcn = cv::impl::{anonymous}::Set<3, 4>; VDepth = cv::impl::{anonymous}::Set<0, 2, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = cv::impl::<unnamed>::NONE; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
> Invalid number of channels in input image:
>     'VScn::contains(scn)'
> where
>     'scn' is 2

This is probably easiest reproducible with the camera_ros node:

# start camera with YUYV
ros2 run camera_ros camera_node --ros-args -p format:=YUYV
# start image view node
ros2 run image_view image_view --ros-args -r /image:=/camera/image_raw

The exception is thrown by cv::imshow.

quic-zhaoyuan commented 1 month ago

Hi @christianrauch, I have test the step on my laptop(ubuntu22.04, ros2 humble), seems it is working, cannot reproduce the issue you description image

quic-zhaoyuan commented 1 month ago

Is this issue based on specific Platform or ROS version

christianrauch commented 1 month ago

Is this issue based on specific Platform or ROS version

I tested this on Ubuntu 24.04 / ROS jazzy with and compiled the node from source.

christianrauch commented 1 month ago

I can reproduce this also with the v4l2_camera package on jazzy:

# 'v4l2_camera' package, 'sudo apt install ros-jazzy-v4l2-camera'
ros2 run v4l2_camera v4l2_camera_node --ros-args -p output_encoding:=yuv422_yuy2
ros2 run image_view image_view --ros-args -r /image:=/image_raw