简体   繁体   English

zxing.net条码解码,无需调整大小

[英]zxing.net barcode decode without resize

I want to decode Multiple QR Code with zxing.net and DecodeMultiple method but by default it return null collection result. 我想用zxing.net和DecodeMultiple方法解码多个QR码,但是默认情况下它返回空集合结果。 When I resize my picture and then decode most of QR code was decoded successfully but one or two small QR Code not decode. 当我调整图片大小然后解码时,大多数QR码都已成功解码,但是一两个小的QR码无法解码。 Here is my Pictures: 这是我的照片: 在此处输入图片说明在此处输入图片说明

and here is my code: 这是我的代码:

BarcodeReader reader = new BarcodeReader();
reader.PossibleFormats = new List<BarcodeFormat>();
reader.PossibleFormats.Add(BarcodeFormat.QR_CODE);
reader.AutoRotate = false;
reader.TryHarder = false;
Bitmap input = (Bitmap)Bitmap.FromFile(Application.StartupPath + "\\1.jpg");
Resize_Picture(Application.StartupPath + "\\1.jpg", Application.StartupPath + "\\1_resized.jpg", 800, 0, 100);
var results = reader.DecodeMultiple((Bitmap)Bitmap.FromFile(Application.StartupPath + "\\2.jpg"));

Why this picture required resize?? 为什么需要调整此图片的大小? what is the best size for QR Code. QR Code的最佳尺寸是多少? Please guide me to decode without image resize. 请指导我解码而无需调整图像大小。 thanks 谢谢

After Edit (I add QR Code for test): 编辑后(我添加了QR代码进行测试):

I upload my QR Cod you can download from here . 我上传了我的QR Cod,您可以从此处下载。

As far as I can see the default binarizer has some trouble with the background color and the anti-aliasing arround the QR codes. 据我所知,默认的二值化器在背景颜色和QR码周围的抗锯齿方面存在一些问题。 You should use the GlobalHistogramBinarizer. 您应该使用GlobalHistogramBinarizer。

BarcodeReader reader = new BarcodeReader(null,
    bitmap => new BitmapLuminanceSource(bitmap),
    luminance => new GlobalHistogramBinarizer(luminance));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM