首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

用Google二维码识别程序库zxing开发的分辨程序,为什么有的能识别,有的识别不了

2013-12-21 
用Google二维码识别程序库zxing开发的识别程序,为什么有的能识别,有的识别不了如题。从GOOLE、百度图片上下

用Google二维码识别程序库zxing开发的识别程序,为什么有的能识别,有的识别不了
如题。
从GOOLE、百度图片上下载下来的一些二维码图片,有的是打了网站水印的,拿手机“我查查”软件能识别出相关包含的信息。但是用zxing开发的程序识别不了(其他的标准的大部分都能识别),这是为什么?谢谢,在线等。

代码如下:
using System;
using System.Drawing;
using System.Windows.Forms;
using com.google.zxing;
using COMMON = com.google.zxing.common;

private void button1_Click(object sender, EventArgs e)
  {
     if (this.openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Image img = Image.FromFile(this.openFileDialog1.FileName);
            Bitmap bmap;
            try
            {
                bmap = new Bitmap(img);
            }
            catch (System.IO.IOException ioe)
            {
                MessageBox.Show(ioe.ToString());
                return;
            }
            if (bmap == null)
            {
                MessageBox.Show("Could not decode image");
                return;
            }           
            LuminanceSource source = new RGBLuminanceSource(bmap, bmap.Width, bmap.Height);
            com.google.zxing.BinaryBitmap bitmap = new com.google.zxing.BinaryBitmap(new COMMON.HybridBinarizer(source));
            Result result;
            try
            {
                result = new MultiFormatReader().decode(bitmap); 
            }
            catch (ReaderException re)
            {
                MessageBox.Show(re.ToString());
                return;
            }
            MessageBox.Show(result.Text);         
    }  像是这种,拿手机能扫描出来。但是用上面的程序识别不出。
猜测是背景上有条纹,
把灰度的阀值调大点看看

热点排行