Camera preview image data processing with Android L and Camera2 API

前端 未结 5 542
失恋的感觉
失恋的感觉 2020-11-27 11:46

I\'m working on an android app that is processing the input image from the camera and displays it to the user. This is fairly simple, I register a PreviewCallback

5条回答
  •  隐瞒了意图╮
    2020-11-27 12:32

    In the ImageReader.OnImageAvailableListener class, close the image after reading as shown below (this will release the buffer for next capture). You will have to handle exception on close

          Image image =  imageReader.acquireNextImage();
          ByteBuffer buffer = image.getPlanes()[0].getBuffer();
          byte[] bytes = new byte[buffer.remaining()];
          buffer.get(bytes);
          image.close();
    

提交回复
热议问题