when I make a call to mCamera.takePicture(null, null, null, null);
(for simplicity I have omitted the callbacks) the preview freezes and shows a preview of the scene that was just captured. Why is that the case. Can I somehow control this behaviour? And, what does actually happen? Is there a new view that gets attached or does my camera preview simple stop?

- 7,131
- 20
- 52
- 83
-
I think this preview is for you to select the image and press Ok, if you choose to press cancel the camera will start afresh? If I understand you right. – Skynet Feb 24 '14 at 15:21
-
It is probably by design. A freeze frame is a visual indication to the user that a picture was taken. That is certainly how my Android phone works. – Robert Harvey Feb 24 '14 at 15:21
-
Yeah it fires onPictureTaken( ) and then it stops. You need to call startPreview( ) on the camera once more in order to get the preview going once again. Probably by overriding the PictureCallback feature and starting it up yourself manually after a picture is taken. – Jay Snayder Feb 24 '14 at 15:22
-
Actually what I would like to understand is what is happening so that i can control this feauture. – user2426316 Feb 24 '14 at 15:25
2 Answers
What does actually happen? Is there a new view that gets attached or does my camera preview simply stop?
No new view gets attached by default. The preview just stops. The documentation for Camera
states this clearly:
Preview will be stopped after the image is taken; callers must call startPreview() again if they want to re-start preview or take more pictures.
It also goes on to say:
After calling this method, you must not call startPreview() or take another picture until the JPEG callback has returned.
So, the best place to call startPreview()
again would be the JPEG callback. Any time before that, the camera hardware is still processing the previous image, and wouldn't be able to give you a preview. That's the main reason that it "freezes"; the camera hardware is just busy.
It's also a visual cue to the user that:
- a picture was taken
- the picture looks like "this"
That's icing on the cake, but even if you didn't care about that, it would still do it.
Can I somehow control this behaviour?
Through the publicly expose API? Definitely not. You can restart the preview once the camera is done processing(as above), but you can't prevent it from freeze-framing when you call takePicture()
.
Whether it's possible by going further into the camera firmware, I can't really say. However, since there are roughly a bazillion different cameras used in Android devices, this would likely be an exercise in futility if you weren't working on one specific device.
Even with one specific device, I can't see how you'd overcome it altogether. At a bare minimum, the camera will be busy processing the image for some amount of time. Even high-end DSLR cameras that I've seen freeze the preview at least for the duration of the exposure.
After calling takePicture() you can hide the preview surface under another view (e.g. ImageView). If you use OpenGL to render the preview texture instead of SurfaceView, you have even more tricks in your sleeve.

- 56,089
- 9
- 113
- 307