com.google.zxing.datamatrix.DataMatrixReader Java Examples

The following examples show how to use com.google.zxing.datamatrix.DataMatrixReader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiFormatReader.java    From ZXing-Orient with Apache License 2.0 4 votes vote down vote up
/**
 * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
 * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
 * is important for performance in continuous scan clients.
 *
 * @param hints The set of hints to use for subsequent calls to decode(image)
 */
public void setHints(Map<DecodeHintType,?> hints) {
  this.hints = hints;

  boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
  @SuppressWarnings("unchecked")
  Collection<BarcodeFormat> formats =
      hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
  Collection<Reader> readers = new ArrayList<>();
  if (formats != null) {
    boolean addOneDReader =
        formats.contains(BarcodeFormat.UPC_A) ||
        formats.contains(BarcodeFormat.UPC_E) ||
        formats.contains(BarcodeFormat.EAN_13) ||
        formats.contains(BarcodeFormat.EAN_8) ||
        formats.contains(BarcodeFormat.CODABAR) ||
        formats.contains(BarcodeFormat.CODE_39) ||
        formats.contains(BarcodeFormat.CODE_93) ||
        formats.contains(BarcodeFormat.CODE_128) ||
        formats.contains(BarcodeFormat.ITF) ||
        formats.contains(BarcodeFormat.RSS_14) ||
        formats.contains(BarcodeFormat.RSS_EXPANDED);
    // Put 1D readers upfront in "normal" mode
    if (addOneDReader && !tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
    if (formats.contains(BarcodeFormat.QR_CODE)) {
      readers.add(new QRCodeReader());
    }
    if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
      readers.add(new DataMatrixReader());
    }
    if (formats.contains(BarcodeFormat.AZTEC)) {
      readers.add(new AztecReader());
    }
    if (formats.contains(BarcodeFormat.PDF_417)) {
       readers.add(new PDF417Reader());
    }
    if (formats.contains(BarcodeFormat.MAXICODE)) {
       readers.add(new MaxiCodeReader());
    }
    // At end in "try harder" mode
    if (addOneDReader && tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
  }
  if (readers.isEmpty()) {
    if (!tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }

    readers.add(new QRCodeReader());
    readers.add(new DataMatrixReader());
    readers.add(new AztecReader());
    readers.add(new PDF417Reader());
    readers.add(new MaxiCodeReader());

    if (tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
  }
  this.readers = readers.toArray(new Reader[readers.size()]);
}
 
Example #2
Source File: MultiFormatReader.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
/**
 * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
 * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
 * is important for performance in continuous scan clients.
 *
 * @param hints The set of hints to use for subsequent calls to decode(image)
 */
public void setHints(Map<DecodeHintType,?> hints) {
  this.hints = hints;

  boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
  @SuppressWarnings("unchecked")
  Collection<BarcodeFormat> formats =
      hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
  Collection<Reader> readers = new ArrayList<Reader>();
  if (formats != null) {
    boolean addOneDReader =
        formats.contains(BarcodeFormat.UPC_A) ||
        formats.contains(BarcodeFormat.UPC_E) ||
        formats.contains(BarcodeFormat.EAN_13) ||
        formats.contains(BarcodeFormat.EAN_8) ||
        formats.contains(BarcodeFormat.CODABAR) ||
        formats.contains(BarcodeFormat.CODE_39) ||
        formats.contains(BarcodeFormat.CODE_93) ||
        formats.contains(BarcodeFormat.CODE_128) ||
        formats.contains(BarcodeFormat.ITF) ||
        formats.contains(BarcodeFormat.RSS_14) ||
        formats.contains(BarcodeFormat.RSS_EXPANDED);
    // Put 1D readers upfront in "normal" mode
    if (addOneDReader && !tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
    if (formats.contains(BarcodeFormat.QR_CODE)) {
      readers.add(new QRCodeReader());
    }
    if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
      readers.add(new DataMatrixReader());
    }
    if (formats.contains(BarcodeFormat.AZTEC)) {
      readers.add(new AztecReader());
    }
    if (formats.contains(BarcodeFormat.PDF_417)) {
       readers.add(new PDF417Reader());
    }
    if (formats.contains(BarcodeFormat.MAXICODE)) {
       readers.add(new MaxiCodeReader());
    }
    // At end in "try harder" mode
    if (addOneDReader && tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
  }
  if (readers.isEmpty()) {
    if (!tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }

    readers.add(new QRCodeReader());
    readers.add(new DataMatrixReader());
    readers.add(new AztecReader());
    readers.add(new PDF417Reader());
    readers.add(new MaxiCodeReader());

    if (tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
  }
  this.readers = readers.toArray(new Reader[readers.size()]);
}
 
Example #3
Source File: MultiFormatReader.java    From weex with Apache License 2.0 4 votes vote down vote up
/**
 * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
 * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
 * is important for performance in continuous scan clients.
 *
 * @param hints The set of hints to use for subsequent calls to decode(image)
 */
public void setHints(Map<DecodeHintType,?> hints) {
  this.hints = hints;

  boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
  @SuppressWarnings("unchecked")
  Collection<BarcodeFormat> formats =
      hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
  Collection<Reader> readers = new ArrayList<Reader>();
  if (formats != null) {
    boolean addOneDReader =
        formats.contains(BarcodeFormat.UPC_A) ||
        formats.contains(BarcodeFormat.UPC_E) ||
        formats.contains(BarcodeFormat.EAN_13) ||
        formats.contains(BarcodeFormat.EAN_8) ||
        formats.contains(BarcodeFormat.CODABAR) ||
        formats.contains(BarcodeFormat.CODE_39) ||
        formats.contains(BarcodeFormat.CODE_93) ||
        formats.contains(BarcodeFormat.CODE_128) ||
        formats.contains(BarcodeFormat.ITF) ||
        formats.contains(BarcodeFormat.RSS_14) ||
        formats.contains(BarcodeFormat.RSS_EXPANDED);
    // Put 1D readers upfront in "normal" mode
    if (addOneDReader && !tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
    if (formats.contains(BarcodeFormat.QR_CODE)) {
      readers.add(new QRCodeReader());
    }
    if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
      readers.add(new DataMatrixReader());
    }
    if (formats.contains(BarcodeFormat.AZTEC)) {
      readers.add(new AztecReader());
    }
    if (formats.contains(BarcodeFormat.PDF_417)) {
       readers.add(new PDF417Reader());
    }
    if (formats.contains(BarcodeFormat.MAXICODE)) {
       readers.add(new MaxiCodeReader());
    }
    // At end in "try harder" mode
    if (addOneDReader && tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
  }
  if (readers.isEmpty()) {
    if (!tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }

    readers.add(new QRCodeReader());
    readers.add(new DataMatrixReader());
    readers.add(new AztecReader());
    readers.add(new PDF417Reader());
    readers.add(new MaxiCodeReader());

    if (tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
  }
  this.readers = readers.toArray(new Reader[readers.size()]);
}
 
Example #4
Source File: MultiFormatReader.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
/**
 * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
 * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
 * is important for performance in continuous scan clients.
 *
 * @param hints The set of hints to use for subsequent calls to decode(image)
 */
public void setHints(Map<DecodeHintType,?> hints) {
  this.hints = hints;

  boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
  @SuppressWarnings("unchecked")
  Collection<BarcodeFormat> formats =
      hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
  Collection<Reader> readers = new ArrayList<>();
  if (formats != null) {
    boolean addOneDReader =
        formats.contains(BarcodeFormat.UPC_A) ||
        formats.contains(BarcodeFormat.UPC_E) ||
        formats.contains(BarcodeFormat.EAN_13) ||
        formats.contains(BarcodeFormat.EAN_8) ||
        formats.contains(BarcodeFormat.CODABAR) ||
        formats.contains(BarcodeFormat.CODE_39) ||
        formats.contains(BarcodeFormat.CODE_93) ||
        formats.contains(BarcodeFormat.CODE_128) ||
        formats.contains(BarcodeFormat.ITF) ||
        formats.contains(BarcodeFormat.RSS_14) ||
        formats.contains(BarcodeFormat.RSS_EXPANDED);
    // Put 1D readers upfront in "normal" mode
    if (addOneDReader && !tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
    if (formats.contains(BarcodeFormat.QR_CODE)) {
      readers.add(new QRCodeReader());
    }
    if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
      readers.add(new DataMatrixReader());
    }
    if (formats.contains(BarcodeFormat.AZTEC)) {
      readers.add(new AztecReader());
    }
    if (formats.contains(BarcodeFormat.PDF_417)) {
       readers.add(new PDF417Reader());
    }
    if (formats.contains(BarcodeFormat.MAXICODE)) {
       readers.add(new MaxiCodeReader());
    }
    // At end in "try harder" mode
    if (addOneDReader && tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
  }
  if (readers.isEmpty()) {
    if (!tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }

    readers.add(new QRCodeReader());
    readers.add(new DataMatrixReader());
    readers.add(new AztecReader());
    readers.add(new PDF417Reader());
    readers.add(new MaxiCodeReader());

    if (tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
  }
  this.readers = readers.toArray(new Reader[readers.size()]);
}
 
Example #5
Source File: MultiFormatReader.java    From reacteu-app with MIT License 4 votes vote down vote up
/**
 * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
 * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
 * is important for performance in continuous scan clients.
 *
 * @param hints The set of hints to use for subsequent calls to decode(image)
 */
public void setHints(Map<DecodeHintType,?> hints) {
  this.hints = hints;

  boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
  Collection<BarcodeFormat> formats =
      hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
  Collection<Reader> readers = new ArrayList<Reader>();
  if (formats != null) {
    boolean addOneDReader =
        formats.contains(BarcodeFormat.UPC_A) ||
        formats.contains(BarcodeFormat.UPC_E) ||
        formats.contains(BarcodeFormat.EAN_13) ||
        formats.contains(BarcodeFormat.EAN_8) ||
        formats.contains(BarcodeFormat.CODABAR) ||
        formats.contains(BarcodeFormat.CODE_39) ||
        formats.contains(BarcodeFormat.CODE_93) ||
        formats.contains(BarcodeFormat.CODE_128) ||
        formats.contains(BarcodeFormat.ITF) ||
        formats.contains(BarcodeFormat.RSS_14) ||
        formats.contains(BarcodeFormat.RSS_EXPANDED);
    // Put 1D readers upfront in "normal" mode
    if (addOneDReader && !tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
    if (formats.contains(BarcodeFormat.QR_CODE)) {
      readers.add(new QRCodeReader());
    }
    if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
      readers.add(new DataMatrixReader());
    }
    if (formats.contains(BarcodeFormat.AZTEC)) {
      readers.add(new AztecReader());
    }
    if (formats.contains(BarcodeFormat.PDF_417)) {
       readers.add(new PDF417Reader());
    }
    if (formats.contains(BarcodeFormat.MAXICODE)) {
       readers.add(new MaxiCodeReader());
    }
    // At end in "try harder" mode
    if (addOneDReader && tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
  }
  if (readers.isEmpty()) {
    if (!tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }

    readers.add(new QRCodeReader());
    readers.add(new DataMatrixReader());
    readers.add(new AztecReader());
    readers.add(new PDF417Reader());
    readers.add(new MaxiCodeReader());

    if (tryHarder) {
      readers.add(new MultiFormatOneDReader(hints));
    }
  }
  this.readers = readers.toArray(new Reader[readers.size()]);
}
 
Example #6
Source File: MultiFormatReader.java    From RipplePower with Apache License 2.0 4 votes vote down vote up
/**
 * This method adds state to the MultiFormatReader. By setting the hints
 * once, subsequent calls to decodeWithState(image) can reuse the same set
 * of readers without reallocating memory. This is important for performance
 * in continuous scan clients.
 * 
 * @param hints
 *            The set of hints to use for subsequent calls to decode(image)
 */
public void setHints(Map<DecodeHintType, ?> hints) {
	this.hints = hints;

	boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
	@SuppressWarnings("unchecked")
	Collection<BarcodeFormat> formats = hints == null ? null
			: (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
	Collection<Reader> readers = new ArrayList<>();
	if (formats != null) {
		boolean addOneDReader = formats.contains(BarcodeFormat.UPC_A) || formats.contains(BarcodeFormat.UPC_E)
				|| formats.contains(BarcodeFormat.EAN_13) || formats.contains(BarcodeFormat.EAN_8)
				|| formats.contains(BarcodeFormat.CODABAR) || formats.contains(BarcodeFormat.CODE_39)
				|| formats.contains(BarcodeFormat.CODE_93) || formats.contains(BarcodeFormat.CODE_128)
				|| formats.contains(BarcodeFormat.ITF) || formats.contains(BarcodeFormat.RSS_14)
				|| formats.contains(BarcodeFormat.RSS_EXPANDED);
		// Put 1D readers upfront in "normal" mode
		if (addOneDReader && !tryHarder) {
			readers.add(new MultiFormatOneDReader(hints));
		}
		if (formats.contains(BarcodeFormat.QR_CODE)) {
			readers.add(new QRCodeReader());
		}
		if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
			readers.add(new DataMatrixReader());
		}
		if (formats.contains(BarcodeFormat.MAXICODE)) {
			readers.add(new MaxiCodeReader());
		}
		// At end in "try harder" mode
		if (addOneDReader && tryHarder) {
			readers.add(new MultiFormatOneDReader(hints));
		}
	}
	if (readers.isEmpty()) {
		if (!tryHarder) {
			readers.add(new MultiFormatOneDReader(hints));
		}

		readers.add(new QRCodeReader());
		readers.add(new DataMatrixReader());
		readers.add(new MaxiCodeReader());

		if (tryHarder) {
			readers.add(new MultiFormatOneDReader(hints));
		}
	}
	this.readers = readers.toArray(new Reader[readers.size()]);
}
 
Example #7
Source File: SymbolTest.java    From OkapiBarcode with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a ZXing reader that can read the specified symbol.
 *
 * @param symbol the symbol to be read
 * @return a ZXing reader that can read the specified symbol
 */
private static Reader findReader(Symbol symbol) {

    // TODO: see if we can massage data enough to check MaxiCode symbols against MaxiCodeReader instances

    if (symbol instanceof Code128 || symbol instanceof UspsPackage) {
        return new Code128Reader();
    } else if (symbol instanceof Code93) {
        return new Code93Reader();
    } else if (symbol instanceof Code3Of9) {
        return new Code39Reader();
    } else if (symbol instanceof Codabar) {
        return new CodaBarReader();
    } else if (symbol instanceof AztecCode &&
               symbol.getDataType() != DataType.GS1 &&
               symbol.getEciMode() == 3 &&
              !symbol.getReaderInit() &&
              !symbol.getContent().isEmpty()) {
        // ZXing does not currently support GS1 in Aztec Code symbols
        // ZXing does not currently support ECI in Aztec Code symbols
        // ZXing does not currently support reader initialization in Aztec Code symbols
        // ZXing cannot find symbols if they don't contain any actual data
        return new AztecReader();
    } else if (symbol instanceof QrCode) {
        return new QRCodeReader();
    } else if (symbol instanceof DataMatrix &&
               symbol.getEciMode() == 3 &&
               ((DataMatrix) symbol).getStructuredAppendTotal() == 1) {
        // ZXing does not currently support ECI in Data Matrix symbols
        // ZXing does not currently support Structured Append in Data Matrix symbols
        return new DataMatrixReader();
    } else if (symbol instanceof Ean) {
        Ean ean = (Ean) symbol;
        if (ean.getMode() == Ean.Mode.EAN8) {
            return new EAN8Reader();
        } else {
            return new EAN13Reader();
        }
    } else if (symbol instanceof Pdf417) {
        Pdf417 pdf417 = (Pdf417) symbol;
        if (pdf417.getMode() != Pdf417.Mode.MICRO) {
            return new PDF417Reader();
        }
    } else if (symbol instanceof Upc) {
        Upc upc = (Upc) symbol;
        if (upc.getMode() == Upc.Mode.UPCA) {
            return new UPCAReader();
        } else {
            return new UPCEReader();
        }
    } else if (symbol instanceof DataBarExpanded) {
        return new RSSExpandedReader();
    } else if (symbol instanceof DataBar14 && !((DataBar14) symbol).getLinkageFlag()) {
        return new RSS14Reader();
    }

    // no corresponding ZXing reader exists, or it behaves badly so we don't use it for testing
    return null;
}
 
Example #8
Source File: DecodeHandler.java    From moVirt with Apache License 2.0 4 votes vote down vote up
DecodeHandler(CameraActivity activity) {
    dataMatrixReader = new DataMatrixReader();
    this.activity = activity;
}