Пример #1
0
        private void BgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            OCRResult r = null;

            switch (this.MethodName)
            {
            case "GeneralBasic": r = OCRUtils_Baidu.Excute_GeneralBasic(e.Argument as byte[]); break;

            case "General": r = OCRUtils_Baidu.Excute_General(e.Argument as byte[]); break;

            case "AccurateBasic": r = OCRUtils_Baidu.Excute_AccurateBasic(e.Argument as byte[]); break;

            case "Accurate": r = OCRUtils_Baidu.Excute_Accurate(e.Argument as byte[]); break;
            }

            e.Result = r;
        }
Пример #2
0
        public void Test_Excute_GeneralBasic()
        {
            var path = @"D:\SC_Github\OCRTools\OCRSolution\UnitTest\Images\0~9_A~G.png";

            byte[] byteArr_Image = null;
            using (System.IO.FileStream fs = new System.IO.FileStream(path: path, mode: System.IO.FileMode.Open))
            {
                byteArr_Image = new byte[fs.Length];
                fs.Read(byteArr_Image, 0, byteArr_Image.Length);
            }

            var r = OCRUtils_Baidu.Excute_GeneralBasic(byteArr_Image);

            Assert.AreEqual <bool>(true, r.IsSuccess);
            Assert.AreEqual <int>(2, r.Details.Count);

            var detail = r.Details[0];

            Assert.AreEqual <string>("1234567890", detail.Content);

            detail = r.Details[1];
            Assert.AreEqual <string>("ABCDEFG", detail.Content);
        }