public final class

ZslRingBuffer

extends ArrayRingBuffer<ImageProxy>

 java.lang.Object

androidx.camera.core.internal.utils.ArrayRingBuffer<ImageProxy>

↳androidx.camera.core.internal.utils.ZslRingBuffer

Gradle dependencies

compile group: 'androidx.camera', name: 'camera-core', version: '1.5.0-alpha01'

  • groupId: androidx.camera
  • artifactId: camera-core
  • version: 1.5.0-alpha01

Artifact androidx.camera:camera-core:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

Used for storing frames for ZSL capture.

Enqueueing process ignores frames when the quality is inadequate for ZSL capture.

Adequate quality is defined as: - AF Focused - AE Converged - AWB Converged

Summary

Constructors
publicZslRingBuffer(int ringBufferCapacity, RingBuffer.OnRemoveCallback<ImageProxy> onRemoveCallback)

Methods
public voidenqueue(ImageProxy imageProxy)

from ArrayRingBuffer<T>dequeue, enqueue, getMaxCapacity, isEmpty
from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public ZslRingBuffer(int ringBufferCapacity, RingBuffer.OnRemoveCallback<ImageProxy> onRemoveCallback)

Methods

public void enqueue(ImageProxy imageProxy)

Source

/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.camera.core.internal.utils;

import androidx.annotation.NonNull;
import androidx.camera.core.ImageInfo;
import androidx.camera.core.ImageProxy;
import androidx.camera.core.impl.CameraCaptureMetaData.AeState;
import androidx.camera.core.impl.CameraCaptureMetaData.AfState;
import androidx.camera.core.impl.CameraCaptureMetaData.AwbState;
import androidx.camera.core.impl.CameraCaptureResult;
import androidx.camera.core.impl.CameraCaptureResults;

/**
 * Used for storing frames for ZSL capture.
 *
 * <p>Enqueueing process ignores frames when the quality is inadequate for ZSL capture.</p>
 *
 * <p>Adequate quality is defined as:
 * - AF Focused
 * - AE Converged
 * - AWB Converged
 * </p>
 */
public final class ZslRingBuffer extends ArrayRingBuffer<ImageProxy> {

    public ZslRingBuffer(int ringBufferCapacity,
            @NonNull OnRemoveCallback<ImageProxy> onRemoveCallback) {
        super(ringBufferCapacity, onRemoveCallback);
    }

    @Override
    public void enqueue(@NonNull ImageProxy imageProxy) {
        if (isValidZslFrame(imageProxy.getImageInfo())) {
            super.enqueue(imageProxy);
        } else {
            mOnRemoveCallback.onRemove(imageProxy);
        }
    }

    private boolean isValidZslFrame(@NonNull ImageInfo imageInfo) {
        CameraCaptureResult cameraCaptureResult =
                CameraCaptureResults.retrieveCameraCaptureResult(imageInfo);

        if (cameraCaptureResult.getAfState() != AfState.LOCKED_FOCUSED
                && cameraCaptureResult.getAfState() != AfState.PASSIVE_FOCUSED)  {
            return false;
        }

        if (cameraCaptureResult.getAeState() != AeState.CONVERGED) {
            return false;
        }

        if (cameraCaptureResult.getAwbState() != AwbState.CONVERGED) {
            return false;
        }

        return true;
    }
}