According to the android camera docs from the Java SDK side, the camera preview frames have to be supplied a (visible and active) surface to be drawn to in order to access the f
I completely forgot I had this question up. 2 years and a couple of Android SDK versions later, we have a working system.
We're using an extended SurfaceTexture
, cameraSurface
with a reference to the required camera. Using cameraSurface's SurfaceTexture
, we call
mCamera.setPreviewTexture(mSurfaceTexture);
mCamera.startPreview();
Then override the current active camera's previewCallback
from your activity or wherever you need it.
mCamera.setPreviewCallback(new PreviewCallback() {
public void onPreviewFrame(final byte[] data, final Camera camera) {
// Process the contents of byte for whatever you need
}
});
This allows you to continuously process what the camera sees, rather than just having to go through stored images. Of course, this will be limited to your camera's preview resolution (which may be different from the still capture or video resolutions).
If I get the time, I'll try to throw up a barebones working demo.
Edit: The SDK I had linked to is no longer freely available. You can still request one via the BitGym contact page.