Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] QCamera + QPainter : is it possible?

[Solved] QCamera + QPainter : is it possible?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xtingray
    wrote on last edited by
    #1

    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!


    Qt Developer

    1 Reply Last reply
    0
    • X Offline
      X Offline
      xtingray
      wrote on last edited by
      #2

      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.

      [1] http://qt-project.org/doc/qt-4.7/demos-mobile-qcamera.html
      [2] http://www.maefloresta.com/portal/files/camera.zip


      Qt Developer

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved