Exemple #1
0
        public TextExtractionResults DoOcr(byte[] image)
        {
            var aws = new Aws.AwsTextTract();

            aws.AmazonAccessKey = this.Config["awstextract_accesskey"];
            aws.AmazonSecretKey = this.Config["awstextract_secretkey"];
            return(aws.Extract(image));
        }
Exemple #2
0
        public void AwsTextTract()
        {
            IConfiguration cfg = BuildConfig();

            Aws.AwsTextTract ocr = new Aws.AwsTextTract();
            ocr.AmazonAccessKey = cfg["awstextract_accesskey"];
            ocr.AmazonSecretKey = cfg["awstextract_secretkey"];
            ocr.Region          = "eu-west-1";
            string pathSample = System.IO.Path.Combine(util.Util.GetProjectDir(), "Data\\pics\\NonReadable.PNG");

            byte[] raw     = System.IO.File.ReadAllBytes(pathSample);
            var    results = ocr.Extract(raw);

            Assert.AreEqual(62, results.Blocks.Length);
            var txtIDRH = results.Blocks.First(t => t.Text.Contains("IDRH"));

            Assert.IsTrue(txtIDRH.X1 > 1018 && txtIDRH.X2 < 1111);
            Assert.IsTrue(txtIDRH.Y1 > 85 && txtIDRH.Y2 < 117);
        }