Reputation: 1934
So I know the default behaviour of the camera is to pause when a picture is taken. I am trying to override this behaviour and have the camera preview continue running while I take multiple pictures in the background.
Is there anyway to accomplish this?
I also add that I am using a camera preview and not a camera intent
Upvotes: 1
Views: 1200
Reputation: 1934
My app actually uses OCR and I needed to take several pictures/frames and pass to the ocr without having the camera preview stopped.
I think maybe I could have been a bit clearer in my initial question. However in the interest of anyone who may have a similar issue I solved it by getting the frames from the camera every 2 secs with the setPreviewCallback method which returns a byte array you can then convert to a bitmap.
mCamera.setPreviewCallback(new PreviewCallback() {
public void onPreviewFrame(byte[] _data, Camera _camera) {
int width = parameters.getPreviewSize().width;
int height = parameters.getPreviewSize().height;
ByteArrayOutputStream outstr = new ByteArrayOutputStream();
Rect rect = new Rect(0, 0, width, height);
YuvImage yuvimage = new YuvImage(_data,
ImageFormat.NV21, width, height, null);
yuvimage.compressToJpeg(rect, 100, outstr);
Bitmap bmp = BitmapFactory.decodeByteArray(
outstr.toByteArray(), 0, outstr.size());
}
});
Upvotes: 2
Reputation: 12160
I assume that you want to implement a panorama app. 1. If you want to implement an app like Samsung's camera, you have to modify the native camera code. However, it is not open source. 2. If you want to implement it in Java, you can refer to the Panorama source code of Android.
Upvotes: 0