【问题标题】:How to set ReadBarcodes properly如何正确设置 ReadBarcodes
【发布时间】:2020-03-27 18:28:13
【问题描述】:

我正在尝试读取 3of9 条码。 3of9 barcode Image 给我的结果是不稳定的,但位置仍然相同。 (尝试多次运行该方法相同的图像/条形码和相同的位置) 我所说的不稳定的意思是有时我会得到条形码的价值 前任。 barcodesd.Length 不为零,因此它得到的barcodesd[0].Value 是 25350111 有时barcodesd.Length = 0

这是我的代码:

public static string DecodeImg(System.Drawing.Bitmap img)
        {
            System.IO.MemoryStream data = new MemoryStream();
            RasterImage srcImage = null;
            try
            {

                BarcodeEngine engine = new BarcodeEngine();
                Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs();

                img.Save(data, System.Drawing.Imaging.ImageFormat.Jpeg);
                data.Seek(0, System.IO.SeekOrigin.Begin);
                srcImage = codecs.Load(data);
                BarcodeData[] barcodesd = engine.Reader.ReadBarcodes(srcImage, LeadRect.Empty, 0, BarcodeEngine.GetSupportedSymbologies(), null);
                srcImage.Dispose();
                if (barcodesd != null)
                {
                    if (barcodesd.Length > 0)
                        return barcodesd[0].Value;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                data.Dispose();

                if (srcImage != null)
                    srcImage.Dispose();
            }

            return "Unable to Read";
        }

【问题讨论】:

  • throw ex.Message; 无法编译。
  • 好的,编辑问题。我对此不好。

标签: c# leadtools-sdk


【解决方案1】:

图像中的条形码未正确编码。看起来无论是谁(或其他)生成它都试图在其中插入 2 个星号“*”字符。 “*”字符不是真正的可编码字符,而是 Code 3 of 9 条码的开始和结束符号。这意味着它不应该插入到条形码字符串中。

由于代码中有 2 个这样的“*”字符,阅读器可能能够“找到”中间部分并自行将其视为有效条形码。但这是不可预测的,因为整个代码的编码不正确。

如果您认为该代码是有效的,并且您有任何来源的证据(例如,不同的条形码阅读器可以始终识别它),请将您拥有的图像发送至 support@leadtools.com 并提供完整的详细信息关于你的发现。还包括有关您使用的 SDK 版本和平台的信息(例如 v20、64 位 C# WinForms)。

【讨论】:

  • 谢谢...是的,我现在已经就这个问题咨询了leadtools的支持。
猜你喜欢
  • 1970-01-01
  • 2011-04-15
  • 2020-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多