acquireNextImage 与 acquireLatestImage 之间的区别

Difference between acquireNextImage Vs acquireLatestImage

我正在使用 Camera2 API 连续拍照并且工作正常, 在这里,我可以使用以下代码保存捕获的图像:

ImageReader.OnImageAvailableListener readerListener = new ImageReader.OnImageAvailableListener() {
                @Override
                public void onImageAvailable(ImageReader reader) {
                    Image image = null;
                    try {

//                        image = reader.acquireLatestImage();
                        image = reader.acquireNextImage();
                        ByteBuffer buffer = image.getPlanes()[0].getBuffer();
                        byte[] bytes = new byte[buffer.capacity()];
                        buffer.get(bytes);
                        save(bytes);
                    } catch (FileNotFoundException e) {
                        logFile.writeCrashLog(TAG + ": " + e.toString());
                        hideProgressDialog();
                    } catch (IOException e) {
                        logFile.writeCrashLog(TAG + ": " + e.toString());
                        hideProgressDialog();
                    } catch (Exception e) {
                        logFile.writeCrashLog(TAG + ": " + e.toString());
                        hideProgressDialog();
                    } finally {
                        if (image != null) {
                            image.close();
                        }
                    }
                }

                private void save(byte[] bytes) throws IOException {
                    OutputStream output = null;
                    try {
                        output = new FileOutputStream(AndroidCameraApiActivity.this.file);
                        output.write(bytes);
                    } catch (Exception e) {
                        logFile.writeCrashLog(TAG + ": " + e.toString());
                        hideProgressDialog();
                    } finally {
                        if (null != output) {
                            output.close();
                        }
                    }
                }
            };

这里我想知道通过acquireLatestImage OR acquireNextImage? 获取图像哪个最适合获取连续图像.

aquireNextImage - 将从 ImageReader Queue

获取下一张图像

aquireLatestImage - 甚至会通过删除 Queue 中的旧图像从 ImageReader 队列中获取下一张图像。

供参考:Image Reader API