CoppeliaRobotics / simROS

Other
24 stars 13 forks source link

How to flip the image ? #9

Closed ajielin closed 2 years ago

ajielin commented 2 years ago

The image publiced in ros topic is upside down, can I solve it from the source code of this plugin,in fact, I find the code of 'imageTransportPublish' as follow , but it seems that it don't work : ` sensor_msgs::Image image_msg; image_msg.header.stamp = ros::Time::now(); image_msg.header.frame_id = in->frame_id; image_msg.encoding = sensor_msgs::image_encodings::RGB8; image_msg.width = in->width; image_msg.height = in->height; image_msg.step = image_msg.width * 3;

    int data_len = image_msg.step * image_msg.height;
    image_msg.data.resize(data_len);
    image_msg.is_bigendian = 0;

    for(unsigned int i = 0; i < image_msg.height; i++)
    {
        int msg_idx = (image_msg.height - i - 1) * image_msg.step;
        int buf_idx = i * image_msg.step;
        for(unsigned int j = 0; j < image_msg.step; j++)
        {
            image_msg.data[msg_idx + j] = in->data[buf_idx + j];
        }
    }`
fferri commented 2 years ago

Use sim.transformImage