Read Data Matrix Barcode using Java

This brief tutorial describes how to read Data Matrix barcode using Java. You will get details on setting up the IDE, a list of steps, and a sample code for a basic Data Matrix code scanner using Java. Code customizations will be discussed at the end of the article to create the barcode image with the specified settings.

Steps for Data Matrix Code Reader using Java

  1. Set the environment to use Aspose.BarCode for Java to read Data Matrix code
  2. Define the path to the image containing Data Matrix codes in it
  3. Apply a license, as Data Matrix code reading is not supported in the trial version
  4. Create the BarCodeReader object by setting the input image file name and target code type as Data Matrix
  5. Set the reading quality to high for handling the difficult images
  6. Scan the loaded image to get a list of all Data Matrix codes
  7. Go through each barcode in the list and display its parameters, including the encoded text

These steps summarize the process for developing a Data Matrix scanner using Java. Import the necessary modules from the library, instantiate the license to handle Data Matrix barcodes, initialize the BarCodeReader for reading the Data Matrix codes only from the given image, and set the quality high for working with difficult images. Read all the Data Matrix barcodes from the image and display text from all of them.

Code for Data Matrix Reader using Java

Use this sample code to develop a simple Data Matrix barcode scanner using Java. For speedy detection, define the recognition region in the image and set a recognition timeout to avoid any hanging in the code. You may consider checking the results’ confidence/reading-quality info to set a trust level for the detected text.

This article helps in reading Data Matrix codes from an image. To generate a Data Matrix code, refer to the article Generate Data Matrix Barcode using Java.