graphical_code_detector.hpp 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #ifndef OPENCV_OBJDETECT_GRAPHICAL_CODE_DETECTOR_HPP
  5. #define OPENCV_OBJDETECT_GRAPHICAL_CODE_DETECTOR_HPP
  6. #include <opencv2/core.hpp>
  7. namespace cv {
  8. //! @addtogroup objdetect_common
  9. //! @{
  10. class CV_EXPORTS_W_SIMPLE GraphicalCodeDetector {
  11. public:
  12. CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first)
  13. GraphicalCodeDetector();
  14. GraphicalCodeDetector(const GraphicalCodeDetector&) = default;
  15. GraphicalCodeDetector(GraphicalCodeDetector&&) = default;
  16. GraphicalCodeDetector& operator=(const GraphicalCodeDetector&) = default;
  17. GraphicalCodeDetector& operator=(GraphicalCodeDetector&&) = default;
  18. /** @brief Detects graphical code in image and returns the quadrangle containing the code.
  19. @param img grayscale or color (BGR) image containing (or not) graphical code.
  20. @param points Output vector of vertices of the minimum-area quadrangle containing the code.
  21. */
  22. CV_WRAP bool detect(InputArray img, OutputArray points) const;
  23. /** @brief Decodes graphical code in image once it's found by the detect() method.
  24. Returns UTF8-encoded output string or empty string if the code cannot be decoded.
  25. @param img grayscale or color (BGR) image containing graphical code.
  26. @param points Quadrangle vertices found by detect() method (or some other algorithm).
  27. @param straight_code The optional output image containing binarized code, will be empty if not found.
  28. */
  29. CV_WRAP std::string decode(InputArray img, InputArray points, OutputArray straight_code = noArray()) const;
  30. /** @brief Both detects and decodes graphical code
  31. @param img grayscale or color (BGR) image containing graphical code.
  32. @param points optional output array of vertices of the found graphical code quadrangle, will be empty if not found.
  33. @param straight_code The optional output image containing binarized code
  34. */
  35. CV_WRAP std::string detectAndDecode(InputArray img, OutputArray points = noArray(),
  36. OutputArray straight_code = noArray()) const;
  37. /** @brief Detects graphical codes in image and returns the vector of the quadrangles containing the codes.
  38. @param img grayscale or color (BGR) image containing (or not) graphical codes.
  39. @param points Output vector of vector of vertices of the minimum-area quadrangle containing the codes.
  40. */
  41. CV_WRAP bool detectMulti(InputArray img, OutputArray points) const;
  42. /** @brief Decodes graphical codes in image once it's found by the detect() method.
  43. @param img grayscale or color (BGR) image containing graphical codes.
  44. @param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
  45. @param points vector of Quadrangle vertices found by detect() method (or some other algorithm).
  46. @param straight_code The optional output vector of images containing binarized codes
  47. */
  48. CV_WRAP bool decodeMulti(InputArray img, InputArray points, CV_OUT std::vector<std::string>& decoded_info,
  49. OutputArrayOfArrays straight_code = noArray()) const;
  50. /** @brief Both detects and decodes graphical codes
  51. @param img grayscale or color (BGR) image containing graphical codes.
  52. @param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
  53. @param points optional output vector of vertices of the found graphical code quadrangles. Will be empty if not found.
  54. @param straight_code The optional vector of images containing binarized codes
  55. - If there are QR codes encoded with a Structured Append mode on the image and all of them detected and decoded correctly,
  56. method writes a full message to position corresponds to 0-th code in a sequence. The rest of QR codes from the same sequence
  57. have empty string.
  58. */
  59. CV_WRAP bool detectAndDecodeMulti(InputArray img, CV_OUT std::vector<std::string>& decoded_info, OutputArray points = noArray(),
  60. OutputArrayOfArrays straight_code = noArray()) const;
  61. struct Impl;
  62. protected:
  63. Ptr<Impl> p;
  64. };
  65. //! @}
  66. }
  67. #endif