camera 和 camers2 有什么区别 API

What are the differences between camera and camers2 API

我正在开发一个应用程序,我试图在移动视觉的帮助下扫描条形码 API。我正在 activity 中创建 TextureView,所以我需要相机在 `TextureView.

上渲染

我一直在使用旧相机 API,刚遇到新相机 2 API。谁能帮我看看它们之间有什么区别?

This article 提供了很多关于如何使用 Camera2 API 设置项目的信息。来自前几段:

DSLR-like levels of customization, such as native control over exposure and raw sensor capture are finally possible. And while this new approach requires a little more thought and legwork, the level of control you get in return is well worth the effort.

因此,主要区别在于您可以更好地控制 phone 相机的功能。也有可能在性能和照片质量方面有所改进,但我没有在任何地方找到任何提及。

如果您不想使用 Camera2 API,因为它有点复杂,已弃用的版本似乎在 大多数 设备上都能正常工作,但是它它很可能最终会被删除,这将导致您的应用程序无法运行。因此,无论您更喜欢使用哪种 API,使用未弃用的总是更好。

为了帮助实施 API,我喜欢一个漂亮而简单的库 here, or if you don't like libraries or have a more specific use for it you could take a look at this sample project