简体   繁体   English

Zxing.Net中GenericMultipleBarcodeReader的自动旋转选项

[英]Autorotate option for GenericMultipleBarcodeReader in Zxing.Net

How can I set the hint 'AutoRotate' for 'GenericMultipleBarcodeReader' in Zxing.net. 如何在Zxing.net中为“ GenericMultipleBarcodeReader”设置提示“ AutoRotate”。 I have set Try_Harder = true. 我已经设置了Try_Harder = true。 But no results for detecting multiple 1d/2d barcodes from a rotated image. 但是,从旋转的图像中检测多个1d / 2d条形码没有结果。 If the image is aligned properly it gives the results. 如果图像正确对齐,则可以得到结果。

Edit: In 'GenericMultipleBarcodeReader' I am using 'ByQuadrantReader'. 编辑:在“ GenericMultipleBarcodeReader”中,我正在使用“ ByQuadrantReader”。 This could detect barcodes and QR codes from properly aligned images. 这样可以从正确对齐的图像中检测条形码和QR码。 For a rotated image it could not find anything. 对于旋转的图像,找不到任何东西。

MultiFormatReader multiReader = new MultiFormatReader();
ZXing.Multi.GenericMultipleBarcodeReader byquadReader = new ZXing.Multi.GenericMultipleBarcodeReader(new ByQuadrantReader(multiReader));              
Dictionary<DecodeHintType, object> hints = new Dictionary<DecodeHintType, object>();
hints.Add(DecodeHintType.TRY_HARDER, true);
List<BarcodeFormat> formats = new List<BarcodeFormat>();
formats.Add(BarcodeFormat.All_1D);
formats.Add(BarcodeFormat.QR_CODE);
hints.Add(DecodeHintType.POSSIBLE_FORMATS, formats);
****
byquadresults = byquadReader.decodeMultiple(binaryBitmap, hints);

Could any one please help me. 谁能帮我。

AutoRotate can only be used with the BarcodeReader class. AutoRotate只能与BarcodeReader类一起使用。

     var bitmap = (Bitmap)Bitmap.FromFile("<path to your image file>");
     var reader = new BarcodeReader
     {
        AutoRotate = true,
        Options = new DecodingOptions
        {
           TryHarder = true,
           PossibleFormats = new List<BarcodeFormat>
           {
              BarcodeFormat.All_1D,
              BarcodeFormat.QR_CODE
           }
        }
     };

     var results = reader.DecodeMultiple(bitmap);

If you want to use the ByQuadrantReader you have to replace the line 如果要使用ByQuadrantReader,则必须替换该行

var reader = new BarcodeReader...

with

var reader = new BarcodeReader(new ByQuadrantReader(new MultiFormatReader()), null, null)...

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

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