RViz drawing extra pixel on left and right of image

asked 2019-11-26 01:56:43 -0500

KenYN gravatar image

On more than one standard image_transport::ImageTransport topic that we publish to with straightforward code below, when we view the image topic in RViz, depending on the size of the window we see a ghost one-pixel line to the left and right of the image which appears to be an extra pixel wrapping around from the other side of the image. eg:

image description

The freehand circles indicate extra pixels that do not appear if I directly capture the topic with rosrun image_view image_view image:=/my_topic and press the Save button. The lines also disappear and reappear as I change the height of the window. On the right-hand line there is a whiter pixel that lines up with the white line on the left-hand side, which leads me to believe this is an off-by-one (or off by 0.5?) rounding bug somewhere.

The code:

class ImageTransportPublisher
{
private:
    std::unique_ptr<image_transport::ImageTransport> m_it;
    image_transport::Publisher m_imageRawPublisher;

public:
    void advertise(ros::NodeHandle &nh, char const * const topic)
    {
        advertise(nh, std::string(topic));
    }

    void advertise(ros::NodeHandle &nh, std::string const &topic)
    {
        m_it = std::unique_ptr<image_transport::ImageTransport>(new image_transport::ImageTransport(nh));
        m_imageRawPublisher = m_it->advertise(topic, 1u);
    }

    uint32_t getNumSubscribers() const
    {
        return m_imageRawPublisher.getNumSubscribers();
    }

    void publish(cv::Mat const &image, std_msgs::Header const &header, std::string const &encoding = sensor_msgs::image_encodings::BGR8) const
    {
        const cv_bridge::CvImage image_message(header, encoding, image);
        m_imageRawPublisher.publish(image_message.toImageMsg());
    }
};
edit retag flag offensive close merge delete

Comments

This reads like a potential bug report, which should probably be posted on the RViz issue tracker.

And I believe the 'correct' terminology could be "cheese".

gvdhoorn gravatar image gvdhoorn  ( 2019-11-26 02:09:32 -0500 )edit

I've just looked at the bug tracker, and it's there. What's the best course of action here since it's a known issue?

KenYN gravatar image KenYN  ( 2019-11-26 02:16:36 -0500 )edit
1

I would suggest adding your information and potentially ask for instructions on how to fix it. A PR would then be perfect. Robert has been somewhat more active as a maintainer, so perhaps you can get things to move that way.

gvdhoorn gravatar image gvdhoorn  ( 2019-11-26 02:19:07 -0500 )edit