cv::HOGDescriptor Struct Reference 对象检测


Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector. 更多...

#include <opencv2/objdetect.hpp>

公共类型

enum   { DEFAULT_NLEVELS = 64 }
 
enum   DescriptorStorageFormat {
   DESCR_FORMAT_COL_BY_COL ,
   DESCR_FORMAT_ROW_BY_ROW
}
 
enum   HistogramNormType { L2Hys = 0 }
 

Public Member Functions

  HOGDescriptor ()
  Creates the HOG descriptor and detector with default params. 更多...
 
  HOGDescriptor ( Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture=1, double _winSigma=-1, HOGDescriptor::HistogramNormType _histogramNormType= HOGDescriptor::L2Hys , double _L2HysThreshold=0.2, bool _gammaCorrection=false, int _nlevels= HOGDescriptor::DEFAULT_NLEVELS , bool _signedGradient=false)
 
  HOGDescriptor (const 字符串 &filename)
 
  HOGDescriptor (const HOGDescriptor &d)
 
virtual  ~HOGDescriptor ()
  Default destructor. 更多...
 
bool  checkDetectorSize () const
  Checks if detector size equal to descriptor size. 更多...
 
virtual void  compute ( InputArray img, std::vector< float > &descriptors, Size winStride= Size (), Size padding= Size (), const std::vector< Point > &locations=std::vector< Point >()) const
  Computes HOG descriptors of given image. 更多...
 
virtual void  computeGradient ( InputArray img, InputOutputArray grad, InputOutputArray angleOfs, Size paddingTL= Size (), Size paddingBR= Size ()) const
  Computes gradients and quantized gradient orientations. 更多...
 
virtual void  copyTo ( HOGDescriptor &c) const
  clones the HOGDescriptor 更多...
 
virtual void  detect ( InputArray img, std::vector< Point > &foundLocations, std::vector< double > &weights, double hitThreshold=0, Size winStride= Size (), Size padding= Size (), const std::vector< Point > &searchLocations=std::vector< Point >()) const
  Performs object detection without a multi-scale window. 更多...
 
virtual void  detect ( InputArray img, std::vector< Point > &foundLocations, double hitThreshold=0, Size winStride= Size (), Size padding= Size (), const std::vector< Point > &searchLocations=std::vector< Point >()) const
  Performs object detection without a multi-scale window. 更多...
 
virtual void  detectMultiScale ( InputArray img, std::vector< Rect > &foundLocations, std::vector< double > &foundWeights, double hitThreshold=0, Size winStride= Size (), Size padding= Size (), double scale=1.05, double finalThreshold=2.0, bool useMeanshiftGrouping=false) const
  Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles. 更多...
 
virtual void  detectMultiScale ( InputArray img, std::vector< Rect > &foundLocations, double hitThreshold=0, Size winStride= Size (), Size padding= Size (), double scale=1.05, double finalThreshold=2.0, bool useMeanshiftGrouping=false) const
  Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles. 更多...
 
virtual void  detectMultiScaleROI ( InputArray img, std::vector< cv::Rect > &foundLocations, std::vector< DetectionROI > &locations, double hitThreshold=0, int groupThreshold=0) const
  evaluate specified ROI and return confidence value for each location in multiple scales 更多...
 
virtual void  detectROI ( InputArray img, const std::vector< cv::Point > &locations, std::vector< cv::Point > &foundLocations, std::vector< double > &confidences, double hitThreshold=0, cv::Size winStride= Size (), cv::Size padding= Size ()) const
  evaluate specified ROI and return confidence value for each location 更多...
 
size_t  getDescriptorSize () const
  Returns the number of coefficients required for the classification. 更多...
 
double  getWinSigma () const
  Returns winSigma value. 更多...
 
void  groupRectangles (std::vector< cv::Rect > &rectList, std::vector< double > &weights, int groupThreshold, double eps) const
  Groups the object candidate rectangles. 更多...
 
virtual bool  load (const 字符串 &filename, const 字符串 &objname= 字符串 ())
  loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file. 更多...
 
virtual bool  read ( FileNode &fn)
  Reads HOGDescriptor parameters from a cv::FileNode . 更多...
 
virtual void  save (const 字符串 &filename, const 字符串 &objname= 字符串 ()) const
  saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file 更多...
 
virtual void  setSVMDetector ( InputArray svmdetector)
  Sets coefficients for the linear SVM classifier. 更多...
 
virtual void  write ( FileStorage &fs, const 字符串 &objname) const
  Stores HOGDescriptor parameters in a cv::FileStorage . 更多...
 

Static Public Member Functions

static std::vector< float >  getDaimlerPeopleDetector ()
  Returns coefficients of the classifier trained for people detection (for 48x96 windows). 更多...
 
static std::vector< float >  getDefaultPeopleDetector ()
  Returns coefficients of the classifier trained for people detection (for 64x128 windows). 更多...
 

Public Attributes

Size   blockSize
  Block size in pixels. Align to cell size. Default value is Size(16,16). 更多...
 
Size   blockStride
  Block stride. It must be a multiple of cell size. Default value is Size(8,8). 更多...
 
Size   cellSize
  Cell size. Default value is Size(8,8). 更多...
 
int  derivAperture
  not documented 更多...
 
float  free_coef
  not documented 更多...
 
bool  gammaCorrection
  Flag to specify whether the gamma correction preprocessing is required or not. 更多...
 
HOGDescriptor::HistogramNormType   histogramNormType
  histogramNormType 更多...
 
double  L2HysThreshold
  L2-Hys normalization method shrinkage. 更多...
 
int  nbins
  Number of bins used in the calculation of histogram of gradients. Default value is 9. 更多...
 
int  nlevels
  Maximum number of detection window increases. Default value is 64. 更多...
 
UMat   oclSvmDetector
  coefficients for the linear SVM classifier used when OpenCL is enabled 更多...
 
bool  signedGradient
  Indicates signed gradient will be used or not. 更多...
 
std::vector< float >  svmDetector
  coefficients for the linear SVM classifier. 更多...
 
double  winSigma
  Gaussian smoothing window parameter. 更多...
 
Size   winSize
  Detection window size. Align to block size and block stride. Default value is Size(64,128). 更多...
 

详细描述

Member Enumeration Documentation

◆  anonymous enum

anonymous enum
枚举器
DEFAULT_NLEVELS 

Default nlevels value.

◆  DescriptorStorageFormat

枚举器
DESCR_FORMAT_COL_BY_COL 
DESCR_FORMAT_ROW_BY_ROW 

◆  HistogramNormType

枚举器
L2Hys 

Default histogramNormType.

Constructor & Destructor Documentation

◆  HOGDescriptor() [1/4]

cv::HOGDescriptor::HOGDescriptor ( )
inline

Creates the HOG descriptor and detector with default params.

aqual to HOGDescriptor (Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9 )

◆  HOGDescriptor() [2/4]

cv::HOGDescriptor::HOGDescriptor ( Size   _winSize ,
Size   _blockSize ,
Size   _blockStride ,
Size   _cellSize ,
int  _nbins ,
int  _derivAperture = 1 ,
double  _winSigma = -1 ,
HOGDescriptor::HistogramNormType   _histogramNormType = HOGDescriptor::L2Hys ,
double  _L2HysThreshold = 0.2 ,
bool  _gammaCorrection = false ,
int  _nlevels = HOGDescriptor::DEFAULT_NLEVELS ,
bool  _signedGradient = false  
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

参数
_winSize sets winSize with given value.
_blockSize sets blockSize with given value.
_blockStride sets blockStride with given value.
_cellSize sets cellSize with given value.
_nbins sets nbins with given value.
_derivAperture sets derivAperture with given value.
_winSigma sets winSigma with given value.
_histogramNormType sets histogramNormType with given value.
_L2HysThreshold sets L2HysThreshold with given value.
_gammaCorrection sets gammaCorrection with given value.
_nlevels sets nlevels with given value.
_signedGradient sets signedGradient with given value.

◆  HOGDescriptor() [3/4]

cv::HOGDescriptor::HOGDescriptor ( const 字符串 filename )
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

参数
filename The file name containing HOGDescriptor properties and coefficients for the linear SVM classifier.

◆  HOGDescriptor() [4/4]

cv::HOGDescriptor::HOGDescriptor ( const HOGDescriptor d )
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

参数
d the HOGDescriptor which cloned to create a new one.

◆  ~HOGDescriptor()

virtual cv::HOGDescriptor::~HOGDescriptor ( )
inline virtual

Default destructor.

成员函数文档编制

◆  checkDetectorSize()

bool cv::HOGDescriptor::checkDetectorSize ( ) const

Checks if detector size equal to descriptor size.

◆  compute()

virtual void cv::HOGDescriptor::compute ( InputArray   img ,
std::vector< float > &  descriptors ,
Size   winStride = Size () ,
Size   padding = Size () ,
const std::vector< Point > &  locations = std::vector<  Point  >()  
) const
virtual

Computes HOG descriptors of given image.

参数
img Matrix of the type CV_8U containing an image where HOG features will be calculated.
descriptors Matrix of the type CV_32F
winStride Window stride. It must be a multiple of block stride.
padding Padding
locations Vector of Point
范例:
samples/cpp/train_HOG.cpp .

◆  computeGradient()

virtual void cv::HOGDescriptor::computeGradient ( InputArray   img ,
InputOutputArray   grad ,
InputOutputArray   angleOfs ,
Size   paddingTL = Size () ,
Size   paddingBR = Size ()  
) const
virtual

Computes gradients and quantized gradient orientations.

参数
img Matrix contains the image to be computed
grad Matrix of type CV_32FC2 contains computed gradients
angleOfs Matrix of type CV_8UC2 contains quantized gradient orientations
paddingTL Padding from top-left
paddingBR Padding from bottom-right

◆  copyTo()

virtual void cv::HOGDescriptor::copyTo ( HOGDescriptor c ) const
virtual

clones the HOGDescriptor

参数
c cloned HOGDescriptor

◆  detect() [1/2]

virtual void cv::HOGDescriptor::detect ( InputArray   img ,
std::vector< Point > &  foundLocations ,
std::vector< double > &  weights ,
double  hitThreshold = 0 ,
Size   winStride = Size () ,
Size   padding = Size () ,
const std::vector< Point > &  searchLocations = std::vector<  Point  >()  
) const
virtual

Performs object detection without a multi-scale window.

参数
img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
foundLocations Vector of point where each point contains left-top corner point of detected object boundaries.
weights Vector that will contain confidence values for each detected object.
hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specified 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.
winStride Window stride. It must be a multiple of block stride.
padding Padding
searchLocations Vector of Point includes set of requested locations to be evaluated.

◆  detect() [2/2]

virtual void cv::HOGDescriptor::detect ( InputArray   img ,
std::vector< Point > &  foundLocations ,
double  hitThreshold = 0 ,
Size   winStride = Size () ,
Size   padding = Size () ,
const std::vector< Point > &  searchLocations = std::vector<  Point  >()  
) const
virtual

Performs object detection without a multi-scale window.

参数
img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
foundLocations Vector of point where each point contains left-top corner point of detected object boundaries.
hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specified 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.
winStride Window stride. It must be a multiple of block stride.
padding Padding
searchLocations Vector of Point includes locations to search.

◆  detectMultiScale() [1/2]

virtual void cv::HOGDescriptor::detectMultiScale ( InputArray   img ,
std::vector< Rect > &  foundLocations ,
std::vector< double > &  foundWeights ,
double  hitThreshold = 0 ,
Size   winStride = Size () ,
Size   padding = Size () ,
double  scale = 1.05 ,
double  finalThreshold = 2.0 ,
bool  useMeanshiftGrouping = false  
) const
virtual

Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.

参数
img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
foundLocations Vector of rectangles where each rectangle contains the detected object.
foundWeights Vector that will contain confidence values for each detected object.
hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specified 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.
winStride Window stride. It must be a multiple of block stride.
padding Padding
scale Coefficient of the detection window increase.
finalThreshold Final threshold
useMeanshiftGrouping indicates grouping algorithm
范例:
samples/cpp/peopledetect.cpp , samples/cpp/train_HOG.cpp ,和 samples/tapi/hog.cpp .

◆  detectMultiScale() [2/2]

virtual void cv::HOGDescriptor::detectMultiScale ( InputArray   img ,
std::vector< Rect > &  foundLocations ,
double  hitThreshold = 0 ,
Size   winStride = Size () ,
Size   padding = Size () ,
double  scale = 1.05 ,
double  finalThreshold = 2.0 ,
bool  useMeanshiftGrouping = false  
) const
virtual

Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.

参数
img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
foundLocations Vector of rectangles where each rectangle contains the detected object.
hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specified 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.
winStride Window stride. It must be a multiple of block stride.
padding Padding
scale Coefficient of the detection window increase.
finalThreshold Final threshold
useMeanshiftGrouping indicates grouping algorithm

◆  detectMultiScaleROI()

virtual void cv::HOGDescriptor::detectMultiScaleROI ( InputArray   img ,
std::vector< cv::Rect > &  foundLocations ,
std::vector< DetectionROI > &  locations ,
double  hitThreshold = 0 ,
int  groupThreshold = 0  
) const
virtual

evaluate specified ROI and return confidence value for each location in multiple scales

参数
img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
foundLocations Vector of rectangles where each rectangle contains the detected object.
locations Vector of DetectionROI
hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specified 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.
groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it.

◆  detectROI()

virtual void cv::HOGDescriptor::detectROI ( InputArray   img ,
const std::vector< cv::Point > &  locations ,
std::vector< cv::Point > &  foundLocations ,
std::vector< double > &  confidences ,
double  hitThreshold = 0 ,
cv::Size   winStride = Size () ,
cv::Size   padding = Size ()  
) const
virtual

evaluate specified ROI and return confidence value for each location

参数
img Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
locations Vector of Point
foundLocations Vector of Point where each Point is detected object's top-left point.
confidences confidences
hitThreshold Threshold for the distance between features and SVM classifying plane. Usually it is 0 and should be specified 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
winStride winStride
padding padding

◆  getDaimlerPeopleDetector()

static std::vector<float> cv::HOGDescriptor::getDaimlerPeopleDetector ( )
static

Returns coefficients of the classifier trained for people detection (for 48x96 windows).

范例:
samples/cpp/peopledetect.cpp .

◆  getDefaultPeopleDetector()

static std::vector<float> cv::HOGDescriptor::getDefaultPeopleDetector ( )
static

Returns coefficients of the classifier trained for people detection (for 64x128 windows).

范例:
samples/cpp/peopledetect.cpp .

◆  getDescriptorSize()

size_t cv::HOGDescriptor::getDescriptorSize ( ) const

Returns the number of coefficients required for the classification.

◆  getWinSigma()

double cv::HOGDescriptor::getWinSigma ( ) const

Returns winSigma value.

◆  groupRectangles()

void cv::HOGDescriptor::groupRectangles ( std::vector< cv::Rect > &  rectList ,
std::vector< double > &  weights ,
int  groupThreshold ,
double  eps  
) const

Groups the object candidate rectangles.

参数
rectList Input/output vector of rectangles. Output vector includes retained and grouped rectangles. (The Python list is not modified in place.)
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.)
groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it.
eps Relative difference between sides of the rectangles to merge them into a group.

◆  load()

virtual bool cv::HOGDescriptor::load ( const 字符串 filename ,
const 字符串 objname = 字符串 ()  
)
virtual

loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file.

参数
filename Path of the file to read.
objname The optional name of the node to read (if empty, the first top-level node will be used).
范例:
samples/cpp/train_HOG.cpp .

◆  read()

virtual bool cv::HOGDescriptor::read ( FileNode fn )
virtual

Reads HOGDescriptor parameters from a cv::FileNode .

参数
fn File node

◆  save()

virtual void cv::HOGDescriptor::save ( const 字符串 filename ,
const 字符串 objname = 字符串 ()  
) const
virtual

saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file

参数
filename File name
objname Object name
范例:
samples/cpp/train_HOG.cpp .

◆  setSVMDetector()

virtual void cv::HOGDescriptor::setSVMDetector ( InputArray   svmdetector )
virtual

Sets coefficients for the linear SVM classifier.

参数
svmdetector coefficients for the linear SVM classifier.
范例:
samples/cpp/peopledetect.cpp , samples/cpp/train_HOG.cpp ,和 samples/tapi/hog.cpp .

◆  write()

virtual void cv::HOGDescriptor::write ( FileStorage fs ,
const 字符串 objname  
) const
virtual

Stores HOGDescriptor parameters in a cv::FileStorage .

参数
fs File storage
objname Object name

Member Data Documentation

◆  blockSize

Size cv::HOGDescriptor::blockSize

Block size in pixels. Align to cell size. Default value is Size(16,16).

◆  blockStride

Size cv::HOGDescriptor::blockStride

Block stride. It must be a multiple of cell size. Default value is Size(8,8).

◆  cellSize

Size cv::HOGDescriptor::cellSize

Cell size. Default value is Size(8,8).

◆  derivAperture

int cv::HOGDescriptor::derivAperture

not documented

◆  free_coef

float cv::HOGDescriptor::free_coef

not documented

◆  gammaCorrection

bool cv::HOGDescriptor::gammaCorrection

Flag to specify whether the gamma correction preprocessing is required or not.

◆  histogramNormType

HOGDescriptor::HistogramNormType cv::HOGDescriptor::histogramNormType

histogramNormType

◆  L2HysThreshold

double cv::HOGDescriptor::L2HysThreshold

L2-Hys normalization method shrinkage.

◆  nbins

int cv::HOGDescriptor::nbins

Number of bins used in the calculation of histogram of gradients. Default value is 9.

◆  nlevels

int cv::HOGDescriptor::nlevels

Maximum number of detection window increases. Default value is 64.

范例:
samples/tapi/hog.cpp .

◆  oclSvmDetector

UMat cv::HOGDescriptor::oclSvmDetector

coefficients for the linear SVM classifier used when OpenCL is enabled

◆  signedGradient

bool cv::HOGDescriptor::signedGradient

Indicates signed gradient will be used or not.

◆  svmDetector

std::vector<float> cv::HOGDescriptor::svmDetector

coefficients for the linear SVM classifier.

◆  winSigma

double cv::HOGDescriptor::winSigma

Gaussian smoothing window parameter.

◆  winSize

Size cv::HOGDescriptor::winSize

Detection window size. Align to block size and block stride. Default value is Size(64,128).

范例:
samples/cpp/train_HOG.cpp .

The documentation for this struct was generated from the following file: