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

source code of opencv/modules/objdetect/include/opencv2/objdetect/graphical_code_detector.hpp