コード例 #1
0
        async void ButtonRight(object sender, EventArgs e)
        {
            buttonRight.Enabled = false;
            buttonNext.Enabled  = false;
            button2.Enabled     = false;

            Bitmap    roibmp;
            Pix       roipix;
            Rectangle roi = ramka.getRoi();

            Cursor = Cursors.WaitCursor;
            roibmp = ramka.Image.Clone(roi, ramka.Image.PixelFormat);
            roipix = PixConverter.ToPix(roibmp);
            roibmp.Dispose();

            Task <string> ocr = Task.Run <string>(() => {
                return(DoOCR(roipix));
            });
            string txt = await ocr;

            System.Diagnostics.Debug.WriteLine(txt);
            if (gOcrTxtForm == null || gOcrTxtForm.IsDisposed)
            {
                gOcrTxtForm = new OCRText();
                gOcrTxtForm.Show();
            }
            gOcrTxtForm.SetText(txt);
            buttonRight.Enabled = true;
            buttonNext.Enabled  = true;
            button2.Enabled     = true;
            Cursor = Cursors.Default;
            roipix.Dispose();
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: tayercoder/UyghurOCR
        async void ButtonRight(object sender, EventArgs e)
        {
            buttonRight.Enabled = false;
            buttonNext.Enabled  = false;
            button2.Enabled     = false;

            Bitmap roibmp;
            Pix    roipix;

            OpenCvSharp.Rect roi = ramka.getRoi();
            Mat src;

            Cursor = Cursors.WaitCursor;
            if (roi.X != -1)
            {
                src = ramka.Image[roi];
            }
            else
            {
                src = ramka.Image;
            }

            roibmp = src.ToBitmap();
            roipix = PixConverter.ToPix(roibmp);

            Task <string> ocr = Task.Run <string>(() => {
                return(DoOCR(roipix));
            });
            string txt = await ocr;

            System.Diagnostics.Debug.WriteLine(txt);
            if (gOcrTxtForm == null || gOcrTxtForm.IsDisposed)
            {
                gOcrTxtForm = new OCRText();
                gOcrTxtForm.Show();
            }
            gOcrTxtForm.SetText(txt);
            buttonRight.Enabled = true;
            buttonNext.Enabled  = true;
            button2.Enabled     = true;
            Cursor = Cursors.Default;
            roibmp.Dispose();
            roipix.Dispose();
        }