سؤال

I need a library to read 2D barcode (datamatrix) from images on C# project (windows Forms). I tried using some SDKs, but the SDKs I tried are not free.

Is there any free SDK for reading 2d Barcode from images?

هل كانت مفيدة؟

المحلول

There's an 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();
  }

You'll need DataMatrix.net!

نصائح أخرى

Best free Datamatrix coder\decoder that i've used is libdmtx: http://www.libdmtx.org/ . It has c# wrapper, so feel free to use it. I can't write sample code right now, but if you won't be able to handle it yourself, i'll help you a bit later with that.

EDIT: libdmtx comes with console utils - if you will be able to read your barcodes with console app, you surely will read it using code.

EDIT2: Here's code samples: http://libdmtx.wikidot.com/libdmtx-net-wrapper

I wonder if you have pictures containing some other info, except the barcode. The thing is - i don't know any free\open source lib to handle finding barcode on a picture, containing any other data properly. And here's the link to other datamatrix implementations: http://www.libdmtx.org/resources.php

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top