86 lines
2.4 KiB
Java
86 lines
2.4 KiB
Java
|
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<T> {
|
||
|
private final Object zzad = new Object();
|
||
|
private Processor<T> zzae;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public interface Processor<T> {
|
||
|
void receiveDetections(Detections<T> detections);
|
||
|
|
||
|
void release();
|
||
|
}
|
||
|
|
||
|
public abstract SparseArray<T> detect(Frame frame);
|
||
|
|
||
|
public boolean isOperational() {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public boolean setFocus(int i) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public void release() {
|
||
|
synchronized (this.zzad) {
|
||
|
Processor<T> 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<T> detections = new Detections<>(detect(frame), metadata, isOperational());
|
||
|
synchronized (this.zzad) {
|
||
|
Processor<T> 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<T> processor) {
|
||
|
synchronized (this.zzad) {
|
||
|
Processor<T> processor2 = this.zzae;
|
||
|
if (processor2 != null) {
|
||
|
processor2.release();
|
||
|
}
|
||
|
this.zzae = processor;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static class Detections<T> {
|
||
|
private final SparseArray<T> zzaf;
|
||
|
private final Frame.Metadata zzag;
|
||
|
private final boolean zzah;
|
||
|
|
||
|
public Detections(SparseArray<T> sparseArray, Frame.Metadata metadata, boolean z) {
|
||
|
this.zzaf = sparseArray;
|
||
|
this.zzag = metadata;
|
||
|
this.zzah = z;
|
||
|
}
|
||
|
|
||
|
public Frame.Metadata getFrameMetadata() {
|
||
|
return this.zzag;
|
||
|
}
|
||
|
|
||
|
public SparseArray<T> getDetectedItems() {
|
||
|
return this.zzaf;
|
||
|
}
|
||
|
|
||
|
public boolean detectorIsOperational() {
|
||
|
return this.zzah;
|
||
|
}
|
||
|
}
|
||
|
}
|