基本信息
源码名称:开源的Tesseract和ZXing库实现OCR 和条码二维码识别
源码大小:29.23M
文件格式:.7z
开发语言:C#
更新时间:2020-02-27
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 10 元 
   源码介绍
开源的Tesseract和ZXing库实现OCR 和条码二维码识别

Rectangle oldRect = new Rectangle(x1 * bs, y1 * bs, (x2 - x1) * bs, (y2 - y1) * bs);  //原图中要切除出一块小图,坐标为(x y)长L 高W
            Rectangle newRect = new Rectangle(0, 0, (x2 - x1) * bs, (y2 - y1) * bs);//新图在画布的左上角坐标为(0 0)长L 高W
            Bitmap newBmp = new Bitmap((x2 - x1) * bs, (y2 - y1) * bs);//放置新图的画布,照搬新图的大小
            Graphics Q = Graphics.FromImage(newBmp);
            Q.DrawImage(Bmp, newRect, oldRect, GraphicsUnit.Pixel);
            pictureBox3.Width = (x2 - x1);
            pictureBox3.Height = (y2 - y1);
            pictureBox3.Image = newBmp;

            if(OCR_cb.Checked == true)
            {

                TesseractProcessor process = new TesseractProcessor();
                process.SetPageSegMode(ePageSegMode.PSM_SINGLE_LINE);
                process.Init(System.Environment.CurrentDirectory "\\", "eng", (int)eOcrEngineMode.OEM_DEFAULT);
                string result = process.Recognize(newBmp);
                if (result == null) MessageBox.Show("读取失败");
                else Result_tb.Text = result;

            }
            else if (Barcode_cb.Checked == true)
            {               
                    DecodingOptions decodeOption = new DecodingOptions();
                    decodeOption.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.All_1D };
                    //读取条形码
                    BarcodeReader br = new BarcodeReader();
                    br.Options = decodeOption;
                    Result result = br.Decode(newBmp as Bitmap);           
                    if (result == null) MessageBox.Show("读取失败");
                    else Result_tb.Text = result.Text;
            }
            else
            {
                DecodingOptions decodeOption = new DecodingOptions();
                decodeOption.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.QR_CODE };
                //读取二维码
                ZXing.BarcodeReader br = new BarcodeReader();
                br.Options = decodeOption;
                ZXing.Result rs = br.Decode(newBmp as Bitmap);
                if (rs == null) MessageBox.Show("读取失败");              
                else Result_tb.Text = rs.Text;
                
            }

        }
    }