如何使用Camera2 API在后台捕获图像? [英] How to capture images in background using Camera2 api?

查看:186
本文介绍了如何使用Camera2 API在后台捕获图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Android安全应用程序,并且我想在后台捕获图像而不进行预览.是否可以使用camera2 API在后台捕获图像?

I am developing an Android security app, and I want to capture images in background without preview. Is it possible to capture images in the background using the camera2 api?

推荐答案

是的,但是从Android 5.0 Marshmallow开始,如果前台应用程序想要使用它,您可能会随时与相机断开连接.

Yes, but as of Android 5.0 Marshmallow, you may be disconnected from the camera at any time, if a foreground app wants to use it instead.

在Android M之前,不建议从后台使用摄像头,因为您将阻止任何前景应用使用它(该应用会在尝试打开摄像头时出现错误,并且通常会因此崩溃).

And before Android M, using the camera from the background is not recommended, since you'll block any foreground app from using it (the app will just get an error trying to open the camera, and generally will crash as a result).

否则,相机API的工作原理相同.在拍摄最终照片之前,您需要先运行相机几秒钟,以确保总体上可以很好地进行测光和对焦,尽管您的实际需求很大程度上取决于用例的细节.

Otherwise, the camera API works the same. You'll need to run the camera for a few seconds before taking the final picture to ensure metering and focus are generally good, though exactly what you need would depend highly on the details of your use case.

这篇关于如何使用Camera2 API在后台捕获图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆