BlinkReceipt / blinkreceipt-android

MIT License
50 stars 16 forks source link

ScanResult is only returning data from the first image when calling `.recognize` with multiple Bitmaps #11

Closed cxrod closed 4 years ago

cxrod commented 4 years ago

Hi, I'm trying to get data from a long receipt in 2 images using the recognize function of the Recognizer class, but is only retrieving the info of the first image.

I'm using version 1.3.6 of the library.

This is my code

            Bitmap[] bitmaps = getBitmaps(stringUris);
            Recognizer.getInstance(reactContext).initialize(getOptions());
            Recognizer.getInstance( reactContext ).recognize(new SimpleRecognizerCallback() {

                @Override
                public void onRecognizerDone(@NonNull final ScanResults results, @NonNull final Media media ) {
                    super.onRecognizerDone( results, media );

                    promise.resolve(parseResultToJson(results));
                }

                @Override
                public void onRecognizerResultsChanged(@NonNull RecognizerResult recognizerResult) {
                    super.onRecognizerResultsChanged(recognizerResult);
                    promise.resolve(parseRecognizerToJson(recognizerResult));
                }
            }, CameraOrientation.ORIENTATION_PORTRAIT, bitmaps) ;

This is a screenshoot of the debugger with 2 bitmaps. image

I will attach the receipt images and the JSON with de result.

Image 1

Image 2

result's JSON

pequots34 commented 4 years ago

@cxrod This is not a general use api. You should not be using the recognizer directly as you should be processing OCR results through the recognizer view. in 1.3.7 this class will no longer be visible.

cxrod commented 4 years ago

@pequots34 ok, Do you have any documentation about it? Im creating a native module on my react native app, so Im al ready have the camera UI cover and I just need to process the images from the URIs.

Thanks for your time. Regards

pequots34 commented 4 years ago

There wouldn't be any documentation as its still in development. The release notes will reflect the change, but essentially you will not longer be able to call into Recognizer class ( Recognizer.getInstance(reactContext ) ). If its react native you will need to build the activity and or fragment in native code ( java / kotlin ) and use the recognizer view that will provide the camera interface.

pequots34 commented 4 years ago

Here is a sample.

https://github.com/BlinkReceipt/blinkreceipt-android/tree/master/blinkreceipt-demo/BlinkReceiptCustomScan