拍照后保持相机捕捉到活动

发布于 2024-10-18 06:49:01 字数 244 浏览 5 评论 0原文

我的应用程序有必要保持相机捕获,直到由活动手动释放为止(我意识到这是不好的做法,因为没有其他应用程序能够使用相机)。我过去可以通过避免 CameraPreview 中的 surfaceDestroyed 函数中的camera.release() 调用来做到这一点,但这在 2.1 后不再有效。

有什么办法可以让相机保持在圈养状态,而不会在表面毁坏后自动释放吗?

作为一个替代前一个问题的解决方法,有没有办法在服务内拍照,而不会使预览视图膨胀?

It is necessary for my application to keep the camera captured until released manually by an Activity (I realize this is bad practice, as no other applications will be able to use the camera). I used to be able to do this by avoiding the camera.release() call in the surfaceDestroyed function from CameraPreview, but this no longer works after 2.1.

Is there any way to keep the camera in captivity, without it being automatically released after surfaceDestroyed?

As a workaround question to answer instead of the previous one, is there any way to take a picture from within a service, without the preview view inflated?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天赋异禀 2024-10-25 06:49:01

您可以调用camera.lock()来重新获取相机硬件上的锁。如果失败,您可以重新打开相机。

然而,这样做的缺点比阻止其他应用程序访问相机要糟糕得多。这也会快速耗尽电池电量,因为它会保持相机传感器和 DSP 的供电。根据此帖子,这可能会杀死电池在两个小时内就没电了。

You may be able to call camera.lock() to re-obtain the lock on the camera hardware. Failing that you can reopen the camera.

However, the drawback to this is much worse than preventing other apps from accessing the camera. This will also rapidly drain the battery, because it keeps the camera sensor and DSP powered. According to this thread, that could potentially kill a battery dead in two hours.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文