what-the-bank/sources/com/google/firebase/ml/vision/text/FirebaseVisionTextRecognize...

77 lines
3.4 KiB
Java

package com.google.firebase.ml.vision.text;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.internal.firebase_ml.zzqh;
import com.google.android.gms.internal.firebase_ml.zzqi;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp;
import com.google.firebase.ml.vision.common.FirebaseVisionImage;
import java.io.Closeable;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes2.dex */
public class FirebaseVisionTextRecognizer implements Closeable {
private static final Map<zzqi, FirebaseVisionTextRecognizer> zzayw = new HashMap();
private static final Map<zzqh, FirebaseVisionTextRecognizer> zzayx = new HashMap();
private final zzqi zzazp;
private final zzqh zzazq;
private final int zzazr;
public static FirebaseVisionTextRecognizer zza(FirebaseApp firebaseApp, FirebaseVisionCloudTextRecognizerOptions firebaseVisionCloudTextRecognizerOptions, boolean z) {
synchronized (FirebaseVisionTextRecognizer.class) {
Preconditions.checkNotNull(firebaseApp, "FirebaseApp must not be null");
Preconditions.checkNotNull(firebaseApp.getPersistenceKey(), "Firebase app name must not be null");
if (!z) {
Preconditions.checkNotNull(firebaseVisionCloudTextRecognizerOptions, "Options must not be null");
}
if (z) {
zzqi zzj = zzqi.zzj(firebaseApp);
Map<zzqi, FirebaseVisionTextRecognizer> map = zzayw;
FirebaseVisionTextRecognizer firebaseVisionTextRecognizer = map.get(zzj);
if (firebaseVisionTextRecognizer == null) {
firebaseVisionTextRecognizer = new FirebaseVisionTextRecognizer(zzj, null, 1);
map.put(zzj, firebaseVisionTextRecognizer);
}
return firebaseVisionTextRecognizer;
}
zzqh zza = zzqh.zza(firebaseApp, firebaseVisionCloudTextRecognizerOptions);
Map<zzqh, FirebaseVisionTextRecognizer> map2 = zzayx;
FirebaseVisionTextRecognizer firebaseVisionTextRecognizer2 = map2.get(zza);
if (firebaseVisionTextRecognizer2 == null) {
firebaseVisionTextRecognizer2 = new FirebaseVisionTextRecognizer(null, zza, 2);
map2.put(zza, firebaseVisionTextRecognizer2);
}
return firebaseVisionTextRecognizer2;
}
}
private FirebaseVisionTextRecognizer(zzqi zzqiVar, zzqh zzqhVar, int i) {
this.zzazr = i;
this.zzazp = zzqiVar;
this.zzazq = zzqhVar;
}
public Task<FirebaseVisionText> processImage(FirebaseVisionImage firebaseVisionImage) {
Preconditions.checkArgument((this.zzazp == null && this.zzazq == null) ? false : true, "Either on-device or cloud text recognizer should be enabled.");
zzqi zzqiVar = this.zzazp;
if (zzqiVar != null) {
return zzqiVar.processImage(firebaseVisionImage);
}
return this.zzazq.processImage(firebaseVisionImage);
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
zzqi zzqiVar = this.zzazp;
if (zzqiVar != null) {
zzqiVar.close();
}
zzqh zzqhVar = this.zzazq;
if (zzqhVar != null) {
zzqhVar.close();
}
}
}