【问题标题】:Reading 2D Barcode from Images [closed]从图像中读取二维条码 [关闭]
【发布时间】:2012-04-10 07:30:33
【问题描述】:

我需要一个库来从 C# 项目(Windows 窗体)上的图像中读取二维条码(数据矩阵)。 我尝试使用一些 SDK,但我尝试的 SDK 不是免费的。

是否有免费的 SDK 可以从图像中读取二维条码?

【问题讨论】:

标签: c# icsharpcode


【解决方案1】:

有一个example available

  using DataMatrix.net;               // Add ref to DataMatrix.net.dll
  using System.Drawing;               // Add ref to System.Drawing.
  [...]

  // ---------------------------------------------------------------
  // Date      180310
  // Purpose   Get text from a DataMatrix image.
  // Entry     sFileName - Name of the barcode file (PNG, + path).
  // Return    The text.
  // Comments  See source, project DataMatrixTest, Program.cs.
  // ---------------------------------------------------------------
  private string DecodeText(string sFileName)
  {
      DmtxImageDecoder decoder = new DmtxImageDecoder();
      System.Drawing.Bitmap oBitmap = new System.Drawing.Bitmap(sFileName);
      List<string> oList = decoder.DecodeImage(oBitmap);

      StringBuilder sb = new StringBuilder();
      sb.Length = 0;
      foreach (string s in oList)
      {
          sb.Append(s);
      }
      return sb.ToString();
  }

你需要DataMatrix.net

【讨论】:

  • 我尝试使用它,但它无法正确解码 unicode 字符(我猜是 2 年前) - 我编码了包含俄罗斯字符的字符串,但它没有给我正确的解码结果。
  • @cookieMonster 实际上 DataMatrix.net 是 A C#/.net-library for encoding and decoding DataMatrix codes (based on a .net-port of libdmtx). - 所以它基于您建议的 libdtmx。顺便说一句 - 遇到俄罗斯字符时,您是否在 @DataMatrix.net 提交了错误通知单?
  • 它可能是“基于”的,但它不是 .net 端口,libdmtx 有自己的端口,并且在解码方面效果更好。
  • 我最多可以阅读。仅来自图像的 2 个条形码。可能是什么原因?
  • @NinethSense 因为我不是这个程序集的作者,你可能想在他们的 sourceforge 网站上直接联系他们(通过票证或他们论坛中的帖子 (sourceforge.net/p/datamatrixnet/discussion/1030456))跨度>
【解决方案2】:

我用过的最好的免费 Datamatrix 编码器\解码器是 libdmtx: http://www.libdmtx.org/ 。它有 c# 包装器,所以请随意使用它。我现在无法编写示例代码,但如果您无法自己处理,我稍后会为您提供帮助。

编辑: libdmtx 带有控制台实用程序 - 如果您能够使用控制台应用程序读取条形码,那么您肯定会使用代码读取它。

编辑2: 这是代码示例:http://libdmtx.wikidot.com/libdmtx-net-wrapper

我想知道您是否有包含除条形码以外的其他信息的图片。问题是 - 我不知道任何免费\开源库来处理在图片上查找条形码,正确包含任何其他数据。 这是其他数据矩阵实现的链接:http://www.libdmtx.org/resources.php

【讨论】:

    猜你喜欢
    • 2022-10-13
    • 2010-09-11
    • 2018-11-19
    • 2018-03-01
    • 1970-01-01
    • 2014-02-24
    • 2012-11-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多