mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge branch 4.x
This commit is contained in:
@@ -45,6 +45,8 @@
|
||||
#define OPENCV_OBJDETECT_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/objdetect/aruco_detector.hpp"
|
||||
#include "opencv2/objdetect/graphical_code_detector.hpp"
|
||||
|
||||
/**
|
||||
@defgroup objdetect Object Detection
|
||||
@@ -101,6 +103,7 @@ using a Boosted Cascade of Simple Features. IEEE CVPR, 2001. The paper is availa
|
||||
<https://github.com/SvHey/thesis/blob/master/Literature/ObjectDetection/violaJones_CVPR2001.pdf>
|
||||
|
||||
@defgroup objdetect_hog HOG (Histogram of Oriented Gradients) descriptor and object detector
|
||||
@defgroup objdetect_barcode Barcode detection and decoding
|
||||
@defgroup objdetect_qrcode QRCode detection and encoding
|
||||
@defgroup objdetect_dnn_face DNN-based face detection and recognition
|
||||
Check @ref tutorial_dnn_face "the corresponding tutorial" for more details.
|
||||
@@ -753,44 +756,27 @@ public:
|
||||
CV_WRAP virtual void encodeStructuredAppend(const String& encoded_info, OutputArrayOfArrays qrcodes) = 0;
|
||||
|
||||
};
|
||||
|
||||
class CV_EXPORTS_W QRCodeDetector
|
||||
class CV_EXPORTS_W_SIMPLE QRCodeDetector : public GraphicalCodeDetector
|
||||
{
|
||||
public:
|
||||
CV_WRAP QRCodeDetector();
|
||||
~QRCodeDetector();
|
||||
|
||||
/** @brief sets the epsilon used during the horizontal scan of QR code stop marker detection.
|
||||
@param epsX Epsilon neighborhood, which allows you to determine the horizontal pattern
|
||||
of the scheme 1:1:3:1:1 according to QR code standard.
|
||||
*/
|
||||
CV_WRAP void setEpsX(double epsX);
|
||||
CV_WRAP QRCodeDetector& setEpsX(double epsX);
|
||||
/** @brief sets the epsilon used during the vertical scan of QR code stop marker detection.
|
||||
@param epsY Epsilon neighborhood, which allows you to determine the vertical pattern
|
||||
of the scheme 1:1:3:1:1 according to QR code standard.
|
||||
*/
|
||||
CV_WRAP void setEpsY(double epsY);
|
||||
CV_WRAP QRCodeDetector& setEpsY(double epsY);
|
||||
|
||||
/** @brief use markers to improve the position of the corners of the QR code
|
||||
*
|
||||
* alignmentMarkers using by default
|
||||
*/
|
||||
CV_WRAP void setUseAlignmentMarkers(bool useAlignmentMarkers);
|
||||
|
||||
/** @brief Detects QR code in image and returns the quadrangle containing the code.
|
||||
@param img grayscale or color (BGR) image containing (or not) QR code.
|
||||
@param points Output vector of vertices of the minimum-area quadrangle containing the code.
|
||||
*/
|
||||
CV_WRAP bool detect(InputArray img, OutputArray points) const;
|
||||
|
||||
/** @brief Decodes QR code in image once it's found by the detect() method.
|
||||
|
||||
Returns UTF8-encoded output string or empty string if the code cannot be decoded.
|
||||
@param img grayscale or color (BGR) image containing QR code.
|
||||
@param points Quadrangle vertices found by detect() method (or some other algorithm).
|
||||
@param straight_qrcode The optional output image containing rectified and binarized QR code
|
||||
*/
|
||||
CV_WRAP std::string decode(InputArray img, InputArray points, OutputArray straight_qrcode = noArray());
|
||||
CV_WRAP QRCodeDetector& setUseAlignmentMarkers(bool useAlignmentMarkers);
|
||||
|
||||
/** @brief Decodes QR code on a curved surface in image once it's found by the detect() method.
|
||||
|
||||
@@ -801,15 +787,6 @@ public:
|
||||
*/
|
||||
CV_WRAP cv::String decodeCurved(InputArray img, InputArray points, OutputArray straight_qrcode = noArray());
|
||||
|
||||
/** @brief Both detects and decodes QR code
|
||||
|
||||
@param img grayscale or color (BGR) image containing QR code.
|
||||
@param points optional output array of vertices of the found QR code quadrangle. Will be empty if not found.
|
||||
@param straight_qrcode The optional output image containing rectified and binarized QR code
|
||||
*/
|
||||
CV_WRAP std::string detectAndDecode(InputArray img, OutputArray points=noArray(),
|
||||
OutputArray straight_qrcode = noArray());
|
||||
|
||||
/** @brief Both detects and decodes QR code on a curved surface
|
||||
|
||||
@param img grayscale or color (BGR) image containing QR code.
|
||||
@@ -818,43 +795,58 @@ public:
|
||||
*/
|
||||
CV_WRAP std::string detectAndDecodeCurved(InputArray img, OutputArray points=noArray(),
|
||||
OutputArray straight_qrcode = noArray());
|
||||
};
|
||||
|
||||
/** @brief Detects QR codes in image and returns the vector of the quadrangles containing the codes.
|
||||
@param img grayscale or color (BGR) image containing (or not) QR codes.
|
||||
@param points Output vector of vector of vertices of the minimum-area quadrangle containing the codes.
|
||||
*/
|
||||
CV_WRAP
|
||||
bool detectMulti(InputArray img, OutputArray points) const;
|
||||
class CV_EXPORTS_W_SIMPLE QRCodeDetectorAruco : public GraphicalCodeDetector {
|
||||
public:
|
||||
CV_WRAP QRCodeDetectorAruco();
|
||||
|
||||
/** @brief Decodes QR codes in image once it's found by the detect() method.
|
||||
@param img grayscale or color (BGR) image containing QR codes.
|
||||
@param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
|
||||
@param points vector of Quadrangle vertices found by detect() method (or some other algorithm).
|
||||
@param straight_qrcode The optional output vector of images containing rectified and binarized QR codes
|
||||
*/
|
||||
CV_WRAP
|
||||
bool decodeMulti(
|
||||
InputArray img, InputArray points,
|
||||
CV_OUT std::vector<std::string>& decoded_info,
|
||||
OutputArrayOfArrays straight_qrcode = noArray()
|
||||
) const;
|
||||
struct CV_EXPORTS_W_SIMPLE Params {
|
||||
CV_WRAP Params();
|
||||
|
||||
/** @brief Both detects and decodes QR codes
|
||||
@param img grayscale or color (BGR) image containing QR codes.
|
||||
@param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
|
||||
@param points optional output vector of vertices of the found QR code quadrangles. Will be empty if not found.
|
||||
@param straight_qrcode The optional output vector of images containing rectified and binarized QR codes
|
||||
*/
|
||||
CV_WRAP
|
||||
bool detectAndDecodeMulti(
|
||||
InputArray img, CV_OUT std::vector<std::string>& decoded_info,
|
||||
OutputArray points = noArray(),
|
||||
OutputArrayOfArrays straight_qrcode = noArray()
|
||||
) const;
|
||||
/** @brief The minimum allowed pixel size of a QR module in the smallest image in the image pyramid, default 4.f */
|
||||
CV_PROP_RW float minModuleSizeInPyramid;
|
||||
|
||||
protected:
|
||||
struct Impl;
|
||||
Ptr<Impl> p;
|
||||
/** @brief The maximum allowed relative rotation for finder patterns in the same QR code, default pi/12 */
|
||||
CV_PROP_RW float maxRotation;
|
||||
|
||||
/** @brief The maximum allowed relative mismatch in module sizes for finder patterns in the same QR code, default 1.75f */
|
||||
CV_PROP_RW float maxModuleSizeMismatch;
|
||||
|
||||
/** @brief The maximum allowed module relative mismatch for timing pattern module, default 2.f
|
||||
*
|
||||
* If relative mismatch of timing pattern module more this value, penalty points will be added.
|
||||
* If a lot of penalty points are added, QR code will be rejected. */
|
||||
CV_PROP_RW float maxTimingPatternMismatch;
|
||||
|
||||
/** @brief The maximum allowed percentage of penalty points out of total pins in timing pattern, default 0.4f */
|
||||
CV_PROP_RW float maxPenalties;
|
||||
|
||||
/** @brief The maximum allowed relative color mismatch in the timing pattern, default 0.2f*/
|
||||
CV_PROP_RW float maxColorsMismatch;
|
||||
|
||||
/** @brief The algorithm find QR codes with almost minimum timing pattern score and minimum size, default 0.9f
|
||||
*
|
||||
* The QR code with the minimum "timing pattern score" and minimum "size" is selected as the best QR code.
|
||||
* If for the current QR code "timing pattern score" * scaleTimingPatternScore < "previous timing pattern score" and "size" < "previous size", then
|
||||
* current QR code set as the best QR code. */
|
||||
CV_PROP_RW float scaleTimingPatternScore;
|
||||
};
|
||||
|
||||
/** @brief QR code detector constructor for Aruco-based algorithm. See cv::QRCodeDetectorAruco::Params */
|
||||
CV_WRAP explicit QRCodeDetectorAruco(const QRCodeDetectorAruco::Params& params);
|
||||
|
||||
/** @brief Detector parameters getter. See cv::QRCodeDetectorAruco::Params */
|
||||
CV_WRAP const QRCodeDetectorAruco::Params& getDetectorParameters() const;
|
||||
|
||||
/** @brief Detector parameters setter. See cv::QRCodeDetectorAruco::Params */
|
||||
CV_WRAP QRCodeDetectorAruco& setDetectorParameters(const QRCodeDetectorAruco::Params& params);
|
||||
|
||||
/** @brief Aruco detector parameters are used to search for the finder patterns. */
|
||||
CV_WRAP aruco::DetectorParameters getArucoParameters();
|
||||
|
||||
/** @brief Aruco detector parameters are used to search for the finder patterns. */
|
||||
CV_WRAP void setArucoParameters(const aruco::DetectorParameters& params);
|
||||
};
|
||||
|
||||
//! @}
|
||||
@@ -862,7 +854,7 @@ protected:
|
||||
|
||||
#include "opencv2/objdetect/detection_based_tracker.hpp"
|
||||
#include "opencv2/objdetect/face.hpp"
|
||||
#include "opencv2/objdetect/aruco_detector.hpp"
|
||||
#include "opencv2/objdetect/charuco_detector.hpp"
|
||||
#include "opencv2/objdetect/barcode.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
*/
|
||||
CV_WRAP void generateImage(Size outSize, OutputArray img, int marginSize = 0, int borderBits = 1) const;
|
||||
|
||||
CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to “protected” (need to fix bindings first)
|
||||
CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first)
|
||||
Board();
|
||||
|
||||
struct Impl;
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
CV_WRAP float getMarkerLength() const;
|
||||
CV_WRAP float getMarkerSeparation() const;
|
||||
|
||||
CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to “protected” (need to fix bindings first)
|
||||
CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first)
|
||||
GridBoard();
|
||||
};
|
||||
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
*/
|
||||
CV_WRAP bool checkCharucoCornersCollinear(InputArray charucoIds) const;
|
||||
|
||||
CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to “protected” (need to fix bindings first)
|
||||
CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first)
|
||||
CharucoBoard();
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ struct CV_EXPORTS_W_SIMPLE DetectorParameters {
|
||||
minCornerDistanceRate = 0.05;
|
||||
minDistanceToBorder = 3;
|
||||
minMarkerDistanceRate = 0.05;
|
||||
cornerRefinementMethod = CORNER_REFINE_NONE;
|
||||
cornerRefinementMethod = (int)CORNER_REFINE_NONE;
|
||||
cornerRefinementWinSize = 5;
|
||||
cornerRefinementMaxIterations = 30;
|
||||
cornerRefinementMinAccuracy = 0.1;
|
||||
@@ -106,7 +106,7 @@ struct CV_EXPORTS_W_SIMPLE DetectorParameters {
|
||||
CV_PROP_RW double minMarkerDistanceRate;
|
||||
|
||||
/** @brief default value CORNER_REFINE_NONE */
|
||||
CV_PROP_RW CornerRefineMethod cornerRefinementMethod;
|
||||
CV_PROP_RW int cornerRefinementMethod;
|
||||
|
||||
/// window size for the corner refinement process (in pixels) (default 5).
|
||||
CV_PROP_RW int cornerRefinementWinSize;
|
||||
|
||||
@@ -110,7 +110,8 @@ enum PredefinedDictionaryType {
|
||||
DICT_APRILTAG_16h5, ///< 4x4 bits, minimum hamming distance between any two codes = 5, 30 codes
|
||||
DICT_APRILTAG_25h9, ///< 5x5 bits, minimum hamming distance between any two codes = 9, 35 codes
|
||||
DICT_APRILTAG_36h10, ///< 6x6 bits, minimum hamming distance between any two codes = 10, 2320 codes
|
||||
DICT_APRILTAG_36h11 ///< 6x6 bits, minimum hamming distance between any two codes = 11, 587 codes
|
||||
DICT_APRILTAG_36h11, ///< 6x6 bits, minimum hamming distance between any two codes = 11, 587 codes
|
||||
DICT_ARUCO_MIP_36h12 ///< 6x6 bits, minimum hamming distance between any two codes = 12, 250 codes
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
// Copyright (c) 2020-2021 darkliang wangberlinT Certseeds
|
||||
|
||||
#ifndef OPENCV_OBJDETECT_BARCODE_HPP
|
||||
#define OPENCV_OBJDETECT_BARCODE_HPP
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/objdetect/graphical_code_detector.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace barcode {
|
||||
|
||||
//! @addtogroup objdetect_barcode
|
||||
//! @{
|
||||
|
||||
class CV_EXPORTS_W_SIMPLE BarcodeDetector : public cv::GraphicalCodeDetector
|
||||
{
|
||||
public:
|
||||
/** @brief Initialize the BarcodeDetector.
|
||||
*/
|
||||
CV_WRAP BarcodeDetector();
|
||||
/** @brief Initialize the BarcodeDetector.
|
||||
*
|
||||
* Parameters allow to load _optional_ Super Resolution DNN model for better quality.
|
||||
* @param prototxt_path prototxt file path for the super resolution model
|
||||
* @param model_path model file path for the super resolution model
|
||||
*/
|
||||
CV_WRAP BarcodeDetector(const std::string &prototxt_path, const std::string &model_path);
|
||||
~BarcodeDetector();
|
||||
|
||||
/** @brief Decodes barcode in image once it's found by the detect() method.
|
||||
*
|
||||
* @param img grayscale or color (BGR) image containing bar code.
|
||||
* @param points vector of rotated rectangle vertices found by detect() method (or some other algorithm).
|
||||
* For N detected barcodes, the dimensions of this array should be [N][4].
|
||||
* Order of four points in vector<Point2f> is bottomLeft, topLeft, topRight, bottomRight.
|
||||
* @param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
|
||||
* @param decoded_type vector strings, specifies the type of these barcodes
|
||||
* @return true if at least one valid barcode have been found
|
||||
*/
|
||||
CV_WRAP bool decodeWithType(InputArray img,
|
||||
InputArray points,
|
||||
CV_OUT std::vector<std::string> &decoded_info,
|
||||
CV_OUT std::vector<std::string> &decoded_type) const;
|
||||
|
||||
/** @brief Both detects and decodes barcode
|
||||
|
||||
* @param img grayscale or color (BGR) image containing barcode.
|
||||
* @param decoded_info UTF8-encoded output vector of string(s) or empty vector of string if the codes cannot be decoded.
|
||||
* @param decoded_type vector of strings, specifies the type of these barcodes
|
||||
* @param points optional output vector of vertices of the found barcode rectangle. Will be empty if not found.
|
||||
* @return true if at least one valid barcode have been found
|
||||
*/
|
||||
CV_WRAP bool detectAndDecodeWithType(InputArray img,
|
||||
CV_OUT std::vector<std::string> &decoded_info,
|
||||
CV_OUT std::vector<std::string> &decoded_type,
|
||||
OutputArray points = noArray()) const;
|
||||
};
|
||||
//! @}
|
||||
|
||||
}} // cv::barcode::
|
||||
|
||||
#endif // OPENCV_OBJDETECT_BARCODE_HPP
|
||||
@@ -0,0 +1,81 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html
|
||||
#ifndef OPENCV_OBJDETECT_GRAPHICAL_CODE_DETECTOR_HPP
|
||||
#define OPENCV_OBJDETECT_GRAPHICAL_CODE_DETECTOR_HPP
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv {
|
||||
|
||||
//! @addtogroup objdetect_common
|
||||
//! @{
|
||||
|
||||
class CV_EXPORTS_W_SIMPLE GraphicalCodeDetector {
|
||||
public:
|
||||
CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first)
|
||||
GraphicalCodeDetector();
|
||||
|
||||
GraphicalCodeDetector(const GraphicalCodeDetector&) = default;
|
||||
GraphicalCodeDetector(GraphicalCodeDetector&&) = default;
|
||||
GraphicalCodeDetector& operator=(const GraphicalCodeDetector&) = default;
|
||||
GraphicalCodeDetector& operator=(GraphicalCodeDetector&&) = default;
|
||||
|
||||
/** @brief Detects graphical code in image and returns the quadrangle containing the code.
|
||||
@param img grayscale or color (BGR) image containing (or not) graphical code.
|
||||
@param points Output vector of vertices of the minimum-area quadrangle containing the code.
|
||||
*/
|
||||
CV_WRAP bool detect(InputArray img, OutputArray points) const;
|
||||
|
||||
/** @brief Decodes graphical code in image once it's found by the detect() method.
|
||||
|
||||
Returns UTF8-encoded output string or empty string if the code cannot be decoded.
|
||||
@param img grayscale or color (BGR) image containing graphical code.
|
||||
@param points Quadrangle vertices found by detect() method (or some other algorithm).
|
||||
@param straight_code The optional output image containing binarized code, will be empty if not found.
|
||||
*/
|
||||
CV_WRAP std::string decode(InputArray img, InputArray points, OutputArray straight_code = noArray()) const;
|
||||
|
||||
/** @brief Both detects and decodes graphical code
|
||||
|
||||
@param img grayscale or color (BGR) image containing graphical code.
|
||||
@param points optional output array of vertices of the found graphical code quadrangle, will be empty if not found.
|
||||
@param straight_code The optional output image containing binarized code
|
||||
*/
|
||||
CV_WRAP std::string detectAndDecode(InputArray img, OutputArray points = noArray(),
|
||||
OutputArray straight_code = noArray()) const;
|
||||
|
||||
|
||||
/** @brief Detects graphical codes in image and returns the vector of the quadrangles containing the codes.
|
||||
@param img grayscale or color (BGR) image containing (or not) graphical codes.
|
||||
@param points Output vector of vector of vertices of the minimum-area quadrangle containing the codes.
|
||||
*/
|
||||
CV_WRAP bool detectMulti(InputArray img, OutputArray points) const;
|
||||
|
||||
/** @brief Decodes graphical codes in image once it's found by the detect() method.
|
||||
@param img grayscale or color (BGR) image containing graphical codes.
|
||||
@param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
|
||||
@param points vector of Quadrangle vertices found by detect() method (or some other algorithm).
|
||||
@param straight_code The optional output vector of images containing binarized codes
|
||||
*/
|
||||
CV_WRAP bool decodeMulti(InputArray img, InputArray points, CV_OUT std::vector<std::string>& decoded_info,
|
||||
OutputArrayOfArrays straight_code = noArray()) const;
|
||||
|
||||
/** @brief Both detects and decodes graphical codes
|
||||
@param img grayscale or color (BGR) image containing graphical codes.
|
||||
@param decoded_info UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
|
||||
@param points optional output vector of vertices of the found graphical code quadrangles. Will be empty if not found.
|
||||
@param straight_code The optional vector of images containing binarized codes
|
||||
*/
|
||||
CV_WRAP bool detectAndDecodeMulti(InputArray img, CV_OUT std::vector<std::string>& decoded_info, OutputArray points = noArray(),
|
||||
OutputArrayOfArrays straight_code = noArray()) const;
|
||||
struct Impl;
|
||||
protected:
|
||||
Ptr<Impl> p;
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user