Optimize image conversion
Hey all,
I am trying to optimize some image conversion code to boost the framerate in my system. I now copy from a source pixel by pixel, but that is not really efficient.
I have a pointer to a uint8_t array, which formerly was a pointer to a char array. Either of the two should be filled in the data field of a sensor_msgs::Image message.
I am not an expert, please enlighten me with the efficient approach here! :)
uint8_t *uint8_pointer = reinterpret_cast<uint8_t*>( (unsigned char*) grayscale_channel[0].L() );
int height = atoi(height_pointer.ToString().Text());
int width = atoi(width_pointer.ToString().Text());
sensor_msgs::Image output_image;
output_image.header.stamp = timestamp.data;
output_image.height = height;
output_image.width = width;
output_image.encoding = "mono8";
output_image.is_bigendian = false;
output_image.step = 1 * width;
for(int i=0; i<(width*height);i++)
{
output_image.data.push_back(uint8_pointer[i]);
}
return output_image;
I tried simply pushing back the dereferenced pointer, however that throws an error during runtime.
The error: