Since I'm not all that familiar with rqt
(nor rqt_image_view) and I think that you may be looking for more than image_view, I'll have to leave it to someone else to provide an answer there. I (currently) do most of my UI work using librviz
, which allows incorporating the various RViz pieces directly into a Qt application. The librviz tutuorial is quite instructive if you choose to go this route.
First, I'd note that image display width, height, and screen position is not really dependent on the incoming image message, but rather the graphical container, so you're thinking about that wrong. Now, with a reference to the rviz::VisualizationManager
, you can do this:
rviz::VisualizationManager* visMan;
QString dispName("MyImage");
QString dispPlugin("rviz/Image");
QString imgTopic("/image/topic");
...
rviz::Display *disp = visMan->createDisplay(dispPlugin, dispName);
disp->subProp("Image Topic")->setValue(imgTopic);
Or, if you prefer to work a little closer to basic Qt, you might do something like this:
// NOTE: I'm guessing at the image format; change as needed
// NOTE: I'm assuming the image will be displayed in a QLabel
QLabel* m_imgLabel;
void MyClass::imageCb(const sensor_msgs::ImageConstPtr &msg) {
// read message contents into QImage
const unsigned char* databeg = &(msg->data.front());
QByteArray imgData = QByteArray((char*)databeg, msg->data.size());
QImage* qimg((uchar*)imgData.data(), msg->width, msg->height, QImage::Format_RGB32);
// stuff QLabel with QPixmap derived from the QImage
int w = m_imgLabel->width(), h= m_imgLabel->height();
QPixmap* qpxm;
qpxm->convertFromImage(*qimg);
qpxm = qpxm->scaled(w, h, Qt::KeepAspectRatio);
m_imgLabel->setPixmap(qpxm);
}
That's just a sketch, not a full definition, and there are complexities that need to be handled (e.g., QImage
documentation states that the data buffer must remain valid throughout the life of the QImage
).
It may also be instructive to look at a post (that I answered) concerning the use of occupancy grids with QImage and a post about setting up multiple, unadorned views in RViz (that doesn't really have a solution yet).