Image format error when reading ROS compressed images

9 ビュー (過去 30 日間)
Asanka Perera
Asanka Perera 2019 年 5 月 11 日
Hi,
I am trying to read ROS compressed images from Matlab using the following commands. I use a real Turtlebot3 robot.
imgSub = rossubscriber('/raspicam_node/image/compressed');
imgMsg = receive(imgSub);
rgbImg = readImage(imgMsg);
The last line gives this error:
Error using robotics.ros.msg.sensor_msgs.CompressedImage/readImage (line 64)
Could not find a semicolon in format character vector jpg. Modify the "format" property of the message object appropriately.
I found that manually changing the ROS message format solves the problem (change from jpg to bgr8; jpeg compressed bgr8).
imgSub = rossubscriber('/raspicam_node/image/compressed');
imgMsg = receive(imgSub);
imgMsg.Format = 'bgr8; jpeg compressed bgr8';
rgbImg = readImage(imgMsg);
Can someone explain why this happens and if it is possible to solve this without hardcoding the format.
Thanks.
  1 件のコメント
Francesco Ciriello
Francesco Ciriello 2020 年 3 月 2 日
Have you tried using the '/raspicam_node/image/compressed' and '/raspicam_node/image/' messages in the Simulink readImage block? I can't seem to get anything but error code 1, i.e. Incorrect image encoding. Check that the incoming message encoding matches the ImageEncoding parameter.

サインインしてコメントする。

採用された回答

Cam Salzberger
Cam Salzberger 2019 年 5 月 13 日
Hello Asanka,
Any messages published by the image_transport package should ensure that the Format field is in the form expected by MATLAB. Consider using the image_transport system on the TurtleBot3, if that is possible.
-Cam
  1 件のコメント
Asanka Perera
Asanka Perera 2019 年 5 月 14 日
Thanks Cam. I will check it.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by