0

I have a simulation in Gazebo in which I am publishing an image raw data topic which have raw image data. Now I want to display that data in qt as a video. I am not sure what I should use as a video widget. What I have in mind is to make a graphicsScene and display data as an QImage but data frequency is to high and loading it to QImage on that frequency doesnt seem to me a good approach. looking forward for optimal suggestions.

Thanks.

(p.s I am using linux 10.04 with qt4.x and Ros electric)

User97693321
  • 3,336
  • 7
  • 45
  • 69

1 Answers1

0

I already use QT+OpenCV to display an image from a webcam @20Hz, and to do this I used QImage.

To be sure, just have a look to the source code of OpenCV, they also use a QImage in the function imshow (if you compile it with QT support). Look at : the source line 2389, you will see how to set a raw image, into a QImage.

If you just want to display an image, I don't think you will need a QGraphicsScene, just set you QImage in a QLabel.

Adrien BARRAL
  • 3,474
  • 1
  • 25
  • 37
  • thanks for reply can u post simple version of code with a some comments. that would be really helpful. – zulqarnain haider Aug 23 '12 at 11:15
  • No, sorry, I hadn't the code. I just repply to your question "Isn't a good approach to use QImage". And I think that is the best approach. You can have a look to the QT image viewer example : http://qt-project.org/doc/qt-5.0/widgets-imageviewer.html. – Adrien BARRAL Aug 23 '12 at 11:22
  • 1
    The main problem using QImage is that i am unable to convert int raw image data to uchar* data to pass it to QImage constructor. can u suggest any approach to make possible this conversion? – zulqarnain haider Aug 23 '12 at 14:17
  • Ok, I can help you to do that... What is the topic you use in ROS ? If you use sensor_msgs/Image, the data are already unsigned char. – Adrien BARRAL Aug 23 '12 at 14:59
  • yes i am using the same message and its type is unit8. first of all in my callback function i am not sure how to transport data to qt widget class. what would be the best way to make it available for QImage this constructor `QImage(uchar* data, int rows, int cols, FORMAT)` – zulqarnain haider Aug 24 '12 at 02:44
  • Uint8 is a uchar, so you can statically cst – Adrien BARRAL Aug 24 '12 at 05:48