Package org.opencv.objdetect
Class HOGDescriptor
java.lang.Object
org.opencv.objdetect.HOGDescriptor
public class HOGDescriptor extends Object
Implementation of HOG (Histogram of Oriented Gradients) descriptor and object detector.
the HOG descriptor algorithm introduced by Navneet Dalal and Bill Triggs CITE: Dalal2005 .
useful links:
https://hal.inria.fr/inria-00548512/document/
https://en.wikipedia.org/wiki/Histogram_of_oriented_gradients
https://software.intel.com/en-us/ipp-dev-reference-histogram-of-oriented-gradients-hog-descriptor
http://www.learnopencv.com/histogram-of-oriented-gradients
http://www.learnopencv.com/handwritten-digits-classification-an-opencv-c-python-tutorial
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_NLEVELS
static int
DESCR_FORMAT_COL_BY_COL
static int
DESCR_FORMAT_ROW_BY_ROW
static int
L2Hys
protected long
nativeObj
-
Constructor Summary
Constructors Modifier Constructor Description HOGDescriptor()
Creates the HOG descriptor and detector with default params.protected
HOGDescriptor(long addr)
HOGDescriptor(String filename)
HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins)
HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture)
HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma)
HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma, int _histogramNormType)
HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma, int _histogramNormType, double _L2HysThreshold)
HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma, int _histogramNormType, double _L2HysThreshold, boolean _gammaCorrection)
HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma, int _histogramNormType, double _L2HysThreshold, boolean _gammaCorrection, int _nlevels)
HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma, int _histogramNormType, double _L2HysThreshold, boolean _gammaCorrection, int _nlevels, boolean _signedGradient)
-
Method Summary
Modifier and Type Method Description static HOGDescriptor
__fromPtr__(long addr)
boolean
checkDetectorSize()
Checks if detector size equal to descriptor size.void
compute(Mat img, MatOfFloat descriptors)
Computes HOG descriptors of given image.void
compute(Mat img, MatOfFloat descriptors, Size winStride)
Computes HOG descriptors of given image.void
compute(Mat img, MatOfFloat descriptors, Size winStride, Size padding)
Computes HOG descriptors of given image.void
compute(Mat img, MatOfFloat descriptors, Size winStride, Size padding, MatOfPoint locations)
Computes HOG descriptors of given image.void
computeGradient(Mat img, Mat grad, Mat angleOfs)
Computes gradients and quantized gradient orientations.void
computeGradient(Mat img, Mat grad, Mat angleOfs, Size paddingTL)
Computes gradients and quantized gradient orientations.void
computeGradient(Mat img, Mat grad, Mat angleOfs, Size paddingTL, Size paddingBR)
Computes gradients and quantized gradient orientations.void
detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights)
Performs object detection without a multi-scale window.void
detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold)
Performs object detection without a multi-scale window.void
detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold, Size winStride)
Performs object detection without a multi-scale window.void
detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold, Size winStride, Size padding)
Performs object detection without a multi-scale window.void
detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold, Size winStride, Size padding, MatOfPoint searchLocations)
Performs object detection without a multi-scale window.void
detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride, Size padding)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride, Size padding, double scale)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride, Size padding, double scale, double finalThreshold)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride, Size padding, double scale, double finalThreshold, boolean useMeanshiftGrouping)
Detects objects of different sizes in the input image.protected void
finalize()
Size
get_blockSize()
Size
get_blockStride()
Size
get_cellSize()
int
get_derivAperture()
boolean
get_gammaCorrection()
int
get_histogramNormType()
double
get_L2HysThreshold()
int
get_nbins()
int
get_nlevels()
boolean
get_signedGradient()
MatOfFloat
get_svmDetector()
double
get_winSigma()
Size
get_winSize()
static MatOfFloat
getDaimlerPeopleDetector()
Returns coefficients of the classifier trained for people detection (for 48x96 windows).static MatOfFloat
getDefaultPeopleDetector()
Returns coefficients of the classifier trained for people detection (for 64x128 windows).long
getDescriptorSize()
Returns the number of coefficients required for the classification.long
getNativeObjAddr()
double
getWinSigma()
Returns winSigma valueboolean
load(String filename)
loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file.boolean
load(String filename, String objname)
loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file.void
save(String filename)
saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a filevoid
save(String filename, String objname)
saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a filevoid
setSVMDetector(Mat svmdetector)
Sets coefficients for the linear SVM classifier.
-
Field Details
-
nativeObj
-
DEFAULT_NLEVELS
- See Also:
- Constant Field Values
-
DESCR_FORMAT_COL_BY_COL
- See Also:
- Constant Field Values
-
DESCR_FORMAT_ROW_BY_ROW
- See Also:
- Constant Field Values
-
L2Hys
- See Also:
- Constant Field Values
-
-
Constructor Details
-
HOGDescriptor
-
HOGDescriptor
public HOGDescriptor()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
public HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma, int _histogramNormType, double _L2HysThreshold, boolean _gammaCorrection, int _nlevels, boolean _signedGradient)- Parameters:
_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
public HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma, int _histogramNormType, double _L2HysThreshold, boolean _gammaCorrection, int _nlevels)- Parameters:
_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.
-
HOGDescriptor
public HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma, int _histogramNormType, double _L2HysThreshold, boolean _gammaCorrection)- Parameters:
_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.
-
HOGDescriptor
public HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma, int _histogramNormType, double _L2HysThreshold)- Parameters:
_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.
-
HOGDescriptor
public HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma, int _histogramNormType)- Parameters:
_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.
-
HOGDescriptor
public HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture, double _winSigma)- Parameters:
_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.
-
HOGDescriptor
public HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins, int _derivAperture)- Parameters:
_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.
-
HOGDescriptor
public HOGDescriptor(Size _winSize, Size _blockSize, Size _blockStride, Size _cellSize, int _nbins)- Parameters:
_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.
-
HOGDescriptor
- Parameters:
filename
- The file name containing HOGDescriptor properties and coefficients for the linear SVM classifier.
-
-
Method Details
-
getNativeObjAddr
-
__fromPtr__
-
getDescriptorSize
Returns the number of coefficients required for the classification.- Returns:
- automatically generated
-
checkDetectorSize
Checks if detector size equal to descriptor size.- Returns:
- automatically generated
-
getWinSigma
Returns winSigma value- Returns:
- automatically generated
-
setSVMDetector
Sets coefficients for the linear SVM classifier.- Parameters:
svmdetector
- coefficients for the linear SVM classifier.
-
load
loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file.- Parameters:
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).- Returns:
- automatically generated
-
load
loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file.- Parameters:
filename
- Path of the file to read.- Returns:
- automatically generated
-
save
saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file- Parameters:
filename
- File nameobjname
- Object name
-
save
saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file- Parameters:
filename
- File name
-
compute
public void compute(Mat img, MatOfFloat descriptors, Size winStride, Size padding, MatOfPoint locations)Computes HOG descriptors of given image.- Parameters:
img
- Matrix of the type CV_8U containing an image where HOG features will be calculated.descriptors
- Matrix of the type CV_32FwinStride
- Window stride. It must be a multiple of block stride.padding
- Paddinglocations
- Vector of Point
-
compute
Computes HOG descriptors of given image.- Parameters:
img
- Matrix of the type CV_8U containing an image where HOG features will be calculated.descriptors
- Matrix of the type CV_32FwinStride
- Window stride. It must be a multiple of block stride.padding
- Padding
-
compute
Computes HOG descriptors of given image.- Parameters:
img
- Matrix of the type CV_8U containing an image where HOG features will be calculated.descriptors
- Matrix of the type CV_32FwinStride
- Window stride. It must be a multiple of block stride.
-
compute
Computes HOG descriptors of given image.- Parameters:
img
- Matrix of the type CV_8U containing an image where HOG features will be calculated.descriptors
- Matrix of the type CV_32F
-
detect
public void detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold, Size winStride, Size padding, MatOfPoint searchLocations)Performs object detection without a multi-scale window.- Parameters:
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
- PaddingsearchLocations
- Vector of Point includes set of requested locations to be evaluated.
-
detect
public void detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold, Size winStride, Size padding)Performs object detection without a multi-scale window.- Parameters:
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
-
detect
public void detect(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold, Size winStride)Performs object detection without a multi-scale window.- Parameters:
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.
-
detect
Performs object detection without a multi-scale window.- Parameters:
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.
-
detect
Performs object detection without a multi-scale window.- Parameters:
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. 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.
-
detectMultiScale
public void detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride, Size padding, double scale, double finalThreshold, boolean useMeanshiftGrouping)Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
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
- Paddingscale
- Coefficient of the detection window increase.finalThreshold
- Final thresholduseMeanshiftGrouping
- indicates grouping algorithm
-
detectMultiScale
public void detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride, Size padding, double scale, double finalThreshold)Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
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
- Paddingscale
- Coefficient of the detection window increase.finalThreshold
- Final threshold
-
detectMultiScale
public void detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride, Size padding, double scale)Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
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
- Paddingscale
- Coefficient of the detection window increase.
-
detectMultiScale
public void detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride, Size padding)Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
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
-
detectMultiScale
public void detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride)Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
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.
-
detectMultiScale
public void detectMultiScale(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold)Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
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.
-
detectMultiScale
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
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. 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.
-
computeGradient
Computes gradients and quantized gradient orientations.- Parameters:
img
- Matrix contains the image to be computedgrad
- Matrix of type CV_32FC2 contains computed gradientsangleOfs
- Matrix of type CV_8UC2 contains quantized gradient orientationspaddingTL
- Padding from top-leftpaddingBR
- Padding from bottom-right
-
computeGradient
Computes gradients and quantized gradient orientations.- Parameters:
img
- Matrix contains the image to be computedgrad
- Matrix of type CV_32FC2 contains computed gradientsangleOfs
- Matrix of type CV_8UC2 contains quantized gradient orientationspaddingTL
- Padding from top-left
-
computeGradient
Computes gradients and quantized gradient orientations.- Parameters:
img
- Matrix contains the image to be computedgrad
- Matrix of type CV_32FC2 contains computed gradientsangleOfs
- Matrix of type CV_8UC2 contains quantized gradient orientations
-
getDefaultPeopleDetector
Returns coefficients of the classifier trained for people detection (for 64x128 windows).- Returns:
- automatically generated
-
getDaimlerPeopleDetector
Returns coefficients of the classifier trained for people detection (for 48x96 windows).- Returns:
- automatically generated
-
get_winSize
-
get_blockSize
-
get_blockStride
-
get_cellSize
-
get_nbins
-
get_derivAperture
-
get_winSigma
-
get_histogramNormType
-
get_L2HysThreshold
-
get_gammaCorrection
-
get_svmDetector
-
get_nlevels
-
get_signedGradient
-
finalize
-