PDA

View Full Version : Higher CPU resource consumption while continous painting on the QLabel



syclopse
2nd July 2011, 14:42
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 ....

mvuori
3rd July 2011, 10:40
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.

syclopse
4th July 2011, 11:13
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 ....

stampede
4th July 2011, 12:03
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 ?

syclopse
4th July 2011, 13:43
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.

stampede
4th July 2011, 14:21
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.

ChrisW67
5th July 2011, 05:38
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?

syclopse
5th July 2011, 06:59
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.

ChrisW67
5th July 2011, 07:32
"(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.