I tested with original camera application (video mode) comes with Samsung Galaxy Tab 8.9. The saved front camera video able to achieve 24 fps, 640x480. (By looking at the properties of video file after transfer to Windows machine)
However, while I write front Camera
code to test.
mCamera2.setPreviewCallbackWithBuffer(new PreviewCallback() {
public void onPreviewFrame(byte[] data, Camera camera) {
// image processing code placed here.
}
});
The maximum result I can achieve is (without saving video to disk. I merely measure the callback function onPreviewFrame triggered rate)
I would like to have performance same as Samsung original camera app. May I know am I missing certain technique?
The reason you're seeing these results is that your callback is getting a sampling of the video rather than the actual video.
When the camera is dumping it's output to the file system, it's doing a very low level write operation that copies the data from the camera's video buffer to the file system, without ever touching the JVM. This is required to keep the video at a high quality and low latency, and ensures a smooth final video. If you need to do video processing on the actual video, it is better done after the video is already done being recorded.
The preview callback is merely giving you a sample of the actual video capture, not the entire video capture -- since most 15fps videos will still look smooth, the preview callback is only giving you a lower resolution, lower fps preview version of the actual video being captured. Even the built-in samsung capture application will only show the preview version, because that's all the preview interface is being given.
It would be impossible to get an accurate benchmark of video recording in Android from anything other than the file system dump or the low-level byte array data structures (using a JNI wrapper for example). It would be easy enough, but attempting to do it directly would block input reading from the camera and blow your benchmarks anyway.