package com.google.android.gms.vision; import android.util.SparseArray; import com.google.android.gms.vision.Frame; /* loaded from: classes2.dex */ public abstract class Detector { private final Object zzad = new Object(); private Processor zzae; /* loaded from: classes2.dex */ public interface Processor { void receiveDetections(Detections detections); void release(); } public abstract SparseArray detect(Frame frame); public boolean isOperational() { return true; } public boolean setFocus(int i) { return true; } public void release() { synchronized (this.zzad) { Processor processor = this.zzae; if (processor != null) { processor.release(); this.zzae = null; } } } public void receiveFrame(Frame frame) { Frame.Metadata metadata = new Frame.Metadata(frame.getMetadata()); metadata.zzd(); Detections detections = new Detections<>(detect(frame), metadata, isOperational()); synchronized (this.zzad) { Processor processor = this.zzae; if (processor == null) { throw new IllegalStateException("Detector processor must first be set with setProcessor in order to receive detection results."); } processor.receiveDetections(detections); } } public void setProcessor(Processor processor) { synchronized (this.zzad) { Processor processor2 = this.zzae; if (processor2 != null) { processor2.release(); } this.zzae = processor; } } /* loaded from: classes2.dex */ public static class Detections { private final SparseArray zzaf; private final Frame.Metadata zzag; private final boolean zzah; public Detections(SparseArray sparseArray, Frame.Metadata metadata, boolean z) { this.zzaf = sparseArray; this.zzag = metadata; this.zzah = z; } public Frame.Metadata getFrameMetadata() { return this.zzag; } public SparseArray getDetectedItems() { return this.zzaf; } public boolean detectorIsOperational() { return this.zzah; } } }