How to display a videostream in the PyQt GUI by a efficient way

David Boddie david at
Sun Sep 30 20:15:33 CEST 2007

On Sun Sep 30 09:10:40 CEST 2007, Kivilaya wrote:

>    I read the method in the given link and learn a lot from it. I'll
> try to display the data inside a QWidget directly instead of the
> current way. But I still have a question, is there any way to make the
> displaying of RGB data in a QWidget more quickly.

You can set certain flags to ensure that the widget isn't being updated
or painted on too often. See the WA_OpaquePaintEvent and
WA_NoSystemBackground flags:

The problem may be related to the conversion process rather than the time
it takes to display the image. You mentioned that you were obtaining the
images as PIL Image objects, but these need to be converted to QImage or
QPixmap objects, so the raw data from the camera is being converted at
least twice before it reaches the screen!

>    In fact, my work is to make a gui for displaying my
> partners'experimental results to our teacher, the source video is no
> need to be encoded to mpeg or h264 format, so I get the video from
> camera in the raw format and display them without encodeing or
> decoding process.

Which operating system is this on? (I'm guessing that it's Windows because
you mentioned the videocapture module.)

>    As my partners will do some experiments on the raw data, maybe add
> a mark to label some area in the current frame, or change some part of
> it, I get every frame as a picture before they process the picture
> data, and then display the picture after their process.

So, do you intend to process the video and store it in a file, or do you
want to make these changes on a live video stream?

> But displaying the pictures one by one in my current way is so slow,
> I'm afraid that time spend on it is too long and the displaying of
> results will be discontinuous. So I think maybe there is another way
> to show these pictures.

Is there another way of getting the data from the camera? Perhaps the
author of videocapture has some ideas that can help you speed up the
conversion and rendering process. Maybe the Device.getBuffer() function
will provide data that can be passed directly to QPixmap.loadFromData().


More information about the Python-list mailing list