Results 1 to 9 of 9

Thread: Higher CPU resource consumption while continous painting on the QLabel

  1. #1
    Join Date
    Apr 2011
    Posts
    39
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Higher CPU resource consumption while continous painting on the QLabel

    Hi,
    I am continuously capturing image from webcam and setting the QPixmap of that QImage on QLabel,

    now this process consume more than half of my resources of CPU (CPU Usage)
    so kindly please guide me to the efficient solution,

    another approach for displaying the captured QImage is also welcomed,
    I have also used the QGraphicsView but it also takes the same,

    so help ....

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Higher CPU resource consumption while continous painting on the QLabel

    I'll offer this:
    * Move the task of gathering the image stream to a low-priority thread.
    * Reduce resolution.
    * As there is a conversion between QPixmap and QImage involved, I'd check that image formats are as economical as possible.
    * Don't process all frames if you don't need to.
    * Change webcam settings and try another webcam driver.

  3. #3
    Join Date
    Apr 2011
    Posts
    39
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Higher CPU resource consumption while continous painting on the QLabel

    for me 3.2 megapixel resolution is compulsory,
    so only thing I can do is to remove the conversion from QImage to QPixmap,
    so Please kindly guide me how can I convert "(uchar*)" data to QPixmap directly,
    Please guide me with an example ....

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Higher CPU resource consumption while continous painting on the QLabel

    another approach for displaying the captured QImage is also welcomed,
    You can display incoming image data using OpenGL, without conversion to QImage. Is there a reason why you want to display images in QLabel ?

  5. #5
    Join Date
    Apr 2011
    Posts
    39
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Higher CPU resource consumption while continous painting on the QLabel

    ya,
    because I want to apply cropping and zooming functionality on it,
    and also resizing of window should not add scrollbar to display area.
    so that's why I have used QLabel.

  6. #6
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Higher CPU resource consumption while continous painting on the QLabel

    because I want to apply cropping and zooming functionality on it
    This can be done with OpenGL-based display as well (but will probably require more work than using QImage/QPixmap methods).
    and also resizing of window should not add scrollbar to display area.
    You can use QGLWidget subclass instead of QLabel in your layout, it won't show any scrollbars either.
    If you want to stick to QLabel based display, try to set Qt::WA_OpaquePaintEvent flag in display widget.

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Higher CPU resource consumption while continous painting on the QLabel

    Quote Originally Posted by syclopse View Post
    so Please kindly guide me how can I convert "(uchar*)" data to QPixmap directly,
    Please guide me with an example ....
    You don't tell us what format the data is in so we cannot be specific. Is there something wrong with the obvious QPixmap::loadFromData() method?

  8. #8
    Join Date
    Apr 2011
    Posts
    39
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Higher CPU resource consumption while continous painting on the QLabel

    As mentioned in QPixmap::loadFromData() function argument,
    what I am facing is that I am able to generate QImage ( constructor defination "QImage(uchar*,int,int,format)") from (uchar*) raw data,
    now QPixmap::loadFromData() function also takes an argument (uchar*),
    but than also I am not able to generate the image on QPixmap directly with QPixmap::loadFromData() function,
    That is the problem I am facing.

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Higher CPU resource consumption while continous painting on the QLabel

    "(uchar*) raw data" is not meaningful as a specification of the format of the data. From your other thread it seems you mean a series of ARGB quads with an implied geometry. You cannot load those directly into a QPixmap out-of-the-box.

    At some point you have to accept that real-time processing of video at better than HDTV (2 megapixel) resolution requires some processor power. This is why video cards and drivers have facilities for offloading various parts of the video processing work.

Similar Threads

  1. Display continous images on the screen
    By tuent in forum Newbie
    Replies: 11
    Last Post: 29th December 2010, 11:46
  2. Is QtSoap Plugin supported with Qt4.6 or higher version ?
    By abk883 in forum Installation and Deployment
    Replies: 2
    Last Post: 29th March 2010, 07:22
  3. Replies: 1
    Last Post: 29th September 2009, 20:44
  4. Replies: 2
    Last Post: 14th January 2008, 19:09
  5. QLabel Painting
    By vijay anandh in forum Qt Programming
    Replies: 4
    Last Post: 15th May 2006, 14:12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.