Hi,
Currently I'm building an application that is an image filter that should run in real-time. It's filter that transforms image captured from the camera and displays a transformed image just like the camera preview does.
The problem that I'm having with this is that, the performance is critical to this app, as every captured pixel should be transformed, this gives about 640x480 pixels x3 (the color dimentions; R, G, B) x about 30-50 operations per color dimension, then converting it back to RGB and generating a new image.
First, when I was testing the algorithm's functional requirements in Matlab, it took about 5-15 seconds to transform a 600x600 image on a quadcore processor. Then I've reimplemented the algorithm in the target platform which is C++ for windows mobile and now I'm getting about 0.2-0.7 frames per second when processing the same image.
The C++ version already has a lot of optimizations like pre-caching and pre-calculating the values of each color and storing the pre-calculated values in trees, reducing distances between data in memory, doing operations with bit operators rather than addition and multiplication when applicable but still the performance was not satisfying.
I tried to find out the bottleneck of the whole algorithm and started with a plain empty TransformFilter, that had on one of the end of the CaptureGraph, the video camera and on the other end the handle to a window and a renderer that should show the live preview of the camera without doing anything. It appeared to be the biggest bottleneck!
A pure preview on a windowed application on Windows Mobile 6.5 was giving me an average of 1-2 frames per second and I'm sure that it's not a matter of testing it on a slow phone. I'm testing it on HTC Diamond 2. It has ~530 MHz and it's camera application shows smooth preview at about 15-20 FPS, even when some effect is applied (like BW, Sofia) the preview performance is very high.
What I'm doing wrong?
How to get preview performance similar to the native camera application?
Is there any "mode' in Windows Mobile that would reduce the context switches and give my process a super high priority?
Thanks in advance for any answer.