Datamatrix Barcodes Not Decoding

45 views
Skip to first unread message

Corey Wischmeyer

unread,
Oct 31, 2017, 3:56:25 PM10/31/17
to zxing
I'm trying to decode datamatrix codes through a "window" in the bottom of a sample plate. As you can see from the attached photo it is slightly recessed.

Using this code, I cannot get zxing to decode the attached image. dmtxread can read it, but I've used it enough to know it can return bad decodes.

It's written in scala, but I think it is pretty clear.

object Main {

def main(args: Array[String]): Unit = {
val curr_barcode = "/Users/cwischmeyer/git/scala_barcode/src/test_5.jpg"
println(curr_barcode)
val image = ImageIO.read(new File(curr_barcode)

val hint = new util.Hashtable[DecodeHintType, Object]()
hint.put(DecodeHintType.TRY_HARDER, java.lang.Boolean.TRUE)
hint.put(DecodeHintType.POSSIBLE_FORMATS, List(BarcodeFormat.DATA_MATRIX))

val lumSource = new BufferedImageLuminanceSource(image)
val bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(lumSource))
val decoder = new DataMatrixReader()
println(decoder.decode(bitmap, hint).getText())
}
}

Any ideas on what I can do to increase the decoding success rate?

Congrats on 10 years!

-Corey

test_5.jpg

gjs

unread,
Oct 31, 2017, 11:07:50 PM10/31/17
to zxing
Seeing you are doing this programmatically, I'd suggest pre-processing the image to progressively adjust the contrast, perhaps in several attempts before giving up...
test_5_datamatrix_with contrast.jpg

Corey Wischmeyer

unread,
Nov 1, 2017, 10:37:34 AM11/1/17
to zxing

Ah! Okay, this is similar to the approach I am using now. I wasn't sure if I was missing something already builtin, or if modifying contrast would interfere with what the library is already trying to do.

Thanks for taking the time!

Reply all
Reply to author
Forward
0 new messages