With Erel's contributions I was able to put together a demo that tests using setPreviewCallbackWithBuffer versus using setPreviewCallback when capturing preview images from the camera. I've attached the demo to this post.
According to many forum posts I've read on the Internet the "WithBuffer" version of this callback was said to be significantly faster than the "allocating a new preview buffer each time" version of the function. I thought it might be worth looking at to see if I can increase the preview frame rate.
The demo has three configurations:
Default – uses the current CameraEx equivalent of setPreviewCallback
PrevBuf – uses the setPreviewCallbackWithBuffer function to set the call back
Process – same as PrevBuf adding some typical processing of the preview image
The upper left image in the demo is the preview panel initialized with Camera. The upper right image is the rotated JPEG acquired in the preview call back. The upper right image works only in the third configuration.
The button beneath the images is disabled in the first configuration. In the second and third configurations it starts the preview buffer activity. This is needed because of the anomaly mentioned by Erel above.
The row of numbers shows the preview image size (note: I hardcoded a size of 640x480. On startup the log output shows a list of supported sizes – be sure 640x480 is in the list for your device), the number of milliseconds between preview call back invocations, and the number of milliseconds required for my image processing.
The seek bar allows you to adjust the Frames per Second throttle in my image processing. This seek bar is used only in the third configuration.
The demo also includes two CustomViews I created (I'm in love with CustomViews
). The row of numbers uses something I call Heading Labels. The seek bar uses a Label Seek Bar.
The results I got were very surprising. There seems to be no speed up using the "With Buffer" version. In fact, the setPreviewCallback version seemed to be slightly faster.
Here are a couple of good links I uncovered. The first link explains why the preview images seem to be rotated funny.
http://www.impulseadventure.com/photo/exif-orientation.html
The second link talks a little bit about setPreviewCallbackWithBuffer.
http://txt.arboreus.com/2012/03/02/android-setpreviewcallbackwithbuffer-buffer-in-the.html
Barry.