/work/install-coverage/include/opencv4/opencv2/objdetect.hpp
Line | Count | Source |
1 | | /*M/////////////////////////////////////////////////////////////////////////////////////// |
2 | | // |
3 | | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. |
4 | | // |
5 | | // By downloading, copying, installing or using the software you agree to this license. |
6 | | // If you do not agree to this license, do not download, install, |
7 | | // copy or use the software. |
8 | | // |
9 | | // |
10 | | // License Agreement |
11 | | // For Open Source Computer Vision Library |
12 | | // |
13 | | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. |
14 | | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. |
15 | | // Copyright (C) 2013, OpenCV Foundation, all rights reserved. |
16 | | // Third party copyrights are property of their respective owners. |
17 | | // |
18 | | // Redistribution and use in source and binary forms, with or without modification, |
19 | | // are permitted provided that the following conditions are met: |
20 | | // |
21 | | // * Redistribution's of source code must retain the above copyright notice, |
22 | | // this list of conditions and the following disclaimer. |
23 | | // |
24 | | // * Redistribution's in binary form must reproduce the above copyright notice, |
25 | | // this list of conditions and the following disclaimer in the documentation |
26 | | // and/or other materials provided with the distribution. |
27 | | // |
28 | | // * The name of the copyright holders may not be used to endorse or promote products |
29 | | // derived from this software without specific prior written permission. |
30 | | // |
31 | | // This software is provided by the copyright holders and contributors "as is" and |
32 | | // any express or implied warranties, including, but not limited to, the implied |
33 | | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
34 | | // In no event shall the Intel Corporation or contributors be liable for any direct, |
35 | | // indirect, incidental, special, exemplary, or consequential damages |
36 | | // (including, but not limited to, procurement of substitute goods or services; |
37 | | // loss of use, data, or profits; or business interruption) however caused |
38 | | // and on any theory of liability, whether in contract, strict liability, |
39 | | // or tort (including negligence or otherwise) arising in any way out of |
40 | | // the use of this software, even if advised of the possibility of such damage. |
41 | | // |
42 | | //M*/ |
43 | | |
44 | | #ifndef OPENCV_OBJDETECT_HPP |
45 | | #define OPENCV_OBJDETECT_HPP |
46 | | |
47 | | #include "opencv2/core.hpp" |
48 | | #include "opencv2/objdetect/aruco_detector.hpp" |
49 | | #include "opencv2/objdetect/graphical_code_detector.hpp" |
50 | | |
51 | | /** |
52 | | @defgroup objdetect Object Detection |
53 | | |
54 | | @{ |
55 | | @defgroup objdetect_cascade_classifier Cascade Classifier for Object Detection |
56 | | |
57 | | The object detector described below has been initially proposed by Paul Viola @cite Viola01 and |
58 | | improved by Rainer Lienhart @cite Lienhart02 . |
59 | | |
60 | | First, a classifier (namely a *cascade of boosted classifiers working with haar-like features*) is |
61 | | trained with a few hundred sample views of a particular object (i.e., a face or a car), called |
62 | | positive examples, that are scaled to the same size (say, 20x20), and negative examples - arbitrary |
63 | | images of the same size. |
64 | | |
65 | | After a classifier is trained, it can be applied to a region of interest (of the same size as used |
66 | | during the training) in an input image. The classifier outputs a "1" if the region is likely to show |
67 | | the object (i.e., face/car), and "0" otherwise. To search for the object in the whole image one can |
68 | | move the search window across the image and check every location using the classifier. The |
69 | | classifier is designed so that it can be easily "resized" in order to be able to find the objects of |
70 | | interest at different sizes, which is more efficient than resizing the image itself. So, to find an |
71 | | object of an unknown size in the image the scan procedure should be done several times at different |
72 | | scales. |
73 | | |
74 | | The word "cascade" in the classifier name means that the resultant classifier consists of several |
75 | | simpler classifiers (*stages*) that are applied subsequently to a region of interest until at some |
76 | | stage the candidate is rejected or all the stages are passed. The word "boosted" means that the |
77 | | classifiers at every stage of the cascade are complex themselves and they are built out of basic |
78 | | classifiers using one of four different boosting techniques (weighted voting). Currently Discrete |
79 | | Adaboost, Real Adaboost, Gentle Adaboost and Logitboost are supported. The basic classifiers are |
80 | | decision-tree classifiers with at least 2 leaves. Haar-like features are the input to the basic |
81 | | classifiers, and are calculated as described below. The current algorithm uses the following |
82 | | Haar-like features: |
83 | | |
84 | |  |
85 | | |
86 | | The feature used in a particular classifier is specified by its shape (1a, 2b etc.), position within |
87 | | the region of interest and the scale (this scale is not the same as the scale used at the detection |
88 | | stage, though these two scales are multiplied). For example, in the case of the third line feature |
89 | | (2c) the response is calculated as the difference between the sum of image pixels under the |
90 | | rectangle covering the whole feature (including the two white stripes and the black stripe in the |
91 | | middle) and the sum of the image pixels under the black stripe multiplied by 3 in order to |
92 | | compensate for the differences in the size of areas. The sums of pixel values over a rectangular |
93 | | regions are calculated rapidly using integral images (see below and the integral description). |
94 | | |
95 | | Check @ref tutorial_cascade_classifier "the corresponding tutorial" for more details. |
96 | | |
97 | | The following reference is for the detection part only. There is a separate application called |
98 | | opencv_traincascade that can train a cascade of boosted classifiers from a set of samples. |
99 | | |
100 | | @note In the new C++ interface it is also possible to use LBP (local binary pattern) features in |
101 | | addition to Haar-like features. .. [Viola01] Paul Viola and Michael J. Jones. Rapid Object Detection |
102 | | using a Boosted Cascade of Simple Features. IEEE CVPR, 2001. The paper is available online at |
103 | | <https://github.com/SvHey/thesis/blob/master/Literature/ObjectDetection/violaJones_CVPR2001.pdf> |
104 | | |
105 | | @defgroup objdetect_hog HOG (Histogram of Oriented Gradients) descriptor and object detector |
106 | | @defgroup objdetect_barcode Barcode detection and decoding |
107 | | @defgroup objdetect_qrcode QRCode detection and encoding |
108 | | @defgroup objdetect_dnn_face DNN-based face detection and recognition |
109 | | |
110 | | Check @ref tutorial_dnn_face "the corresponding tutorial" for more details. |
111 | | |
112 | | @defgroup objdetect_common Common functions and classes |
113 | | @defgroup objdetect_aruco ArUco markers and boards detection for robust camera pose estimation |
114 | | @{ |
115 | | ArUco Marker Detection |
116 | | Square fiducial markers (also known as Augmented Reality Markers) are useful for easy, |
117 | | fast and robust camera pose estimation. |
118 | | |
119 | | The main functionality of ArucoDetector class is detection of markers in an image. If the markers are grouped |
120 | | as a board, then you can try to recover the missing markers with ArucoDetector::refineDetectedMarkers(). |
121 | | ArUco markers can also be used for advanced chessboard corner finding. To do this, group the markers in the |
122 | | CharucoBoard and find the corners of the chessboard with the CharucoDetector::detectBoard(). |
123 | | |
124 | | The implementation is based on the ArUco Library by R. Muñoz-Salinas and S. Garrido-Jurado @cite Aruco2014. |
125 | | |
126 | | Markers can also be detected based on the AprilTag 2 @cite wang2016iros fiducial detection method. |
127 | | |
128 | | @sa @cite Aruco2014 |
129 | | This code has been originally developed by Sergio Garrido-Jurado as a project |
130 | | for Google Summer of Code 2015 (GSoC 15). |
131 | | |
132 | | <br> |
133 | | |
134 | | @warning In OpenCV, the order of the returned corners locations for the AprilTag family is not aligned with the ArUco one.\n |
135 | | Note that this order is also different from the convention adopted by the official [AprilTag library](https://github.com/AprilRobotics/apriltag/). |
136 | |  { width=80% } |
137 | | |
138 | | <br> |
139 | | |
140 | | An overview of the supported ArUco markers family is visible in the following image: |
141 | |  { width=80% } |
142 | | |
143 | | <br> |
144 | | |
145 | | An overview of the supported AprilTag markers family is visible in the following image: |
146 | |  { width=80% } |
147 | | |
148 | | @note The generated images (in the above picture) using @ref aruco::generateImageMarker for the AprilTag markers have been |
149 | | rotated by 180 degree in order to match the official AprilTag images. |
150 | | When using the @ref aruco::generateImageMarker function, it will output by default a different image from the official AprilTag convention, |
151 | | see the [AprilRobotics/apriltag-imgs](https://github.com/AprilRobotics/apriltag-imgs) repository. |
152 | | This is the reason why you see a different corners order between ArUco and AprilTag in the above image. |
153 | | |
154 | | <br> |
155 | | |
156 | | For the ArUco marker family, the recommended family is the DICT_ARUCO_MIP_36h12 one, [see](https://stackoverflow.com/a/51511558). |
157 | | In general, a smaller marker family (e.g. `4x4` vs `6x6`) should give you a better detection rate with respect to the camera distance, |
158 | | at the expense of having more probability to have issues with false detection or marker id decoding error. |
159 | | 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 |
160 | | to correct wrong bits during the marker id decoding process. |
161 | | |
162 | | You can download some pregenerated MIP_36h12 ArUco marker images from: |
163 | | - https://sourceforge.net/projects/aruco/files/ |
164 | | - or use the `samples/cpp/tutorial_code/objectDetection/create_marker.cpp` sample to generate the marker image for your |
165 | | desired marker family (which uses the @ref aruco::generateImageMarker function) |
166 | | |
167 | | For the AprilTag family, you can find some pregenerated marker images in the |
168 | | [AprilRobotics/apriltag-imgs](https://github.com/AprilRobotics/apriltag-imgs) repository. |
169 | | |
170 | | @note For accurate corners location extraction, a white border (to have a strong gradient between white and black transition) around the marker is important. |
171 | | This is necessary to precisely extract the marker contour in difficult conditions such as bad illumination, confusing color background, etc. |
172 | | |
173 | | <br> |
174 | | |
175 | | 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). |
176 | | Please refer to the: |
177 | | - @ref aruco::DetectorParameters |
178 | | - "Detector Parameters" section in the @ref tutorial_aruco_detection tutorial or in the @ref tutorial_aruco_faq page |
179 | | - [ArUco Library Documentation](https://drive.google.com/file/d/1OiavRVYVJ-WH88sQg1LUsh8CuJZUQyrX) for additional information from the ArUco library |
180 | | |
181 | | The corner refinement method can be changed according to the @ref aruco::CornerRefineMethod to improve the corners location accuracy |
182 | | at the expense of more computation time. |
183 | | |
184 | | <br> |
185 | | |
186 | | To estimate the marker pose with respect to the camera frame, we recommend you to look at the following sources of information: |
187 | | - @ref tutorial_aruco_detection for a tutorial about ArUco markers detection |
188 | | - @ref calib3d for some theoretical background about the pinhole camera model and the @ref calib3d_solvePnP page |
189 | | - @ref solvePnP, @ref solvePnPGeneric, @ref solveP3P for the relevant pose estimation methods |
190 | | @} |
191 | | |
192 | | @} |
193 | | */ |
194 | | |
195 | | typedef struct CvHaarClassifierCascade CvHaarClassifierCascade; |
196 | | |
197 | | namespace cv |
198 | | { |
199 | | |
200 | | //! @addtogroup objdetect_common |
201 | | //! @{ |
202 | | |
203 | | ///////////////////////////// Object Detection //////////////////////////// |
204 | | |
205 | | /** @brief This class is used for grouping object candidates detected by Cascade Classifier, HOG etc. |
206 | | |
207 | | instance of the class is to be passed to cv::partition |
208 | | */ |
209 | | class CV_EXPORTS SimilarRects |
210 | | { |
211 | | public: |
212 | 0 | SimilarRects(double _eps) : eps(_eps) {} |
213 | | inline bool operator()(const Rect& r1, const Rect& r2) const |
214 | 0 | { |
215 | 0 | double delta = eps * ((std::min)(r1.width, r2.width) + (std::min)(r1.height, r2.height)) * 0.5; |
216 | 0 | return std::abs(r1.x - r2.x) <= delta && |
217 | 0 | std::abs(r1.y - r2.y) <= delta && |
218 | 0 | std::abs(r1.x + r1.width - r2.x - r2.width) <= delta && |
219 | 0 | std::abs(r1.y + r1.height - r2.y - r2.height) <= delta; |
220 | 0 | } |
221 | | double eps; |
222 | | }; |
223 | | |
224 | | /** @brief Groups the object candidate rectangles. |
225 | | |
226 | | @param rectList Input/output vector of rectangles. Output vector includes retained and grouped |
227 | | rectangles. (The Python list is not modified in place.) |
228 | | @param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a |
229 | | group of rectangles to retain it. |
230 | | @param eps Relative difference between sides of the rectangles to merge them into a group. |
231 | | |
232 | | The function is a wrapper for the generic function partition . It clusters all the input rectangles |
233 | | using the rectangle equivalence criteria that combines rectangles with similar sizes and similar |
234 | | locations. The similarity is defined by eps. When eps=0 , no clustering is done at all. If |
235 | | \f$\texttt{eps}\rightarrow +\inf\f$ , all the rectangles are put in one cluster. Then, the small |
236 | | clusters containing less than or equal to groupThreshold rectangles are rejected. In each other |
237 | | cluster, the average rectangle is computed and put into the output rectangle list. |
238 | | */ |
239 | | CV_EXPORTS void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, double eps = 0.2); |
240 | | /** @overload */ |
241 | | CV_EXPORTS_W void groupRectangles(CV_IN_OUT std::vector<Rect>& rectList, CV_OUT std::vector<int>& weights, |
242 | | int groupThreshold, double eps = 0.2); |
243 | | /** @overload */ |
244 | | CV_EXPORTS void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, |
245 | | double eps, std::vector<int>* weights, std::vector<double>* levelWeights ); |
246 | | /** @overload */ |
247 | | CV_EXPORTS void groupRectangles(std::vector<Rect>& rectList, std::vector<int>& rejectLevels, |
248 | | std::vector<double>& levelWeights, int groupThreshold, double eps = 0.2); |
249 | | /** @overload */ |
250 | | CV_EXPORTS void groupRectangles_meanshift(std::vector<Rect>& rectList, std::vector<double>& foundWeights, |
251 | | std::vector<double>& foundScales, |
252 | | double detectThreshold = 0.0, Size winDetSize = Size(64, 128)); |
253 | | //! @} |
254 | | |
255 | | //! @addtogroup objdetect_cascade_classifier |
256 | | //! @{ |
257 | | |
258 | | template<> struct DefaultDeleter<CvHaarClassifierCascade>{ CV_EXPORTS void operator ()(CvHaarClassifierCascade* obj) const; }; |
259 | | |
260 | | enum { CASCADE_DO_CANNY_PRUNING = 1, |
261 | | CASCADE_SCALE_IMAGE = 2, |
262 | | CASCADE_FIND_BIGGEST_OBJECT = 4, |
263 | | CASCADE_DO_ROUGH_SEARCH = 8 |
264 | | }; |
265 | | |
266 | | class CV_EXPORTS_W BaseCascadeClassifier : public Algorithm |
267 | | { |
268 | | public: |
269 | | virtual ~BaseCascadeClassifier(); |
270 | | virtual bool empty() const CV_OVERRIDE = 0; |
271 | | virtual bool load( const String& filename ) = 0; |
272 | | virtual void detectMultiScale( InputArray image, |
273 | | CV_OUT std::vector<Rect>& objects, |
274 | | double scaleFactor, |
275 | | int minNeighbors, int flags, |
276 | | Size minSize, Size maxSize ) = 0; |
277 | | |
278 | | virtual void detectMultiScale( InputArray image, |
279 | | CV_OUT std::vector<Rect>& objects, |
280 | | CV_OUT std::vector<int>& numDetections, |
281 | | double scaleFactor, |
282 | | int minNeighbors, int flags, |
283 | | Size minSize, Size maxSize ) = 0; |
284 | | |
285 | | virtual void detectMultiScale( InputArray image, |
286 | | CV_OUT std::vector<Rect>& objects, |
287 | | CV_OUT std::vector<int>& rejectLevels, |
288 | | CV_OUT std::vector<double>& levelWeights, |
289 | | double scaleFactor, |
290 | | int minNeighbors, int flags, |
291 | | Size minSize, Size maxSize, |
292 | | bool outputRejectLevels ) = 0; |
293 | | |
294 | | virtual bool isOldFormatCascade() const = 0; |
295 | | virtual Size getOriginalWindowSize() const = 0; |
296 | | virtual int getFeatureType() const = 0; |
297 | | virtual void* getOldCascade() = 0; |
298 | | |
299 | | class CV_EXPORTS MaskGenerator |
300 | | { |
301 | | public: |
302 | 0 | virtual ~MaskGenerator() {} |
303 | | virtual Mat generateMask(const Mat& src)=0; |
304 | 0 | virtual void initializeMask(const Mat& /*src*/) { } |
305 | | }; |
306 | | virtual void setMaskGenerator(const Ptr<MaskGenerator>& maskGenerator) = 0; |
307 | | virtual Ptr<MaskGenerator> getMaskGenerator() = 0; |
308 | | }; |
309 | | |
310 | | /** @example samples/cpp/facedetect.cpp |
311 | | This program demonstrates usage of the Cascade classifier class |
312 | | \image html Cascade_Classifier_Tutorial_Result_Haar.jpg "Sample screenshot" width=321 height=254 |
313 | | */ |
314 | | /** @brief Cascade classifier class for object detection. |
315 | | */ |
316 | | class CV_EXPORTS_W CascadeClassifier |
317 | | { |
318 | | public: |
319 | | CV_WRAP CascadeClassifier(); |
320 | | /** @brief Loads a classifier from a file. |
321 | | |
322 | | @param filename Name of the file from which the classifier is loaded. |
323 | | */ |
324 | | CV_WRAP CascadeClassifier(const String& filename); |
325 | | ~CascadeClassifier(); |
326 | | /** @brief Checks whether the classifier has been loaded. |
327 | | */ |
328 | | CV_WRAP bool empty() const; |
329 | | /** @brief Loads a classifier from a file. |
330 | | |
331 | | @param filename Name of the file from which the classifier is loaded. The file may contain an old |
332 | | HAAR classifier trained by the haartraining application or a new cascade classifier trained by the |
333 | | traincascade application. |
334 | | */ |
335 | | CV_WRAP bool load( const String& filename ); |
336 | | /** @brief Reads a classifier from a FileStorage node. |
337 | | |
338 | | @note The file may contain a new cascade classifier (trained by the traincascade application) only. |
339 | | */ |
340 | | CV_WRAP bool read( const FileNode& node ); |
341 | | |
342 | | /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list |
343 | | of rectangles. |
344 | | |
345 | | @param image Matrix of the type CV_8U containing an image where objects are detected. |
346 | | @param objects Vector of rectangles where each rectangle contains the detected object, the |
347 | | rectangles may be partially outside the original image. |
348 | | @param scaleFactor Parameter specifying how much the image size is reduced at each image scale. |
349 | | @param minNeighbors Parameter specifying how many neighbors each candidate rectangle should have |
350 | | to retain it. |
351 | | @param flags Parameter with the same meaning for an old cascade as in the function |
352 | | cvHaarDetectObjects. It is not used for a new cascade. |
353 | | @param minSize Minimum possible object size. Objects smaller than that are ignored. |
354 | | @param maxSize Maximum possible object size. Objects larger than that are ignored. If `maxSize == minSize` model is evaluated on single scale. |
355 | | */ |
356 | | CV_WRAP void detectMultiScale( InputArray image, |
357 | | CV_OUT std::vector<Rect>& objects, |
358 | | double scaleFactor = 1.1, |
359 | | int minNeighbors = 3, int flags = 0, |
360 | | Size minSize = Size(), |
361 | | Size maxSize = Size() ); |
362 | | |
363 | | /** @overload |
364 | | @param image Matrix of the type CV_8U containing an image where objects are detected. |
365 | | @param objects Vector of rectangles where each rectangle contains the detected object, the |
366 | | rectangles may be partially outside the original image. |
367 | | @param numDetections Vector of detection numbers for the corresponding objects. An object's number |
368 | | of detections is the number of neighboring positively classified rectangles that were joined |
369 | | together to form the object. |
370 | | @param scaleFactor Parameter specifying how much the image size is reduced at each image scale. |
371 | | @param minNeighbors Parameter specifying how many neighbors each candidate rectangle should have |
372 | | to retain it. |
373 | | @param flags Parameter with the same meaning for an old cascade as in the function |
374 | | cvHaarDetectObjects. It is not used for a new cascade. |
375 | | @param minSize Minimum possible object size. Objects smaller than that are ignored. |
376 | | @param maxSize Maximum possible object size. Objects larger than that are ignored. If `maxSize == minSize` model is evaluated on single scale. |
377 | | */ |
378 | | CV_WRAP_AS(detectMultiScale2) void detectMultiScale( InputArray image, |
379 | | CV_OUT std::vector<Rect>& objects, |
380 | | CV_OUT std::vector<int>& numDetections, |
381 | | double scaleFactor=1.1, |
382 | | int minNeighbors=3, int flags=0, |
383 | | Size minSize=Size(), |
384 | | Size maxSize=Size() ); |
385 | | |
386 | | /** @overload |
387 | | This function allows you to retrieve the final stage decision certainty of classification. |
388 | | For this, one needs to set `outputRejectLevels` on true and provide the `rejectLevels` and `levelWeights` parameter. |
389 | | For each resulting detection, `levelWeights` will then contain the certainty of classification at the final stage. |
390 | | This value can then be used to separate strong from weaker classifications. |
391 | | |
392 | | A code sample on how to use it efficiently can be found below: |
393 | | @code |
394 | | Mat img; |
395 | | vector<double> weights; |
396 | | vector<int> levels; |
397 | | vector<Rect> detections; |
398 | | CascadeClassifier model("/path/to/your/model.xml"); |
399 | | model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true); |
400 | | cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl; |
401 | | @endcode |
402 | | */ |
403 | | CV_WRAP_AS(detectMultiScale3) void detectMultiScale( InputArray image, |
404 | | CV_OUT std::vector<Rect>& objects, |
405 | | CV_OUT std::vector<int>& rejectLevels, |
406 | | CV_OUT std::vector<double>& levelWeights, |
407 | | double scaleFactor = 1.1, |
408 | | int minNeighbors = 3, int flags = 0, |
409 | | Size minSize = Size(), |
410 | | Size maxSize = Size(), |
411 | | bool outputRejectLevels = false ); |
412 | | |
413 | | CV_WRAP bool isOldFormatCascade() const; |
414 | | CV_WRAP Size getOriginalWindowSize() const; |
415 | | CV_WRAP int getFeatureType() const; |
416 | | void* getOldCascade(); |
417 | | |
418 | | CV_WRAP static bool convert(const String& oldcascade, const String& newcascade); |
419 | | |
420 | | void setMaskGenerator(const Ptr<BaseCascadeClassifier::MaskGenerator>& maskGenerator); |
421 | | Ptr<BaseCascadeClassifier::MaskGenerator> getMaskGenerator(); |
422 | | |
423 | | Ptr<BaseCascadeClassifier> cc; |
424 | | }; |
425 | | |
426 | | CV_EXPORTS Ptr<BaseCascadeClassifier::MaskGenerator> createFaceDetectionMaskGenerator(); |
427 | | //! @} |
428 | | |
429 | | //! @addtogroup objdetect_hog |
430 | | //! @{ |
431 | | //////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector ////////////// |
432 | | |
433 | | //! struct for detection region of interest (ROI) |
434 | | struct DetectionROI |
435 | | { |
436 | | //! scale(size) of the bounding box |
437 | | double scale; |
438 | | //! set of requested locations to be evaluated |
439 | | std::vector<cv::Point> locations; |
440 | | //! vector that will contain confidence values for each location |
441 | | std::vector<double> confidences; |
442 | | }; |
443 | | |
444 | | /**@brief Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector. |
445 | | |
446 | | the HOG descriptor algorithm introduced by Navneet Dalal and Bill Triggs @cite Dalal2005 . |
447 | | |
448 | | useful links: |
449 | | |
450 | | https://hal.inria.fr/inria-00548512/document/ |
451 | | |
452 | | https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients |
453 | | |
454 | | https://software.intel.com/en-us/ipp-dev-reference-histogram-of-oriented-gradients-hog-descriptor |
455 | | |
456 | | http://www.learnopencv.com/histogram-of-oriented-gradients |
457 | | |
458 | | http://www.learnopencv.com/handwritten-digits-classification-an-opencv-c-python-tutorial |
459 | | |
460 | | */ |
461 | | struct CV_EXPORTS_W HOGDescriptor |
462 | | { |
463 | | public: |
464 | | enum HistogramNormType { L2Hys = 0 //!< Default histogramNormType |
465 | | }; |
466 | | enum { DEFAULT_NLEVELS = 64 //!< Default nlevels value. |
467 | | }; |
468 | | enum DescriptorStorageFormat { DESCR_FORMAT_COL_BY_COL, DESCR_FORMAT_ROW_BY_ROW }; |
469 | | |
470 | | /**@brief Creates the HOG descriptor and detector with default parameters. |
471 | | |
472 | | aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 ) |
473 | | */ |
474 | | CV_WRAP HOGDescriptor() : winSize(64,128), blockSize(16,16), blockStride(8,8), |
475 | | cellSize(8,8), nbins(9), derivAperture(1), winSigma(-1), |
476 | | histogramNormType(HOGDescriptor::L2Hys), L2HysThreshold(0.2), gammaCorrection(true), |
477 | | free_coef(-1.f), nlevels(HOGDescriptor::DEFAULT_NLEVELS), signedGradient(false) |
478 | 0 | {} |
479 | | |
480 | | /** @overload |
481 | | @param _winSize sets winSize with given value. |
482 | | @param _blockSize sets blockSize with given value. |
483 | | @param _blockStride sets blockStride with given value. |
484 | | @param _cellSize sets cellSize with given value. |
485 | | @param _nbins sets nbins with given value. |
486 | | @param _derivAperture sets derivAperture with given value. |
487 | | @param _winSigma sets winSigma with given value. |
488 | | @param _histogramNormType sets histogramNormType with given value. |
489 | | @param _L2HysThreshold sets L2HysThreshold with given value. |
490 | | @param _gammaCorrection sets gammaCorrection with given value. |
491 | | @param _nlevels sets nlevels with given value. |
492 | | @param _signedGradient sets signedGradient with given value. |
493 | | */ |
494 | | CV_WRAP HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, |
495 | | Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1, |
496 | | HOGDescriptor::HistogramNormType _histogramNormType=HOGDescriptor::L2Hys, |
497 | | double _L2HysThreshold=0.2, bool _gammaCorrection=false, |
498 | | int _nlevels=HOGDescriptor::DEFAULT_NLEVELS, bool _signedGradient=false) |
499 | | : winSize(_winSize), blockSize(_blockSize), blockStride(_blockStride), cellSize(_cellSize), |
500 | | nbins(_nbins), derivAperture(_derivAperture), winSigma(_winSigma), |
501 | | histogramNormType(_histogramNormType), L2HysThreshold(_L2HysThreshold), |
502 | | gammaCorrection(_gammaCorrection), free_coef(-1.f), nlevels(_nlevels), signedGradient(_signedGradient) |
503 | 0 | {} |
504 | | |
505 | | /** @overload |
506 | | |
507 | | Creates the HOG descriptor and detector and loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file. |
508 | | @param filename The file name containing HOGDescriptor properties and coefficients for the linear SVM classifier. |
509 | | */ |
510 | | CV_WRAP HOGDescriptor(const String& filename) |
511 | 0 | { |
512 | 0 | load(filename); |
513 | 0 | } |
514 | | |
515 | | /** @overload |
516 | | @param d the HOGDescriptor which cloned to create a new one. |
517 | | */ |
518 | | HOGDescriptor(const HOGDescriptor& d) |
519 | 0 | { |
520 | 0 | d.copyTo(*this); |
521 | 0 | } |
522 | | |
523 | | /**@brief Default destructor. |
524 | | */ |
525 | 0 | virtual ~HOGDescriptor() {} |
526 | | |
527 | | /**@brief Returns the number of coefficients required for the classification. |
528 | | */ |
529 | | CV_WRAP size_t getDescriptorSize() const; |
530 | | |
531 | | /** @brief Checks if detector size equal to descriptor size. |
532 | | */ |
533 | | CV_WRAP bool checkDetectorSize() const; |
534 | | |
535 | | /** @brief Returns winSigma value |
536 | | */ |
537 | | CV_WRAP double getWinSigma() const; |
538 | | |
539 | | /**@example samples/cpp/peopledetect.cpp |
540 | | */ |
541 | | /**@brief Sets coefficients for the linear SVM classifier. |
542 | | @param svmdetector coefficients for the linear SVM classifier. |
543 | | */ |
544 | | CV_WRAP virtual void setSVMDetector(InputArray svmdetector); |
545 | | |
546 | | /** @brief Reads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file node. |
547 | | @param fn File node |
548 | | */ |
549 | | virtual bool read(FileNode& fn); |
550 | | |
551 | | /** @brief Stores HOGDescriptor parameters and coefficients for the linear SVM classifier in a file storage. |
552 | | @param fs File storage |
553 | | @param objname Object name |
554 | | */ |
555 | | virtual void write(FileStorage& fs, const String& objname) const; |
556 | | |
557 | | /** @brief loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file |
558 | | @param filename Name of the file to read. |
559 | | @param objname The optional name of the node to read (if empty, the first top-level node will be used). |
560 | | */ |
561 | | CV_WRAP virtual bool load(const String& filename, const String& objname = String()); |
562 | | |
563 | | /** @brief saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file |
564 | | @param filename File name |
565 | | @param objname Object name |
566 | | */ |
567 | | CV_WRAP virtual void save(const String& filename, const String& objname = String()) const; |
568 | | |
569 | | /** @brief clones the HOGDescriptor |
570 | | @param c cloned HOGDescriptor |
571 | | */ |
572 | | virtual void copyTo(HOGDescriptor& c) const; |
573 | | |
574 | | /**@example samples/cpp/train_HOG.cpp |
575 | | */ |
576 | | /** @brief Computes HOG descriptors of given image. |
577 | | @param img Matrix of the type CV_8U containing an image where HOG features will be calculated. |
578 | | @param descriptors Matrix of the type CV_32F |
579 | | @param winStride Window stride. It must be a multiple of block stride. |
580 | | @param padding Padding |
581 | | @param locations Vector of Point |
582 | | */ |
583 | | CV_WRAP virtual void compute(InputArray img, |
584 | | CV_OUT std::vector<float>& descriptors, |
585 | | Size winStride = Size(), Size padding = Size(), |
586 | | const std::vector<Point>& locations = std::vector<Point>()) const; |
587 | | |
588 | | /** @brief Performs object detection without a multi-scale window. |
589 | | @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. |
590 | | @param foundLocations Vector of point where each point contains left-top corner point of detected object boundaries. |
591 | | @param weights Vector that will contain confidence values for each detected object. |
592 | | @param hitThreshold Threshold for the distance between features and SVM classifying plane. |
593 | | Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). |
594 | | But if the free coefficient is omitted (which is allowed), you can specify it manually here. |
595 | | @param winStride Window stride. It must be a multiple of block stride. |
596 | | @param padding Padding |
597 | | @param searchLocations Vector of Point includes set of requested locations to be evaluated. |
598 | | */ |
599 | | CV_WRAP virtual void detect(InputArray img, CV_OUT std::vector<Point>& foundLocations, |
600 | | CV_OUT std::vector<double>& weights, |
601 | | double hitThreshold = 0, Size winStride = Size(), |
602 | | Size padding = Size(), |
603 | | const std::vector<Point>& searchLocations = std::vector<Point>()) const; |
604 | | |
605 | | /** @brief Performs object detection without a multi-scale window. |
606 | | @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. |
607 | | @param foundLocations Vector of point where each point contains left-top corner point of detected object boundaries. |
608 | | @param hitThreshold Threshold for the distance between features and SVM classifying plane. |
609 | | Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). |
610 | | But if the free coefficient is omitted (which is allowed), you can specify it manually here. |
611 | | @param winStride Window stride. It must be a multiple of block stride. |
612 | | @param padding Padding |
613 | | @param searchLocations Vector of Point includes locations to search. |
614 | | */ |
615 | | virtual void detect(InputArray img, CV_OUT std::vector<Point>& foundLocations, |
616 | | double hitThreshold = 0, Size winStride = Size(), |
617 | | Size padding = Size(), |
618 | | const std::vector<Point>& searchLocations=std::vector<Point>()) const; |
619 | | |
620 | | /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list |
621 | | of rectangles. |
622 | | @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. |
623 | | @param foundLocations Vector of rectangles where each rectangle contains the detected object. |
624 | | @param foundWeights Vector that will contain confidence values for each detected object. |
625 | | @param hitThreshold Threshold for the distance between features and SVM classifying plane. |
626 | | Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). |
627 | | But if the free coefficient is omitted (which is allowed), you can specify it manually here. |
628 | | @param winStride Window stride. It must be a multiple of block stride. |
629 | | @param padding Padding |
630 | | @param scale Coefficient of the detection window increase. |
631 | | @param groupThreshold Coefficient to regulate the similarity threshold. When detected, some objects can be covered |
632 | | by many rectangles. 0 means not to perform grouping. |
633 | | @param useMeanshiftGrouping indicates grouping algorithm |
634 | | */ |
635 | | CV_WRAP virtual void detectMultiScale(InputArray img, CV_OUT std::vector<Rect>& foundLocations, |
636 | | CV_OUT std::vector<double>& foundWeights, double hitThreshold = 0, |
637 | | Size winStride = Size(), Size padding = Size(), double scale = 1.05, |
638 | | double groupThreshold = 2.0, bool useMeanshiftGrouping = false) const; |
639 | | |
640 | | /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list |
641 | | of rectangles. |
642 | | @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. |
643 | | @param foundLocations Vector of rectangles where each rectangle contains the detected object. |
644 | | @param hitThreshold Threshold for the distance between features and SVM classifying plane. |
645 | | Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). |
646 | | But if the free coefficient is omitted (which is allowed), you can specify it manually here. |
647 | | @param winStride Window stride. It must be a multiple of block stride. |
648 | | @param padding Padding |
649 | | @param scale Coefficient of the detection window increase. |
650 | | @param groupThreshold Coefficient to regulate the similarity threshold. When detected, some objects can be covered |
651 | | by many rectangles. 0 means not to perform grouping. |
652 | | @param useMeanshiftGrouping indicates grouping algorithm |
653 | | */ |
654 | | virtual void detectMultiScale(InputArray img, CV_OUT std::vector<Rect>& foundLocations, |
655 | | double hitThreshold = 0, Size winStride = Size(), |
656 | | Size padding = Size(), double scale = 1.05, |
657 | | double groupThreshold = 2.0, bool useMeanshiftGrouping = false) const; |
658 | | |
659 | | /** @brief Computes gradients and quantized gradient orientations. |
660 | | @param img Matrix contains the image to be computed |
661 | | @param grad Matrix of type CV_32FC2 contains computed gradients |
662 | | @param angleOfs Matrix of type CV_8UC2 contains quantized gradient orientations |
663 | | @param paddingTL Padding from top-left |
664 | | @param paddingBR Padding from bottom-right |
665 | | */ |
666 | | CV_WRAP virtual void computeGradient(InputArray img, InputOutputArray grad, InputOutputArray angleOfs, |
667 | | Size paddingTL = Size(), Size paddingBR = Size()) const; |
668 | | |
669 | | /** @brief Returns coefficients of the classifier trained for people detection (for 64x128 windows). |
670 | | */ |
671 | | CV_WRAP static std::vector<float> getDefaultPeopleDetector(); |
672 | | |
673 | | /**@example samples/tapi/hog.cpp |
674 | | */ |
675 | | /** @brief Returns coefficients of the classifier trained for people detection (for 48x96 windows). |
676 | | */ |
677 | | CV_WRAP static std::vector<float> getDaimlerPeopleDetector(); |
678 | | |
679 | | //! Detection window size. Align to block size and block stride. Default value is Size(64,128). |
680 | | CV_PROP Size winSize; |
681 | | |
682 | | //! Block size in pixels. Align to cell size. Default value is Size(16,16). |
683 | | CV_PROP Size blockSize; |
684 | | |
685 | | //! Block stride. It must be a multiple of cell size. Default value is Size(8,8). |
686 | | CV_PROP Size blockStride; |
687 | | |
688 | | //! Cell size. Default value is Size(8,8). |
689 | | CV_PROP Size cellSize; |
690 | | |
691 | | //! Number of bins used in the calculation of histogram of gradients. Default value is 9. |
692 | | CV_PROP int nbins; |
693 | | |
694 | | //! not documented |
695 | | CV_PROP int derivAperture; |
696 | | |
697 | | //! Gaussian smoothing window parameter. |
698 | | CV_PROP double winSigma; |
699 | | |
700 | | //! histogramNormType |
701 | | CV_PROP HOGDescriptor::HistogramNormType histogramNormType; |
702 | | |
703 | | //! L2-Hys normalization method shrinkage. |
704 | | CV_PROP double L2HysThreshold; |
705 | | |
706 | | //! Flag to specify whether the gamma correction preprocessing is required or not. |
707 | | CV_PROP bool gammaCorrection; |
708 | | |
709 | | //! coefficients for the linear SVM classifier. |
710 | | CV_PROP std::vector<float> svmDetector; |
711 | | |
712 | | //! coefficients for the linear SVM classifier used when OpenCL is enabled |
713 | | UMat oclSvmDetector; |
714 | | |
715 | | //! not documented |
716 | | float free_coef; |
717 | | |
718 | | //! Maximum number of detection window increases. Default value is 64 |
719 | | CV_PROP int nlevels; |
720 | | |
721 | | //! Indicates signed gradient will be used or not |
722 | | CV_PROP bool signedGradient; |
723 | | |
724 | | /** @brief evaluate specified ROI and return confidence value for each location |
725 | | @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. |
726 | | @param locations Vector of Point |
727 | | @param foundLocations Vector of Point where each Point is detected object's top-left point. |
728 | | @param confidences confidences |
729 | | @param hitThreshold Threshold for the distance between features and SVM classifying plane. Usually |
730 | | it is 0 and should be specified in the detector coefficients (as the last free coefficient). But if |
731 | | the free coefficient is omitted (which is allowed), you can specify it manually here |
732 | | @param winStride winStride |
733 | | @param padding padding |
734 | | */ |
735 | | virtual void detectROI(InputArray img, const std::vector<cv::Point> &locations, |
736 | | CV_OUT std::vector<cv::Point>& foundLocations, CV_OUT std::vector<double>& confidences, |
737 | | double hitThreshold = 0, cv::Size winStride = Size(), |
738 | | cv::Size padding = Size()) const; |
739 | | |
740 | | /** @brief evaluate specified ROI and return confidence value for each location in multiple scales |
741 | | @param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected. |
742 | | @param foundLocations Vector of rectangles where each rectangle contains the detected object. |
743 | | @param locations Vector of DetectionROI |
744 | | @param hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specified |
745 | | in the detector coefficients (as the last free coefficient). But if the free coefficient is omitted (which is allowed), you can specify it manually here. |
746 | | @param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it. |
747 | | */ |
748 | | virtual void detectMultiScaleROI(InputArray img, |
749 | | CV_OUT std::vector<cv::Rect>& foundLocations, |
750 | | std::vector<DetectionROI>& locations, |
751 | | double hitThreshold = 0, |
752 | | int groupThreshold = 0) const; |
753 | | |
754 | | /** @brief Groups the object candidate rectangles. |
755 | | @param rectList Input/output vector of rectangles. Output vector includes retained and grouped rectangles. (The Python list is not modified in place.) |
756 | | @param weights Input/output vector of weights of rectangles. Output vector includes weights of retained and grouped rectangles. (The Python list is not modified in place.) |
757 | | @param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it. |
758 | | @param eps Relative difference between sides of the rectangles to merge them into a group. |
759 | | */ |
760 | | void groupRectangles(std::vector<cv::Rect>& rectList, std::vector<double>& weights, int groupThreshold, double eps) const; |
761 | | }; |
762 | | //! @} |
763 | | |
764 | | //! @addtogroup objdetect_qrcode |
765 | | //! @{ |
766 | | |
767 | | class CV_EXPORTS_W QRCodeEncoder { |
768 | | protected: |
769 | | QRCodeEncoder(); // use ::create() |
770 | | public: |
771 | | virtual ~QRCodeEncoder(); |
772 | | |
773 | | enum EncodeMode { |
774 | | MODE_AUTO = -1, |
775 | | MODE_NUMERIC = 1, // 0b0001 |
776 | | MODE_ALPHANUMERIC = 2, // 0b0010 |
777 | | MODE_BYTE = 4, // 0b0100 |
778 | | MODE_ECI = 7, // 0b0111 |
779 | | MODE_KANJI = 8, // 0b1000 |
780 | | MODE_STRUCTURED_APPEND = 3 // 0b0011 |
781 | | }; |
782 | | |
783 | | enum CorrectionLevel { |
784 | | CORRECT_LEVEL_L = 0, |
785 | | CORRECT_LEVEL_M = 1, |
786 | | CORRECT_LEVEL_Q = 2, |
787 | | CORRECT_LEVEL_H = 3 |
788 | | }; |
789 | | |
790 | | enum ECIEncodings { |
791 | | ECI_SHIFT_JIS = 20, |
792 | | ECI_UTF8 = 26, |
793 | | }; |
794 | | |
795 | | /** @brief QR code encoder parameters. */ |
796 | | struct CV_EXPORTS_W_SIMPLE Params |
797 | | { |
798 | | CV_WRAP Params(); |
799 | | |
800 | | //! The optional version of QR code (by default - maximum possible depending on the length of the string). |
801 | | CV_PROP_RW int version; |
802 | | |
803 | | //! The optional level of error correction (by default - the lowest). |
804 | | CV_PROP_RW QRCodeEncoder::CorrectionLevel correction_level; |
805 | | |
806 | | //! The optional encoding mode - Numeric, Alphanumeric, Byte, Kanji, ECI or Structured Append. |
807 | | CV_PROP_RW QRCodeEncoder::EncodeMode mode; |
808 | | |
809 | | //! The optional number of QR codes to generate in Structured Append mode. |
810 | | CV_PROP_RW int structure_number; |
811 | | }; |
812 | | |
813 | | /** @brief Constructor |
814 | | @param parameters QR code encoder parameters QRCodeEncoder::Params |
815 | | */ |
816 | | static CV_WRAP |
817 | | Ptr<QRCodeEncoder> create(const QRCodeEncoder::Params& parameters = QRCodeEncoder::Params()); |
818 | | |
819 | | /** @brief Generates QR code from input string. |
820 | | @param encoded_info Input string to encode. |
821 | | @param qrcode Generated QR code. |
822 | | */ |
823 | | CV_WRAP virtual void encode(const String& encoded_info, OutputArray qrcode) = 0; |
824 | | |
825 | | /** @brief Generates QR code from input string in Structured Append mode. The encoded message is splitting over a number of QR codes. |
826 | | @param encoded_info Input string to encode. |
827 | | @param qrcodes Vector of generated QR codes. |
828 | | */ |
829 | | CV_WRAP virtual void encodeStructuredAppend(const String& encoded_info, OutputArrayOfArrays qrcodes) = 0; |
830 | | |
831 | | }; |
832 | | class CV_EXPORTS_W_SIMPLE QRCodeDetector : public GraphicalCodeDetector |
833 | | { |
834 | | public: |
835 | | CV_WRAP QRCodeDetector(); |
836 | | |
837 | | /** @brief sets the epsilon used during the horizontal scan of QR code stop marker detection. |
838 | | @param epsX Epsilon neighborhood, which allows you to determine the horizontal pattern |
839 | | of the scheme 1:1:3:1:1 according to QR code standard. |
840 | | */ |
841 | | CV_WRAP QRCodeDetector& setEpsX(double epsX); |
842 | | /** @brief sets the epsilon used during the vertical scan of QR code stop marker detection. |
843 | | @param epsY Epsilon neighborhood, which allows you to determine the vertical pattern |
844 | | of the scheme 1:1:3:1:1 according to QR code standard. |
845 | | */ |
846 | | CV_WRAP QRCodeDetector& setEpsY(double epsY); |
847 | | |
848 | | /** @brief use markers to improve the position of the corners of the QR code |
849 | | * |
850 | | * alignmentMarkers using by default |
851 | | */ |
852 | | CV_WRAP QRCodeDetector& setUseAlignmentMarkers(bool useAlignmentMarkers); |
853 | | |
854 | | /** @brief Decodes QR code on a curved surface in image once it's found by the detect() method. |
855 | | |
856 | | Returns UTF8-encoded output string or empty string if the code cannot be decoded. |
857 | | @param img grayscale or color (BGR) image containing QR code. |
858 | | @param points Quadrangle vertices found by detect() method (or some other algorithm). |
859 | | @param straight_qrcode The optional output image containing rectified and binarized QR code |
860 | | */ |
861 | | CV_WRAP cv::String decodeCurved(InputArray img, InputArray points, OutputArray straight_qrcode = noArray()); |
862 | | |
863 | | /** @brief Both detects and decodes QR code on a curved surface |
864 | | |
865 | | @param img grayscale or color (BGR) image containing QR code. |
866 | | @param points optional output array of vertices of the found QR code quadrangle. Will be empty if not found. |
867 | | @param straight_qrcode The optional output image containing rectified and binarized QR code |
868 | | */ |
869 | | CV_WRAP std::string detectAndDecodeCurved(InputArray img, OutputArray points=noArray(), |
870 | | OutputArray straight_qrcode = noArray()); |
871 | | |
872 | | /** @brief Returns a kind of encoding for the decoded info from the latest @ref decode or @ref detectAndDecode call |
873 | | @param codeIdx an index of the previously decoded QR code. |
874 | | When @ref decode or @ref detectAndDecode is used, valid value is zero. |
875 | | For @ref decodeMulti or @ref detectAndDecodeMulti use indices corresponding to the output order. |
876 | | */ |
877 | | CV_WRAP QRCodeEncoder::ECIEncodings getEncoding(int codeIdx = 0); |
878 | | }; |
879 | | |
880 | | class CV_EXPORTS_W_SIMPLE QRCodeDetectorAruco : public GraphicalCodeDetector { |
881 | | public: |
882 | | CV_WRAP QRCodeDetectorAruco(); |
883 | | |
884 | | struct CV_EXPORTS_W_SIMPLE Params { |
885 | | CV_WRAP Params(); |
886 | | |
887 | | /** @brief The minimum allowed pixel size of a QR module in the smallest image in the image pyramid, default 4.f */ |
888 | | CV_PROP_RW float minModuleSizeInPyramid; |
889 | | |
890 | | /** @brief The maximum allowed relative rotation for finder patterns in the same QR code, default pi/12 */ |
891 | | CV_PROP_RW float maxRotation; |
892 | | |
893 | | /** @brief The maximum allowed relative mismatch in module sizes for finder patterns in the same QR code, default 1.75f */ |
894 | | CV_PROP_RW float maxModuleSizeMismatch; |
895 | | |
896 | | /** @brief The maximum allowed module relative mismatch for timing pattern module, default 2.f |
897 | | * |
898 | | * If relative mismatch of timing pattern module more this value, penalty points will be added. |
899 | | * If a lot of penalty points are added, QR code will be rejected. */ |
900 | | CV_PROP_RW float maxTimingPatternMismatch; |
901 | | |
902 | | /** @brief The maximum allowed percentage of penalty points out of total pins in timing pattern, default 0.4f */ |
903 | | CV_PROP_RW float maxPenalties; |
904 | | |
905 | | /** @brief The maximum allowed relative color mismatch in the timing pattern, default 0.2f*/ |
906 | | CV_PROP_RW float maxColorsMismatch; |
907 | | |
908 | | /** @brief The algorithm find QR codes with almost minimum timing pattern score and minimum size, default 0.9f |
909 | | * |
910 | | * The QR code with the minimum "timing pattern score" and minimum "size" is selected as the best QR code. |
911 | | * If for the current QR code "timing pattern score" * scaleTimingPatternScore < "previous timing pattern score" and "size" < "previous size", then |
912 | | * current QR code set as the best QR code. */ |
913 | | CV_PROP_RW float scaleTimingPatternScore; |
914 | | }; |
915 | | |
916 | | /** @brief QR code detector constructor for Aruco-based algorithm. See cv::QRCodeDetectorAruco::Params */ |
917 | | CV_WRAP explicit QRCodeDetectorAruco(const QRCodeDetectorAruco::Params& params); |
918 | | |
919 | | /** @brief Detector parameters getter. See cv::QRCodeDetectorAruco::Params */ |
920 | | CV_WRAP const QRCodeDetectorAruco::Params& getDetectorParameters() const; |
921 | | |
922 | | /** @brief Detector parameters setter. See cv::QRCodeDetectorAruco::Params */ |
923 | | CV_WRAP QRCodeDetectorAruco& setDetectorParameters(const QRCodeDetectorAruco::Params& params); |
924 | | |
925 | | /** @brief Aruco detector parameters are used to search for the finder patterns. */ |
926 | | CV_WRAP const aruco::DetectorParameters& getArucoParameters() const; |
927 | | |
928 | | /** @brief Aruco detector parameters are used to search for the finder patterns. */ |
929 | | CV_WRAP void setArucoParameters(const aruco::DetectorParameters& params); |
930 | | }; |
931 | | |
932 | | //! @} |
933 | | } |
934 | | |
935 | | #include "opencv2/objdetect/detection_based_tracker.hpp" |
936 | | #include "opencv2/objdetect/face.hpp" |
937 | | #include "opencv2/objdetect/charuco_detector.hpp" |
938 | | #include "opencv2/objdetect/barcode.hpp" |
939 | | |
940 | | #endif |