Path: blob/master/modules/objdetect/include/opencv2/objdetect.hpp
16344 views
/*M///////////////////////////////////////////////////////////////////////////////////////1//2// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.3//4// By downloading, copying, installing or using the software you agree to this license.5// If you do not agree to this license, do not download, install,6// copy or use the software.7//8//9// License Agreement10// For Open Source Computer Vision Library11//12// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.13// Copyright (C) 2009, Willow Garage Inc., all rights reserved.14// Copyright (C) 2013, OpenCV Foundation, all rights reserved.15// Third party copyrights are property of their respective owners.16//17// Redistribution and use in source and binary forms, with or without modification,18// are permitted provided that the following conditions are met:19//20// * Redistribution's of source code must retain the above copyright notice,21// this list of conditions and the following disclaimer.22//23// * Redistribution's in binary form must reproduce the above copyright notice,24// this list of conditions and the following disclaimer in the documentation25// and/or other materials provided with the distribution.26//27// * The name of the copyright holders may not be used to endorse or promote products28// derived from this software without specific prior written permission.29//30// This software is provided by the copyright holders and contributors "as is" and31// any express or implied warranties, including, but not limited to, the implied32// warranties of merchantability and fitness for a particular purpose are disclaimed.33// In no event shall the Intel Corporation or contributors be liable for any direct,34// indirect, incidental, special, exemplary, or consequential damages35// (including, but not limited to, procurement of substitute goods or services;36// loss of use, data, or profits; or business interruption) however caused37// and on any theory of liability, whether in contract, strict liability,38// or tort (including negligence or otherwise) arising in any way out of39// the use of this software, even if advised of the possibility of such damage.40//41//M*/4243#ifndef OPENCV_OBJDETECT_HPP44#define OPENCV_OBJDETECT_HPP4546#include "opencv2/core.hpp"4748/**49@defgroup objdetect Object Detection5051Haar Feature-based Cascade Classifier for Object Detection52----------------------------------------------------------5354The object detector described below has been initially proposed by Paul Viola @cite Viola01 and55improved by Rainer Lienhart @cite Lienhart02 .5657First, a classifier (namely a *cascade of boosted classifiers working with haar-like features*) is58trained with a few hundred sample views of a particular object (i.e., a face or a car), called59positive examples, that are scaled to the same size (say, 20x20), and negative examples - arbitrary60images of the same size.6162After a classifier is trained, it can be applied to a region of interest (of the same size as used63during the training) in an input image. The classifier outputs a "1" if the region is likely to show64the object (i.e., face/car), and "0" otherwise. To search for the object in the whole image one can65move the search window across the image and check every location using the classifier. The66classifier is designed so that it can be easily "resized" in order to be able to find the objects of67interest at different sizes, which is more efficient than resizing the image itself. So, to find an68object of an unknown size in the image the scan procedure should be done several times at different69scales.7071The word "cascade" in the classifier name means that the resultant classifier consists of several72simpler classifiers (*stages*) that are applied subsequently to a region of interest until at some73stage the candidate is rejected or all the stages are passed. The word "boosted" means that the74classifiers at every stage of the cascade are complex themselves and they are built out of basic75classifiers using one of four different boosting techniques (weighted voting). Currently Discrete76Adaboost, Real Adaboost, Gentle Adaboost and Logitboost are supported. The basic classifiers are77decision-tree classifiers with at least 2 leaves. Haar-like features are the input to the basic78classifiers, and are calculated as described below. The current algorithm uses the following79Haar-like features:80818283The feature used in a particular classifier is specified by its shape (1a, 2b etc.), position within84the region of interest and the scale (this scale is not the same as the scale used at the detection85stage, though these two scales are multiplied). For example, in the case of the third line feature86(2c) the response is calculated as the difference between the sum of image pixels under the87rectangle covering the whole feature (including the two white stripes and the black stripe in the88middle) and the sum of the image pixels under the black stripe multiplied by 3 in order to89compensate for the differences in the size of areas. The sums of pixel values over a rectangular90regions are calculated rapidly using integral images (see below and the integral description).9192To see the object detector at work, have a look at the facedetect demo:93<https://github.com/opencv/opencv/tree/master/samples/cpp/dbt_face_detection.cpp>9495The following reference is for the detection part only. There is a separate application called96opencv_traincascade that can train a cascade of boosted classifiers from a set of samples.9798@note In the new C++ interface it is also possible to use LBP (local binary pattern) features in99addition to Haar-like features. .. [Viola01] Paul Viola and Michael J. Jones. Rapid Object Detection100using a Boosted Cascade of Simple Features. IEEE CVPR, 2001. The paper is available online at101<http://research.microsoft.com/en-us/um/people/viola/Pubs/Detect/violaJones_CVPR2001.pdf>102103@{104@defgroup objdetect_c C API105@}106*/107108typedef struct CvHaarClassifierCascade CvHaarClassifierCascade;109110namespace cv111{112113//! @addtogroup objdetect114//! @{115116///////////////////////////// Object Detection ////////////////////////////117118//! class for grouping object candidates, detected by Cascade Classifier, HOG etc.119//! instance of the class is to be passed to cv::partition (see cxoperations.hpp)120class CV_EXPORTS SimilarRects121{122public:123SimilarRects(double _eps) : eps(_eps) {}124inline bool operator()(const Rect& r1, const Rect& r2) const125{126double delta = eps * ((std::min)(r1.width, r2.width) + (std::min)(r1.height, r2.height)) * 0.5;127return std::abs(r1.x - r2.x) <= delta &&128std::abs(r1.y - r2.y) <= delta &&129std::abs(r1.x + r1.width - r2.x - r2.width) <= delta &&130std::abs(r1.y + r1.height - r2.y - r2.height) <= delta;131}132double eps;133};134135/** @brief Groups the object candidate rectangles.136137@param rectList Input/output vector of rectangles. Output vector includes retained and grouped138rectangles. (The Python list is not modified in place.)139@param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a140group of rectangles to retain it.141@param eps Relative difference between sides of the rectangles to merge them into a group.142143The function is a wrapper for the generic function partition . It clusters all the input rectangles144using the rectangle equivalence criteria that combines rectangles with similar sizes and similar145locations. The similarity is defined by eps. When eps=0 , no clustering is done at all. If146\f$\texttt{eps}\rightarrow +\inf\f$ , all the rectangles are put in one cluster. Then, the small147clusters containing less than or equal to groupThreshold rectangles are rejected. In each other148cluster, the average rectangle is computed and put into the output rectangle list.149*/150CV_EXPORTS void groupRectangles(std::vector<Rect>& rectList, int groupThreshold, double eps = 0.2);151/** @overload */152CV_EXPORTS_W void groupRectangles(CV_IN_OUT std::vector<Rect>& rectList, CV_OUT std::vector<int>& weights,153int groupThreshold, double eps = 0.2);154/** @overload */155CV_EXPORTS void groupRectangles(std::vector<Rect>& rectList, int groupThreshold,156double eps, std::vector<int>* weights, std::vector<double>* levelWeights );157/** @overload */158CV_EXPORTS void groupRectangles(std::vector<Rect>& rectList, std::vector<int>& rejectLevels,159std::vector<double>& levelWeights, int groupThreshold, double eps = 0.2);160/** @overload */161CV_EXPORTS void groupRectangles_meanshift(std::vector<Rect>& rectList, std::vector<double>& foundWeights,162std::vector<double>& foundScales,163double detectThreshold = 0.0, Size winDetSize = Size(64, 128));164165template<> struct DefaultDeleter<CvHaarClassifierCascade>{ CV_EXPORTS void operator ()(CvHaarClassifierCascade* obj) const; };166167enum { CASCADE_DO_CANNY_PRUNING = 1,168CASCADE_SCALE_IMAGE = 2,169CASCADE_FIND_BIGGEST_OBJECT = 4,170CASCADE_DO_ROUGH_SEARCH = 8171};172173class CV_EXPORTS_W BaseCascadeClassifier : public Algorithm174{175public:176virtual ~BaseCascadeClassifier();177virtual bool empty() const CV_OVERRIDE = 0;178virtual bool load( const String& filename ) = 0;179virtual void detectMultiScale( InputArray image,180CV_OUT std::vector<Rect>& objects,181double scaleFactor,182int minNeighbors, int flags,183Size minSize, Size maxSize ) = 0;184185virtual void detectMultiScale( InputArray image,186CV_OUT std::vector<Rect>& objects,187CV_OUT std::vector<int>& numDetections,188double scaleFactor,189int minNeighbors, int flags,190Size minSize, Size maxSize ) = 0;191192virtual void detectMultiScale( InputArray image,193CV_OUT std::vector<Rect>& objects,194CV_OUT std::vector<int>& rejectLevels,195CV_OUT std::vector<double>& levelWeights,196double scaleFactor,197int minNeighbors, int flags,198Size minSize, Size maxSize,199bool outputRejectLevels ) = 0;200201virtual bool isOldFormatCascade() const = 0;202virtual Size getOriginalWindowSize() const = 0;203virtual int getFeatureType() const = 0;204virtual void* getOldCascade() = 0;205206class CV_EXPORTS MaskGenerator207{208public:209virtual ~MaskGenerator() {}210virtual Mat generateMask(const Mat& src)=0;211virtual void initializeMask(const Mat& /*src*/) { }212};213virtual void setMaskGenerator(const Ptr<MaskGenerator>& maskGenerator) = 0;214virtual Ptr<MaskGenerator> getMaskGenerator() = 0;215};216217/** @example samples/cpp/facedetect.cpp218This program demonstrates usage of the Cascade classifier class219\image html Cascade_Classifier_Tutorial_Result_Haar.jpg "Sample screenshot" width=321 height=254220*/221/** @brief Cascade classifier class for object detection.222*/223class CV_EXPORTS_W CascadeClassifier224{225public:226CV_WRAP CascadeClassifier();227/** @brief Loads a classifier from a file.228229@param filename Name of the file from which the classifier is loaded.230*/231CV_WRAP CascadeClassifier(const String& filename);232~CascadeClassifier();233/** @brief Checks whether the classifier has been loaded.234*/235CV_WRAP bool empty() const;236/** @brief Loads a classifier from a file.237238@param filename Name of the file from which the classifier is loaded. The file may contain an old239HAAR classifier trained by the haartraining application or a new cascade classifier trained by the240traincascade application.241*/242CV_WRAP bool load( const String& filename );243/** @brief Reads a classifier from a FileStorage node.244245@note The file may contain a new cascade classifier (trained traincascade application) only.246*/247CV_WRAP bool read( const FileNode& node );248249/** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list250of rectangles.251252@param image Matrix of the type CV_8U containing an image where objects are detected.253@param objects Vector of rectangles where each rectangle contains the detected object, the254rectangles may be partially outside the original image.255@param scaleFactor Parameter specifying how much the image size is reduced at each image scale.256@param minNeighbors Parameter specifying how many neighbors each candidate rectangle should have257to retain it.258@param flags Parameter with the same meaning for an old cascade as in the function259cvHaarDetectObjects. It is not used for a new cascade.260@param minSize Minimum possible object size. Objects smaller than that are ignored.261@param maxSize Maximum possible object size. Objects larger than that are ignored. If `maxSize == minSize` model is evaluated on single scale.262263The function is parallelized with the TBB library.264265@note266- (Python) A face detection example using cascade classifiers can be found at267opencv_source_code/samples/python/facedetect.py268*/269CV_WRAP void detectMultiScale( InputArray image,270CV_OUT std::vector<Rect>& objects,271double scaleFactor = 1.1,272int minNeighbors = 3, int flags = 0,273Size minSize = Size(),274Size maxSize = Size() );275276/** @overload277@param image Matrix of the type CV_8U containing an image where objects are detected.278@param objects Vector of rectangles where each rectangle contains the detected object, the279rectangles may be partially outside the original image.280@param numDetections Vector of detection numbers for the corresponding objects. An object's number281of detections is the number of neighboring positively classified rectangles that were joined282together to form the object.283@param scaleFactor Parameter specifying how much the image size is reduced at each image scale.284@param minNeighbors Parameter specifying how many neighbors each candidate rectangle should have285to retain it.286@param flags Parameter with the same meaning for an old cascade as in the function287cvHaarDetectObjects. It is not used for a new cascade.288@param minSize Minimum possible object size. Objects smaller than that are ignored.289@param maxSize Maximum possible object size. Objects larger than that are ignored. If `maxSize == minSize` model is evaluated on single scale.290*/291CV_WRAP_AS(detectMultiScale2) void detectMultiScale( InputArray image,292CV_OUT std::vector<Rect>& objects,293CV_OUT std::vector<int>& numDetections,294double scaleFactor=1.1,295int minNeighbors=3, int flags=0,296Size minSize=Size(),297Size maxSize=Size() );298299/** @overload300This function allows you to retrieve the final stage decision certainty of classification.301For this, one needs to set `outputRejectLevels` on true and provide the `rejectLevels` and `levelWeights` parameter.302For each resulting detection, `levelWeights` will then contain the certainty of classification at the final stage.303This value can then be used to separate strong from weaker classifications.304305A code sample on how to use it efficiently can be found below:306@code307Mat img;308vector<double> weights;309vector<int> levels;310vector<Rect> detections;311CascadeClassifier model("/path/to/your/model.xml");312model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);313cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;314@endcode315*/316CV_WRAP_AS(detectMultiScale3) void detectMultiScale( InputArray image,317CV_OUT std::vector<Rect>& objects,318CV_OUT std::vector<int>& rejectLevels,319CV_OUT std::vector<double>& levelWeights,320double scaleFactor = 1.1,321int minNeighbors = 3, int flags = 0,322Size minSize = Size(),323Size maxSize = Size(),324bool outputRejectLevels = false );325326CV_WRAP bool isOldFormatCascade() const;327CV_WRAP Size getOriginalWindowSize() const;328CV_WRAP int getFeatureType() const;329void* getOldCascade();330331CV_WRAP static bool convert(const String& oldcascade, const String& newcascade);332333void setMaskGenerator(const Ptr<BaseCascadeClassifier::MaskGenerator>& maskGenerator);334Ptr<BaseCascadeClassifier::MaskGenerator> getMaskGenerator();335336Ptr<BaseCascadeClassifier> cc;337};338339CV_EXPORTS Ptr<BaseCascadeClassifier::MaskGenerator> createFaceDetectionMaskGenerator();340341//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////342343//! struct for detection region of interest (ROI)344struct DetectionROI345{346//! scale(size) of the bounding box347double scale;348//! set of requested locations to be evaluated349std::vector<cv::Point> locations;350//! vector that will contain confidence values for each location351std::vector<double> confidences;352};353354/**@brief Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector.355356the HOG descriptor algorithm introduced by Navneet Dalal and Bill Triggs @cite Dalal2005 .357358useful links:359360https://hal.inria.fr/inria-00548512/document/361362https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients363364https://software.intel.com/en-us/ipp-dev-reference-histogram-of-oriented-gradients-hog-descriptor365366http://www.learnopencv.com/histogram-of-oriented-gradients367368http://www.learnopencv.com/handwritten-digits-classification-an-opencv-c-python-tutorial369370*/371struct CV_EXPORTS_W HOGDescriptor372{373public:374enum HistogramNormType { L2Hys = 0 //!< Default histogramNormType375};376enum { DEFAULT_NLEVELS = 64 //!< Default nlevels value.377};378enum DescriptorStorageFormat { DESCR_FORMAT_COL_BY_COL, DESCR_FORMAT_ROW_BY_ROW };379380/**@brief Creates the HOG descriptor and detector with default params.381382aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 )383*/384CV_WRAP HOGDescriptor() : winSize(64,128), blockSize(16,16), blockStride(8,8),385cellSize(8,8), nbins(9), derivAperture(1), winSigma(-1),386histogramNormType(HOGDescriptor::L2Hys), L2HysThreshold(0.2), gammaCorrection(true),387free_coef(-1.f), nlevels(HOGDescriptor::DEFAULT_NLEVELS), signedGradient(false)388{}389390/** @overload391@param _winSize sets winSize with given value.392@param _blockSize sets blockSize with given value.393@param _blockStride sets blockStride with given value.394@param _cellSize sets cellSize with given value.395@param _nbins sets nbins with given value.396@param _derivAperture sets derivAperture with given value.397@param _winSigma sets winSigma with given value.398@param _histogramNormType sets histogramNormType with given value.399@param _L2HysThreshold sets L2HysThreshold with given value.400@param _gammaCorrection sets gammaCorrection with given value.401@param _nlevels sets nlevels with given value.402@param _signedGradient sets signedGradient with given value.403*/404CV_WRAP HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride,405Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1,406HOGDescriptor::HistogramNormType _histogramNormType=HOGDescriptor::L2Hys,407double _L2HysThreshold=0.2, bool _gammaCorrection=false,408int _nlevels=HOGDescriptor::DEFAULT_NLEVELS, bool _signedGradient=false)409: winSize(_winSize), blockSize(_blockSize), blockStride(_blockStride), cellSize(_cellSize),410nbins(_nbins), derivAperture(_derivAperture), winSigma(_winSigma),411histogramNormType(_histogramNormType), L2HysThreshold(_L2HysThreshold),412gammaCorrection(_gammaCorrection), free_coef(-1.f), nlevels(_nlevels), signedGradient(_signedGradient)413{}414415/** @overload416@param filename The file name containing HOGDescriptor properties and coefficients for the linear SVM classifier.417*/418CV_WRAP HOGDescriptor(const String& filename)419{420load(filename);421}422423/** @overload424@param d the HOGDescriptor which cloned to create a new one.425*/426HOGDescriptor(const HOGDescriptor& d)427{428d.copyTo(*this);429}430431/**@brief Default destructor.432*/433virtual ~HOGDescriptor() {}434435/**@brief Returns the number of coefficients required for the classification.436*/437CV_WRAP size_t getDescriptorSize() const;438439/** @brief Checks if detector size equal to descriptor size.440*/441CV_WRAP bool checkDetectorSize() const;442443/** @brief Returns winSigma value444*/445CV_WRAP double getWinSigma() const;446447/**@example samples/cpp/peopledetect.cpp448*/449/**@brief Sets coefficients for the linear SVM classifier.450@param svmdetector coefficients for the linear SVM classifier.451*/452CV_WRAP virtual void setSVMDetector(InputArray svmdetector);453454/** @brief Reads HOGDescriptor parameters from a cv::FileNode.455@param fn File node456*/457virtual bool read(FileNode& fn);458459/** @brief Stores HOGDescriptor parameters in a cv::FileStorage.460@param fs File storage461@param objname Object name462*/463virtual void write(FileStorage& fs, const String& objname) const;464465/** @brief loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file.466@param filename Path of the file to read.467@param objname The optional name of the node to read (if empty, the first top-level node will be used).468*/469CV_WRAP virtual bool load(const String& filename, const String& objname = String());470471/** @brief saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file472@param filename File name473@param objname Object name474*/475CV_WRAP virtual void save(const String& filename, const String& objname = String()) const;476477/** @brief clones the HOGDescriptor478@param c cloned HOGDescriptor479*/480virtual void copyTo(HOGDescriptor& c) const;481482/**@example samples/cpp/train_HOG.cpp483*/484/** @brief Computes HOG descriptors of given image.485@param img Matrix of the type CV_8U containing an image where HOG features will be calculated.486@param descriptors Matrix of the type CV_32F487@param winStride Window stride. It must be a multiple of block stride.488@param padding Padding489@param locations Vector of Point490*/491CV_WRAP virtual void compute(InputArray img,492CV_OUT std::vector<float>& descriptors,493Size winStride = Size(), Size padding = Size(),494const std::vector<Point>& locations = std::vector<Point>()) const;495496/** @brief Performs object detection without a multi-scale window.497@param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.498@param foundLocations Vector of point where each point contains left-top corner point of detected object boundaries.499@param weights Vector that will contain confidence values for each detected object.500@param hitThreshold Threshold for the distance between features and SVM classifying plane.501Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).502But if the free coefficient is omitted (which is allowed), you can specify it manually here.503@param winStride Window stride. It must be a multiple of block stride.504@param padding Padding505@param searchLocations Vector of Point includes set of requested locations to be evaluated.506*/507CV_WRAP virtual void detect(InputArray img, CV_OUT std::vector<Point>& foundLocations,508CV_OUT std::vector<double>& weights,509double hitThreshold = 0, Size winStride = Size(),510Size padding = Size(),511const std::vector<Point>& searchLocations = std::vector<Point>()) const;512513/** @brief Performs object detection without a multi-scale window.514@param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.515@param foundLocations Vector of point where each point contains left-top corner point of detected object boundaries.516@param hitThreshold Threshold for the distance between features and SVM classifying plane.517Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).518But if the free coefficient is omitted (which is allowed), you can specify it manually here.519@param winStride Window stride. It must be a multiple of block stride.520@param padding Padding521@param searchLocations Vector of Point includes locations to search.522*/523virtual void detect(InputArray img, CV_OUT std::vector<Point>& foundLocations,524double hitThreshold = 0, Size winStride = Size(),525Size padding = Size(),526const std::vector<Point>& searchLocations=std::vector<Point>()) const;527528/** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list529of rectangles.530@param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.531@param foundLocations Vector of rectangles where each rectangle contains the detected object.532@param foundWeights Vector that will contain confidence values for each detected object.533@param hitThreshold Threshold for the distance between features and SVM classifying plane.534Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).535But if the free coefficient is omitted (which is allowed), you can specify it manually here.536@param winStride Window stride. It must be a multiple of block stride.537@param padding Padding538@param scale Coefficient of the detection window increase.539@param finalThreshold Final threshold540@param useMeanshiftGrouping indicates grouping algorithm541*/542CV_WRAP virtual void detectMultiScale(InputArray img, CV_OUT std::vector<Rect>& foundLocations,543CV_OUT std::vector<double>& foundWeights, double hitThreshold = 0,544Size winStride = Size(), Size padding = Size(), double scale = 1.05,545double finalThreshold = 2.0,bool useMeanshiftGrouping = false) const;546547/** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list548of rectangles.549@param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.550@param foundLocations Vector of rectangles where each rectangle contains the detected object.551@param hitThreshold Threshold for the distance between features and SVM classifying plane.552Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).553But if the free coefficient is omitted (which is allowed), you can specify it manually here.554@param winStride Window stride. It must be a multiple of block stride.555@param padding Padding556@param scale Coefficient of the detection window increase.557@param finalThreshold Final threshold558@param useMeanshiftGrouping indicates grouping algorithm559*/560virtual void detectMultiScale(InputArray img, CV_OUT std::vector<Rect>& foundLocations,561double hitThreshold = 0, Size winStride = Size(),562Size padding = Size(), double scale = 1.05,563double finalThreshold = 2.0, bool useMeanshiftGrouping = false) const;564565/** @brief Computes gradients and quantized gradient orientations.566@param img Matrix contains the image to be computed567@param grad Matrix of type CV_32FC2 contains computed gradients568@param angleOfs Matrix of type CV_8UC2 contains quantized gradient orientations569@param paddingTL Padding from top-left570@param paddingBR Padding from bottom-right571*/572CV_WRAP virtual void computeGradient(InputArray img, InputOutputArray grad, InputOutputArray angleOfs,573Size paddingTL = Size(), Size paddingBR = Size()) const;574575/** @brief Returns coefficients of the classifier trained for people detection (for 64x128 windows).576*/577CV_WRAP static std::vector<float> getDefaultPeopleDetector();578579/**@example samples/tapi/hog.cpp580*/581/** @brief Returns coefficients of the classifier trained for people detection (for 48x96 windows).582*/583CV_WRAP static std::vector<float> getDaimlerPeopleDetector();584585//! Detection window size. Align to block size and block stride. Default value is Size(64,128).586CV_PROP Size winSize;587588//! Block size in pixels. Align to cell size. Default value is Size(16,16).589CV_PROP Size blockSize;590591//! Block stride. It must be a multiple of cell size. Default value is Size(8,8).592CV_PROP Size blockStride;593594//! Cell size. Default value is Size(8,8).595CV_PROP Size cellSize;596597//! Number of bins used in the calculation of histogram of gradients. Default value is 9.598CV_PROP int nbins;599600//! not documented601CV_PROP int derivAperture;602603//! Gaussian smoothing window parameter.604CV_PROP double winSigma;605606//! histogramNormType607CV_PROP HOGDescriptor::HistogramNormType histogramNormType;608609//! L2-Hys normalization method shrinkage.610CV_PROP double L2HysThreshold;611612//! Flag to specify whether the gamma correction preprocessing is required or not.613CV_PROP bool gammaCorrection;614615//! coefficients for the linear SVM classifier.616CV_PROP std::vector<float> svmDetector;617618//! coefficients for the linear SVM classifier used when OpenCL is enabled619UMat oclSvmDetector;620621//! not documented622float free_coef;623624//! Maximum number of detection window increases. Default value is 64625CV_PROP int nlevels;626627//! Indicates signed gradient will be used or not628CV_PROP bool signedGradient;629630/** @brief evaluate specified ROI and return confidence value for each location631@param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.632@param locations Vector of Point633@param foundLocations Vector of Point where each Point is detected object's top-left point.634@param confidences confidences635@param hitThreshold Threshold for the distance between features and SVM classifying plane. Usually636it is 0 and should be specified in the detector coefficients (as the last free coefficient). But if637the free coefficient is omitted (which is allowed), you can specify it manually here638@param winStride winStride639@param padding padding640*/641virtual void detectROI(InputArray img, const std::vector<cv::Point> &locations,642CV_OUT std::vector<cv::Point>& foundLocations, CV_OUT std::vector<double>& confidences,643double hitThreshold = 0, cv::Size winStride = Size(),644cv::Size padding = Size()) const;645646/** @brief evaluate specified ROI and return confidence value for each location in multiple scales647@param img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.648@param foundLocations Vector of rectangles where each rectangle contains the detected object.649@param locations Vector of DetectionROI650@param hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specified651in the detector coefficients (as the last free coefficient). But if the free coefficient is omitted (which is allowed), you can specify it manually here.652@param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it.653*/654virtual void detectMultiScaleROI(InputArray img,655CV_OUT std::vector<cv::Rect>& foundLocations,656std::vector<DetectionROI>& locations,657double hitThreshold = 0,658int groupThreshold = 0) const;659660/** @brief Groups the object candidate rectangles.661@param rectList Input/output vector of rectangles. Output vector includes retained and grouped rectangles. (The Python list is not modified in place.)662@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.)663@param groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it.664@param eps Relative difference between sides of the rectangles to merge them into a group.665*/666void groupRectangles(std::vector<cv::Rect>& rectList, std::vector<double>& weights, int groupThreshold, double eps) const;667};668669class CV_EXPORTS QRCodeDetector670{671public:672QRCodeDetector();673~QRCodeDetector();674675void setEpsX(double epsX);676void setEpsY(double epsY);677678bool detect(InputArray in, OutputArray points) const;679protected:680struct Impl;681Ptr<Impl> p;682};683684/** @brief Detect QR code in image and return minimum area of quadrangle that describes QR code.685@param in Matrix of the type CV_8U containing an image where QR code are detected.686@param points Output vector of vertices of a quadrangle of minimal area that describes QR code.687@param eps_x Epsilon neighborhood, which allows you to determine the horizontal pattern of the scheme 1:1:3:1:1 according to QR code standard.688@param eps_y Epsilon neighborhood, which allows you to determine the vertical pattern of the scheme 1:1:3:1:1 according to QR code standard.689*/690CV_EXPORTS bool detectQRCode(InputArray in, std::vector<Point> &points, double eps_x = 0.2, double eps_y = 0.1);691692/** @brief Decode QR code in image and return text that is encrypted in QR code.693@param in Matrix of the type CV_8UC1 containing an image where QR code are detected.694@param points Input vector of vertices of a quadrangle of minimal area that describes QR code.695@param decoded_info String information that is encrypted in QR code.696@param straight_qrcode Matrix of the type CV_8UC1 containing an binary straight QR code.697*/698CV_EXPORTS bool decodeQRCode(InputArray in, InputArray points, std::string &decoded_info, OutputArray straight_qrcode = noArray());699//! @} objdetect700701}702703#include "opencv2/objdetect/detection_based_tracker.hpp"704705#endif706707708