Reading 2D Barcode from Images [closed]
Asked Answered
R

2

8

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?

Ress answered 10/4, 2012 at 7:30 Comment(3)
codeproject.com/Articles/10162/Creating-EAN-13-Barcodes-with-C, community.bartdesmet.net/blogs/bart/archive/2006/09/18/…, idautomation.com/formscontrols/free, ... which spec are you trying to follow?Silverware
i need to read 2D datamatrix from an imageRess
which barcode-spec do you want to meet? code39, code128, code49, pdf417, qr, data-matrix? ... not very clear to me ... but i guess you are after Data Matrix (en.wikipedia.org/wiki/Data_Matrix) - am i right?Silverware
S
5

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!

Silverware answered 11/4, 2012 at 11:53 Comment(5)
i've tried to use it, but it couldn't decode unicode chars properly (it was 2 years ago, i guess) - i encoded string, which contained russian chars and it failed to give me proper result on decoding.Smog
@Smog actually DataMatrix.net is A C#/.net-library for encoding and decoding DataMatrix codes (based on a .net-port of libdmtx). - so it's based on your suggested libdtmx. btw - did you file a bug-ticket @ DataMatrix.net when coming across russian chars?Silverware
it may be 'based on', but it's not a .net port, libdmtx has it's own port and it works better in terms of decoding.Smog
I am able to read max. 2 barcodes only from an image. What could be the reason?Anatomist
@Anatomist as i am not the author of this assembly, you may want to directly contact them on their sourceforge site (either via a ticket or a thread in their forum (sourceforge.net/p/datamatrixnet/discussion/1030456))Silverware
S
2

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

Smog answered 11/4, 2012 at 12:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.