63 lines
2.9 KiB
Java
63 lines
2.9 KiB
Java
|
package com.google.android.gms.internal.firebase_ml;
|
||
|
|
||
|
import android.util.Pair;
|
||
|
import com.google.android.gms.common.internal.Preconditions;
|
||
|
import com.google.android.gms.tasks.Task;
|
||
|
import com.google.android.gms.tasks.Tasks;
|
||
|
import com.google.firebase.FirebaseApp;
|
||
|
import com.google.firebase.ml.common.FirebaseMLException;
|
||
|
import com.google.firebase.ml.vision.cloud.FirebaseVisionCloudDetectorOptions;
|
||
|
import com.google.firebase.ml.vision.common.FirebaseVisionImage;
|
||
|
import java.io.Closeable;
|
||
|
import java.io.IOException;
|
||
|
import java.util.Collections;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public abstract class zzpo<ResultType> implements Closeable {
|
||
|
private final zzjf imageContext;
|
||
|
protected final FirebaseApp zzapo;
|
||
|
private final zznq zzasm;
|
||
|
private final zzpp zzawm;
|
||
|
private final zzjc zzawn;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public zzpo(FirebaseApp firebaseApp, String str, FirebaseVisionCloudDetectorOptions firebaseVisionCloudDetectorOptions) {
|
||
|
this(firebaseApp, new zzjc().zza(Integer.valueOf(firebaseVisionCloudDetectorOptions.getMaxResults())).zzay(str).zzax(zzpm.zzbl(firebaseVisionCloudDetectorOptions.getModelType())), (zzjf) null, firebaseVisionCloudDetectorOptions.isEnforceCertFingerprintMatch());
|
||
|
}
|
||
|
|
||
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
||
|
public void close() throws IOException {
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public abstract ResultType zza(zzir zzirVar, float f);
|
||
|
|
||
|
protected abstract int zznh();
|
||
|
|
||
|
protected abstract int zzni();
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public zzpo(FirebaseApp firebaseApp, String str, zzjf zzjfVar, boolean z) {
|
||
|
this(firebaseApp, new zzjc().zzay(str).zzax(zzpm.zzbl(1)), (zzjf) Preconditions.checkNotNull(zzjfVar, "ImageContext must not be null"), z);
|
||
|
}
|
||
|
|
||
|
private zzpo(FirebaseApp firebaseApp, zzjc zzjcVar, zzjf zzjfVar, boolean z) {
|
||
|
Preconditions.checkNotNull(firebaseApp, "FirebaseApp must not be null");
|
||
|
Preconditions.checkNotNull(firebaseApp.getPersistenceKey(), "Firebase app name must not be null");
|
||
|
this.zzawn = (zzjc) Preconditions.checkNotNull(zzjcVar);
|
||
|
this.zzasm = zznq.zza(firebaseApp);
|
||
|
this.zzawm = new zzpp(this, firebaseApp, z);
|
||
|
this.zzapo = firebaseApp;
|
||
|
this.imageContext = zzjfVar;
|
||
|
}
|
||
|
|
||
|
public final Task<ResultType> zza(FirebaseVisionImage firebaseVisionImage) {
|
||
|
Preconditions.checkNotNull(firebaseVisionImage, "Input image can not be null");
|
||
|
Pair<byte[], Float> zze = firebaseVisionImage.zze(zznh(), zzni());
|
||
|
if (zze.first == null) {
|
||
|
return Tasks.forException(new FirebaseMLException("Can not convert the image format", 3));
|
||
|
}
|
||
|
return this.zzasm.zza((zznm<T, zzpp>) this.zzawm, (zzpp) new zzpn((byte[]) zze.first, ((Float) zze.second).floatValue(), Collections.singletonList(this.zzawn), this.imageContext));
|
||
|
}
|
||
|
}
|