ZXingOpenCV.cpp 505 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright 2021 Axel Waggershauser
  3. */
  4. // SPDX-License-Identifier: Apache-2.0
  5. #include "ZXingOpenCV.h"
  6. #include <iostream>
  7. using namespace cv;
  8. int main()
  9. {
  10. namedWindow("Display window");
  11. Mat image;
  12. VideoCapture cap(0);
  13. if (!cap.isOpened())
  14. std::cout << "cannot open camera";
  15. else
  16. while (waitKey(25) != 27) {
  17. cap >> image;
  18. auto barcodes = ReadBarcodes(image);
  19. for (auto& barcode : barcodes)
  20. DrawBarcode(image, barcode);
  21. imshow("Display window", image);
  22. }
  23. return 0;
  24. }