MATLAB Answers


Image format error when reading ROS compressed images

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.

  댓글 수: 0

로그인 to comment.

답변 수: 1

Cam Salzberger 님의 답변 13 May 2019
 채택된 답변

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.

  댓글 수: 1

Thanks Cam. I will check it.

로그인 to comment.

Translated by