barcode.hpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. // Copyright (c) 2020-2021 darkliang wangberlinT Certseeds
  5. #ifndef OPENCV_OBJDETECT_BARCODE_HPP
  6. #define OPENCV_OBJDETECT_BARCODE_HPP
  7. #include <opencv2/core.hpp>
  8. #include <opencv2/objdetect/graphical_code_detector.hpp>
  9. namespace cv {
  10. namespace barcode {
  11. //! @addtogroup objdetect_barcode
  12. //! @{
  13. class CV_EXPORTS_W_SIMPLE BarcodeDetector : public cv::GraphicalCodeDetector
  14. {
  15. public:
  16. /** @brief Initialize the BarcodeDetector.
  17. */
  18. CV_WRAP BarcodeDetector();
  19. /** @brief Initialize the BarcodeDetector.
  20. *
  21. * Parameters allow to load _optional_ Super Resolution DNN model for better quality.
  22. * @param prototxt_path prototxt file path for the super resolution model
  23. * @param model_path model file path for the super resolution model
  24. */
  25. CV_WRAP BarcodeDetector(const std::string &prototxt_path, const std::string &model_path);
  26. ~BarcodeDetector();
  27. /** @brief Decodes barcode in image once it's found by the detect() method.
  28. *
  29. * @param img grayscale or color (BGR) image containing bar code.
  30. * @param points vector of rotated rectangle vertices found by detect() method (or some other algorithm).
  31. * For N detected barcodes, the dimensions of this array should be [N][4].
  32. * Order of four points in vector<Point2f> is bottomLeft, topLeft, topRight, bottomRight.
  33. * @param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
  34. * @param decoded_type vector strings, specifies the type of these barcodes
  35. * @return true if at least one valid barcode have been found
  36. */
  37. CV_WRAP bool decodeWithType(InputArray img,
  38. InputArray points,
  39. CV_OUT std::vector<std::string> &decoded_info,
  40. CV_OUT std::vector<std::string> &decoded_type) const;
  41. /** @brief Both detects and decodes barcode
  42. * @param img grayscale or color (BGR) image containing barcode.
  43. * @param decoded_info UTF8-encoded output vector of string(s) or empty vector of string if the codes cannot be decoded.
  44. * @param decoded_type vector of strings, specifies the type of these barcodes
  45. * @param points optional output vector of vertices of the found barcode rectangle. Will be empty if not found.
  46. * @return true if at least one valid barcode have been found
  47. */
  48. CV_WRAP bool detectAndDecodeWithType(InputArray img,
  49. CV_OUT std::vector<std::string> &decoded_info,
  50. CV_OUT std::vector<std::string> &decoded_type,
  51. OutputArray points = noArray()) const;
  52. };
  53. //! @}
  54. }} // cv::barcode::
  55. #endif // OPENCV_OBJDETECT_BARCODE_HPP