【发布时间】: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。
【问题讨论】: