示例#1
0
        public MainWindow()
        {
            InitializeComponent();
            this.Title = this.Title + " - V{0}".FormatWith(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());

            initData();

            OCRUtils_Baidu.InitBaiduKey();

            initUI();
            initEvent();
            this.txtImage.Focus();
        }
示例#2
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;
        }
示例#3
0
        public void Test_Excute_Accurate()
        {
            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_Accurate(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);
        }
示例#4
0
        private void initData()
        {
            if (System.IO.File.Exists(App.FullName) == false)
            {
                ShowApiSecurityInfo();
                return;
            }

            string jsonStr = System.IO.File.ReadAllText(App.FullName);
            List <ApiSecurityInfo> list = Util.JsonUtils.DeserializeObject <List <ApiSecurityInfo> >(jsonStr);

            if (list == null || list.Count <= 0)
            {
                ShowApiSecurityInfo();
                return;
            }

            cbxBaiduApiKey.ItemsSource = list;

            var matchFirst = list[0];

            cbxBaiduApiKey.SelectedItem = matchFirst;
            OCRUtils_Baidu.SetBaiduKey(matchFirst);
        }
示例#5
0
 public void Init()
 {
     OCRUtils_Baidu.InitBaiduKey();
 }
示例#6
0
        private void CbxBaiduApiKey_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ApiSecurityInfo selected = cbxBaiduApiKey.SelectedItem as ApiSecurityInfo;

            OCRUtils_Baidu.SetBaiduKey(selected);
        }