Search code examples
android-studiokotlinandroid-cameraandroid-camera2android-camerax

How can I get each frame in camera2 api in android studio like PreviewCallback in camera api and ImageAnalysis.Analyzer in camerax?


How can I get each frame in Camera2 api in android studio like PreviewCallback in Camera api and ImageAnalysis.Analyzer in Camerax? I looked at other questions but they do not answer my question properly.


Solution

  • Basically, use ImageReader. Configure it for YUV_420_888, and get its Surface to use as part of Camera session configuration.

    Then include its Surface in each CaptureRequest you send to the camera, and process new frames in ImageReader.OnImageAvailableListener().