ZXingQtReader.cpp 914 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 2020 Axel Waggershauser
  3. */
  4. // SPDX-License-Identifier: Apache-2.0
  5. #include "ZXingQtReader.h"
  6. #include <QDebug>
  7. using namespace ZXingQt;
  8. int main(int argc, char* argv[])
  9. {
  10. if (argc != 2) {
  11. qDebug() << "Please supply exactly one image filename";
  12. return 1;
  13. }
  14. QString filePath = argv[1];
  15. QImage image = QImage(filePath);
  16. if (image.isNull()) {
  17. qDebug() << "Could not load the filename as an image:" << filePath;
  18. return 1;
  19. }
  20. auto options = ReaderOptions()
  21. .setFormats(BarcodeFormat::MatrixCodes)
  22. .setTryInvert(false)
  23. .setTextMode(TextMode::HRI)
  24. .setMaxNumberOfSymbols(10);
  25. auto barcodes = ReadBarcodes(image, options);
  26. for (auto& barcode : barcodes) {
  27. qDebug() << "Text: " << barcode.text();
  28. qDebug() << "Format: " << barcode.format();
  29. qDebug() << "Content:" << barcode.contentType();
  30. qDebug() << "";
  31. }
  32. return barcodes.isEmpty() ? 1 : 0;
  33. }