Skip to content Skip to sidebar Skip to footer

Android Camera Disable Stoppreview On Takepicture

I'm trying to build an app which uses the camera API to take one picture every second for 10 seconds. I followed the tutorial in this link Android Camera API and modified the code

Solution 1:

Maybe for you the resolution delivered in onPreviewFrame() can be enough? Then, there is no need to restart the camera after 'taking a picture'. The live preview will not freeze.

If you target devices with API >= 21 (Lollipop), you should use the new camera2 API instead of the deprecatedCamera API. The new API has many improvements, and among them - it can help with smooth multi-image capture.

Even if you are stuck with old API, there are some improvements to make.

One of the problems with your existing code is that it works with the camera device on UI thread. Rather, use a background HandlerThread to open the camera, and also make sure that onPictureTaken() restarts preview and returns iommediately, offloading all processing to yet another worker thread.

Post a Comment for "Android Camera Disable Stoppreview On Takepicture"