ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Problem with displaying image messages inside Qt GUI with librviz

asked 2021-03-12 01:26:14 -0500

nikko gravatar image

Hey all,

I'm having a problem that my image messages are displayed in a separate window rather than inside my self-made Qt main window where they should be. Otherwise the code works and the images are showed.

I can display my point cloud messages in the GUI very easily with librviz. There is something different with image display? What is it?

Here is code snippets of both point cloud and image view display initialization in my GUI:

    void setup_rviz_lidar()

    rvizLayoutWidget = new QWidget(centralwidget);
    rvizLayoutWidget->setGeometry(QRect(400, 10, 600, 600));

    layoutRviz = new QHBoxLayout(rvizLayoutWidget);
    render_panel_ = new rviz::RenderPanel();
    layoutRviz->addWidget( render_panel_ );

    manager_ = new rviz::VisualizationManager( render_panel_ );
    render_panel_->initialize( manager_->getSceneManager(), manager_ );

    // Create point cloud display.
    laser_ = manager_->createDisplay( "rviz/PointCloud2", "Point cloud", true );
    laser_->subProp("Size (Pixels)")->setValue("2");
    laser_->subProp("Color Transformer")->setValue("Intensity");
    laser_->subProp("Invert Rainbow")->setValue("true");
    laser_->subProp("Decay Time")->setValue("1");


void setup_rviz_video() // pops up as separate window  :(
    rvizLayoutWidget2 = new QWidget(centralwidget);
    rvizLayoutWidget2->setGeometry(QRect(10, 215, 390, 390));

    layoutRviz2 = new QHBoxLayout(rvizLayoutWidget2);
    render_panel2_ = new rviz::RenderPanel();

    manager2_ = new rviz::VisualizationManager(render_panel2_);
    render_panel2_->initialize( manager2_->getSceneManager(), manager2_);

    image_ = manager2_->createDisplay( "rviz/Image", "Image", true );
    image_->subProp("Image Topic")->setValue("camera/ipximage");

Thanks in advance!


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-03-12 08:08:28 -0500

nikko gravatar image

I found one solution

Instead of using rviz::RenderPanel and rviz::VisualizationManager I utilized ImageView class. Got hint about it by investigating this graph here:

This is how it is initialized in my gui (QMainwindow):

void setup_rviz_video()
        rvizLayoutWidget2 = new QWidget(centralwidget);
        rvizLayoutWidget2->setGeometry(QRect(10, 265, 390, 345));
        layoutRviz2 = new QVBoxLayout(rvizLayoutWidget2);

        mImageview = new ImageView();


Yet I was not able to find the ImageView files anywhere in my ROS(melodic). So I just copy pasted the source and header -files to my project from the docs:

I just modified the image size and topic name in image_view.cpp and all worked well.

Please, if someone has a better, easier or faster way to do this, let me know!

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2021-03-12 01:26:14 -0500

Seen: 402 times

Last updated: Mar 12 '21