Giter Club home page Giter Club logo

Comments (11)

DoDoENT avatar DoDoENT commented on August 16, 2024

When creating RecognizerSettings object, you can add multiple recognizers to it.

By default, when multiple recognizers are active, the first one who recognises the image returns the result - this means that either barcode or OCR will be performed on camera frame. However, if you want to ensure both recognizers are executed for every camera frame (regardless if first one has already successfully recognised image), you can allow returning multiple results.

from blinkid-android.

leeyikkong avatar leeyikkong commented on August 16, 2024

I still cannot get 2 type of scan in same time. May I know what is the problem? Thank you

RecognitionSettings settings = new RecognitionSettings();

    settings.setAllowMultipleScanResultsOnSingleImage(true);
    // setup array of recognition settings (described in chapter "Recognition
    // settings and results")

    //settings.setRecognizerSettingsArray(setupPhoneNumberReader());
    settings.setRecognizerSettingsArray(setupBarcodeReader());

    intent.putExtra(ScanCard.EXTRAS_RECOGNITION_SETTINGS, settings);

    // Starting Activity
    startActivityForResult(intent, MY_REQUEST_CODE);

.
.
.

private RecognizerSettings[] setupBarcodeReader(){
    Log.i(TAG, "barcode is Recognised, Select barcode Setting. ");

    ZXingRecognizerSettings  sett = new ZXingRecognizerSettings();
    BlinkOCRRecognizerSettings sett1 = BarcodeTemplate.barcodeTemplate();

    sett.setInverseScanning(false);
    sett.setScanCode128(true);

    return new RecognizerSettings[]{sett1, sett};
}

from blinkid-android.

i1E avatar i1E commented on August 16, 2024

Hi @leeyikkong,

if you allow multiple scan results on a single image, that does not mean that you will always obtain results from all used recognizers. This just means that when some recognizer has produced the result on the current frame, recognition chain will not be stopped and other recognizers will get a chance to use current frame to produce the result. It is not mandatory for all recognizers to produce results and you will obtain results only from successful recognizers. In your case barcode recognizer is faster than BlinkOCRRecognizer and needs a less number of frames to produce the result. BlinkOCRRecognizer gets chance to produce the result from the same number of frames, but it does not succeed and only barcode result is returned.

If you want to be sure that you will always obtain both results, you have two options:

  1. Use provided scan activity (ScanCard for example) and when you obtain results, store them and exclude RecognizerSettings for the recognizer/recognizers that have produced the result/results. Then start activity again with updated recognition settings (exclude successful recognizers) to obtain missing results.

  2. Implement your own custom scan activity and when you obtain results in onScanningDone method, store the results and use the reconfigureRecognizers method on RecognizerView to set new recognition settings with excluded recognizers that have already produced results.

Second option is much better because you do not have to start scan activity multiple times, which means better user experience, but it will take more time to implement.

from blinkid-android.

leeyikkong avatar leeyikkong commented on August 16, 2024

for the first option, which mean is after first scan activity done, then it auto restart another scancard activity again, but using the other recognizer setting?

from blinkid-android.

leeyikkong avatar leeyikkong commented on August 16, 2024

if use blinkocr, it can scan barcode and other information in the same time? I go through one of the demo application of blinkOCR, if not mistaken is the blinkOCRFullScreen, when i scan the barcode, it also will show the other information in the same time.

from blinkid-android.

i1E avatar i1E commented on August 16, 2024

Yes, you are right for the first option.

The demo app that you have mentioned (BlinkOCRFullScreen) uses the second approach which is better, you can use code from FullScreenOCR activity as an example for implementing your own activity. BlinkOCR SDK is included in the BlinkID SDK and you can use all its components in BlinkID.

from blinkid-android.

leeyikkong avatar leeyikkong commented on August 16, 2024
 public void onScanningDone(RecognitionResults results) {
    Barcode barcode = null;
    // called when scanning completes. In this example, we first check if dataArray contains
    // barcode result and display a barcode contents in the Toast.
    // We also check if dataArray contains raw parser result and log it to ADB.
    BaseRecognitionResult[] dataArray = results.getRecognitionResults();
    for (BaseRecognitionResult r : dataArray) {
        if (r instanceof BarDecoderScanResult) { // r is barcode scan result
            BarDecoderScanResult bdsr = (BarDecoderScanResult) r;
            //BlinkOCRRecognitionResult bocrRes = (BlinkOCRRecognitionResult) r;
            // create toast with contents: Barcode type: barcode contents
            String res = bdsr.getStringData();
            barcodeNo = res;
            Log.i("Parsed bar", res.replace("[^0-9 ]", ""));

        } else if (r instanceof BlinkOCRRecognitionResult) {
            BlinkOCRRecognitionResult bocrRes = (BlinkOCRRecognitionResult) r;

            // obtain parse result from the parser named "Raw"
            String result = bocrRes.getParsedResult("Raw");
            String rawParsed = result.replaceAll("[^0-9]", "");
            Log.i(TAG, "Parsed >> " + rawParsed.replaceAll("[^0-9]", ""));
            if (rawParsed.substring(0, 3).equals("015") || rawParsed.substring(0, 3).equals("010")) {
                if (rawParsed.substring(0, 3).equals("015")) {
                    phoneNo = rawParsed.substring(0, 3) + "-" + rawParsed.substring(3, 7) + " " + rawParsed.substring(7, 11);
                } else {
                    phoneNo = rawParsed.substring(0, 3) + "-" + rawParsed.substring(3, 6) + " " + rawParsed.substring(6, 10);
                }
                Log.i(TAG, "My Phone Number = " + phoneNo);
                Log.i(TAG, "My Barcode Number = " + barcodeNo);
            } else {
                Log.i(TAG, " BECAUSE OF HERE CRASH MY APPLICATION");

            }
/*                // obtain OCR result that was used for parsing
            OcrResult ocrResult = bocrRes.getOcrResult();
            Log.i(TAG,"OcrResult >>" + ocrResult.toString());*/
        }
    }
    // Finally we reset recognizer's internal state so it will not combine old recognition
    // results with new one. Scanning is resumed automatically after this method ends.
    mRecognizerView.resetRecognitionState();
}

May I know how to rescan the information when I get the information that I do not need? The application will crash because of the results get from the scan which are NOT I want. When the First Scan is started, it will get the result, that why if sometime my camera did not point to the information that I want to scan, it will get the wrong information. Thank You.

from blinkid-android.

i1E avatar i1E commented on August 16, 2024

Hi @leeyikkong,

you should not crash your application when you obtain the result(information) which you don't need. Just continue scanning until you get the desired information.

from blinkid-android.

leeyikkong avatar leeyikkong commented on August 16, 2024

because of it continue scanning, I can see the result in Log, it continue show the result, sometime the result is symbol, sometime show digit/characters. if I want to get the correct result, then how should I get it?

from blinkid-android.

i1E avatar i1E commented on August 16, 2024

You should try different parser for the information you want to recognize, RawParser returns raw text (everything). You can try using the RegexParser with regular expression that describes the information which you want to read. Please, take a look at this example.

from blinkid-android.

leeyikkong avatar leeyikkong commented on August 16, 2024

Its WORK! Thanks a lot..

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.