Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to convert 'rgb8' image for display: 'Image is wrongly formed: height * step != size or 1080 * 5760 != 6266880' #4

Open
aviogit opened this issue Mar 12, 2018 · 2 comments

Comments

@aviogit
Copy link

aviogit commented Mar 12, 2018

I tried to create a new launch file with 1920x1080 resolution for capture. Here it is, to me it looks good.

#> cat launch/camera_module_v2_1920x1080_30fps_autocapture.launch 
<?xml version="1.0"?>
<launch>
  <arg name="name" default="raspicam_node" />
  <node type="raspicam_node" pkg="raspicam_node" name="$(arg name)" output="screen">
 
    <param name="camera_info_url" value="package://$(arg name)/camera_info/camera_module_v2_1920x1080.yaml"/>
    <param name="width" value="1920"/>
    <param name="height" value="1080"/>
    <param name="framerate" value="30"/>
    <param name="camera_frame_id" value="raspicam"/>

  </node>
  
  <node pkg="rosservice" type="rosservice" name="start_capture" args="call --wait $(arg name)/start_capture"/>

</launch>

However, when I try to subscribe to image_raw, both on the Pi3 or remotely, I get this error

[ERROR] [1520855482.326728991]: Unable to convert 'rgb8' image for display: 'Image is wrongly formed: height * step != size  or  1080 * 5760 != 6266880'

And it seems to make sense, given that 6266880 is really the msg.data.size() coming from raspicam_node.cpp:277

if(buffer->flags & (MMAL_BUFFER_HEADER_FLAG_FRAME_END | MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED)){
			sensor_msgs::Image msg;
			msg.header.seq = pData->frame;
			msg.header.frame_id = tf_prefix;
			msg.header.frame_id = camera_frame_id;
			msg.header.stamp = ros::Time::now();
			msg.height = pData->pstate->height;
			msg.width = pData->pstate->width;
			msg.encoding = "rgb8";
			msg.is_bigendian = 0;
			msg.step = pData->pstate->width*3;
			msg.data.insert( msg.data.end(), pData->buffer[pData->frame & 1], &(pData->buffer[pData->frame & 1][pData->id]) );
			image_pub.publish(msg);
			c_info.header.seq = pData->frame;
			c_info.header.stamp = msg.header.stamp;
			c_info.header.frame_id = msg.header.frame_id;
			camera_info_pub.publish(c_info);
			pData->frame++;
			pData->id = 0;
}

And before publishing, if I add:

msg.data.resize(msg.data.size()-46080);

the topic becomes valid and the image is correctly shown by image_view. Any idea on how to correctly fix this issue?

@rainfall1998
Copy link

hi did u get this solved?

@ArkadiuszNiemiec
Copy link

The problem is that raspicam_node saves the resolution from launchfile but raspivid is cheating and changing it by itself. The raspicam_node should check what the raspivid is returning and correcting set resolution accordingly.
Example: I have set a 1640x1232 resolution but raspivid returned a data with size equal to 6091008 instead of 6061440. To fix it I have changed the resolution in config to 1648x1232.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants