Exemplo n.º 1
0
        public void RunOCR(Bitmap inputImage)
        {
            inputImagePV.Image = inputImage;
            Bitmap removeBorderImage = BorderRemoval.RemoveBorder(inputImage);

            removeBorderPV.Image = removeBorderImage;
            Bitmap removeNoiseImage = NoiseCleaner.RemoveNoiseWithBorder(removeBorderImage);

            noiseRemovalPV.Image = removeNoiseImage;
            Bitmap croppedImage = WhitespaceCropper.CropWhitespace(removeNoiseImage);

            croppedPV.Image = croppedImage;
            if (EmptyImageDetector.IsImageEmpty(croppedImage))
            {
                recognizedGradeLabel.Text       = "0";
                recognitionConfidenceLabel.Text = "empty";
            }
            else
            {
                Bitmap digestImage = DigestExtractor.ExtractDigestImage(croppedImage);
                digestPV.Image = digestImage;

                GradeDigest       digest            = GradeDigest.FromImage(digestImage);
                RecognitionResult recognitionResult = GradeOCR.Program.RecognizeGrade(digest);

                recognizedGradeLabel.Text       = recognitionResult.Grade.ToString();
                recognitionConfidenceLabel.Text = recognitionResult.Confident ? "sure" : "unsure";
            }
        }
Exemplo n.º 2
0
        public static Option <GradeDigest> GetGradeDigest(Bitmap img)
        {
            Bitmap croppedImage =
                WhitespaceCropper.CropWhitespace(
                    NoiseCleaner.RemoveNoiseWithBorder(
                        BorderRemoval.RemoveBorder(img)));

            if (EmptyImageDetector.IsImageEmpty(croppedImage))
            {
                return(new None <GradeDigest>());
            }
            else
            {
                return(new Some <GradeDigest>(
                           GradeDigest.FromImage(
                               DigestExtractor.ExtractDigestImage(croppedImage))));
            }
        }