Multi-Threaded Image Processing using Qt Camera
This article shows how to apply live image processing effects to the camera viewfinder using multi-threading and capture full resolution snapshots.
Image processing is a resource intensive task. This article describes means how to apply image processing effects to the camera viewfinder using multi-threading to keep the user interface responsive. The following topics are covered in detail:
- Using the Qt Mobility camera class in Qml.
- Spawning a worker thread for background image processing.
- Adding a simple black and white effect.
- Discussion about hardware acceleration.
The code provided here shows only the most important functional parts. The full code can be downloaded here (TODO).
Using the Qt Mobility Camera in Qml
The Qml camera component provides basic means to view and capture camera images directly from the Qml scripting language. For our purpose the Qml camera is not suitable because we need (i) live viewfinder image data stream and (ii) the final image as a data stream. In this article a stripped-down version of the custom Qml camera component from the Qt Camera Demo is used which uses the Qt Mobility Camera classes.
First, the Qt Mobility dependency and Symbian capabilities have to be added to the project (*.pro) file:
TARGET.CAPABILITY += LocalServices \ # camera
ReadUserData \ #
WriteUserData \ # writing image file
UserEnvironment # camera
On Symbian, depending on the expected memory usage the heap- and stack sizes should be increased as well:
TARGET.EPOCSTACKSIZE = 0x14000
TARGET.EPOCHEAPSIZE = 0x20000 0x8000000
Add categories below. Remove Category:Draft when the page is complete or near complete