【Android】 Camera2 Introduce

Learn from android document:https://developer.android.com/reference/android/hardware/camera2/package-summary

【Highlight Summary】

       Replace the deprecated Camera class, camera2 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.

                       

        相机核心操作模型

  • CameraManager: to enumerate, query, open available camera devices.
  • CameraDevices: provide a set of static property information that describes the hardware device and the available settings and output parameters for device. CameraCharateristics object is such information.
  • CameraCaptureSession.CaptureCallback:  a callback object for tracking the progress of a CaptureRequest submitted to the camera device. 
  • CaptureResult: the subset of the results of a single image capture from the image sensor. Contains a subset of the final configuration for the capture hardware (sensor, lens, flash), the processing pipeline, the control algorithms, and the output buffers.
    • STATISTICS_FACE_DETECT_MODE: operating mode for the face detector unit.List of the faces detected through camera face detection in this capture, only available if CaptureRequest.statistics_face_detect_mode!=OFF. Available on all devices.
      • FULL:  face rectangles, scores, landmarks, and face IDs are all valid.
      • OFF: don't include face detection statistics in capture results.
      • SIMPLE: return face rectangle and confidence values only.
    • STATICSTICS_FACES: list of the faces deteccted through camera face detection in this capture.
      • SHADING_MODE_HIGH_QUALITY: apply high-quality lens shading correction, at the cost of possibly reduced frame rate.
      • SHADING_MODE_FAST: apply lens shading corrections, without slowing framerate relative to sensor raw output.
  • CameraDevice: the CameraDevice class is a representation of a single camera connected to an Android device, allowing for fine-grain control of image capture and post-processing at high frame rates. 
  • CaptureRequest: an immutable package of settings and outputs needed to capture a single image from the camera device
  • Pipline:
    • 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 SurfaceViewSurfaceTexture via Surface(SurfaceTexture)MediaCodecMediaRecorderAllocation, and 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 TypeSurfaceTexture, and ImageReader with a YUV_420_888 format, respectively.
    • 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.
    • 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.
    • After processing a request, the cam era 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.

Camera2开发流程

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

路途…

点滴记录

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值