【问题标题】:ZXing multiformat reading under C#?C#下ZXing多格式阅读?
【发布时间】:2012-02-01 03:20:08
【问题描述】:

将 ZXing 与网络摄像头 Feed 结合使用,尝试读取各种条码/QR 码。只有一个问题,它拒绝阅读它们。它会读取我周围的一个条形码,我认为是 128 型,但是当我试图让它读取其他任何东西时,什么都没有发生。

这是我现在用来设置读取各种类型的提示的代码:

reader = new MultiFormatReader();

hints = new Hashtable();
fmts = new ArrayList();
fmts.Add(BarcodeFormat.DATAMATRIX);
fmts.Add(BarcodeFormat.QR_CODE);
fmts.Add(BarcodeFormat.PDF417);
fmts.Add(BarcodeFormat.UPC_E);
fmts.Add(BarcodeFormat.UPC_A);
fmts.Add(BarcodeFormat.CODE_128);
fmts.Add(BarcodeFormat.CODE_39);
fmts.Add(BarcodeFormat.ITF);
fmts.Add(BarcodeFormat.EAN_8);
fmts.Add(BarcodeFormat.EAN_13);
hints.Add(DecodeHintType.TRY_HARDER, true);
hints.Add(DecodeHintType.POSSIBLE_FORMATS, fmts);

reader.Hints = hints;

(基于:http://osdir.com/ml/zxing/2010-02/msg00043.html

而实际的解码代码是这样的……

RGBLuminanceSource lumi = new RGBLuminanceSource((Bitmap)image, width, height);
Result result = reader.decode(new BinaryBitmap(new HybridBinarizer(lumi)), hints);
readData = result.Text;

我在做傻事吗?有没有其他人在 C# 下使用 ZXing 取得成功?

非常感谢所有帮助。

干杯。

附: Win7 32b VS2008下使用ZXing 1.7。

【问题讨论】:

    标签: c# winforms barcode zxing


    【解决方案1】:

    尝试使用 GlobalHistogramBinarizer,HybridBinarizer 似乎不起作用..

    QRCodeReader reader = new QRCodeReader();
           Bitmap bmp = new Bitmap(@"2.bmp");
    
    
            LuminanceSource s = new RGBLuminanceSource(bmp, bmp.Width, bmp.Height);
            BinaryBitmap bb = new BinaryBitmap(new GlobalHistogramBinarizer(s));
            Hashtable hints = new Hashtable();
    
            Result result = reader.decode(bb);
    
    
            MessageBox.Show(result.Text); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多