android.hardware.camera2 Android Camera类 翻译

android.hardware.camera2 added in API level 21
The android.hardware.camera2 package provides an interface to individual camera devices connected to an Android device. It replaces the deprecated Camera class.

android.hardware.camera2包为连接到android设备的各个摄像头设备提供了接口。它替换了不推荐使用的camera类。

This package models a camera device as a pipeline, which takes in input requests for capturing a single frame, captures the single image per the request, and then outputs one capture result metadata packet, plus a set of output image buffers for the request. The requests are processed in-order, and multiple requests can be in flight at once. Since the camera device is a pipeline with multiple stages, having multiple requests in flight is required to maintain full framerate on most Android devices.

此包将摄像机设备建模为管道,它接收捕获单个帧的输入请求,根据请求捕获单个图像,然后输出一个捕获结果元数据包,再加上一组用于请求的输出图像缓冲区。请求按顺序处理,多个请求可以同时执行。由于相机设备是一个具有多个阶段的管道,在飞行中需要有多个请求才能在大多数Android设备上保持完整的帧速率。

To enumerate, query, and open available camera devices, obtain a CameraManager instance.

如果想要枚举、查询和打开可用的照相机设备,请获取CameraManager实例。

Individual CameraDevices provide a set of static property information that describes the hardware device and the available settings and output parameters for the device. This information is provided through the CameraCharacteristics object, and is available through getCameraCharacteristics(String).

单个摄像设备提供一组静态属性信息,描述硬件设备以及设备的可用设置和输出参数。此信息通过cameracharacteristics对象提供,并可通过getcameracharacteristics(string)获得。

To capture or stream images from a camera device, the application must first create a camera capture session with a set of output Surfaces for use with the camera device, with createCaptureSession(SessionConfiguration). Each Surface has to be pre-configured with an appropriate size and format (if applicable) to match the sizes and formats available from the camera device. A target Surface can be obtained from a variety of classes, including SurfaceView, SurfaceTexture via Surface(SurfaceTexture), MediaCodec, MediaRecorder, Allocation, and ImageReader.

要想从相机设备捕获或传输图像,首先应用程序必须创建一个带有一组输出Surface 的相机捕获会话,以用于相机设备和CreateCaptureSession(会话配置)。每个Surface 必须预先配置适当的尺寸和格式(如适用),以匹配摄像机设备提供的尺寸和格式。目标Surface 可以从各种类中获得,包括SurfaceView、SurfaceTextviaSurface(SurfaceTexture)、Mediacodec、MediaRecorder、Allocation和ImageReader。

Generally, camera preview images are sent to SurfaceView or TextureView (via its SurfaceTexture). Capture of JPEG images or RAW buffers for DngCreator can be done with ImageReader with the JPEG and RAW_SENSOR formats. Application-driven processing of camera data in RenderScript, OpenGL ES, or directly in managed or native code is best done through Allocation with a YUV Type, SurfaceTexture, and ImageReader with a YUV_420_888 format, respectively.

一般来讲,相机预览图像会发送到SurfaceView或TextureView(通过其SurfaceTexture)。可以使用带有jpeg和raw_传感器格式的ImageReader来捕获dngCreator的jpeg图像或原始缓冲区。在renderscript、opengl es或直接在托管代码或本机代码中应用程序驱动的摄像机数据处理最好通过分别使用yuv_420_888格式的yuv类型、surfacetexture和imagereader进行分配。

The application then needs to construct a CaptureRequest, which defines all the capture parameters needed by a camera device to capture a single image. The request also lists which of the configured output Surfaces should be used as targets for this capture. The CameraDevice has a factory method for creating a request builder for a given use case, which is optimized for the Android device the application is running on.

然后,应用程序需要构造一个CaptureRequest,它定义了相机设备捕获单个图像所需的所有捕获参数。请求还列出了应将配置的输出Surfaces 中的哪些Surfaces 用作此捕获的目标。Cameradevice有一个为给定用例创建请求生成器的工厂方法,该方法针对运行应用程序的Android设备进行了优化。

Once the request has been set up, it can be handed to the active capture session either for a one-shot capture or for an endlessly repeating use. Both methods also have a variant that accepts a list of requests to use as a burst capture / repeating burst. Repeating requests have a lower priority than captures, so a request submitted through capture() while there’s a repeating request configured will be captured before any new instances of the currently repeating (burst) capture will begin capture.

一旦设置了请求,就可以将其提交到活动捕获会话,以进行单次捕获或进行无休止的重复使用。这两种方法都有一个变体,它接受用作突发捕获/重复突发的请求列表。重复请求的优先级低于捕获,因此在配置了重复请求的情况下,通过capture()提交的请求将在当前重复(突发)捕获的任何新实例开始捕获之前被捕获。

After processing a request, the camera device will produce a TotalCaptureResult object, which contains information about the state of the camera device at time of capture, and the final settings used. These may vary somewhat from the request, if rounding or resolving contradictory parameters was necessary. The camera device will also send a frame of image data into each of the output Surfaces included in the request. These are produced asynchronously relative to the output CaptureResult, sometimes substantially later.

处理请求后,相机设备将生成一个totalCapturesult对象,其中包含有关拍摄时相机设备状态的信息以及使用的最终设置。如果需要舍入或解决矛盾的参数,这些参数可能与请求有所不同。摄像机设备还将向请求中包含的每个输出Surfaces 发送一帧图像数据。这些都是相对于输出捕获结果异步生成的,有时是实质上更晚的。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值