PDA

View Full Version : Capturing the raw image from webcam and display it on QWidget



syclopse
18th July 2011, 07:21
Hi,

I am capturing the raw image and forming the QImage and then using the QImage to QPixmap conversion I am displaying it on QLabel.

Now the problem is that my CPU usage is 70-75 %.

and I want to reduce that
so Please suggest me the solution,
or the defect where my program is consuming more memory.

stampede
18th July 2011, 09:47
Probably you are capturing the images in some kind of while(1) loop, right ?
Here (http://www.qtcentre.org/threads/43056-Qt-OpenCV-simple-example) I have posted an example of capturing, processing and converting raw image data to QImage, QImage to QPixmap and displaying it in QLabel. Conversion of raw data to QImage is done pixel-by-pixel, surely its not optimal. Without image processing CPU usage in task manager is ~19-23%, and ~50% with image processing step.
Post the code, without it we can only guess. Am I right with while(1) ? :)

syclopse
18th July 2011, 14:54
Thanks for reply,

But that my code is also taking the same CPU usage with image processing but that is too high,
so I want to reduce that ....
and I am capturing the image using separate thread ....

stampede
18th July 2011, 16:00
But that my code is also taking the same CPU usage with image processing but that is too high
Why is that too high ? Are users complaining ? System hangs ?
If you want your program to do something more than displaying still ui, you wont escape some CPU load.

and I am capturing the image using separate thread ....
Ok, can you show the capture code ?

syclopse
22nd July 2011, 07:40
Actually I am capturing Image from webcam at 2048x1536 resolution and processing rotation and zooming on it.

but I anyhow want to reduce the CPU usage that my application is using.

any other way is also invited ....