[英]CameraX cameraView and previewView
What is different between camerax cameraView and previewView? camerax cameraView 和 previewView 有什么不同? because i can't find resources or articles about comparing 2 view for previewing camerax因为我找不到有关比较 2 视图以预览 camerax 的资源或文章
PreviewView
is a custom View you can use to display a camera preview. PreviewView
是可用于显示相机预览的自定义视图。 You can add it to your XML layout, then in your Activity
/ Fragment
, hook it up with a Preview
use case to get the preview stream started.您可以将其添加到您的 XML 布局中,然后在您的Activity
/ Fragment
中,将其与Preview
用例挂钩,以启动预览 stream。 So while using PreviewView
, you're responsible for setting up the camera, creating the Preview
use case (and other use cases you may want to use), and binding them to a lifecycle.因此,在使用PreviewView
时,您负责设置相机、创建Preview
用例(以及您可能想要使用的其他用例),并将它们绑定到生命周期。 You can read more about PreviewView
and how it works in this article .您可以在本文中阅读有关PreviewView
及其工作原理的更多信息。
CameraView
is a custom View that does many things, it was built to allow users to quickly set up a "camera app" by adding the View in their XML layout. CameraView
是一个可以做很多事情的自定义视图,它旨在允许用户通过在其 XML 布局中添加视图来快速设置“相机应用程序”。 It allows to display a camera preview, take pictures, record videos, zoom in/out on the viewfinder, and provides different APIs to configure the camera (lens facing, flash, scale type, capture mode, etc).它允许显示相机预览、拍照、录制视频、放大/缩小取景器,并提供不同的 API 来配置相机(镜头朝向、flash、缩放类型、捕捉模式等)。 It handles setting up the camera, binding and unbinding the use cases and what not.它处理设置相机、绑定和解除绑定用例等等。 An important thing to note is that for displaying a preview, it internally uses PreviewView
.需要注意的重要一点是,为了显示预览,它在内部使用PreviewView
。 I haven't come across many articles online on CameraView
, I'd recommend this one though.我在CameraView
上没有在网上看到很多文章,不过我会推荐这篇。
If you need flexibility in setting up the camera and building/configuring the use cases, or if you need to use the ImageAnalysis
use case, then CameraView
is probably not the right choice to go with.如果您需要灵活地设置相机和构建/配置用例,或者如果您需要使用ImageAnalysis
用例,那么CameraView
可能不是 go 的正确选择。 PreviewView
was built to offload the burden of setting up and handling the preview surface used by the camera, and handling the hard bits of displaying a preview (scaling, rotating, aspect ratio, etc). PreviewView
旨在减轻设置和处理相机使用的预览表面以及处理显示预览(缩放、旋转、纵横比等)的困难部分的负担。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.