christianrauch / camera_ros

ROS 2 node for libcamera supported cameras (V4L2, Raspberry Pi Camera Modules)
https://libcamera.org
MIT License
69 stars 30 forks source link

Unable to convert 'nv21' image for display #54

Closed izeemeen closed 4 months ago

izeemeen commented 4 months ago

Hi all! The following error occurs when launching a camera.launch file:

ros2 launch camera_ros camera.launch.py

[INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2024-07-24-15-29-20-427928-ubuntu-2041
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [component_container-1]: process started with pid [2053]
[component_container-1] [INFO] [1721834961.087827984] [camera_container]: Load Library: /home/ubuntu/camera_ws/install/camera_ros/lib/libcamera_component.so
[component_container-1] [INFO] [1721834961.316648791] [camera_container]: Found class: rclcpp_components::NodeFactoryTemplate<camera::CameraNode>
[component_container-1] [INFO] [1721834961.316824232] [camera_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<camera::CameraNode>
[component_container-1] [0:06:40.105212037] [2053]  INFO Camera camera_manager.cpp:313 libcamera v0.3.0+158-929978ee
[component_container-1] [0:06:40.149408044] [2064]  WARN RPiSdn sdn.cpp:40 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[component_container-1] [0:06:40.153584650] [2064]  INFO RPI vc4.cpp:400 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media0 and ISP device /dev/media1
[component_container-1] [INFO] [1721834961.397289286] [camera]: 
[component_container-1] >> stream formats:
[component_container-1]    - Pixelformat: NV21 (64x64 - 2592x1944)
[component_container-1]    - Pixelformat: XBGR8888 (64x64 - 2592x1944)
[component_container-1]    - Pixelformat: BGR888 (64x64 - 2592x1944)
[component_container-1]    - Pixelformat: RGB888 (64x64 - 2592x1944)
[component_container-1]    - Pixelformat: XRGB8888 (64x64 - 2592x1944)
[component_container-1]    - Pixelformat: YUYV (64x64 - 2592x1944)
[component_container-1]    - Pixelformat: UYVY (64x64 - 2592x1944)
[component_container-1] [WARN] [1721834961.397474543] [camera]: no pixel format selected, using default: "NV21"
[component_container-1] [WARN] [1721834961.397522486] [camera]: set parameter 'format' to silent this warning
[component_container-1] [0:06:40.155329772] [2053]  INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-NV21
[component_container-1] [0:06:40.156127465] [2064]  INFO RPI vc4.cpp:569 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 640x480-SGBRG10_1X10 - Selected unicam format: 640x480-pGAA
[component_container-1] [INFO] [1721834961.400578053] [camera]: camera "/base/soc/i2c0mux/i2c@1/ov5647@36" configured with 640x480-NV21 stream
[component_container-1] [WARN] [1721834961.403826395] [camera]: control NoiseReductionMode (10002) not handled
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/camera' in container '/camera_container'
[component_container-1] [INFO] [1721834961.522132714] [camera_container]: Load Library: /opt/ros/humble/lib/libimage_view_nodes.so
[component_container-1] [INFO] [1721834961.679897886] [camera_container]: Found class: rclcpp_components::NodeFactoryTemplate<image_view::DisparityViewNode>
[component_container-1] [INFO] [1721834961.680048365] [camera_container]: Found class: rclcpp_components::NodeFactoryTemplate<image_view::ExtractImagesNode>
[component_container-1] [INFO] [1721834961.680082642] [camera_container]: Found class: rclcpp_components::NodeFactoryTemplate<image_view::ImageSaverNode>
[component_container-1] [INFO] [1721834961.680109549] [camera_container]: Found class: rclcpp_components::NodeFactoryTemplate<image_view::ImageViewNode>
[component_container-1] [INFO] [1721834961.680141327] [camera_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<image_view::ImageViewNode>
[component_container-1] [INFO] [1721834961.698082418] [image_view_node]: Using transport "raw"
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/image_view_node' in container '/camera_container'
[component_container-1] [INFO] [1721834961.953929869] [camera]: using default calibration URL
[component_container-1] [INFO] [1721834961.954186347] [camera]: camera calibration URL: file:///home/ubuntu/.ros/camera_info/ov5647__base_soc_i2c0mux_i2c_1_ov5647_36_640x480.yaml
[component_container-1] [ERROR] [1721834961.954429862] [camera_calibration_parsers]: Unable to open camera calibration file [/home/ubuntu/.ros/camera_info/ov5647__base_soc_i2c0mux_i2c_1_ov5647_36_640x480.yaml]
[component_container-1] [WARN] [1721834961.954510398] [camera]: Camera calibration file /home/ubuntu/.ros/camera_info/ov5647__base_soc_i2c0mux_i2c_1_ov5647_36_640x480.yaml not found
[component_container-1] [ERROR] [1721834970.011306695] [image_view_node]: Unable to convert 'nv21' image for display: 'Unrecognized image encoding [nv21]'
[component_container-1] [ERROR] [1721834970.074317630] [image_view_node]: Unable to convert 'nv21' image for display: 'Unrecognized image encoding [nv21]'
[component_container-1] [ERROR] [1721834970.137519747] [image_view_node]: Unable to convert 'nv21' image for display: 'Unrecognized image encoding [nv21]'
[component_container-1] [ERROR] [1721834970.200460368] [image_view_node]: Unable to convert 'nv21' image for display: 'Unrecognized image encoding [nv21]'
[component_container-1] [ERROR] [1721834970.263405026] [image_view_node]: Unable to convert 'nv21' image for display: 'Unrecognized image encoding [nv21]'

Can you tell me how I can fix it?

christianrauch commented 4 months ago

Can you provide details about your hardware (which camera) and software (Linux distribution and libcamera version) setup?

The formats nv21 and nv24 are not supported by the cv_bridge (yet). You have to choose a different format or manually decode the raw image data. In this particular case, the format is autoselected which is then not compatible with the rest of the pipeline.

I recommend launching the node manually with your desired configuration, either by your own launch file or simply by ros2 run. If you are up for it, you can add the format parameter to the launch file, after width and height, and send a PR. This way, you can reuse the launch file with a different pixel format.

izeemeen commented 4 months ago

Thank you @christianrauch! I added "format" and it worked.