예제 #1
0
 MultiFormatUPCEANReader::MultiFormatUPCEANReader(DecodeHints hints) : readers() {
   if (hints.containsFormat(BarcodeFormat_EAN_13)) {
     readers.push_back(Ref<OneDReader>(new EAN13Reader()));
   } else if (hints.containsFormat(BarcodeFormat_UPC_A)) {
     readers.push_back(Ref<OneDReader>(new UPCAReader()));
   }
   if (hints.containsFormat(BarcodeFormat_EAN_8)) {
     readers.push_back(Ref<OneDReader>(new EAN8Reader()));
   }
   if (hints.containsFormat(BarcodeFormat_UPC_E)) {
     readers.push_back(Ref<OneDReader>(new UPCEReader()));
   }
   if (readers.size() == 0) {
     readers.push_back(Ref<OneDReader>(new EAN13Reader()));
     // UPC-A is covered by EAN-13
     readers.push_back(Ref<OneDReader>(new EAN8Reader()));
     readers.push_back(Ref<OneDReader>(new UPCEReader()));
   }
 }
예제 #2
0
MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() {
  if (hints.containsFormat(BarcodeFormat::EAN_13) ||
      hints.containsFormat(BarcodeFormat::EAN_8) ||
      hints.containsFormat(BarcodeFormat::UPC_A) ||
      hints.containsFormat(BarcodeFormat::UPC_E)) {
    readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader(hints)));
  }
  if (hints.containsFormat(BarcodeFormat::CODE_39)) {
    readers.push_back(Ref<OneDReader>(new Code39Reader()));
  }
  if (hints.containsFormat(BarcodeFormat::CODE_93)) {
    readers.push_back(Ref<OneDReader>(new Code93Reader()));
  }
  if (hints.containsFormat(BarcodeFormat::CODE_128)) {
    readers.push_back(Ref<OneDReader>(new Code128Reader()));
  }
  if (hints.containsFormat(BarcodeFormat::ITF)) {
    readers.push_back(Ref<OneDReader>(new ITFReader()));
  }
  if (hints.containsFormat(BarcodeFormat::CODABAR)) {
    readers.push_back(Ref<OneDReader>(new CodaBarReader()));
  }
/*
  if (hints.containsFormat(BarcodeFormat::RSS_14)) {
    readers.push_back(Ref<OneDReader>(new RSS14Reader()));
  }
*/
/*
  if (hints.containsFormat(BarcodeFormat::RSS_EXPANDED)) {
    readers.push_back(Ref<OneDReader>(new RSS14ExpandedReader()));
  }
*/
  if (readers.size() == 0) {
    readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader(hints)));
    readers.push_back(Ref<OneDReader>(new Code39Reader()));
    readers.push_back(Ref<OneDReader>(new CodaBarReader()));
    readers.push_back(Ref<OneDReader>(new Code93Reader()));
    readers.push_back(Ref<OneDReader>(new Code128Reader()));
    readers.push_back(Ref<OneDReader>(new ITFReader()));
    // readers.push_back(Ref<OneDReader>(new RSS14Reader()));
    // readers.push_back(Ref<OneDReader>(new RSS14ExpandedReader()));
  }
}
void MultiFormatReader::setHints(DecodeHints hints) {
  hints_ = hints;
  readers_.clear();
  bool tryHarder = hints.getTryHarder();

  bool addOneDReader = hints.containsFormat(BarcodeFormat::UPC_E) ||
    hints.containsFormat(BarcodeFormat::UPC_A) ||
    hints.containsFormat(BarcodeFormat::UPC_E) ||
    hints.containsFormat(BarcodeFormat::EAN_13) ||
    hints.containsFormat(BarcodeFormat::EAN_8) ||
    hints.containsFormat(BarcodeFormat::CODABAR) ||
    hints.containsFormat(BarcodeFormat::CODE_39) ||
    hints.containsFormat(BarcodeFormat::CODE_93) ||
    hints.containsFormat(BarcodeFormat::CODE_128) ||
    hints.containsFormat(BarcodeFormat::ITF) ||
    hints.containsFormat(BarcodeFormat::RSS_14) ||
    hints.containsFormat(BarcodeFormat::RSS_EXPANDED);
  if (addOneDReader && !tryHarder) {
    readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
  }
  if (hints.containsFormat(BarcodeFormat::QR_CODE)) {
    readers_.push_back(Ref<Reader>(new zxing::qrcode::QRCodeReader()));
  }
  if (hints.containsFormat(BarcodeFormat::DATA_MATRIX)) {
    readers_.push_back(Ref<Reader>(new zxing::datamatrix::DataMatrixReader()));
  }
  if (hints.containsFormat(BarcodeFormat::AZTEC)) {
    readers_.push_back(Ref<Reader>(new zxing::aztec::AztecReader()));
  }
    if (hints.containsFormat(BarcodeFormat::PDF_417)) {
        readers_.push_back(Ref<Reader>(new zxing::pdf417::PDF417Reader()));
    }
/*
      if (formats.contains(BarcodeFormat.PDF_417)) {
         readers.add(new PDF417Reader());
      }
      if (formats.contains(BarcodeFormat.MAXICODE)) {
         readers.add(new MaxiCodeReader());
      }
*/
  if (addOneDReader && tryHarder) {
    readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
  }
  if (readers_.size() == 0) {
    if (!tryHarder) {
      readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
    }
    readers_.push_back(Ref<Reader>(new zxing::qrcode::QRCodeReader()));
    readers_.push_back(Ref<Reader>(new zxing::datamatrix::DataMatrixReader()));
    readers_.push_back(Ref<Reader>(new zxing::aztec::AztecReader()));
    readers_.push_back(Ref<Reader>(new zxing::pdf417::PDF417Reader()));
      
    // readers.add(new PDF417Reader());
    // readers.add(new MaxiCodeReader());

    if (tryHarder) {
      readers_.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader(hints)));
    }
  }
}