コード例 #1
0
        private void SetOcrConfig(AnylineOcrScanView scanView)
        {
            //Configure the OCR for IBANs
            AnylineOcrConfig anylineOcrConfig = new AnylineOcrConfig();

            // use the line mode (line length and font may vary)
            anylineOcrConfig.SetScanMode(AnylineOcrConfig.ScanMode.Auto);

            // set the languages used for OCR
            anylineOcrConfig.SetTesseractLanguages("anyline_capitals");

            // allow only capital letters and numbers
            anylineOcrConfig.CharWhitelist = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";

            // a simple regex for a basic validation of the IBAN, results that don't match this, will not be returned
            // (full validation is more complex, as different countries have different formats)
            anylineOcrConfig.ValidationRegex = "[A-Z0-9]{8}$";

            /*
             *
             * // since we use the new OCR auto mode, we don't need to set these parameters anymore!
             *
             * // set the height range the text can have
             * anylineOcrConfig.MinCharHeight = 45;
             * anylineOcrConfig.MaxCharHeight = 85;
             *
             * // The minimum confidence required to return a result, a value between 0 and 100.
             * // (higher confidence means less likely to get a wrong result, but may be slower to get a result)
             * anylineOcrConfig.MinConfidence = 85;
             *
             * // removes small contours (helpful in this case as no letters with small artifacts are allowed, like iצה�)
             * anylineOcrConfig.RemoveSmallContours = true;
             *
             * // Experimental parameter to set the minimum sharpness (value between 0-100; 0 to turn sharpness detection off)
             * // The goal of the minimum sharpness is to avoid a time consuming ocr step,
             * // if the image is blurry and good results are therefore not likely.
             * anylineOcrConfig.MinSharpness = 60;
             *
             * // scan white text on black backgroundd
             * anylineOcrConfig.IsBrightTextOnDark = true;
             */

            // set the ocr config
            scanView.SetAnylineOcrConfig(anylineOcrConfig);
        }
コード例 #2
0
        private static void SetOcrConfig(AnylineOcrScanView scanView)
        {
            //Configure the OCR for IBANs
            AnylineOcrConfig anylineOcrConfig = new AnylineOcrConfig();

            anylineOcrConfig.SetScanMode(AnylineOcrConfig.ScanMode.Grid);

            anylineOcrConfig.SetTesseractLanguages("bottlecap");
            anylineOcrConfig.CharWhitelist      = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
            anylineOcrConfig.MinCharHeight      = 14;
            anylineOcrConfig.MaxCharHeight      = 65;
            anylineOcrConfig.MinConfidence      = 75;
            anylineOcrConfig.ValidationRegex    = "^[0-9A-Z]{3}\n[0-9A-Z]{3}\n[0-9A-Z]{3}";
            anylineOcrConfig.CharCountX         = 3;
            anylineOcrConfig.CharCountY         = 3;
            anylineOcrConfig.CharPaddingXFactor = .3;
            anylineOcrConfig.CharPaddingYFactor = .5;
            anylineOcrConfig.IsBrightTextOnDark = true;

            scanView.SetAnylineOcrConfig(anylineOcrConfig);
        }
コード例 #3
0
        private void SetOcrConfig(AnylineOcrScanView scanView)
        {
            //Configure the OCR for IBANs
            AnylineOcrConfig anylineOcrConfig = new AnylineOcrConfig();

            // use the line mode (line length and font may vary)
            anylineOcrConfig.SetScanMode(AnylineOcrConfig.ScanMode.Line);

            // set the languages used for OCR
            anylineOcrConfig.SetTesseractLanguages("eng_no_dict", "deu");

            // allow only capital letters and numbers
            anylineOcrConfig.CharWhitelist = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";

            // set the height range the text can have
            anylineOcrConfig.MinCharHeight = 20; //note: if you set this too low, it tries to find all the small letters too
            anylineOcrConfig.MaxCharHeight = 60;

            // The minimum confidence required to return a result, a value between 0 and 100.
            // (higher confidence means less likely to get a wrong result, but may be slower to get a result)
            anylineOcrConfig.MinConfidence = 65;

            // a simple regex for a basic validation of the IBAN, results that don't match this, will not be returned
            // (full validation is more complex, as different countries have different formats)
            anylineOcrConfig.ValidationRegex = "^[A-Z]{2}([0-9A-Z]\\s*){13,32}$";

            // removes small contours (helpful in this case as no letters with small artifacts are allowed, like iצה�)
            anylineOcrConfig.RemoveSmallContours = true;

            // Experimental parameter to set the minimum sharpness (value between 0-100; 0 to turn sharpness detection off)
            // The goal of the minimum sharpness is to avoid a time consuming ocr step,
            // if the image is blurry and good results are therefore not likely.
            anylineOcrConfig.MinSharpness = 66;

            // set the ocr config
            scanView.SetAnylineOcrConfig(anylineOcrConfig);
        }