androidimagereadercamera2

Android camera2: java.lang.IllegalStateException: maxImages (1) has already been acquired, call #close before acquiring more


Hello having trouble to fix this issue.

I already have a imageReader.close called inside the ImageAvailable callback but still having the error:

java.lang.IllegalStateException: maxImages (1) has already been acquired, call #close before acquiring more.

Code I have is here:

private ImageReader.OnImageAvailableListener imageAvailableListener = new ImageReader.OnImageAvailableListener()
{
    @Override
    public void onImageAvailable(ImageReader reader) {
        Image img = mReader.acquireLatestImage();

        mReader.close();
    }

};

ps. I also use the argument reader as well but not seem to solve the problem


Solution

  • Ok I have solved my problem. I need to close the img object not the ImageReader.