0

我正在使用 Google MLKit 从图像中识别文本。无法检测到文本并陷入 onFailure 回调,异常如下 com.google.firebase.ml.common.FirebaseMLException: batchAnnotateImages call failure

我正在使用云版本的文本识别 API,而不是在设备版本上。代码如下

private void readFromCloud(Bitmap bitmap){
    FirebaseVisionCloudDetectorOptions options =
            new FirebaseVisionCloudDetectorOptions.Builder()
                    .setModelType(FirebaseVisionCloudDetectorOptions.LATEST_MODEL)
                    .setMaxResults(15)
                    .build();
    FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(bitmap);
    FirebaseVisionCloudTextDetector detector = FirebaseVision.getInstance()
            .getVisionCloudTextDetector();
    Task<FirebaseVisionCloudText> result = detector.detectInImage(image)
            .addOnSuccessListener(new OnSuccessListener<FirebaseVisionCloudText>() {
                @Override
                public void onSuccess(FirebaseVisionCloudText firebaseVisionCloudText) {
                    // Task completed successfully
                    // ...
                    readTextFromCloud(firebaseVisionCloudText);
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.e("FAILEd","Failed");
                    // Task failed with an exception
                    // ...
                }
            });
}

堆栈跟踪如下:

06-12 14:28:41.547 13370-14113/com.example.gurithelpdesk_15.application1 E/ImageAnnotatorTask: batchAnnotateImages call failed with exception: 
javax.net.ssl.SSLException: Write error: ssl=0x7a5b0ae800: I/O error during system call, Connection reset by peer
    at com.android.org.conscrypt.NativeCrypto.SSL_write(Native Method)
    at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:855)
    at com.android.okhttp.okio.Okio$1.write(Okio.java:81)
    at com.android.okhttp.okio.AsyncTimeout$1.write(AsyncTimeout.java:155)
    at com.android.okhttp.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
    at com.android.okhttp.okio.RealBufferedSink.write(RealBufferedSink.java:46)
    at com.android.okhttp.internal.http.HttpConnection$FixedLengthSink.write(HttpConnection.java:350)
    at com.android.okhttp.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
    at com.android.okhttp.okio.RealBufferedSink$1.write(RealBufferedSink.java:198)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.write(BufferedOutputStream.java:126)
    at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:254)
    at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:212)
    at java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:146)
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
    at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:135)
    at java.io.OutputStreamWriter.write(OutputStreamWriter.java:220)
    at com.google.android.gms.internal.firebase_ml.zzii.zzbu(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzii.zzbt(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzbh.writeString(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzax.zza(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzax.zza(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzax.zza(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzax.zza(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzax.zza(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzax.zzd(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzat.writeTo(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzp.zza(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzu.writeTo(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzap.zzaf(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzz.zzaa(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzf.zzj(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzhv.zza(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzhu.zza(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzgu.call(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzgp.zza(Unknown Source)
    at com.google.android.gms.internal.firebase_ml.zzgq.run(Unknown Source)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.os.HandlerThread.run(HandlerThread.java:61)

请帮我解决这个问题。

4

0 回答 0