Exemplo n.º 1
0
        /// <summary>
        /// 获取截屏区域的文字
        /// </summary>
        /// <param name="bitmap"></param>
        private void GetSnapArea(Bitmap bitmap)
        {
            Show.Text = null;
            DateTime startTime = DateTime.Now;
            string   str       = OCRApi.getFileBase64(bitmap);
            string   text      = OCRApi.GetWords(str, true);

            OCRApi.Str2Json(text, WordsNum, Show);
            DateTime endTime  = DateTime.Now;
            TimeSpan duration = endTime - startTime;

            NeedTime.Text   = string.Format("{0:N3}", duration.TotalSeconds) + " S";
            this.Visibility = Visibility.Visible;
        }
Exemplo n.º 2
0
        private void OpenPic_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "PNG|*.png|JPG|*.jpg|JPEG|*.jpeg|BMP|*.bmp|TIFF|*.tiff|WEBP|*.webp";
            ofd.RestoreDirectory = true;
            if (ofd.ShowDialog() == true)
            {
                Show.Text = null;
                DateTime startTime = DateTime.Now;
                string   text      = OCRApi.GetWords(ofd.FileName);
                OCRApi.Str2Json(text, WordsNum, Show);
                DateTime endTime  = DateTime.Now;
                TimeSpan duration = endTime - startTime;
                NeedTime.Text = string.Format("{0:N3}", duration.TotalSeconds) + " S";
            }
        }
Exemplo n.º 3
0
        private void Grid_Drop(object sender, System.Windows.DragEventArgs e)
        {
            string fileName = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();

            string[] path   = fileName.Split('.');
            string   suffix = path[path.Length - 1];

            if (suffix == "png" || suffix == "jpg" || suffix == "webm" || suffix == "jpeg" || suffix == "tiff")
            {
                Show.Text = null;
                DateTime startTime = DateTime.Now;
                string   text      = OCRApi.GetWords(fileName);
                OCRApi.Str2Json(text, WordsNum, Show);
                DateTime endTime  = DateTime.Now;
                TimeSpan duration = endTime - startTime;
                NeedTime.Text = string.Format("{0:N3}", duration.TotalSeconds) + " S";
            }
            else
            {
                MessageBox.Show("文件格式错误");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 手写笔迹识别
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HandWrite_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "PNG|*.png|JPG|*.jpg|JPEG|*.jpeg|BMP|*.bmp|TIFF|*.tiff|WEBP|*.webp";
            ofd.RestoreDirectory = true;
            if (ofd.ShowDialog() == true)
            {
                try
                {
                    Show.Text = null;
                    DateTime startTime = DateTime.Now;
                    string   text      = OCRApi.getHandWriting(ofd.FileName);
                    OCRApi.Str2Json(text, WordsNum, Show);
                    DateTime endTime  = DateTime.Now;
                    TimeSpan duration = endTime - startTime;
                    NeedTime.Text = string.Format("{0:N3}", duration.TotalSeconds) + " S";
                }
                catch
                {
                    MessageBox.Show("手写笔迹识别出现错误,可能是识别次数过多");
                }
            }
        }
Exemplo n.º 5
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     OCRApi.Clear();
     Show.Text     = null;
     WordsNum.Text = null;
 }