Esempio n. 1
0
        public decimal GetOcrMoney(ScreenConfig config, out Bitmap bitMap)
        {
            bitMap = ScreenPlugins.GetBitmapFromPoint(config);
            if (bitMap == null)
            {
                return(0M);
            }

            #region 图片处理 方便OCR解析更加准确
            var bitMapOce = bitMap;

            bitMapOce = GetZoom(bitMap, 3.5);
            //灰度化
            ToGrey(bitMapOce);
            //二值化
            Thresholding(bitMapOce);
            #endregion

            #region OCR文字识别
            var ocr  = new TesseractEngine(_config.OCRResourcePath, "chi_sim", EngineMode.Default);
            var page = ocr.Process(bitMapOce, PageSegMode.RawLine);
            #endregion

            #region OCR解析处理
            var moneyStr = page?.GetText();
            foreach (var item in ConstDefintion.MONEY_REPLACE)
            {
                moneyStr = moneyStr.Replace(item.Key, item.Value);
            }
            #endregion

            TextHelper.Write("data->" + page?.GetText() + " 转换后->" + moneyStr);
            return(ResolveMoney(moneyStr));
        }
Esempio n. 2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            DateTime    dt          = DateTime.Now;
            Bitmap      bitMap      = ScreenPlugins.GetScreenSnapshot();
            BitmapImage bitmapImage = ScreenPlugins.BitmapToBitmapImage(bitMap);

            Window7 win7 = new Window7(bitmapImage, bitMap, this);

            win7.ShowDialog();

            //image1.Source
            ImageSource img = System.Windows.Clipboard.GetImage();

            this.ImagePannel.Width  = img.Width;
            this.ImagePannel.Height = img.Height;
            this.ImagePannel.Source = img;
        }
Esempio n. 3
0
        private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            System.Drawing.Bitmap bitmap;
            if (DownFlag == true && capture != null)
            {
                int    left   = Convert.ToInt32(capture.Margin.Left);
                int    top    = Convert.ToInt32(capture.Margin.Top);
                int    width  = Convert.ToInt32(capture.Width);
                int    height = Convert.ToInt32(capture.Height);
                double r_1    = left + width;
                double h_1    = top + height;

                var leftTopSize    = new System.Drawing.Size(left, top);
                var leftBottomSize = new System.Drawing.Size(left, top + height);

                var rightTopSize    = new System.Drawing.Size(left + width, top);
                var rightBottomSize = new System.Drawing.Size(left + width, top + height);

                //坐标相关配置
                var config = new WP.Device.Framework.Screen.ScreenConfig()
                {
                    LeftBottomCoordinate  = leftBottomSize,
                    LeftTopCoordinate     = leftTopSize,
                    RightBottomCoordinate = rightBottomSize,
                    RightTopCoordinate    = rightTopSize,
                };

                //Ocr 获取金额
                var money = DeviceGlobalManage.GetOcrMoney(config, out bitmap);
                this.mainWindow.txbMoneyScreen.Text = money.ToString();


                using (System.Drawing.Bitmap map = (System.Drawing.Bitmap)bitmap)
                {
                    BitmapSource source = ScreenPlugins.GetBitMapSourceFromBitmap(map);
                    Clipboard.SetImage(source);

                    bitmap.Dispose();
                    GlobalBitmap.Dispose();
                    this.Close();
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 委托事件获取当前时间
        /// </summary>
        /// <param name="para"></param>
        private void UpdateValue(decimal para, Bitmap bit)
        {
            this.txbMoneyScreen.Text = para.ToString();

            if (bit == null)
            {
                return;
            }
            BitmapSource source = ScreenPlugins.GetBitMapSourceFromBitmap(bit);

            //System.Windows.Clipboard.SetImage(source);

            //ImageSource img = System.Windows.Clipboard.GetImage();
            if (source != null)
            {
                this.ImagePannel.Width  = source.Width;
                this.ImagePannel.Height = source.Height;
                this.ImagePannel.Source = source;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 委托事件获取
        /// </summary>
        /// <param name="para"></param>
        private void UpdateFindFormValue(decimal para, Bitmap bit)
        {
            this.txbMoneyForm.Text = para.ToString();

            if (bit == null)
            {
                return;
            }
            BitmapSource source = ScreenPlugins.GetBitMapSourceFromBitmap(bit);

            System.Windows.Clipboard.SetImage(source);

            ImageSource img = System.Windows.Clipboard.GetImage();

            if (img != null)
            {
                this.ImagePannel2.Width  = img.Width;
                this.ImagePannel2.Height = img.Height;
                this.ImagePannel2.Source = img;
            }
        }