首页 > 代码库 > Camera2 doc
Camera2 doc
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.
这个包把相机设备模拟成一个流水线(管道?), 这个流水线可以接受拍摄单个frame的输入请求, 可以为每一个请求拍摄一个图片, 然后输出一个拍摄结果元数据包, 附带所请求的输出图片buffers集合。
这些请求被顺序处理,并且多个请求可以同时被发出。 由于相机设备室一个多状态的流水线, 为了在大多数安卓设备上保持全帧率, 同时发出多个请求成为必须.
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)
独立的CameraDevices提供一个描述硬件设备&可用设置&输出参数的静态的属性信息集合。这些信息通过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(List, CameraCaptureSession.StateCallback, Handler). 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.
想从一个相机设备拍照或获取数据流,应用需要首先创建一个带有供camera device使用的surfaces集合的camera capture session, 如此:createCaptureSession(List, CameraCaptureSession.StateCallback, Handler). 每一个surface必须提前配置好和相机设备相对于的大小和格式。
一个目标surface可以从几个类获得, 比如SurfaceView, SurfaceTexture via Surface, 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_SENSOR的ImageReader可以完成JPEG和DngCreater的RAW buffers的拍照。
程序驱动的数据处理可以通过分别分配YUV type, SurfaceTexture, 和YUV_420_888格式的ImageReader使在RenderScript, OpenGL ES, 或直接管理或native code得到很好的处理。
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,CaptureRequest定义了设备拍摄一张照片需要的所有拍摄参数。
此request还列出了作为此次拍照的tartgets的配置好的output surfaces。
CameraDevice类有一个为一个用户case创建一个request builder的工厂方法,此方法已经针对程序运行的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 session作为one-shot capture或者无限循环处理。
这两个方法也都有一个变量可以接受作为burst/重复burst的请求list。
Repeating requests比captures优先级低,所以当repeating request正在执行时来了一个capture() request,这个capture会先执行,然后再执行repeating的下一个拍照实例。
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.
处理完一个request后, camera device会生成一个TotalCaptureResult对象, 包含了拍照时设备的状态信息和所用的配置。
这些设置根据request变化,如果解决对立参数必要的话。
相机设备还会给request里的每一个output surfaces发送图片数据。
这些数据和captureResult是异步的,稍微晚一点。
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.
这个包把相机设备模拟成一个流水线(管道?), 这个流水线可以接受拍摄单个frame的输入请求, 可以为每一个请求拍摄一个图片, 然后输出一个拍摄结果元数据包, 附带所请求的输出图片buffers集合。
这些请求被顺序处理,并且多个请求可以同时被发出。 由于相机设备室一个多状态的流水线, 为了在大多数安卓设备上保持全帧率, 同时发出多个请求成为必须.
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)
独立的CameraDevices提供一个描述硬件设备&可用设置&输出参数的静态的属性信息集合。这些信息通过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(List, CameraCaptureSession.StateCallback, Handler). 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.
想从一个相机设备拍照或获取数据流,应用需要首先创建一个带有供camera device使用的surfaces集合的camera capture session, 如此:createCaptureSession(List, CameraCaptureSession.StateCallback, Handler). 每一个surface必须提前配置好和相机设备相对于的大小和格式。
一个目标surface可以从几个类获得, 比如SurfaceView, SurfaceTexture via Surface, 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_SENSOR的ImageReader可以完成JPEG和DngCreater的RAW buffers的拍照。
程序驱动的数据处理可以通过分别分配YUV type, SurfaceTexture, 和YUV_420_888格式的ImageReader使在RenderScript, OpenGL ES, 或直接管理或native code得到很好的处理。
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,CaptureRequest定义了设备拍摄一张照片需要的所有拍摄参数。
此request还列出了作为此次拍照的tartgets的配置好的output surfaces。
CameraDevice类有一个为一个用户case创建一个request builder的工厂方法,此方法已经针对程序运行的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 session作为one-shot capture或者无限循环处理。
这两个方法也都有一个变量可以接受作为burst/重复burst的请求list。
Repeating requests比captures优先级低,所以当repeating request正在执行时来了一个capture() request,这个capture会先执行,然后再执行repeating的下一个拍照实例。
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.
处理完一个request后, camera device会生成一个TotalCaptureResult对象, 包含了拍照时设备的状态信息和所用的配置。
这些设置根据request变化,如果解决对立参数必要的话。
相机设备还会给request里的每一个output surfaces发送图片数据。
这些数据和captureResult是异步的,稍微晚一点。
Camera2 doc
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。