0

I am using Firebase ML Kit Text Recognition API and getting the error which is added below during text recognition:

A/native: image_util_common.cc:2757 Check failed: 'out_pix' Must be non NULL 
          terminating.
A/native: image_util_common.cc:2797 Check failed: 'out_pix' Must be non NULL 
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 19193 (FirebaseMLHandl)
A/native: terminating.

When I have converted the images from jpg to bmp as it is suggested, just the error was changed to:

E/zygote: The String#value field is not present on Android versions >= 6.0
E/native: jni_helper.cc:170 GetContents failed: /data/user/0/com.google.android.gms/app_vision/ocr/data/models/rpn_lstm_engine_tfmini.bincfg
E/native: jni_helper.cc:170 GetContents failed: /data/user/0/com.google.android.gms/app_vision/ocr/data/models/semanticlift_engine_0.2.bincfg
A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 13092 (ocr_seg_4/13092)

Here is the code that triggers the API:

Uri uri = Uri.fromFile(file);
FirebaseVisionImage image = FirebaseVisionImage.fromFilePath(context, uri); 

FirebaseVisionTextDetector detector = FirebaseVision.getInstance().getVisionTextDetector();

Task<FirebaseVisionText> result =
        detector.detectInImage(image)
                .addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() {

                    List<String> words = new ArrayList<>();

                    @Override
                    public void onSuccess(FirebaseVisionText firebaseVisionText) {
                        for (FirebaseVisionText.Block block: firebaseVisionText.getBlocks()) {
                            Rect boundingBox = block.getBoundingBox();
                            Point[] cornerPoints = block.getCornerPoints();
                            String text = block.getText();
                            Log.d(TAG, "Detected Text: " + text);

                            for (FirebaseVisionText.Line line: block.getLines()) {
                                for (FirebaseVisionText.Element element: line.getElements()) {
                                    String textPart = element.getText();
                                    words.add(textPart);
                                    Log.d(TAG, "textPart: " + textPart);
                                }
                            }
                        }
                    }
                })
                .addOnFailureListener(
                        new OnFailureListener() {
                            @Override
                            public void onFailure(@NonNull Exception e) {
                                // Task failed with an exception
                                // ...
                            }
                        });
talha06
  • 6,206
  • 21
  • 92
  • 147
  • 1
    what format of image file are you using? Could you share the image file and I will take a look? Also, you might want to try converting the image to Bitmap and see whether it works. Thanks. – Isabella Chen May 21 '18 at 01:50
  • Seems like a crash in converting to Bitmap from Uri. +1 to trying converting to Bitmap yourself offline and then see if it works. Also, to check if the Uri is correct, can you create an ImageView and check if the image can be displayed correctly? ImageView.setImageURI(uri); – Pannag Sanketi May 21 '18 at 04:25
  • @IsabellaChen I work on a large number of images which are `.jpg` files as some of them can be seen from the attached screenshot. The images I use are part of a dataset named `Total-Text`, you can access it from here: https://github.com/cs-chan/Total-Text-Dataset. – talha06 May 21 '18 at 10:03
  • @PannagSanketi The Uri should be correct since I directly create it from each file (as I loop over the files) which is located in a folder in the external storage. – talha06 May 21 '18 at 11:43
  • 1
    @talha06, I downloaded the data set and tried a few images and they all worked fine for me. See detection result: https://drive.google.com/open?id=15cwxilPCImsHufT3iaR9jX8ZnXDzzHbN and https://drive.google.com/open?id=1QKDHMH-IsbBRfhNdwyFUf9-nQybv_bOQ Which specific image doesn't work for you? Tell me the file name and I will try. And could you also try reading out the file yourself to a Bitmap: MediaStore.Images.Media.getBitmap(context.getContentResolver(), imageUri). You can see in debugger whether the image looks correct. – Isabella Chen May 21 '18 at 23:10
  • @IsabellaChen Thanks Isabella for your care. Despite that I have converted all files to Bitmap, the result is still same. Just the error is changed as I have added to the OP. – talha06 May 22 '18 at 20:34
  • @talha06, none of the images worked for you or some worked and some didn't? If the latter, could you share the image name? Also, what's your Android OS version? – Isabella Chen May 23 '18 at 00:31
  • @IsabellaChen The latter, and actually the image that the error occurs during text recognition on varies. The Android API level is 26. – talha06 May 23 '18 at 00:34
  • @talha06 Could you share one of the file name that caused error? As I mentioned earlier, I already downloaded the same data set. If I can repro locally, it's much easier to track down what's going wrong here. And I confirm the error came from OCR c++ code in Google Play services. – Isabella Chen May 23 '18 at 01:18
  • @IsabellaChen As I mentioned above, the image that is the reason of the error varies; but since you ask, I note here the filenames of some images: `img631.bmp`, `img640.bmp`, `img1554.bmp` – talha06 May 23 '18 at 01:44
  • @talha06, I tried on O-MR1 and detection were successful for img631 & img640 for me. I probably misunderstood what you meant for "the image that is the reason of the error varies". You mean for a particular image, it sometimes yields an error and sometimes worked fine? We will keep researching, but might take some time. Thank you! – Isabella Chen May 26 '18 at 00:34
  • @IsabellaChen Exactly Isabella, thanks for your care. Hopefully, you will detect & fix the issue anytime soon. When you have news, I kindly request you to share them here. Thanks again. – talha06 May 26 '18 at 12:06

0 Answers0