I am developing an Android app to detect text from the PDF file.
First, I tried to use Google Cloud Vision API. But it required to OAuth 2.0. So I changed from it to Firebase ML Kit.
But when I run 'fromFilePath' method, NPE occurred.
val file = getPdfFile()
Log.d(TAG, "file.length: ${file.length()}") // File size is printed correctly!
// NPE occurred while below code running
val image = FirebaseVisionImage.fromFilePath(context, Uri.fromFile(file))
// Because already NPE occurred, I cannot reach out to below code.
val detector = FirebaseVision.getInstance()
.cloudDocumentTextRecognizer
Process: com.youknow.redact, PID: 13122 java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
It looks like the Firebase ML kit doesn't support PDF file, right?
Is there any good solution?
Is it impossible to recognize text from the PDF file using Firebase ML kit?
I tried to test more file formats: JPG, TIFF
All is same, just input file is changed. JPG works fine, but TIFF has the same problem.
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
at com.google.android.gms.internal.firebase_ml.zzox.zza(Unknown Source)
at com.google.firebase.ml.vision.common.FirebaseVisionImage.fromFilePath(Unknown Source)