vendor: OpenCV 5.0.0 snapshot at 40738fb16ceddb5fb3fea747585f7ce6abb0605b
This commit is contained in:
@@ -0,0 +1,597 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_OBJDETECT_HPP
|
||||
#define OPENCV_OBJDETECT_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/features.hpp"
|
||||
#include "opencv2/objdetect/aruco_detector.hpp"
|
||||
#include "opencv2/objdetect/graphical_code_detector.hpp"
|
||||
#include "opencv2/objdetect/mcc_checker_detector.hpp"
|
||||
|
||||
/**
|
||||
@defgroup objdetect Object Detection
|
||||
|
||||
@{
|
||||
@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.
|
||||
|
||||
@defgroup objdetect_common Common functions and classes
|
||||
@defgroup objdetect_aruco ArUco markers and boards detection for robust camera pose estimation
|
||||
@{
|
||||
ArUco Marker Detection
|
||||
Square fiducial markers (also known as Augmented Reality Markers) are useful for easy,
|
||||
fast and robust camera pose estimation.
|
||||
|
||||
The main functionality of ArucoDetector class is detection of markers in an image. If the markers are grouped
|
||||
as a board, then you can try to recover the missing markers with ArucoDetector::refineDetectedMarkers().
|
||||
ArUco markers can also be used for advanced chessboard corner finding. To do this, group the markers in the
|
||||
CharucoBoard and find the corners of the chessboard with the CharucoDetector::detectBoard().
|
||||
|
||||
The implementation is based on the ArUco Library by R. Muñoz-Salinas and S. Garrido-Jurado @cite Aruco2014.
|
||||
|
||||
Markers can also be detected based on the AprilTag 2 @cite wang2016iros fiducial marker detection method.
|
||||
|
||||
@sa @cite Aruco2014
|
||||
This code has been originally developed by Sergio Garrido-Jurado as a project
|
||||
for Google Summer of Code 2015 (GSoC 15).
|
||||
|
||||
<br>
|
||||
|
||||
@warning In OpenCV, the order of the returned corners locations for the AprilTag family is not aligned with the ArUco one.\n
|
||||
Note that this order is also different from the convention adopted by the official [AprilTag library](https://github.com/AprilRobotics/apriltag/).
|
||||
 { width=80% }
|
||||
|
||||
<br>
|
||||
|
||||
An overview of the supported ArUco markers family is visible in the following image:
|
||||
 { width=80% }
|
||||
|
||||
<br>
|
||||
|
||||
An overview of the supported AprilTag markers family is visible in the following image:
|
||||
 { width=80% }
|
||||
|
||||
@note The generated images (in the above picture) using @ref aruco::generateImageMarker for the AprilTag markers have been
|
||||
rotated by 180 degree in order to match the official AprilTag images.
|
||||
When using the @ref aruco::generateImageMarker function, it will output by default a different image from the official AprilTag convention,
|
||||
see the [AprilRobotics/apriltag-imgs](https://github.com/AprilRobotics/apriltag-imgs) repository.
|
||||
This is the reason why you see a different corners order between ArUco and AprilTag in the above image.
|
||||
|
||||
<br>
|
||||
|
||||
For the ArUco marker family, the recommended family is the DICT_ARUCO_MIP_36h12 one, [see](https://stackoverflow.com/a/51511558).
|
||||
In general, a smaller marker family (e.g. `4x4` vs `6x6`) should give you a better detection rate with respect to the camera distance,
|
||||
at the expense of having more probability to have issues with false detection or marker id decoding error.
|
||||
The number of marker ids in a family is also something to take into account with respect to the application use case and the ability
|
||||
to correct wrong bits during the marker id decoding process.
|
||||
|
||||
You can download some pregenerated MIP_36h12 ArUco marker images from:
|
||||
- https://sourceforge.net/projects/aruco/files/
|
||||
- or use the `samples/cpp/tutorial_code/objectDetection/create_marker.cpp` sample to generate the marker image for your
|
||||
desired marker family (which uses the @ref aruco::generateImageMarker function)
|
||||
|
||||
For the AprilTag family, you can find some pregenerated marker images in the
|
||||
[AprilRobotics/apriltag-imgs](https://github.com/AprilRobotics/apriltag-imgs) repository.
|
||||
|
||||
@note For accurate corners location extraction, a white border (to have a strong gradient between white and black transition) around the marker is important.
|
||||
This is necessary to precisely extract the marker contour in difficult conditions such as bad illumination, confusing color background, etc.
|
||||
|
||||
<br>
|
||||
|
||||
There are multiple parameters which can be tweaked to improve the marker detection rate or to be adapted to your use case (e.g. image resolution).
|
||||
Please refer to the:
|
||||
- @ref aruco::DetectorParameters
|
||||
- "Detector Parameters" section in the @ref tutorial_aruco_detection tutorial or in the @ref tutorial_aruco_faq page
|
||||
- [ArUco Library Documentation](https://drive.google.com/file/d/1OiavRVYVJ-WH88sQg1LUsh8CuJZUQyrX) for additional information from the ArUco library
|
||||
|
||||
The corner refinement method can be changed according to the @ref aruco::CornerRefineMethod to improve the corners location accuracy
|
||||
at the expense of more computation time.
|
||||
|
||||
<br>
|
||||
|
||||
To estimate the marker pose with respect to the camera frame, we recommend you to look at the following sources of information:
|
||||
- @ref tutorial_aruco_detection for a tutorial about ArUco markers detection
|
||||
- @ref _3d for some theoretical background about the pinhole camera model and the @ref calib3d_solvePnP page
|
||||
- @ref solvePnP, @ref solvePnPGeneric, @ref solveP3P for the relevant pose estimation methods
|
||||
@}
|
||||
|
||||
@}
|
||||
*/
|
||||
|
||||
namespace cv
|
||||
{
|
||||
//! @addtogroup objdetect_qrcode
|
||||
//! @{
|
||||
|
||||
/** @brief QR code encoder. */
|
||||
class CV_EXPORTS_W QRCodeEncoder {
|
||||
protected:
|
||||
QRCodeEncoder(); // use ::create()
|
||||
public:
|
||||
virtual ~QRCodeEncoder();
|
||||
|
||||
enum EncodeMode {
|
||||
MODE_AUTO = -1,
|
||||
MODE_NUMERIC = 1, // 0b0001
|
||||
MODE_ALPHANUMERIC = 2, // 0b0010
|
||||
MODE_BYTE = 4, // 0b0100
|
||||
MODE_ECI = 7, // 0b0111
|
||||
MODE_KANJI = 8, // 0b1000
|
||||
MODE_STRUCTURED_APPEND = 3 // 0b0011
|
||||
};
|
||||
|
||||
enum CorrectionLevel {
|
||||
CORRECT_LEVEL_L = 0,
|
||||
CORRECT_LEVEL_M = 1,
|
||||
CORRECT_LEVEL_Q = 2,
|
||||
CORRECT_LEVEL_H = 3
|
||||
};
|
||||
|
||||
enum ECIEncodings {
|
||||
ECI_SHIFT_JIS = 20,
|
||||
ECI_UTF8 = 26,
|
||||
};
|
||||
|
||||
/** @brief QR code encoder parameters. */
|
||||
struct CV_EXPORTS_W_SIMPLE Params
|
||||
{
|
||||
CV_WRAP Params();
|
||||
|
||||
//! The optional version of QR code (by default - maximum possible depending on the length of the string).
|
||||
CV_PROP_RW int version;
|
||||
|
||||
//! The optional level of error correction (by default - the lowest).
|
||||
CV_PROP_RW QRCodeEncoder::CorrectionLevel correction_level;
|
||||
|
||||
//! The optional encoding mode - Numeric, Alphanumeric, Byte, Kanji, ECI or Structured Append.
|
||||
CV_PROP_RW QRCodeEncoder::EncodeMode mode;
|
||||
|
||||
//! The optional number of QR codes to generate in Structured Append mode.
|
||||
CV_PROP_RW int structure_number;
|
||||
};
|
||||
|
||||
/** @brief Constructor
|
||||
@param parameters QR code encoder parameters QRCodeEncoder::Params
|
||||
*/
|
||||
static CV_WRAP
|
||||
Ptr<QRCodeEncoder> create(const QRCodeEncoder::Params& parameters = QRCodeEncoder::Params());
|
||||
|
||||
/** @brief Generates QR code from input string.
|
||||
@param encoded_info Input string to encode.
|
||||
@param qrcode Generated QR code.
|
||||
*/
|
||||
CV_WRAP virtual void encode(const String& encoded_info, OutputArray qrcode) = 0;
|
||||
|
||||
/** @brief Generates QR code from input string in Structured Append mode. The encoded message is splitting over a number of QR codes.
|
||||
@param encoded_info Input string to encode.
|
||||
@param qrcodes Vector of generated QR codes.
|
||||
*/
|
||||
CV_WRAP virtual void encodeStructuredAppend(const String& encoded_info, OutputArrayOfArrays qrcodes) = 0;
|
||||
|
||||
};
|
||||
|
||||
/** @brief QR code detector. */
|
||||
class CV_EXPORTS_W_SIMPLE QRCodeDetector : public GraphicalCodeDetector
|
||||
{
|
||||
public:
|
||||
CV_WRAP 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 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 QRCodeDetector& setEpsY(double epsY);
|
||||
|
||||
/** @brief use markers to improve the position of the corners of the QR code
|
||||
*
|
||||
* alignmentMarkers using by default
|
||||
*/
|
||||
CV_WRAP QRCodeDetector& setUseAlignmentMarkers(bool useAlignmentMarkers);
|
||||
|
||||
/** @brief Decodes QR code on a curved surface 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 cv::String decodeCurved(InputArray img, InputArray points, 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.
|
||||
@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 detectAndDecodeCurved(InputArray img, OutputArray points=noArray(),
|
||||
OutputArray straight_qrcode = noArray());
|
||||
|
||||
/** @brief Returns a kind of encoding for the decoded info from the latest @ref decode or @ref detectAndDecode call
|
||||
@param codeIdx an index of the previously decoded QR code.
|
||||
When @ref decode or @ref detectAndDecode is used, valid value is zero.
|
||||
For @ref decodeMulti or @ref detectAndDecodeMulti use indices corresponding to the output order.
|
||||
*/
|
||||
CV_WRAP QRCodeEncoder::ECIEncodings getEncoding(int codeIdx = 0);
|
||||
};
|
||||
|
||||
/** @brief QR code detector based on Aruco markers detection code. */
|
||||
class CV_EXPORTS_W_SIMPLE QRCodeDetectorAruco : public GraphicalCodeDetector {
|
||||
public:
|
||||
CV_WRAP QRCodeDetectorAruco();
|
||||
|
||||
struct CV_EXPORTS_W_SIMPLE Params {
|
||||
CV_WRAP Params();
|
||||
|
||||
/** @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;
|
||||
|
||||
/** @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 const aruco::DetectorParameters& getArucoParameters() const;
|
||||
|
||||
/** @brief Aruco detector parameters are used to search for the finder patterns. */
|
||||
CV_WRAP void setArucoParameters(const aruco::DetectorParameters& params);
|
||||
};
|
||||
|
||||
enum { CALIB_CB_ADAPTIVE_THRESH = 1,
|
||||
CALIB_CB_NORMALIZE_IMAGE = 2,
|
||||
CALIB_CB_FILTER_QUADS = 4,
|
||||
CALIB_CB_FAST_CHECK = 8,
|
||||
CALIB_CB_EXHAUSTIVE = 16,
|
||||
CALIB_CB_ACCURACY = 32,
|
||||
CALIB_CB_LARGER = 64,
|
||||
CALIB_CB_MARKER = 128,
|
||||
CALIB_CB_PLAIN = 256
|
||||
};
|
||||
|
||||
enum { CALIB_CB_SYMMETRIC_GRID = 1,
|
||||
CALIB_CB_ASYMMETRIC_GRID = 2,
|
||||
CALIB_CB_CLUSTERING = 4
|
||||
};
|
||||
|
||||
/** @brief Finds the positions of internal corners of the chessboard.
|
||||
|
||||
@param image Source chessboard view. It must be an 8-bit grayscale or color image.
|
||||
@param patternSize Number of inner corners per a chessboard row and column
|
||||
( patternSize = cv::Size(points_per_row,points_per_column) = cv::Size(columns,rows) ).
|
||||
@param corners Output array of detected corners.
|
||||
@param flags Various operation flags that can be zero or a combination of the following values:
|
||||
- @ref CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black
|
||||
and white, rather than a fixed threshold level (computed from the average image brightness).
|
||||
- @ref CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before
|
||||
applying fixed or adaptive thresholding.
|
||||
- @ref CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter,
|
||||
square-like shape) to filter out false quads extracted at the contour retrieval stage.
|
||||
- @ref CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners,
|
||||
and shortcut the call if none is found. This can drastically speed up the call in the
|
||||
degenerate condition when no chessboard is observed.
|
||||
- @ref CALIB_CB_PLAIN All other flags are ignored. The input image is taken as is.
|
||||
No image processing is done to improve to find the checkerboard. This has the effect of speeding up the
|
||||
execution of the function but could lead to not recognizing the checkerboard if the image
|
||||
is not previously binarized in the appropriate manner.
|
||||
|
||||
@return True if all of the corners are found and placed in a certain order (row by row,
|
||||
left to right in every row). Otherwise, if the function fails to find all the corners or reorder them,
|
||||
it returns false.
|
||||
|
||||
The function attempts to determine whether the input image is a view of the chessboard pattern and
|
||||
locate the internal chessboard corners. For example, a regular chessboard has 8 x 8 squares and
|
||||
7 x 7 internal corners, that is, points where the black squares touch each other. The detected
|
||||
coordinates are approximate, and to determine their positions more accurately, the function
|
||||
calls #cornerSubPix. You also may use the function #cornerSubPix with different parameters if
|
||||
returned coordinates are not accurate enough.
|
||||
|
||||
Sample usage of detecting and drawing chessboard corners: :
|
||||
@code
|
||||
Size patternsize(8,6); //interior number of corners
|
||||
Mat gray = ....; //source image
|
||||
vector<Point2f> corners; //this will be filled by the detected corners
|
||||
|
||||
//CALIB_CB_FAST_CHECK saves a lot of time on images
|
||||
//that do not contain any chessboard corners
|
||||
bool patternfound = findChessboardCorners(gray, patternsize, corners,
|
||||
CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE
|
||||
+ CALIB_CB_FAST_CHECK);
|
||||
|
||||
if(patternfound)
|
||||
cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1),
|
||||
TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
|
||||
|
||||
drawChessboardCorners(img, patternsize, Mat(corners), patternfound);
|
||||
@endcode
|
||||
@note The function requires white space (like a square-thick border, the wider the better) around
|
||||
the board to make the detection more robust in various environments. Otherwise, if there is no
|
||||
border and the background is dark, the outer black squares cannot be segmented properly and so the
|
||||
square grouping and ordering algorithm fails.
|
||||
|
||||
Use the `generate_pattern.py` Python script (@ref tutorial_camera_calibration_pattern)
|
||||
to create the desired checkerboard pattern.
|
||||
*/
|
||||
CV_EXPORTS_W bool findChessboardCorners( InputArray image, Size patternSize, OutputArray corners,
|
||||
int flags = CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE );
|
||||
|
||||
/** @brief Checks whether the image contains chessboard of the specific size or not.
|
||||
|
||||
@param img Source chessboard view.
|
||||
@param size Size of the chessboard.
|
||||
|
||||
@return Whether a chessboard was found.
|
||||
*/
|
||||
CV_EXPORTS_W bool checkChessboard(InputArray img, Size size);
|
||||
|
||||
/** @brief Finds the positions of internal corners of the chessboard using a sector based approach.
|
||||
|
||||
@param image Source chessboard view. It must be an 8-bit grayscale or color image.
|
||||
@param patternSize Number of inner corners per a chessboard row and column
|
||||
( patternSize = cv::Size(points_per_row,points_per_column) = cv::Size(columns,rows) ).
|
||||
@param corners Output array of detected corners.
|
||||
@param flags Various operation flags that can be zero or a combination of the following values:
|
||||
- @ref CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before detection.
|
||||
- @ref CALIB_CB_EXHAUSTIVE Run an exhaustive search to improve detection rate.
|
||||
- @ref CALIB_CB_ACCURACY Up sample input image to improve sub-pixel accuracy due to aliasing effects.
|
||||
- @ref CALIB_CB_LARGER The detected pattern is allowed to be larger than patternSize (see description).
|
||||
- @ref CALIB_CB_MARKER The detected pattern must have a marker (see description).
|
||||
This should be used if an accurate camera calibration is required.
|
||||
@param meta Optional output array of detected corners (CV_8UC1 and size = cv::Size(columns,rows)).
|
||||
Each entry stands for one corner of the pattern and can have one of the following values:
|
||||
- 0 = no meta data attached
|
||||
- 1 = left-top corner of a black cell
|
||||
- 2 = left-top corner of a white cell
|
||||
- 3 = left-top corner of a black cell with a white marker dot
|
||||
- 4 = left-top corner of a white cell with a black marker dot (pattern origin in case of markers otherwise first corner)
|
||||
|
||||
The function is analog to #findChessboardCorners but uses a localized radon
|
||||
transformation approximated by box filters being more robust to all sort of
|
||||
noise, faster on larger images and is able to directly return the sub-pixel
|
||||
position of the internal chessboard corners. The Method is based on the paper
|
||||
@cite duda2018 "Accurate Detection and Localization of Checkerboard Corners for
|
||||
Calibration" demonstrating that the returned sub-pixel positions are more
|
||||
accurate than the one returned by cornerSubPix allowing a precise camera
|
||||
calibration for demanding applications.
|
||||
|
||||
In the case, the flags @ref CALIB_CB_LARGER or @ref CALIB_CB_MARKER are given,
|
||||
the result can be recovered from the optional meta array. Both flags are
|
||||
helpful to use calibration patterns exceeding the field of view of the camera.
|
||||
These oversized patterns allow more accurate calibrations as corners can be
|
||||
utilized, which are as close as possible to the image borders. For a
|
||||
consistent coordinate system across all images, the optional marker (see image
|
||||
below) can be used to move the origin of the board to the location where the
|
||||
black circle is located.
|
||||
|
||||
@note The function requires a white boarder with roughly the same width as one
|
||||
of the checkerboard fields around the whole board to improve the detection in
|
||||
various environments. In addition, because of the localized radon
|
||||
transformation it is beneficial to use round corners for the field corners
|
||||
which are located on the outside of the board. The following figure illustrates
|
||||
a sample checkerboard optimized for the detection. However, any other checkerboard
|
||||
can be used as well.
|
||||
|
||||
Use the `generate_pattern.py` Python script (@ref tutorial_camera_calibration_pattern)
|
||||
to create the corresponding checkerboard pattern:
|
||||
\image html pics/checkerboard_radon.png width=60%
|
||||
*/
|
||||
CV_EXPORTS_AS(findChessboardCornersSBWithMeta)
|
||||
bool findChessboardCornersSB(InputArray image,Size patternSize, OutputArray corners,
|
||||
int flags,OutputArray meta);
|
||||
/** @overload */
|
||||
CV_EXPORTS_W inline
|
||||
bool findChessboardCornersSB(InputArray image, Size patternSize, OutputArray corners,
|
||||
int flags = 0)
|
||||
{
|
||||
return findChessboardCornersSB(image, patternSize, corners, flags, noArray());
|
||||
}
|
||||
|
||||
/** @brief Estimates the sharpness of a detected chessboard.
|
||||
|
||||
Image sharpness, as well as brightness, are a critical parameter for accuracte
|
||||
camera calibration. For accessing these parameters for filtering out
|
||||
problematic calibraiton images, this method calculates edge profiles by traveling from
|
||||
black to white chessboard cell centers. Based on this, the number of pixels is
|
||||
calculated required to transit from black to white. This width of the
|
||||
transition area is a good indication of how sharp the chessboard is imaged
|
||||
and should be below ~3.0 pixels.
|
||||
|
||||
@param image Gray image used to find chessboard corners
|
||||
@param patternSize Size of a found chessboard pattern
|
||||
@param corners Corners found by #findChessboardCornersSB
|
||||
@param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength
|
||||
@param vertical By default edge responses for horizontal lines are calculated
|
||||
@param sharpness Optional output array with a sharpness value for calculated edge responses (see description)
|
||||
|
||||
The optional sharpness array is of type CV_32FC1 and has for each calculated
|
||||
profile one row with the following five entries:
|
||||
* 0 = x coordinate of the underlying edge in the image
|
||||
* 1 = y coordinate of the underlying edge in the image
|
||||
* 2 = width of the transition area (sharpness)
|
||||
* 3 = signal strength in the black cell (min brightness)
|
||||
* 4 = signal strength in the white cell (max brightness)
|
||||
|
||||
@return Scalar(average sharpness, average min brightness, average max brightness,0)
|
||||
*/
|
||||
CV_EXPORTS_W Scalar estimateChessboardSharpness(InputArray image, Size patternSize, InputArray corners,
|
||||
float rise_distance=0.8F,bool vertical=false,
|
||||
OutputArray sharpness=noArray());
|
||||
|
||||
|
||||
//! finds subpixel-accurate positions of the chessboard corners
|
||||
CV_EXPORTS_W bool find4QuadCornerSubpix( InputArray img, InputOutputArray corners, Size region_size );
|
||||
|
||||
/** @brief Renders the detected chessboard corners.
|
||||
|
||||
@param image Destination image. It must be an 8-bit color image.
|
||||
@param patternSize Number of inner corners per a chessboard row and column
|
||||
(patternSize = cv::Size(points_per_row,points_per_column)).
|
||||
@param corners Array of detected corners, the output of #findChessboardCorners.
|
||||
@param patternWasFound Parameter indicating whether the complete board was found or not. The
|
||||
return value of #findChessboardCorners should be passed here.
|
||||
|
||||
The function draws individual chessboard corners detected either as red circles if the board was not
|
||||
found, or as colored corners connected with lines if the board was found.
|
||||
*/
|
||||
CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSize,
|
||||
InputArray corners, bool patternWasFound );
|
||||
|
||||
struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters
|
||||
{
|
||||
CV_WRAP CirclesGridFinderParameters();
|
||||
CV_PROP_RW cv::Size2f densityNeighborhoodSize;
|
||||
CV_PROP_RW float minDensity;
|
||||
CV_PROP_RW int kmeansAttempts;
|
||||
CV_PROP_RW int minDistanceToAddKeypoint;
|
||||
CV_PROP_RW int keypointScale;
|
||||
CV_PROP_RW float minGraphConfidence;
|
||||
CV_PROP_RW float vertexGain;
|
||||
CV_PROP_RW float vertexPenalty;
|
||||
CV_PROP_RW float existingVertexGain;
|
||||
CV_PROP_RW float edgeGain;
|
||||
CV_PROP_RW float edgePenalty;
|
||||
CV_PROP_RW float convexHullFactor;
|
||||
CV_PROP_RW float minRNGEdgeSwitchDist;
|
||||
|
||||
enum GridType
|
||||
{
|
||||
SYMMETRIC_GRID, ASYMMETRIC_GRID
|
||||
};
|
||||
CV_PROP_RW GridType gridType;
|
||||
|
||||
CV_PROP_RW float squareSize; //!< Distance between two adjacent points. Used by CALIB_CB_CLUSTERING.
|
||||
CV_PROP_RW float maxRectifiedDistance; //!< Max deviation from prediction. Used by CALIB_CB_CLUSTERING.
|
||||
};
|
||||
|
||||
/** @brief Finds centers in the grid of circles.
|
||||
|
||||
@param image grid view of input circles; it must be an 8-bit grayscale or color image.
|
||||
@param patternSize number of circles per row and column
|
||||
( patternSize = Size(points_per_row, points_per_column) ).
|
||||
@param centers output array of detected centers.
|
||||
@param flags various operation flags that can be one of the following values:
|
||||
- @ref CALIB_CB_SYMMETRIC_GRID uses symmetric pattern of circles.
|
||||
- @ref CALIB_CB_ASYMMETRIC_GRID uses asymmetric pattern of circles.
|
||||
- @ref CALIB_CB_CLUSTERING uses a special algorithm for grid detection. It is more robust to
|
||||
perspective distortions but much more sensitive to background clutter.
|
||||
@param blobDetector feature detector that finds blobs like dark circles on light background.
|
||||
If `blobDetector` is NULL then `image` represents Point2f array of candidates.
|
||||
@param parameters struct for finding circles in a grid pattern.
|
||||
|
||||
return True if all of the centers have been found and they have been placed in a certain order
|
||||
(row by row, left to right in every row). Otherwise, if the function fails to find all the corners
|
||||
or reorder them, it returns false.
|
||||
|
||||
The function attempts to determine whether the input image contains a grid of circles. If it is, the
|
||||
function locates centers of the circles.
|
||||
|
||||
Sample usage of detecting and drawing the centers of circles: :
|
||||
@code
|
||||
Size patternsize(7,7); //number of centers
|
||||
Mat gray = ...; //source image
|
||||
vector<Point2f> centers; //this will be filled by the detected centers
|
||||
|
||||
bool patternfound = findCirclesGrid(gray, patternsize, centers);
|
||||
|
||||
drawChessboardCorners(img, patternsize, Mat(centers), patternfound);
|
||||
@endcode
|
||||
@note The function requires white space (like a square-thick border, the wider the better) around
|
||||
the board to make the detection more robust in various environments.
|
||||
*/
|
||||
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
|
||||
OutputArray centers, int flags,
|
||||
const Ptr<FeatureDetector> &blobDetector,
|
||||
const CirclesGridFinderParameters& parameters);
|
||||
|
||||
/** @overload */
|
||||
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
|
||||
OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID,
|
||||
const Ptr<FeatureDetector> &blobDetector = cv::SimpleBlobDetector::create());
|
||||
|
||||
//! @}
|
||||
}
|
||||
|
||||
#include "opencv2/objdetect/face.hpp"
|
||||
#include "opencv2/objdetect/charuco_detector.hpp"
|
||||
#include "opencv2/objdetect/barcode.hpp"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,199 @@
|
||||
// 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_ARUCO_BOARD_HPP
|
||||
#define OPENCV_OBJDETECT_ARUCO_BOARD_HPP
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace aruco {
|
||||
//! @addtogroup objdetect_aruco
|
||||
//! @{
|
||||
|
||||
class Dictionary;
|
||||
|
||||
/** @brief Board of ArUco markers
|
||||
*
|
||||
* A board is a set of markers in the 3D space with a common coordinate system.
|
||||
* The common form of a board of marker is a planar (2D) board, however any 3D layout can be used.
|
||||
* A Board object is composed by:
|
||||
* - The object points of the marker corners, i.e. their coordinates respect to the board system.
|
||||
* - The dictionary which indicates the type of markers of the board
|
||||
* - The identifier of all the markers in the board.
|
||||
*/
|
||||
class CV_EXPORTS_W_SIMPLE Board {
|
||||
public:
|
||||
/** @brief Common Board constructor
|
||||
*
|
||||
* @param objPoints array of object points of all the marker corners in the board
|
||||
* @param dictionary the dictionary of markers employed for this board
|
||||
* @param ids vector of the identifiers of the markers in the board
|
||||
*/
|
||||
CV_WRAP Board(InputArrayOfArrays objPoints, const Dictionary& dictionary, InputArray ids);
|
||||
|
||||
/** @brief return the Dictionary of markers employed for this board
|
||||
*/
|
||||
CV_WRAP const Dictionary& getDictionary() const;
|
||||
|
||||
/** @brief return array of object points of all the marker corners in the board.
|
||||
*
|
||||
* Each marker include its 4 corners in this order:
|
||||
* - objPoints[i][0] - left-top point of i-th marker
|
||||
* - objPoints[i][1] - right-top point of i-th marker
|
||||
* - objPoints[i][2] - right-bottom point of i-th marker
|
||||
* - objPoints[i][3] - left-bottom point of i-th marker
|
||||
*
|
||||
* Markers are placed in a certain order - row by row, left to right in every row. For M markers, the size is Mx4.
|
||||
*/
|
||||
CV_WRAP const std::vector<std::vector<Point3f> >& getObjPoints() const;
|
||||
|
||||
/** @brief vector of the identifiers of the markers in the board (should be the same size as objPoints)
|
||||
* @return vector of the identifiers of the markers
|
||||
*/
|
||||
CV_WRAP const std::vector<int>& getIds() const;
|
||||
|
||||
/** @brief get coordinate of the bottom right corner of the board, is set when calling the function create()
|
||||
*/
|
||||
CV_WRAP const Point3f& getRightBottomCorner() const;
|
||||
|
||||
/** @brief Given a board configuration and a set of detected markers, returns the corresponding
|
||||
* image points and object points, can be used in solvePnP()
|
||||
*
|
||||
* @param detectedCorners List of detected marker corners of the board.
|
||||
* For cv::Board and cv::GridBoard the method expects std::vector<std::vector<Point2f>> or std::vector<Mat> with Aruco marker corners.
|
||||
* For cv::CharucoBoard the method expects std::vector<Point2f> or Mat with ChAruco corners (chess board corners matched with Aruco markers).
|
||||
*
|
||||
* @param detectedIds List of identifiers for each marker or charuco corner.
|
||||
* For any Board class the method expects std::vector<int> or Mat.
|
||||
*
|
||||
* @param objPoints Vector of marker points in the board coordinate space.
|
||||
* For any Board class the method expects std::vector<cv::Point3f> objectPoints or cv::Mat
|
||||
*
|
||||
* @param imgPoints Vector of marker points in the image coordinate space.
|
||||
* For any Board class the method expects std::vector<cv::Point2f> objectPoints or cv::Mat
|
||||
*
|
||||
* @sa solvePnP
|
||||
*/
|
||||
CV_WRAP void matchImagePoints(InputArrayOfArrays detectedCorners, InputArray detectedIds,
|
||||
OutputArray objPoints, OutputArray imgPoints) const;
|
||||
|
||||
/** @brief Draw a planar board
|
||||
*
|
||||
* @param outSize size of the output image in pixels.
|
||||
* @param img output image with the board. The size of this image will be outSize
|
||||
* and the board will be on the center, keeping the board proportions.
|
||||
* @param marginSize minimum margins (in pixels) of the board in the output image
|
||||
* @param borderBits width of the marker borders.
|
||||
*
|
||||
* This function return the image of the board, ready to be printed.
|
||||
*/
|
||||
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)
|
||||
Board();
|
||||
|
||||
struct Impl;
|
||||
protected:
|
||||
Board(const Ptr<Impl>& impl);
|
||||
Ptr<Impl> impl;
|
||||
};
|
||||
|
||||
/** @brief Planar board with grid arrangement of markers
|
||||
*
|
||||
* More common type of board. All markers are placed in the same plane in a grid arrangement.
|
||||
* The board image can be drawn using generateImage() method.
|
||||
*/
|
||||
class CV_EXPORTS_W_SIMPLE GridBoard : public Board {
|
||||
public:
|
||||
/**
|
||||
* @brief GridBoard constructor
|
||||
*
|
||||
* @param size number of markers in x and y directions
|
||||
* @param markerLength marker side length (normally in meters)
|
||||
* @param markerSeparation separation between two markers (same unit as markerLength)
|
||||
* @param dictionary dictionary of markers indicating the type of markers
|
||||
* @param ids set of marker ids in dictionary to use on board.
|
||||
*/
|
||||
CV_WRAP GridBoard(const Size& size, float markerLength, float markerSeparation,
|
||||
const Dictionary &dictionary, InputArray ids = noArray());
|
||||
|
||||
CV_WRAP Size getGridSize() const;
|
||||
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)
|
||||
GridBoard();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief ChArUco board is a planar chessboard where the markers are placed inside the white squares of a chessboard.
|
||||
*
|
||||
* The benefits of ChArUco boards is that they provide both, ArUco markers versatility and chessboard corner precision,
|
||||
* which is important for calibration and pose estimation. The board image can be drawn using generateImage() method.
|
||||
*/
|
||||
class CV_EXPORTS_W_SIMPLE CharucoBoard : public Board {
|
||||
public:
|
||||
/** @brief CharucoBoard constructor
|
||||
*
|
||||
* @param size number of chessboard squares in x and y directions
|
||||
* @param squareLength squareLength chessboard square side length (normally in meters)
|
||||
* @param markerLength marker side length (same unit than squareLength)
|
||||
* @param dictionary dictionary of markers indicating the type of markers
|
||||
* @param ids array of id used markers
|
||||
* The first markers in the dictionary are used to fill the white chessboard squares.
|
||||
*/
|
||||
CV_WRAP CharucoBoard(const Size& size, float squareLength, float markerLength,
|
||||
const Dictionary &dictionary, InputArray ids = noArray());
|
||||
|
||||
/** @brief set legacy chessboard pattern.
|
||||
*
|
||||
* Legacy setting creates chessboard patterns starting with a white box in the upper left corner
|
||||
* if there is an even row count of chessboard boxes, otherwise it starts with a black box.
|
||||
* This setting ensures compatibility to patterns created with OpenCV versions prior OpenCV 4.6.0.
|
||||
* See https://github.com/opencv/opencv/issues/23152.
|
||||
*
|
||||
* Default value: false.
|
||||
*/
|
||||
CV_WRAP void setLegacyPattern(bool legacyPattern);
|
||||
CV_WRAP bool getLegacyPattern() const;
|
||||
|
||||
CV_WRAP Size getChessboardSize() const;
|
||||
CV_WRAP float getSquareLength() const;
|
||||
CV_WRAP float getMarkerLength() const;
|
||||
|
||||
/** @brief get CharucoBoard::chessboardCorners
|
||||
*/
|
||||
CV_WRAP std::vector<Point3f> getChessboardCorners() const;
|
||||
|
||||
/** @brief get CharucoBoard::nearestMarkerIdx, for each charuco corner, nearest marker index in ids array
|
||||
*/
|
||||
CV_PROP std::vector<std::vector<int> > getNearestMarkerIdx() const;
|
||||
|
||||
/** @brief get CharucoBoard::nearestMarkerCorners, for each charuco corner, nearest marker corner id of each marker
|
||||
*/
|
||||
CV_PROP std::vector<std::vector<int> > getNearestMarkerCorners() const;
|
||||
|
||||
/** @brief check whether the ChArUco markers are collinear
|
||||
*
|
||||
* @param charucoIds list of identifiers for each corner in charucoCorners per frame.
|
||||
* @return bool value, 1 (true) if detected corners form a line, 0 (false) if they do not.
|
||||
* solvePnP, calibration functions will fail if the corners are collinear (true).
|
||||
*
|
||||
* The number of ids in charucoIDs should be <= the number of chessboard corners in the board.
|
||||
* This functions checks whether the charuco corners are on a straight line (returns true, if so), or not (false).
|
||||
* Axis parallel, as well as diagonal and other straight lines detected. Degenerate cases:
|
||||
* for number of charucoIDs <= 2,the function returns true.
|
||||
*/
|
||||
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)
|
||||
CharucoBoard();
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,495 @@
|
||||
// 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_ARUCO_DETECTOR_HPP
|
||||
#define OPENCV_OBJDETECT_ARUCO_DETECTOR_HPP
|
||||
|
||||
#include <opencv2/objdetect/aruco_dictionary.hpp>
|
||||
#include <opencv2/objdetect/aruco_board.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace aruco {
|
||||
|
||||
//! @addtogroup objdetect_aruco
|
||||
//! @{
|
||||
|
||||
enum CornerRefineMethod{
|
||||
CORNER_REFINE_NONE, ///< Tag and corners detection based on the ArUco approach
|
||||
CORNER_REFINE_SUBPIX, ///< ArUco approach and refine the corners locations using corner subpixel accuracy
|
||||
CORNER_REFINE_CONTOUR, ///< ArUco approach and refine the corners locations using the contour-points line fitting
|
||||
CORNER_REFINE_APRILTAG, ///< Tag and corners detection based on the AprilTag 2 approach @cite wang2016iros
|
||||
};
|
||||
|
||||
static constexpr float DEFAULT_VALID_BIT_ID_THRESHOLD{0.49f};
|
||||
|
||||
/** @brief struct DetectorParameters is used by ArucoDetector
|
||||
*/
|
||||
struct CV_EXPORTS_W_SIMPLE DetectorParameters {
|
||||
CV_WRAP DetectorParameters() {
|
||||
adaptiveThreshWinSizeMin = 3;
|
||||
adaptiveThreshWinSizeMax = 23;
|
||||
adaptiveThreshWinSizeStep = 10;
|
||||
adaptiveThreshConstant = 7;
|
||||
minMarkerPerimeterRate = 0.03;
|
||||
maxMarkerPerimeterRate = 4.;
|
||||
polygonalApproxAccuracyRate = 0.03;
|
||||
minCornerDistanceRate = 0.05;
|
||||
minDistanceToBorder = 3;
|
||||
minMarkerDistanceRate = 0.125;
|
||||
cornerRefinementMethod = (int)CORNER_REFINE_NONE;
|
||||
cornerRefinementWinSize = 5;
|
||||
relativeCornerRefinmentWinSize = 0.3f;
|
||||
cornerRefinementMaxIterations = 30;
|
||||
cornerRefinementMinAccuracy = 0.1;
|
||||
markerBorderBits = 1;
|
||||
perspectiveRemovePixelPerCell = 4;
|
||||
perspectiveRemoveIgnoredMarginPerCell = 0.13;
|
||||
maxErroneousBitsInBorderRate = 0.35;
|
||||
minOtsuStdDev = 5.0;
|
||||
errorCorrectionRate = 0.6;
|
||||
aprilTagQuadDecimate = 0.0;
|
||||
aprilTagQuadSigma = 0.0;
|
||||
aprilTagMinClusterPixels = 5;
|
||||
aprilTagMaxNmaxima = 10;
|
||||
aprilTagCriticalRad = (float)(10 * CV_PI / 180);
|
||||
aprilTagMaxLineFitMse = 10.0;
|
||||
aprilTagMinWhiteBlackDiff = 5;
|
||||
aprilTagDeglitch = 0;
|
||||
detectInvertedMarker = false;
|
||||
useAruco3Detection = false;
|
||||
minSideLengthCanonicalImg = 32;
|
||||
minMarkerLengthRatioOriginalImg = 0.0;
|
||||
validBitIdThreshold = DEFAULT_VALID_BIT_ID_THRESHOLD;
|
||||
}
|
||||
|
||||
/** @brief Read a new set of DetectorParameters from FileNode (use FileStorage.root()).
|
||||
*/
|
||||
CV_WRAP bool readDetectorParameters(const FileNode& fn);
|
||||
|
||||
/** @brief Write a set of DetectorParameters to FileStorage
|
||||
*/
|
||||
CV_WRAP bool writeDetectorParameters(FileStorage& fs, const String& name = String());
|
||||
|
||||
/// minimum window size for adaptive thresholding before finding contours (default 3).
|
||||
CV_PROP_RW int adaptiveThreshWinSizeMin;
|
||||
|
||||
/// maximum window size for adaptive thresholding before finding contours (default 23).
|
||||
CV_PROP_RW int adaptiveThreshWinSizeMax;
|
||||
|
||||
/// increments from adaptiveThreshWinSizeMin to adaptiveThreshWinSizeMax during the thresholding (default 10).
|
||||
CV_PROP_RW int adaptiveThreshWinSizeStep;
|
||||
|
||||
/// constant for adaptive thresholding before finding contours (default 7)
|
||||
CV_PROP_RW double adaptiveThreshConstant;
|
||||
|
||||
/** @brief determine minimum perimeter for marker contour to be detected.
|
||||
*
|
||||
* This is defined as a rate respect to the maximum dimension of the input image (default 0.03).
|
||||
*/
|
||||
CV_PROP_RW double minMarkerPerimeterRate;
|
||||
|
||||
/** @brief determine maximum perimeter for marker contour to be detected.
|
||||
*
|
||||
* This is defined as a rate respect to the maximum dimension of the input image (default 4.0).
|
||||
*/
|
||||
CV_PROP_RW double maxMarkerPerimeterRate;
|
||||
|
||||
/// minimum accuracy during the polygonal approximation process to determine which contours are squares. (default 0.03)
|
||||
CV_PROP_RW double polygonalApproxAccuracyRate;
|
||||
|
||||
/// minimum distance between corners for detected markers relative to its perimeter (default 0.05)
|
||||
CV_PROP_RW double minCornerDistanceRate;
|
||||
|
||||
/// minimum distance of any corner to the image border for detected markers (in pixels) (default 3)
|
||||
CV_PROP_RW int minDistanceToBorder;
|
||||
|
||||
/** @brief minimum average distance between the corners of the two markers to be grouped (default 0.125).
|
||||
*
|
||||
* The rate is relative to the smaller perimeter of the two markers.
|
||||
* Two markers are grouped if average distance between the corners of the two markers is less than
|
||||
* min(MarkerPerimeter1, MarkerPerimeter2)*minMarkerDistanceRate.
|
||||
*
|
||||
* default value is 0.125 because 0.125*MarkerPerimeter = (MarkerPerimeter / 4) * 0.5 = half the side of the marker.
|
||||
*
|
||||
* @note default value was changed from 0.05 after 4.8.1 release, because the filtering algorithm has been changed.
|
||||
* Now a few candidates from the same group can be added to the list of candidates if they are far from each other.
|
||||
* @sa minGroupDistance.
|
||||
*/
|
||||
CV_PROP_RW double minMarkerDistanceRate;
|
||||
|
||||
/** @brief minimum average distance between the corners of the two markers in group to add them to the list of candidates
|
||||
*
|
||||
* The average distance between the corners of the two markers is calculated relative to its module size (default 0.21).
|
||||
*/
|
||||
CV_PROP_RW float minGroupDistance = 0.21f;
|
||||
|
||||
/** @brief default value CORNER_REFINE_NONE */
|
||||
CV_PROP_RW int cornerRefinementMethod;
|
||||
|
||||
/** @brief maximum window size for the corner refinement process (in pixels) (default 5).
|
||||
*
|
||||
* The window size may decrease if the ArUco marker is too small, check relativeCornerRefinmentWinSize.
|
||||
* The final window size is calculated as:
|
||||
* min(cornerRefinementWinSize, averageArucoModuleSize*relativeCornerRefinmentWinSize),
|
||||
* where averageArucoModuleSize is average module size of ArUco marker in pixels.
|
||||
* (ArUco marker is composed of black and white modules)
|
||||
*/
|
||||
CV_PROP_RW int cornerRefinementWinSize;
|
||||
|
||||
/** @brief Dynamic window size for corner refinement relative to Aruco module size (default 0.3).
|
||||
*
|
||||
* The final window size is calculated as:
|
||||
* min(cornerRefinementWinSize, averageArucoModuleSize*relativeCornerRefinmentWinSize),
|
||||
* where averageArucoModuleSize is average module size of ArUco marker in pixels.
|
||||
* (ArUco marker is composed of black and white modules)
|
||||
* In the case of markers located far from each other, it may be useful to increase the value of the parameter to 0.4-0.5.
|
||||
* In the case of markers located close to each other, it may be useful to decrease the parameter value to 0.1-0.2.
|
||||
*/
|
||||
CV_PROP_RW float relativeCornerRefinmentWinSize;
|
||||
|
||||
/// maximum number of iterations for stop criteria of the corner refinement process (default 30).
|
||||
CV_PROP_RW int cornerRefinementMaxIterations;
|
||||
|
||||
/// minimum error for the stop cristeria of the corner refinement process (default: 0.1)
|
||||
CV_PROP_RW double cornerRefinementMinAccuracy;
|
||||
|
||||
/// number of bits of the marker border, i.e. marker border width (default 1).
|
||||
CV_PROP_RW int markerBorderBits;
|
||||
|
||||
/// number of bits (per dimension) for each cell of the marker when removing the perspective (default 4).
|
||||
CV_PROP_RW int perspectiveRemovePixelPerCell;
|
||||
|
||||
/** @brief width of the margin of pixels on each cell not considered for the determination of the cell bit.
|
||||
*
|
||||
* Represents the rate respect to the total size of the cell, i.e. perspectiveRemovePixelPerCell (default 0.13)
|
||||
*/
|
||||
CV_PROP_RW double perspectiveRemoveIgnoredMarginPerCell;
|
||||
|
||||
/** @brief maximum number of accepted erroneous bits in the border (i.e. number of allowed white bits in the border).
|
||||
*
|
||||
* Represented as a rate respect to the total number of bits per marker (default 0.35).
|
||||
*/
|
||||
CV_PROP_RW double maxErroneousBitsInBorderRate;
|
||||
|
||||
/** @brief minimum standard deviation in pixels values during the decodification step to apply Otsu
|
||||
* thresholding (otherwise, all the bits are set to 0 or 1 depending on mean higher than 128 or not) (default 5.0)
|
||||
*/
|
||||
CV_PROP_RW double minOtsuStdDev;
|
||||
|
||||
/// error correction rate respect to the maximum error correction capability for each dictionary (default 0.6).
|
||||
CV_PROP_RW double errorCorrectionRate;
|
||||
|
||||
/** @brief April :: User-configurable parameters.
|
||||
*
|
||||
* Detection of quads can be done on a lower-resolution image, improving speed at a cost of
|
||||
* pose accuracy and a slight decrease in detection rate. Decoding the binary payload is still
|
||||
*/
|
||||
CV_PROP_RW float aprilTagQuadDecimate;
|
||||
|
||||
/// what Gaussian blur should be applied to the segmented image (used for quad detection?)
|
||||
CV_PROP_RW float aprilTagQuadSigma;
|
||||
|
||||
// April :: Internal variables
|
||||
/// reject quads containing too few pixels (default 5).
|
||||
CV_PROP_RW int aprilTagMinClusterPixels;
|
||||
|
||||
/// how many corner candidates to consider when segmenting a group of pixels into a quad (default 10).
|
||||
CV_PROP_RW int aprilTagMaxNmaxima;
|
||||
|
||||
/** @brief reject quads where pairs of edges have angles that are close to straight or close to 180 degrees.
|
||||
*
|
||||
* Zero means that no quads are rejected. (In radians) (default 10*PI/180)
|
||||
*/
|
||||
CV_PROP_RW float aprilTagCriticalRad;
|
||||
|
||||
/// when fitting lines to the contours, what is the maximum mean squared error
|
||||
CV_PROP_RW float aprilTagMaxLineFitMse;
|
||||
|
||||
/** @brief add an extra check that the white model must be (overall) brighter than the black model.
|
||||
*
|
||||
* When we build our model of black & white pixels, we add an extra check that the white model must be (overall)
|
||||
* brighter than the black model. How much brighter? (in pixel values, [0,255]), (default 5)
|
||||
*/
|
||||
CV_PROP_RW int aprilTagMinWhiteBlackDiff;
|
||||
|
||||
/// should the thresholded image be deglitched? Only useful for very noisy images (default 0).
|
||||
CV_PROP_RW int aprilTagDeglitch;
|
||||
|
||||
/** @brief to check if there is a white marker.
|
||||
*
|
||||
* In order to generate a "white" marker just invert a normal marker by using a tilde, ~markerImage. (default false)
|
||||
*/
|
||||
CV_PROP_RW bool detectInvertedMarker;
|
||||
|
||||
/** @brief enable the new and faster Aruco detection strategy.
|
||||
*
|
||||
* Proposed in the paper:
|
||||
* Romero-Ramirez et al: Speeded up detection of squared fiducial markers (2018)
|
||||
* https://www.researchgate.net/publication/325787310_Speeded_Up_Detection_of_Squared_Fiducial_Markers
|
||||
*/
|
||||
CV_PROP_RW bool useAruco3Detection;
|
||||
|
||||
/// minimum side length of a marker in the canonical image. Latter is the binarized image in which contours are searched.
|
||||
CV_PROP_RW int minSideLengthCanonicalImg;
|
||||
|
||||
/// range [0,1], eq (2) from paper. The parameter tau_i has a direct influence on the processing speed.
|
||||
CV_PROP_RW float minMarkerLengthRatioOriginalImg;
|
||||
|
||||
/// range [0,1], define the acceptable threshold when comparing the detected marker to the dictionary during marker identification.
|
||||
CV_PROP_RW float validBitIdThreshold;
|
||||
};
|
||||
|
||||
/** @brief struct RefineParameters is used by ArucoDetector
|
||||
*/
|
||||
struct CV_EXPORTS_W_SIMPLE RefineParameters {
|
||||
CV_WRAP RefineParameters(float minRepDistance = 10.f, float errorCorrectionRate = 3.f, bool checkAllOrders = true);
|
||||
|
||||
|
||||
/** @brief Read a new set of RefineParameters from FileNode (use FileStorage.root()).
|
||||
*/
|
||||
CV_WRAP bool readRefineParameters(const FileNode& fn);
|
||||
|
||||
/** @brief Write a set of RefineParameters to FileStorage
|
||||
*/
|
||||
CV_WRAP bool writeRefineParameters(FileStorage& fs, const String& name = String());
|
||||
|
||||
/** @brief minRepDistance minimum distance between the corners of the rejected candidate and the reprojected marker
|
||||
in order to consider it as a correspondence.
|
||||
*/
|
||||
CV_PROP_RW float minRepDistance;
|
||||
|
||||
/** @brief errorCorrectionRate rate of allowed erroneous bits respect to the error correction capability of the used dictionary.
|
||||
*
|
||||
* -1 ignores the error correction step.
|
||||
*/
|
||||
CV_PROP_RW float errorCorrectionRate;
|
||||
|
||||
/** @brief checkAllOrders consider the four possible corner orders in the rejectedCorners array.
|
||||
*
|
||||
* If it set to false, only the provided corner order is considered (default true).
|
||||
*/
|
||||
CV_PROP_RW bool checkAllOrders;
|
||||
};
|
||||
|
||||
/** @brief The main functionality of ArucoDetector class is detection of markers in an image with detectMarkers() method.
|
||||
*
|
||||
* After detecting some markers in the image, you can try to find undetected markers from this dictionary with
|
||||
* refineDetectedMarkers() method.
|
||||
*
|
||||
* @see DetectorParameters, RefineParameters
|
||||
*/
|
||||
class CV_EXPORTS_W ArucoDetector : public Algorithm
|
||||
{
|
||||
public:
|
||||
/** @brief Basic ArucoDetector constructor
|
||||
*
|
||||
* @param dictionary indicates the type of markers that will be searched
|
||||
* @param detectorParams marker detection parameters
|
||||
* @param refineParams marker refine detection parameters
|
||||
*/
|
||||
CV_WRAP ArucoDetector(const Dictionary &dictionary = getPredefinedDictionary(cv::aruco::DICT_4X4_50),
|
||||
const DetectorParameters &detectorParams = DetectorParameters(),
|
||||
const RefineParameters& refineParams = RefineParameters());
|
||||
|
||||
/** @brief ArucoDetector constructor for multiple dictionaries
|
||||
*
|
||||
* @param dictionaries indicates the type of markers that will be searched. Empty dictionaries will throw an error.
|
||||
* @param detectorParams marker detection parameters
|
||||
* @param refineParams marker refine detection parameters
|
||||
*/
|
||||
CV_WRAP ArucoDetector(const std::vector<Dictionary> &dictionaries,
|
||||
const DetectorParameters &detectorParams = DetectorParameters(),
|
||||
const RefineParameters& refineParams = RefineParameters());
|
||||
|
||||
/** @brief Basic marker detection
|
||||
*
|
||||
* @param image input image
|
||||
* @param corners vector of detected marker corners. For each marker, its four corners
|
||||
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
|
||||
* the dimensions of this array is Nx4. The order of the corners is clockwise.
|
||||
* @param ids vector of identifiers of the detected markers. The identifier is of type int
|
||||
* (e.g. std::vector<int>). For N detected markers, the size of ids is also N.
|
||||
* The identifiers have the same order than the markers in the imgPoints array.
|
||||
* @param rejectedImgPoints contains the imgPoints of those squares whose inner code has not a
|
||||
* correct codification. Useful for debugging purposes.
|
||||
*
|
||||
* Performs marker detection in the input image. Only markers included in the first specified dictionary
|
||||
* are searched. For each detected marker, it returns the 2D position of its corner in the image
|
||||
* and its corresponding identifier.
|
||||
* Note that this function does not perform pose estimation.
|
||||
* @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
|
||||
* input image with corresponding camera model, if camera parameters are known
|
||||
* @sa undistort, estimatePoseSingleMarkers, estimatePoseBoard
|
||||
*/
|
||||
CV_WRAP void detectMarkers(InputArray image, OutputArrayOfArrays corners, OutputArray ids,
|
||||
OutputArrayOfArrays rejectedImgPoints = noArray()) const;
|
||||
|
||||
/** @brief Marker detection with confidence computation
|
||||
*
|
||||
* @param image input image
|
||||
* @param corners vector of detected marker corners. For each marker, its four corners
|
||||
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
|
||||
* the dimensions of this array is Nx4. The order of the corners is clockwise.
|
||||
* @param ids vector of identifiers of the detected markers. The identifier is of type int
|
||||
* (e.g. std::vector<int>). For N detected markers, the size of ids is also N.
|
||||
* The identifiers have the same order than the markers in the imgPoints array.
|
||||
* @param markersConfidence contains the normalized confidence [0;1] of the markers' detection,
|
||||
* defined as 1 minus the normalized uncertainty (percentage of incorrect pixel detections),
|
||||
* with 1 describing a pixel perfect detection. The confidence values are of type float
|
||||
* (e.g. std::vector<float>)
|
||||
* @param rejectedImgPoints contains the imgPoints of those squares whose inner code has not a
|
||||
* correct codification. Useful for debugging purposes.
|
||||
*
|
||||
* Performs marker detection in the input image. Only markers included in the first specified dictionary
|
||||
* are searched. For each detected marker, it returns the 2D position of its corner in the image
|
||||
* and its corresponding identifier.
|
||||
* Note that this function does not perform pose estimation.
|
||||
* @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
|
||||
* input image with corresponding camera model, if camera parameters are known
|
||||
* @sa undistort, estimatePoseSingleMarkers, estimatePoseBoard
|
||||
*/
|
||||
CV_WRAP void detectMarkersWithConfidence(InputArray image, OutputArrayOfArrays corners, OutputArray ids, OutputArray markersConfidence,
|
||||
OutputArrayOfArrays rejectedImgPoints = noArray()) const;
|
||||
|
||||
/** @brief Refine not detected markers based on the already detected and the board layout
|
||||
*
|
||||
* @param image input image
|
||||
* @param board layout of markers in the board.
|
||||
* @param detectedCorners vector of already detected marker corners.
|
||||
* @param detectedIds vector of already detected marker identifiers.
|
||||
* @param rejectedCorners vector of rejected candidates during the marker detection process.
|
||||
* @param cameraMatrix optional input 3x3 floating-point camera matrix
|
||||
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
|
||||
* @param distCoeffs optional vector of distortion coefficients
|
||||
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
|
||||
* @param recoveredIdxs Optional array to returns the indexes of the recovered candidates in the
|
||||
* original rejectedCorners array.
|
||||
*
|
||||
* This function tries to find markers that were not detected in the basic detecMarkers function.
|
||||
* First, based on the current detected marker and the board layout, the function interpolates
|
||||
* the position of the missing markers. Then it tries to find correspondence between the reprojected
|
||||
* markers and the rejected candidates based on the minRepDistance and errorCorrectionRate parameters.
|
||||
* If camera parameters and distortion coefficients are provided, missing markers are reprojected
|
||||
* using projectPoint function. If not, missing marker projections are interpolated using global
|
||||
* homography, and all the marker corners in the board must have the same Z coordinate.
|
||||
* @note This function assumes that the board only contains markers from one dictionary, so only the
|
||||
* first configured dictionary is used. It has to match the dictionary of the board to work properly.
|
||||
*/
|
||||
CV_WRAP void refineDetectedMarkers(InputArray image, const Board &board,
|
||||
InputOutputArrayOfArrays detectedCorners,
|
||||
InputOutputArray detectedIds, InputOutputArrayOfArrays rejectedCorners,
|
||||
InputArray cameraMatrix = noArray(), InputArray distCoeffs = noArray(),
|
||||
OutputArray recoveredIdxs = noArray()) const;
|
||||
|
||||
/** @brief Basic marker detection
|
||||
*
|
||||
* @param image input image
|
||||
* @param corners vector of detected marker corners. For each marker, its four corners
|
||||
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
|
||||
* the dimensions of this array is Nx4. The order of the corners is clockwise.
|
||||
* @param ids vector of identifiers of the detected markers. The identifier is of type int
|
||||
* (e.g. std::vector<int>). For N detected markers, the size of ids is also N.
|
||||
* The identifiers have the same order than the markers in the imgPoints array.
|
||||
* @param rejectedImgPoints contains the imgPoints of those squares whose inner code has not a
|
||||
* correct codification. Useful for debugging purposes.
|
||||
* @param dictIndices vector of dictionary indices for each detected marker. Use getDictionaries() to get the
|
||||
* list of corresponding dictionaries.
|
||||
*
|
||||
* Performs marker detection in the input image. Only markers included in the specific dictionaries
|
||||
* are searched. For each detected marker, it returns the 2D position of its corner in the image
|
||||
* and its corresponding identifier.
|
||||
* Note that this function does not perform pose estimation.
|
||||
* @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
|
||||
* input image with corresponding camera model, if camera parameters are known
|
||||
* @sa undistort, estimatePoseSingleMarkers, estimatePoseBoard
|
||||
*/
|
||||
CV_WRAP void detectMarkersMultiDict(InputArray image, OutputArrayOfArrays corners, OutputArray ids,
|
||||
OutputArrayOfArrays rejectedImgPoints = noArray(), OutputArray dictIndices = noArray()) const;
|
||||
|
||||
/** @brief Returns first dictionary from internal list used for marker detection.
|
||||
*
|
||||
* @return The first dictionary from the configured ArucoDetector.
|
||||
*/
|
||||
CV_WRAP const Dictionary& getDictionary() const;
|
||||
|
||||
/** @brief Sets and replaces the first dictionary in internal list to be used for marker detection.
|
||||
*
|
||||
* @param dictionary The new dictionary that will replace the first dictionary in the internal list.
|
||||
*/
|
||||
CV_WRAP void setDictionary(const Dictionary& dictionary);
|
||||
|
||||
/** @brief Returns all dictionaries currently used for marker detection as a vector.
|
||||
*
|
||||
* @return A std::vector<Dictionary> containing all dictionaries used by the ArucoDetector.
|
||||
*/
|
||||
CV_WRAP std::vector<Dictionary> getDictionaries() const;
|
||||
|
||||
/** @brief Sets the entire collection of dictionaries to be used for marker detection, replacing any existing dictionaries.
|
||||
*
|
||||
* @param dictionaries A std::vector<Dictionary> containing the new set of dictionaries to be used.
|
||||
*
|
||||
* Configures the ArucoDetector to use the provided vector of dictionaries for marker detection.
|
||||
* This method replaces any dictionaries that were previously set.
|
||||
* @note Setting an empty vector of dictionaries will throw an error.
|
||||
*/
|
||||
CV_WRAP void setDictionaries(const std::vector<Dictionary>& dictionaries);
|
||||
|
||||
CV_WRAP const DetectorParameters& getDetectorParameters() const;
|
||||
CV_WRAP void setDetectorParameters(const DetectorParameters& detectorParameters);
|
||||
|
||||
CV_WRAP const RefineParameters& getRefineParameters() const;
|
||||
CV_WRAP void setRefineParameters(const RefineParameters& refineParameters);
|
||||
|
||||
/** @brief Stores algorithm parameters in a file storage
|
||||
*/
|
||||
virtual void write(FileStorage& fs) const override;
|
||||
|
||||
/** @brief simplified API for language bindings
|
||||
*/
|
||||
CV_WRAP inline void write(FileStorage& fs, const String& name) { Algorithm::write(fs, name); }
|
||||
|
||||
/** @brief Reads algorithm parameters from a file storage
|
||||
*/
|
||||
CV_WRAP virtual void read(const FileNode& fn) override;
|
||||
protected:
|
||||
struct ArucoDetectorImpl;
|
||||
Ptr<ArucoDetectorImpl> arucoDetectorImpl;
|
||||
};
|
||||
|
||||
/** @brief Draw detected markers in image
|
||||
*
|
||||
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not altered.
|
||||
* @param corners positions of marker corners on input image.
|
||||
* (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the dimensions of
|
||||
* this array should be Nx4. The order of the corners should be clockwise.
|
||||
* @param ids vector of identifiers for markers in markersCorners .
|
||||
* Optional, if not provided, ids are not painted.
|
||||
* @param borderColor color of marker borders. Rest of colors (text color and first corner color)
|
||||
* are calculated based on this one to improve visualization.
|
||||
*
|
||||
* Given an array of detected marker corners and its corresponding ids, this functions draws
|
||||
* the markers in the image. The marker borders are painted and the markers identifiers if provided.
|
||||
* Useful for debugging purposes.
|
||||
*/
|
||||
CV_EXPORTS_W void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays corners,
|
||||
InputArray ids = noArray(), Scalar borderColor = Scalar(0, 255, 0));
|
||||
|
||||
/** @brief Generate a canonical marker image
|
||||
*
|
||||
* @param dictionary dictionary of markers indicating the type of markers
|
||||
* @param id identifier of the marker that will be returned. It has to be a valid id in the specified dictionary.
|
||||
* @param sidePixels size of the image in pixels
|
||||
* @param img output image with the marker
|
||||
* @param borderBits width of the marker border.
|
||||
*
|
||||
* This function returns a marker image in its canonical form (i.e. ready to be printed)
|
||||
*/
|
||||
CV_EXPORTS_W void generateImageMarker(const Dictionary &dictionary, int id, int sidePixels, OutputArray img,
|
||||
int borderBits = 1);
|
||||
|
||||
//! @}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,164 @@
|
||||
// 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_DICTIONARY_HPP
|
||||
#define OPENCV_OBJDETECT_DICTIONARY_HPP
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace aruco {
|
||||
|
||||
//! @addtogroup objdetect_aruco
|
||||
//! @{
|
||||
|
||||
|
||||
/** @brief Dictionary is a set of unique ArUco markers of the same size
|
||||
*
|
||||
* `bytesList` storing as 2-dimensions Mat with 4-th channels (CV_8UC4 type was used) and contains the marker codewords where:
|
||||
* - bytesList.rows is the dictionary size
|
||||
* - each marker is encoded using `nbytes = ceil(markerSize*markerSize/8.)` bytes
|
||||
* - each row contains all 4 rotations of the marker, so its length is `4*nbytes`
|
||||
* - the byte order in the bytesList[i] row:
|
||||
* `//bytes without rotation/bytes with rotation 1/bytes with rotation 2/bytes with rotation 3//`
|
||||
* So `bytesList.ptr(i)[k*nbytes + j]` is the j-th byte of i-th marker, in its k-th rotation.
|
||||
* @note Python bindings generate matrix with shape of bytesList `dictionary_size x nbytes x 4`,
|
||||
* but it should be indexed like C++ version. Python example for j-th byte of i-th marker, in its k-th rotation:
|
||||
* `aruco_dict.bytesList[id].ravel()[k*nbytes + j]`
|
||||
*/
|
||||
class CV_EXPORTS_W_SIMPLE Dictionary {
|
||||
|
||||
public:
|
||||
CV_PROP_RW Mat bytesList; ///< marker code information. See class description for more details
|
||||
CV_PROP_RW int markerSize; ///< number of bits per dimension
|
||||
CV_PROP_RW int maxCorrectionBits; ///< maximum number of bits that can be corrected
|
||||
|
||||
CV_WRAP Dictionary();
|
||||
|
||||
/** @brief Basic ArUco dictionary constructor
|
||||
*
|
||||
* @param bytesList bits for all ArUco markers in dictionary see memory layout in the class description
|
||||
* @param _markerSize ArUco marker size in units
|
||||
* @param maxcorr maximum number of bits that can be corrected
|
||||
*/
|
||||
CV_WRAP Dictionary(const Mat &bytesList, int _markerSize, int maxcorr = 0);
|
||||
|
||||
/** @brief Read a new dictionary from FileNode.
|
||||
*
|
||||
* Dictionary example in YAML format:\n
|
||||
* nmarkers: 35\n
|
||||
* markersize: 6\n
|
||||
* maxCorrectionBits: 5\n
|
||||
* marker_0: "101011111011111001001001101100000000"\n
|
||||
* ...\n
|
||||
* marker_34: "011111010000111011111110110101100101"
|
||||
*/
|
||||
CV_WRAP bool readDictionary(const cv::FileNode& fn);
|
||||
|
||||
/** @brief Write a dictionary to FileStorage, format is the same as in readDictionary().
|
||||
*/
|
||||
CV_WRAP void writeDictionary(FileStorage& fs, const String& name = String());
|
||||
|
||||
/** @brief Given a matrix of bits. Returns whether if marker is identified or not.
|
||||
*
|
||||
* Returns reference to the marker id in the dictionary (if any) and its rotation.
|
||||
*/
|
||||
CV_WRAP bool identify(const Mat &onlyBits, CV_OUT int &idx, CV_OUT int &rotation, double maxCorrectionRate) const;
|
||||
|
||||
/** @brief Given a matrix of pixel ratio raging from 0 to 1. Returns whether if marker is identified or not.
|
||||
*
|
||||
* Returns reference to the marker id in the dictionary (if any) and its rotation.
|
||||
*/
|
||||
CV_WRAP bool identify(const Mat &onlyCellPixelRatio, CV_OUT int &idx, CV_OUT int &rotation, double maxCorrectionRate, float validBitIdThreshold) const;
|
||||
|
||||
/** @brief Returns Hamming distance of the input bits to the specific id.
|
||||
*
|
||||
* If `allRotations` flag is set, the four possible marker rotations are considered
|
||||
*/
|
||||
CV_WRAP int getDistanceToId(InputArray bits, int id, bool allRotations = true) const;
|
||||
|
||||
/** @brief Generate a canonical marker image
|
||||
*/
|
||||
CV_WRAP void generateImageMarker(int id, int sidePixels, OutputArray _img, int borderBits = 1) const;
|
||||
|
||||
|
||||
/** @brief Transform matrix of bits to list of bytes with 4 marker rotations
|
||||
*/
|
||||
CV_WRAP static Mat getByteListFromBits(const Mat &bits);
|
||||
|
||||
|
||||
/** @brief Transform list of bytes to matrix of bits
|
||||
*/
|
||||
CV_WRAP static Mat getBitsFromByteList(const Mat &byteList, int markerSize, int rotationId = 0);
|
||||
|
||||
/** @brief Get ground truth bits float
|
||||
*/
|
||||
CV_WRAP Mat getMarkerBits(int markerId, int rotationId = 0) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/** @brief Predefined markers dictionaries/sets
|
||||
*
|
||||
* Each dictionary indicates the number of bits and the number of markers contained
|
||||
* - DICT_ARUCO_ORIGINAL: standard ArUco Library Markers. 1024 markers, 5x5 bits, 0 minimum
|
||||
distance
|
||||
*/
|
||||
enum PredefinedDictionaryType {
|
||||
DICT_4X4_50 = 0, ///< 4x4 bits, minimum hamming distance between any two codes = 4, 50 codes
|
||||
DICT_4X4_100, ///< 4x4 bits, minimum hamming distance between any two codes = 3, 100 codes
|
||||
DICT_4X4_250, ///< 4x4 bits, minimum hamming distance between any two codes = 3, 250 codes
|
||||
DICT_4X4_1000, ///< 4x4 bits, minimum hamming distance between any two codes = 2, 1000 codes
|
||||
DICT_5X5_50, ///< 5x5 bits, minimum hamming distance between any two codes = 8, 50 codes
|
||||
DICT_5X5_100, ///< 5x5 bits, minimum hamming distance between any two codes = 7, 100 codes
|
||||
DICT_5X5_250, ///< 5x5 bits, minimum hamming distance between any two codes = 6, 250 codes
|
||||
DICT_5X5_1000, ///< 5x5 bits, minimum hamming distance between any two codes = 5, 1000 codes
|
||||
DICT_6X6_50, ///< 6x6 bits, minimum hamming distance between any two codes = 13, 50 codes
|
||||
DICT_6X6_100, ///< 6x6 bits, minimum hamming distance between any two codes = 12, 100 codes
|
||||
DICT_6X6_250, ///< 6x6 bits, minimum hamming distance between any two codes = 11, 250 codes
|
||||
DICT_6X6_1000, ///< 6x6 bits, minimum hamming distance between any two codes = 9, 1000 codes
|
||||
DICT_7X7_50, ///< 7x7 bits, minimum hamming distance between any two codes = 19, 50 codes
|
||||
DICT_7X7_100, ///< 7x7 bits, minimum hamming distance between any two codes = 18, 100 codes
|
||||
DICT_7X7_250, ///< 7x7 bits, minimum hamming distance between any two codes = 17, 250 codes
|
||||
DICT_7X7_1000, ///< 7x7 bits, minimum hamming distance between any two codes = 14, 1000 codes
|
||||
DICT_ARUCO_ORIGINAL, ///< 6x6 bits, minimum hamming distance between any two codes = 3, 1024 codes
|
||||
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_ARUCO_MIP_36h12 ///< 6x6 bits, minimum hamming distance between any two codes = 12, 250 codes
|
||||
};
|
||||
|
||||
|
||||
/** @brief Returns one of the predefined dictionaries defined in PredefinedDictionaryType
|
||||
*/
|
||||
CV_EXPORTS Dictionary getPredefinedDictionary(PredefinedDictionaryType name);
|
||||
|
||||
|
||||
/** @brief Returns one of the predefined dictionaries referenced by DICT_*.
|
||||
*/
|
||||
CV_EXPORTS_W Dictionary getPredefinedDictionary(int dict);
|
||||
|
||||
/** @brief Extend base dictionary by new nMarkers
|
||||
*
|
||||
* @param nMarkers number of markers in the dictionary
|
||||
* @param markerSize number of bits per dimension of each markers
|
||||
* @param baseDictionary Include the markers in this dictionary at the beginning (optional)
|
||||
* @param randomSeed a user supplied seed for theRNG()
|
||||
*
|
||||
* This function creates a new dictionary composed by nMarkers markers and each markers composed
|
||||
* by markerSize x markerSize bits. If baseDictionary is provided, its markers are directly
|
||||
* included and the rest are generated based on them. If the size of baseDictionary is higher
|
||||
* than nMarkers, only the first nMarkers in baseDictionary are taken and no new marker is added.
|
||||
*/
|
||||
CV_EXPORTS_W Dictionary extendDictionary(int nMarkers, int markerSize, const Dictionary &baseDictionary = Dictionary(),
|
||||
int randomSeed=0);
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,117 @@
|
||||
// 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. Super resolution is disabled.
|
||||
*/
|
||||
CV_WRAP BarcodeDetector();
|
||||
|
||||
/** @brief Initialize the BarcodeDetector with a Super Resolution model.
|
||||
*
|
||||
* Loads a Super Resolution DNN model in ONNX format, used to upscale small/low-quality
|
||||
* barcode crops before decoding for better quality.
|
||||
*
|
||||
* @note Caffe models (`sr.prototxt` / `sr.caffemodel`) are no longer supported; convert
|
||||
* the model to ONNX (a converted `sr.onnx` is available from
|
||||
* https://github.com/WeChatCV/opencv_3rdparty/tree/wechat_qrcode).
|
||||
*
|
||||
* @param super_resolution_model_path path to a single-file ONNX Super Resolution model.
|
||||
*/
|
||||
CV_WRAP BarcodeDetector(CV_WRAP_FILE_PATH const std::string &super_resolution_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;
|
||||
|
||||
/** @brief Get detector downsampling threshold.
|
||||
*
|
||||
* @return detector downsampling threshold
|
||||
*/
|
||||
CV_WRAP double getDownsamplingThreshold() const;
|
||||
|
||||
/** @brief Set detector downsampling threshold.
|
||||
*
|
||||
* By default, the detect method resizes the input image to this limit if the smallest image size is is greater than the threshold.
|
||||
* Increasing this value can improve detection accuracy and the number of results at the expense of performance.
|
||||
* Correlates with detector scales. Setting this to a large value will disable downsampling.
|
||||
* @param thresh downsampling limit to apply (default 512)
|
||||
* @see setDetectorScales
|
||||
*/
|
||||
CV_WRAP BarcodeDetector& setDownsamplingThreshold(double thresh);
|
||||
|
||||
/** @brief Returns detector box filter sizes.
|
||||
*
|
||||
* @param sizes output parameter for returning the sizes.
|
||||
*/
|
||||
CV_WRAP void getDetectorScales(CV_OUT std::vector<float>& sizes) const;
|
||||
|
||||
/** @brief Set detector box filter sizes.
|
||||
*
|
||||
* Adjusts the value and the number of box filters used in the detect step.
|
||||
* The filter sizes directly correlate with the expected line widths for a barcode. Corresponds to expected barcode distance.
|
||||
* If the downsampling limit is increased, filter sizes need to be adjusted in an inversely proportional way.
|
||||
* @param sizes box filter sizes, relative to minimum dimension of the image (default [0.01, 0.03, 0.06, 0.08])
|
||||
*/
|
||||
CV_WRAP BarcodeDetector& setDetectorScales(const std::vector<float>& sizes);
|
||||
|
||||
/** @brief Get detector gradient magnitude threshold.
|
||||
*
|
||||
* @return detector gradient magnitude threshold.
|
||||
*/
|
||||
CV_WRAP double getGradientThreshold() const;
|
||||
|
||||
/** @brief Set detector gradient magnitude threshold.
|
||||
*
|
||||
* Sets the coherence threshold for detected bounding boxes.
|
||||
* Increasing this value will generate a closer fitted bounding box width and can reduce false-positives.
|
||||
* Values between 16 and 1024 generally work, while too high of a value will remove valid detections.
|
||||
* @param thresh gradient magnitude threshold (default 64).
|
||||
*/
|
||||
CV_WRAP BarcodeDetector& setGradientThreshold(double thresh);
|
||||
};
|
||||
//! @}
|
||||
|
||||
}} // cv::barcode::
|
||||
|
||||
#endif // OPENCV_OBJDETECT_BARCODE_HPP
|
||||
@@ -0,0 +1,161 @@
|
||||
// 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_CHARUCO_DETECTOR_HPP
|
||||
#define OPENCV_OBJDETECT_CHARUCO_DETECTOR_HPP
|
||||
|
||||
#include "opencv2/objdetect/aruco_detector.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace aruco {
|
||||
|
||||
//! @addtogroup objdetect_aruco
|
||||
//! @{
|
||||
|
||||
struct CV_EXPORTS_W_SIMPLE CharucoParameters {
|
||||
CV_WRAP CharucoParameters() {
|
||||
minMarkers = 2;
|
||||
tryRefineMarkers = false;
|
||||
checkMarkers = true;
|
||||
}
|
||||
/// cameraMatrix optional 3x3 floating-point camera matrix
|
||||
CV_PROP_RW Mat cameraMatrix;
|
||||
|
||||
/// distCoeffs optional vector of distortion coefficients
|
||||
CV_PROP_RW Mat distCoeffs;
|
||||
|
||||
/// minMarkers number of adjacent markers that must be detected to return a charuco corner, default = 2
|
||||
CV_PROP_RW int minMarkers;
|
||||
|
||||
/// try to use refine board, default false
|
||||
CV_PROP_RW bool tryRefineMarkers;
|
||||
|
||||
/// run check to verify that markers belong to the same board, default true
|
||||
CV_PROP_RW bool checkMarkers;
|
||||
};
|
||||
|
||||
class CV_EXPORTS_W CharucoDetector : public Algorithm {
|
||||
public:
|
||||
/** @brief Basic CharucoDetector constructor
|
||||
*
|
||||
* @param board ChAruco board
|
||||
* @param charucoParams charuco detection parameters
|
||||
* @param detectorParams marker detection parameters
|
||||
* @param refineParams marker refine detection parameters
|
||||
*/
|
||||
CV_WRAP CharucoDetector(const CharucoBoard& board,
|
||||
const CharucoParameters& charucoParams = CharucoParameters(),
|
||||
const DetectorParameters &detectorParams = DetectorParameters(),
|
||||
const RefineParameters& refineParams = RefineParameters());
|
||||
|
||||
CV_WRAP const CharucoBoard& getBoard() const;
|
||||
CV_WRAP void setBoard(const CharucoBoard& board);
|
||||
|
||||
CV_WRAP const CharucoParameters& getCharucoParameters() const;
|
||||
CV_WRAP void setCharucoParameters(CharucoParameters& charucoParameters);
|
||||
|
||||
CV_WRAP const DetectorParameters& getDetectorParameters() const;
|
||||
CV_WRAP void setDetectorParameters(const DetectorParameters& detectorParameters);
|
||||
|
||||
CV_WRAP const RefineParameters& getRefineParameters() const;
|
||||
CV_WRAP void setRefineParameters(const RefineParameters& refineParameters);
|
||||
|
||||
/**
|
||||
* @brief detect aruco markers and interpolate position of ChArUco board corners
|
||||
* @param image input image necessary for corner refinement. Note that markers are not detected and
|
||||
* should be sent in corners and ids parameters.
|
||||
* @param charucoCorners interpolated chessboard corners.
|
||||
* @param charucoIds interpolated chessboard corners identifiers.
|
||||
* @param markerCorners vector of already detected markers corners. For each marker, its four
|
||||
* corners are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the
|
||||
* dimensions of this array should be Nx4. The order of the corners should be clockwise.
|
||||
* If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
|
||||
* @param markerIds list of identifiers for each marker in corners.
|
||||
* If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
|
||||
*
|
||||
* This function receives the detected markers and returns the 2D position of the chessboard corners
|
||||
* from a ChArUco board using the detected Aruco markers.
|
||||
*
|
||||
* If markerCorners and markerCorners are empty, the detectMarkers() will run and detect aruco markers and ids.
|
||||
*
|
||||
* If camera parameters are provided, the process is based in an approximated pose estimation, else it is based on local homography.
|
||||
* Only visible corners are returned. For each corner, its corresponding identifier is also returned in charucoIds.
|
||||
* @sa findChessboardCorners
|
||||
* @note After OpenCV 4.6.0, there was an incompatible change in the ChArUco pattern generation algorithm for even row counts.
|
||||
* Use cv::aruco::CharucoBoard::setLegacyPattern() to ensure compatibility with patterns created using OpenCV versions prior to 4.6.0.
|
||||
* For more information, see the issue: https://github.com/opencv/opencv/issues/23152
|
||||
*/
|
||||
CV_WRAP void detectBoard(InputArray image, OutputArray charucoCorners, OutputArray charucoIds,
|
||||
InputOutputArrayOfArrays markerCorners = noArray(),
|
||||
InputOutputArray markerIds = noArray()) const;
|
||||
|
||||
/**
|
||||
* @brief Detect ChArUco Diamond markers
|
||||
*
|
||||
* @param image input image necessary for corner subpixel.
|
||||
* @param diamondCorners output list of detected diamond corners (4 corners per diamond). The order
|
||||
* is the same than in marker corners: top left, top right, bottom right and bottom left. Similar
|
||||
* format than the corners returned by detectMarkers (e.g std::vector<std::vector<cv::Point2f> > ).
|
||||
* @param diamondIds ids of the diamonds in diamondCorners. The id of each diamond is in fact of
|
||||
* type Vec4i, so each diamond has 4 ids, which are the ids of the aruco markers composing the
|
||||
* diamond.
|
||||
* @param markerCorners list of detected marker corners from detectMarkers function.
|
||||
* If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
|
||||
* @param markerIds list of marker ids in markerCorners.
|
||||
* If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
|
||||
*
|
||||
* This function detects Diamond markers from the previous detected ArUco markers. The diamonds
|
||||
* are returned in the diamondCorners and diamondIds parameters. If camera calibration parameters
|
||||
* are provided, the diamond search is based on reprojection. If not, diamond search is based on
|
||||
* homography. Homography is faster than reprojection, but less accurate.
|
||||
*/
|
||||
CV_WRAP void detectDiamonds(InputArray image, OutputArrayOfArrays diamondCorners, OutputArray diamondIds,
|
||||
InputOutputArrayOfArrays markerCorners = noArray(),
|
||||
InputOutputArray markerIds = noArray()) const;
|
||||
protected:
|
||||
struct CharucoDetectorImpl;
|
||||
Ptr<CharucoDetectorImpl> charucoDetectorImpl;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Draws a set of Charuco corners
|
||||
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
|
||||
* altered.
|
||||
* @param charucoCorners vector of detected charuco corners
|
||||
* @param charucoIds list of identifiers for each corner in charucoCorners
|
||||
* @param cornerColor color of the square surrounding each corner
|
||||
*
|
||||
* This function draws a set of detected Charuco corners. If identifiers vector is provided, it also
|
||||
* draws the id of each corner.
|
||||
*/
|
||||
CV_EXPORTS_W void drawDetectedCornersCharuco(InputOutputArray image, InputArray charucoCorners,
|
||||
InputArray charucoIds = noArray(), Scalar cornerColor = Scalar(255, 0, 0));
|
||||
|
||||
/**
|
||||
* @brief Draw a set of detected ChArUco Diamond markers
|
||||
*
|
||||
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
|
||||
* altered.
|
||||
* @param diamondCorners positions of diamond corners in the same format returned by
|
||||
* detectCharucoDiamond(). (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
|
||||
* the dimensions of this array should be Nx4. The order of the corners should be clockwise.
|
||||
* @param diamondIds vector of identifiers for diamonds in diamondCorners, in the same format
|
||||
* returned by detectCharucoDiamond() (e.g. std::vector<Vec4i>).
|
||||
* Optional, if not provided, ids are not painted.
|
||||
* @param borderColor color of marker borders. Rest of colors (text color and first corner color)
|
||||
* are calculated based on this one.
|
||||
*
|
||||
* Given an array of detected diamonds, this functions draws them in the image. The marker borders
|
||||
* are painted and the markers identifiers if provided.
|
||||
* Useful for debugging purposes.
|
||||
*/
|
||||
CV_EXPORTS_W void drawDetectedDiamonds(InputOutputArray image, InputArrayOfArrays diamondCorners,
|
||||
InputArray diamondIds = noArray(),
|
||||
Scalar borderColor = Scalar(0, 0, 255));
|
||||
|
||||
//! @}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,179 @@
|
||||
// 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_FACE_HPP
|
||||
#define OPENCV_OBJDETECT_FACE_HPP
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @addtogroup objdetect_dnn_face
|
||||
//! @{
|
||||
|
||||
/** @brief DNN-based face detector
|
||||
|
||||
model download link: https://github.com/opencv/opencv_zoo/tree/master/models/face_detection_yunet
|
||||
*/
|
||||
class CV_EXPORTS_W FaceDetectorYN
|
||||
{
|
||||
public:
|
||||
virtual ~FaceDetectorYN() {}
|
||||
|
||||
/** @brief Set the size for the network input, which overwrites the input size of creating model. Call this method when the size of input image does not match the input size when creating model
|
||||
*
|
||||
* @param input_size the size of the input image
|
||||
*/
|
||||
CV_WRAP virtual void setInputSize(const Size& input_size) = 0;
|
||||
|
||||
CV_WRAP virtual Size getInputSize() = 0;
|
||||
|
||||
/** @brief Set the score threshold to filter out bounding boxes of score less than the given value
|
||||
*
|
||||
* @param score_threshold threshold for filtering out bounding boxes
|
||||
*/
|
||||
CV_WRAP virtual void setScoreThreshold(float score_threshold) = 0;
|
||||
|
||||
CV_WRAP virtual float getScoreThreshold() = 0;
|
||||
|
||||
/** @brief Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given value
|
||||
*
|
||||
* @param nms_threshold threshold for NMS operation
|
||||
*/
|
||||
CV_WRAP virtual void setNMSThreshold(float nms_threshold) = 0;
|
||||
|
||||
CV_WRAP virtual float getNMSThreshold() = 0;
|
||||
|
||||
/** @brief Set the number of bounding boxes preserved before NMS
|
||||
*
|
||||
* @param top_k the number of bounding boxes to preserve from top rank based on score
|
||||
*/
|
||||
CV_WRAP virtual void setTopK(int top_k) = 0;
|
||||
|
||||
CV_WRAP virtual int getTopK() = 0;
|
||||
|
||||
/** @brief Detects faces in the input image. Following is an example output.
|
||||
|
||||
* 
|
||||
|
||||
* @param image an image to detect
|
||||
* @param faces detection results stored in a 2D cv::Mat of shape [num_faces, 15]
|
||||
* - 0-1: x, y of bbox top left corner
|
||||
* - 2-3: width, height of bbox
|
||||
* - 4-5: x, y of right eye (blue point in the example image)
|
||||
* - 6-7: x, y of left eye (red point in the example image)
|
||||
* - 8-9: x, y of nose tip (green point in the example image)
|
||||
* - 10-11: x, y of right corner of mouth (pink point in the example image)
|
||||
* - 12-13: x, y of left corner of mouth (yellow point in the example image)
|
||||
* - 14: face score
|
||||
*/
|
||||
CV_WRAP virtual int detect(InputArray image, OutputArray faces) = 0;
|
||||
|
||||
/** @brief Creates an instance of face detector class with given parameters
|
||||
*
|
||||
* @param model the path to the requested model
|
||||
* @param config the path to the config file for compatibility, which is not requested for ONNX models
|
||||
* @param input_size the size of the input image
|
||||
* @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value
|
||||
* @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value
|
||||
* @param top_k keep top K bboxes before NMS
|
||||
* @param backend_id the id of backend
|
||||
* @param target_id the id of target device
|
||||
*/
|
||||
CV_WRAP static Ptr<FaceDetectorYN> create(CV_WRAP_FILE_PATH const String& model,
|
||||
CV_WRAP_FILE_PATH const String& config,
|
||||
const Size& input_size,
|
||||
float score_threshold = 0.9f,
|
||||
float nms_threshold = 0.3f,
|
||||
int top_k = 5000,
|
||||
int backend_id = 0,
|
||||
int target_id = 0);
|
||||
|
||||
/** @overload
|
||||
*
|
||||
* @param framework Name of origin framework
|
||||
* @param bufferModel A buffer with a content of binary file with weights
|
||||
* @param bufferConfig A buffer with a content of text file contains network configuration
|
||||
* @param input_size the size of the input image
|
||||
* @param score_threshold the threshold to filter out bounding boxes of score smaller than the given value
|
||||
* @param nms_threshold the threshold to suppress bounding boxes of IoU bigger than the given value
|
||||
* @param top_k keep top K bboxes before NMS
|
||||
* @param backend_id the id of backend
|
||||
* @param target_id the id of target device
|
||||
*/
|
||||
CV_WRAP static Ptr<FaceDetectorYN> create(const String& framework,
|
||||
const std::vector<uchar>& bufferModel,
|
||||
const std::vector<uchar>& bufferConfig,
|
||||
const Size& input_size,
|
||||
float score_threshold = 0.9f,
|
||||
float nms_threshold = 0.3f,
|
||||
int top_k = 5000,
|
||||
int backend_id = 0,
|
||||
int target_id = 0);
|
||||
|
||||
};
|
||||
|
||||
/** @brief DNN-based face recognizer
|
||||
|
||||
model download link: https://github.com/opencv/opencv_zoo/tree/master/models/face_recognition_sface
|
||||
*/
|
||||
class CV_EXPORTS_W FaceRecognizerSF
|
||||
{
|
||||
public:
|
||||
virtual ~FaceRecognizerSF() {}
|
||||
|
||||
/** @brief Definition of distance used for calculating the distance between two face features
|
||||
*/
|
||||
enum DisType { FR_COSINE=0, FR_NORM_L2=1 };
|
||||
|
||||
/** @brief Aligns detected face with the source input image and crops it
|
||||
* @param src_img input image
|
||||
* @param face_box the detected face result from the input image
|
||||
* @param aligned_img output aligned image
|
||||
*/
|
||||
CV_WRAP virtual void alignCrop(InputArray src_img, InputArray face_box, OutputArray aligned_img) const = 0;
|
||||
|
||||
/** @brief Extracts face feature from aligned image
|
||||
* @param aligned_img input aligned image
|
||||
* @param face_feature output face feature
|
||||
*/
|
||||
CV_WRAP virtual void feature(InputArray aligned_img, OutputArray face_feature) = 0;
|
||||
|
||||
/** @brief Calculates the distance between two face features
|
||||
* @param face_feature1 the first input feature
|
||||
* @param face_feature2 the second input feature of the same size and the same type as face_feature1
|
||||
* @param dis_type defines how to calculate the distance between two face features with optional values "FR_COSINE" or "FR_NORM_L2"
|
||||
*/
|
||||
CV_WRAP virtual double match(InputArray face_feature1, InputArray face_feature2, int dis_type = FaceRecognizerSF::FR_COSINE) const = 0;
|
||||
|
||||
/** @brief Creates an instance of this class with given parameters
|
||||
* @param model the path of the onnx model used for face recognition
|
||||
* @param config the path to the config file for compatibility, which is not requested for ONNX models
|
||||
* @param backend_id the id of backend
|
||||
* @param target_id the id of target device
|
||||
*/
|
||||
CV_WRAP static Ptr<FaceRecognizerSF> create(CV_WRAP_FILE_PATH const String& model, CV_WRAP_FILE_PATH const String& config, int backend_id = 0, int target_id = 0);
|
||||
|
||||
/**
|
||||
* @brief Creates an instance of this class from a buffer containing the model weights and configuration.
|
||||
* @param framework Name of the framework (ONNX, etc.)
|
||||
* @param bufferModel A buffer containing the binary model weights.
|
||||
* @param bufferConfig A buffer containing the network configuration.
|
||||
* @param backend_id The id of the backend.
|
||||
* @param target_id The id of the target device.
|
||||
*
|
||||
* @return A pointer to the created instance of FaceRecognizerSF.
|
||||
*/
|
||||
CV_WRAP static Ptr<FaceRecognizerSF> create(const String& framework,
|
||||
const std::vector<uchar>& bufferModel,
|
||||
const std::vector<uchar>& bufferConfig,
|
||||
int backend_id = 0,
|
||||
int target_id = 0);
|
||||
};
|
||||
|
||||
//! @}
|
||||
} // namespace cv
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
// 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
|
||||
|
||||
- If there are QR codes encoded with a Structured Append mode on the image and all of them detected and decoded correctly,
|
||||
method writes a full message to position corresponds to 0-th code in a sequence. The rest of QR codes from the same sequence
|
||||
have empty string.
|
||||
*/
|
||||
CV_WRAP bool detectAndDecodeMulti(InputArray img, CV_OUT std::vector<std::string>& decoded_info, OutputArray points = noArray(),
|
||||
OutputArrayOfArrays straight_code = noArray()) const;
|
||||
|
||||
#ifdef OPENCV_BINDINGS_PARSER
|
||||
CV_WRAP_AS(detectAndDecodeBytes) NativeByteArray detectAndDecode(InputArray img, OutputArray points = noArray(),
|
||||
OutputArray straight_code = noArray()) const;
|
||||
CV_WRAP_AS(decodeBytes) NativeByteArray decode(InputArray img, InputArray points, OutputArray straight_code = noArray()) const;
|
||||
CV_WRAP_AS(decodeBytesMulti) bool decodeMulti(InputArray img, InputArray points, CV_OUT std::vector<NativeByteArray>& decoded_info,
|
||||
OutputArrayOfArrays straight_code = noArray()) const;
|
||||
CV_WRAP_AS(detectAndDecodeBytesMulti) bool detectAndDecodeMulti(InputArray img, CV_OUT std::vector<NativeByteArray>& decoded_info, OutputArray points = noArray(),
|
||||
OutputArrayOfArrays straight_code = noArray()) const;
|
||||
#endif
|
||||
|
||||
struct Impl;
|
||||
protected:
|
||||
Ptr<Impl> p;
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,307 @@
|
||||
// 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.
|
||||
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 Pedro Diamel Marrero Fernández
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef OPENCV_OBJDETECT_MCC_CHECKER_DETECTOR_HPP
|
||||
#define OPENCV_OBJDETECT_MCC_CHECKER_DETECTOR_HPP
|
||||
#include <opencv2/core.hpp>
|
||||
#ifdef HAVE_OPENCV_DNN
|
||||
#include <opencv2/dnn.hpp>
|
||||
#endif
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// #define MCC_DEBUG
|
||||
//---------------------------------------------------------------
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace mcc
|
||||
{
|
||||
//! @addtogroup mcc
|
||||
//! @{
|
||||
|
||||
/** ColorChart
|
||||
*
|
||||
* @brief enum to hold the type of the checker
|
||||
*/
|
||||
enum ColorChart
|
||||
{
|
||||
MCC24 = 0, ///< Standard Macbeth Chart with 24 squares
|
||||
SG140, ///< DigitalSG with 140 squares
|
||||
VINYL18, ///< DKK color chart with 12 squares and 6 rectangle
|
||||
};
|
||||
|
||||
/** CChecker
|
||||
*
|
||||
* @brief checker object
|
||||
*
|
||||
* This class contains the information about the detected checkers,i.e, their
|
||||
* type, the corners of the chart, the color profile, the cost, centers chart,
|
||||
* etc.
|
||||
*/
|
||||
class CV_EXPORTS_W CChecker: public Algorithm
|
||||
{
|
||||
public:
|
||||
CChecker() {}
|
||||
virtual ~CChecker() {}
|
||||
/** @brief Create a new CChecker object.
|
||||
*
|
||||
* @return A pointer to the implementation of the CChecker
|
||||
*/
|
||||
CV_WRAP static Ptr<CChecker> create();
|
||||
public:
|
||||
CV_WRAP virtual void setTarget(ColorChart _target) = 0;
|
||||
CV_WRAP virtual void setBox(std::vector<Point2f> _box) = 0;
|
||||
CV_WRAP virtual void setChartsRGB(Mat _chartsRGB) = 0;
|
||||
CV_WRAP virtual void setChartsYCbCr(Mat _chartsYCbCr) = 0;
|
||||
CV_WRAP virtual void setCost(float _cost) = 0;
|
||||
CV_WRAP virtual void setCenter(Point2f _center) = 0;
|
||||
|
||||
CV_WRAP virtual ColorChart getTarget() = 0;
|
||||
CV_WRAP virtual std::vector<Point2f> getBox() = 0;
|
||||
|
||||
/** @brief Computes and returns the coordinates of the central parts of the charts modules.
|
||||
*
|
||||
* This method computes transformation matrix from the checkers's coordinates (`CChecker::getBox()`)
|
||||
* and find by this the coordinates of the central parts of the charts modules.
|
||||
* It is used in `CCheckerDetector::draw()` and in `ChartsRGB` calculation.
|
||||
*/
|
||||
CV_WRAP virtual std::vector<Point2f> getColorCharts() = 0;
|
||||
|
||||
CV_WRAP virtual Mat getChartsRGB(bool getStats = true) = 0;
|
||||
CV_WRAP virtual Mat getChartsYCbCr() = 0;
|
||||
CV_WRAP virtual float getCost() = 0;
|
||||
CV_WRAP virtual Point2f getCenter() = 0;
|
||||
};
|
||||
|
||||
/** @brief struct DetectorParametersMCC is used by CCheckerDetector
|
||||
*/
|
||||
struct CV_EXPORTS_W_SIMPLE DetectorParametersMCC
|
||||
{
|
||||
CV_WRAP DetectorParametersMCC(){
|
||||
adaptiveThreshWinSizeMin=23;
|
||||
adaptiveThreshWinSizeMax=153;
|
||||
adaptiveThreshWinSizeStep=16;
|
||||
adaptiveThreshConstant=7;
|
||||
minContoursAreaRate=0.003;
|
||||
minContoursArea=100;
|
||||
confidenceThreshold=0.5;
|
||||
minContourSolidity=0.9;
|
||||
findCandidatesApproxPolyDPEpsMultiplier=0.05;
|
||||
borderWidth=0;
|
||||
B0factor=1.25f;
|
||||
maxError=0.1f;
|
||||
minContourPointsAllowed=4;
|
||||
minContourLengthAllowed=100;
|
||||
minInterContourDistance=100;
|
||||
minInterCheckerDistance=10000;
|
||||
minImageSize=1000;
|
||||
minGroupSize=4;
|
||||
}
|
||||
/// minimum window size for adaptive thresholding before finding contours (default 23).
|
||||
CV_PROP_RW int adaptiveThreshWinSizeMin;
|
||||
|
||||
/// maximum window size for adaptive thresholding before finding contours (default 153).
|
||||
CV_PROP_RW int adaptiveThreshWinSizeMax;
|
||||
|
||||
/// increments from adaptiveThreshWinSizeMin to adaptiveThreshWinSizeMax during the thresholding (default 16).
|
||||
CV_PROP_RW int adaptiveThreshWinSizeStep;
|
||||
|
||||
/// constant for adaptive thresholding before finding contours (default 7)
|
||||
CV_PROP_RW double adaptiveThreshConstant;
|
||||
|
||||
/** @brief determine minimum area for marker contour to be detected
|
||||
*
|
||||
* This is defined as a rate respect to the area of the input image. Used only if neural network is used (default 0.03).
|
||||
*/
|
||||
CV_PROP_RW double minContoursAreaRate;
|
||||
|
||||
/** @brief determine minimum area for marker contour to be detected
|
||||
*
|
||||
* This is defined as the actual area. Used only if neural network is used (default 100).
|
||||
*/
|
||||
CV_PROP_RW double minContoursArea;
|
||||
|
||||
/// minimum confidence for a bounding box detected by neural network to classify as detection.(default 0.5) (0<=confidenceThreshold<=1)
|
||||
CV_PROP_RW double confidenceThreshold;
|
||||
|
||||
/// minimum solidity of a contour for it be detected as a square in the chart. (default 0.9).
|
||||
CV_PROP_RW double minContourSolidity;
|
||||
|
||||
/// multipler to be used in ApproxPolyDP function (default 0.05)
|
||||
CV_PROP_RW double findCandidatesApproxPolyDPEpsMultiplier;
|
||||
|
||||
/// width of the padding used to pass the inital neural network detection in the succeeding system.(default 0)
|
||||
CV_PROP_RW int borderWidth;
|
||||
|
||||
/// distance between two neighboring squares of the same chart as a ratio of the large dimension of a square (default 1.25).
|
||||
CV_PROP_RW float B0factor;
|
||||
|
||||
/// maximum allowed error in the detection of a chart (default 0.1).
|
||||
CV_PROP_RW float maxError;
|
||||
|
||||
/// minimum points in a detected contour (default 4).
|
||||
CV_PROP_RW int minContourPointsAllowed;
|
||||
|
||||
/// minimum length of a contour (default 100).
|
||||
CV_PROP_RW int minContourLengthAllowed;
|
||||
|
||||
/// minimum distance between two contours (default 100).
|
||||
CV_PROP_RW int minInterContourDistance;
|
||||
|
||||
/// minimum distance between two checkers (default 10000).
|
||||
CV_PROP_RW int minInterCheckerDistance;
|
||||
|
||||
/// minimum size of the smaller dimension of the image (default 1000).
|
||||
CV_PROP_RW int minImageSize;
|
||||
|
||||
/// minimum number of squares in a chart that must be detected (default 4).
|
||||
CV_PROP_RW int minGroupSize;
|
||||
};
|
||||
|
||||
/** @brief A class to find the positions of the ColorCharts in the image.
|
||||
*/
|
||||
|
||||
class CV_EXPORTS_W CCheckerDetector : public Algorithm
|
||||
{
|
||||
public:
|
||||
/** @brief Find the ColorCharts in the given image.
|
||||
*
|
||||
* The found charts are not returned but instead stored in the
|
||||
* detector, these can be accessed later on using getBestColorChecker()
|
||||
* and getListColorChecker()
|
||||
* @param image image in color space BGR
|
||||
* @param regionsOfInterest regions of image to look for the chart, if
|
||||
* it is empty, charts are looked for in the
|
||||
* entire image
|
||||
* @param nc number of charts in the image, if you don't know the exact
|
||||
* then keeping this number high helps.
|
||||
* @return true if atleast one chart is detected otherwise false
|
||||
*/
|
||||
|
||||
CV_WRAP_AS(processWithROI) virtual bool
|
||||
process(InputArray image, const std::vector<Rect> ®ionsOfInterest,
|
||||
const int nc = 1) = 0;
|
||||
|
||||
|
||||
/** @brief Find the ColorCharts in the given image.
|
||||
*
|
||||
* Differs from the above one only in the arguments.
|
||||
*
|
||||
* This version searches for the chart in the full image.
|
||||
*
|
||||
* The found charts are not returned but instead stored in the
|
||||
* detector, these can be accessed later on using getBestColorChecker()
|
||||
* and getListColorChecker()
|
||||
* @param image image in color space BGR
|
||||
* @param nc number of charts in the image, if you don't know the exact
|
||||
* then keeping this number high helps.
|
||||
* @return true if atleast one chart is detected otherwise false
|
||||
*/
|
||||
|
||||
CV_WRAP virtual bool
|
||||
process(InputArray image, const int nc = 1) = 0;
|
||||
|
||||
/** @brief Get the best color checker. By the best it means the one
|
||||
* detected with the highest confidence.
|
||||
* @return checker A single colorchecker, if atleast one colorchecker
|
||||
* was detected, 'nullptr' otherwise.
|
||||
*/
|
||||
CV_WRAP virtual Ptr<mcc::CChecker> getBestColorChecker() = 0;
|
||||
|
||||
/** @brief Get the list of all detected colorcheckers
|
||||
* @return checkers vector of colorcheckers
|
||||
*/
|
||||
CV_WRAP virtual std::vector<Ptr<CChecker>> getListColorChecker() = 0;
|
||||
|
||||
/** @brief Returns the implementation of the CCheckerDetector.
|
||||
*
|
||||
*/
|
||||
CV_WRAP static Ptr<CCheckerDetector> create();
|
||||
|
||||
#ifdef HAVE_OPENCV_DNN
|
||||
/** @brief Set the net which will be used to find the approximate
|
||||
* bounding boxes for the color charts. And returns the implementation of the CCheckerDetector.
|
||||
*
|
||||
* It is not necessary to use this, but this usually results in
|
||||
* better detection rate.
|
||||
*
|
||||
* @param net the neural network, if the network in empty, then
|
||||
* the function will return false.
|
||||
*/
|
||||
CV_WRAP static Ptr<CCheckerDetector> create(const dnn::Net &net);
|
||||
#endif
|
||||
|
||||
/** @brief Draws the checker to the given image.
|
||||
* @param img image in color space BGR
|
||||
* @param checkers The checkers which will be drawn by this object.
|
||||
* @param color The color by with which the squares of the checker
|
||||
* will be drawn
|
||||
* @param thickness The thickness with which the sqaures will be
|
||||
* drawn
|
||||
*/
|
||||
|
||||
CV_WRAP virtual void draw(std::vector<Ptr<CChecker>>& checkers, InputOutputArray img, const Scalar color = CV_RGB(0,250,0), const int thickness = 2) = 0;
|
||||
|
||||
/** @brief Gets the reference color for chart.
|
||||
*/
|
||||
|
||||
CV_WRAP virtual Mat getRefColors() = 0;
|
||||
|
||||
/** @brief Sets the detection paramaters for mcc.
|
||||
* @param params DetectorParametersMCC structure containing detection configuration parameters.
|
||||
*/
|
||||
|
||||
CV_WRAP virtual void setDetectionParams(const DetectorParametersMCC ¶ms) = 0;
|
||||
|
||||
/** @brief Sets the color chart type for MCC detection.
|
||||
* @param chartType ColorChart enum specifying the type of color chart to detect.
|
||||
*/
|
||||
|
||||
CV_WRAP virtual void setColorChartType(ColorChart chartType) = 0;
|
||||
|
||||
#ifdef HAVE_OPENCV_DNN
|
||||
/** @brief Enables or disables the use of the neural network for detection.
|
||||
* @param useDnn Boolean flag to indicate whether to use neural network (true) or not (false).
|
||||
*/
|
||||
|
||||
CV_WRAP virtual void setUseDnnModel(bool useDnn) = 0;
|
||||
|
||||
CV_WRAP virtual bool getUseDnnModel() const = 0;
|
||||
#endif
|
||||
|
||||
CV_WRAP virtual const DetectorParametersMCC& getDetectionParams() const = 0;
|
||||
|
||||
CV_WRAP virtual ColorChart getColorChartType() const = 0;
|
||||
};
|
||||
|
||||
//! @} mcc
|
||||
} // namespace mcc
|
||||
} // namespace cv
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
#error this is a compatibility header which should not be used inside the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/objdetect.hpp"
|
||||
Reference in New Issue
Block a user