Important: Please read the Qt Code of Conduct -

[Solved] QCamera + QPainter : is it possible?

  • Hello there,

    Right now I am using some handy resources of the Qt Mobility API from my desktop application (Qt 4.8). For the latest feature, I'm working with a QCamera object to handle the video stream coming from a webcam and it works great, but I wonder if it is possible to add some kind of QImage "mask" over the video display, something like a watermark created either from a QPainter object or some kind of paint event.

    I really appreciate any hint. Thanks!

  • And the answer is yes! Finally I could find the way to do it :D

    Based on the source code of an old demo [1] I figured out the way it can be done.

    The trick behind the solution is to connect a QCamera object to an instance of a subclass (created by yourself) of QAbstractVideoSurface, from that instance you'll have access to its paint() method, where you'll be able to create a QPainter object, which means you'll be able to paint anything you want "over" the video stream.

    I made a little example [2] in case someone wants to check it out.
    Note: This code was tested successfully in a desktop environment using Ubuntu 13.10 with Qt 4.8 and the QtMobility dependency.


Log in to reply