Giter Club home page Giter Club logo

Comments (7)

DoDoENT avatar DoDoENT commented on August 16, 2024

If data array is null, then nothing was scanned. Are you sure you are sending the correct orientation of bitmap? Your code reports bitmap in orientation portrait, i.e. as if the bitmap was taken with device camera while device being in portrait mode (i.e. the text lines are vertical and start at the bottom of the image and end at the top). If the bitmap image you are scanning has normal orientation (i.e. text lines are horizontal and text starts from the left and ends on the right - just like in web page), then you should pass LANDSCAPE_RIGHT orientation.

from blinkid-android.

NachoLorenzoG avatar NachoLorenzoG commented on August 16, 2024

Thanks for your response. You are right, I am taking a photo with the camera and I am placing it in an ImageView to check the orientation. Image has a number horizontally aligned displayed from left to right (when I place this image in the ImageView it has the correct orientation). I have tried to configure the orientation in ORIENTATION_LANDSCAPE_RIGHT but it's not working either. What orientation should I use?

from blinkid-android.

DoDoENT avatar DoDoENT commented on August 16, 2024

If ImageView is displaying image correctly, then landscape right is the correct orientation to use. However, it could be possible that OCR of the image was incorrect, so regex parser couldn't match your expression (i.e. it's possible that OCR produced punctuation or spaces inside your word and your regex does not account for that).

You can inspect the raw OCR result with the getOcrResult and if you know you only expect uppercase letters and digits, you might want to tweak RegexParser's OCR engine options and add only uppercase letters and digits to whitelist. However, bogus spaces could still appear within your words (though not so often), so you should also tweak your regex to account for that.

from blinkid-android.

NachoLorenzoG avatar NachoLorenzoG commented on August 16, 2024

Thanks I am getting some data now. However, the result is not as good as expected, I have tried the sample app of the regex expression and it's much more accurate with the same image. I am setting the SettingsRecognition as you mentioned:

private RecognizerSettings[] setupSettingsArray() {
        BlinkOCREngineOptions engineOptions = new BlinkOCREngineOptions();
        // only digits are allowed.
        engineOptions.addAllDigitsToWhitelist(OcrFont.OCR_FONT_ANY);
        engineOptions.setMinimumLineHeight(40);
       
        RegexParserSettings regexParserSettings = new RegexParserSettings("[0-9]+", engineOptions);
        BlinkOCRRecognizerSettings sett = new BlinkOCRRecognizerSettings();

        sett.addParser("myRegexParser", regexParserSettings);

        return new RecognizerSettings[] { sett };
    }

To analyze the results I am looking at the OcrResult but it gives me lots of 1's and multiple lines for an image with a single line of text:

@Override
    public void onScanningDone(RecognitionResults results) {

        BaseRecognitionResult[] dataArray = results.getRecognitionResults();
        // we've enabled only one recognizer, so we expect only one element in dataArray
        Log.d(TAG, "Recognition settings: " + dataArray);
        if(dataArray!= null && dataArray.length == 1){
            if (dataArray[0] instanceof BlinkOCRRecognitionResult) {
                BlinkOCRRecognitionResult result = (BlinkOCRRecognitionResult) dataArray[0];

                if (result.isValid() && !result.isEmpty()) {
                    OcrResult ocrResult = result.getOcrResult();
                    if(ocrResult!= null){
                        Toast.makeText(context, "Result: " + ocrResult.toString(), Toast.LENGTH_LONG).show();
                        Log.d(TAG, "Result raw: " + ocrResult.getBlocks()[0].toString());
                    }
                }
            }
        }

How can improve the analysis of the data to get a result as good as the obtained in the RegexExample handled in SegmentScanActivity ?

from blinkid-android.

DoDoENT avatar DoDoENT commented on August 16, 2024

Hi @LukeEdghar.

The difference between your code and SegmentScanActivity is that your code uses DirectAPI, which can process only single bitmap image you send for processing, while SegmentScanActivity processes camera frames as they arrive from the camera. While doing so, it can utilise time redundant information to improve the OCR quality, i.e. it combines consecutive OCR results from multiple video frames to obtain a better quality OCR result.

This feature is not available via DirectAPI - you need to use either SegmentScanActivity, or custom scan activity with our camera management.

from blinkid-android.

NachoLorenzoG avatar NachoLorenzoG commented on August 16, 2024

To help others if they face the same problem. I have notice that if you pass an image with a very high resolution it doesn't recognize the text properly (it makes artifacts). To improve the accuracy it's better to scale down the image.

from blinkid-android.

culoi avatar culoi commented on August 16, 2024

Closing the issue, please reopen if you have questions or contact us directly at [email protected].

from blinkid-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.