0

I have a decoded video frame coming over a distributed bus. Currently, I am using a QLabel that receives the frame buffer via Qt Signal/Slot and sets it's pixmap.

void VideoViewer::slot_update_view( unsigned char* frame, QSize size )
{
        QImage img( frame, size.width(), size.height(), QImage::Format_RGB888 );
        _label->setPixmap( QPixmap::fromImage( img ).scaledToWidth( width(), Qt::SmoothTransformation ) );
}

This works, but using QLabel feels hacky. Is there a better solution? Eventually I'd like to draw on top of the video.

davepmiller
  • 2,620
  • 3
  • 33
  • 61
  • 1
    You could create a widget which just draws the image, probably using OpenGL (easy with Qt) to improve perf, and also quality if you need scaling. – hyde Apr 07 '15 at 21:44

1 Answers1

1

I'd say, the best way to make it less 'hacky' and more robust is to use some low-level image classes instead of raw pointers to buffers. For example, you could use a representation like the one in OpenCV.

Using plain buffers can be really risky, and bugs will be hard to track.

grzkv
  • 2,599
  • 3
  • 26
  • 37
  • Thanks for your answer Roman. The char* has already been decoded and checked. I'm really just interested in the best method of display, preferable within Qt. – davepmiller Apr 07 '15 at 21:42
  • Yes, but there is a risk that it can be broken. Encapsulating all the image attributes inside a single structure seems like a more reliable solution. – grzkv Apr 07 '15 at 21:45