This is the first day of my participation in the Gwen Challenge in November. Check out the details: the last Gwen Challenge in 2021

Camera2 uses the concept of a pipe to connect android devices to the camera. The system sends Capture requests to the camera, which returns to the camera adata, which is handed over to surface and displayed. This is all set up in a session called CameraCaptureSession.

1. Start a thread dedicated to photographing things

2. Initialize surface

3. Set the CAMERA ID and determine which camera to use

4. Set up picture buffer and save data

5. Turn on the camera

Three callback. 1, the CameraDevice StateCallback after open the camera, the state of the hardware, after successful open to set up a capture session, access to data streams that are related to the camera

2, CameraCaptureSession. StateCallback judge whether the current session to establish successful, establish session after the completion of the repeated requests, to get the data flow

. 3, CameraCaptureSession CaptureCallback photos and take photos in the process of success, continuous shooting, such as state, you can add some logic

The detailed steps

  1. Start a thread for the camera

  1. Create a listening event for TextureView,

3. Set camera parameters

4. Dynamically obtain the required permissions of the Camera, and then open the Camera

In the callback function that successfully opens the camera, open the preview screen

5. Start previewing

6. Start taking pictures

Release related resources and restart the preview

Set up ImageReader and prepare to store images

7. Store pictures