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 Details

  • Constructor Details

    • HOGDescriptor

      protected HOGDescriptor​(long addr)
    • HOGDescriptor

      public HOGDescriptor()
      Creates the HOG descriptor and detector with default parameters. 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

      public HOGDescriptor​(String filename)
      Creates the HOG descriptor and detector and loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file.
      Parameters:
      filename - The file name containing HOGDescriptor properties and coefficients for the linear SVM classifier.
  • Method Details

    • getNativeObjAddr

      public long getNativeObjAddr()
    • __fromPtr__

      public static HOGDescriptor __fromPtr__​(long addr)
    • getDescriptorSize

      public long getDescriptorSize()
      Returns the number of coefficients required for the classification.
      Returns:
      automatically generated
    • checkDetectorSize

      public boolean checkDetectorSize()
      Checks if detector size equal to descriptor size.
      Returns:
      automatically generated
    • getWinSigma

      public double getWinSigma()
      Returns winSigma value
      Returns:
      automatically generated
    • setSVMDetector

      public void setSVMDetector​(Mat svmdetector)
      Sets coefficients for the linear SVM classifier.
      Parameters:
      svmdetector - coefficients for the linear SVM classifier.
    • load

      public boolean load​(String filename, String objname)
      loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file
      Parameters:
      filename - Name 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

      public boolean load​(String filename)
      loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file
      Parameters:
      filename - Name of the file to read.
      Returns:
      automatically generated
    • save

      public void save​(String filename, String objname)
      saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file
      Parameters:
      filename - File name
      objname - Object name
    • save

      public void save​(String filename)
      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_32F
      winStride - Window stride. It must be a multiple of block stride.
      padding - Padding
      locations - Vector of Point
    • compute

      public void compute​(Mat img, MatOfFloat descriptors, Size winStride, Size padding)
      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
      winStride - Window stride. It must be a multiple of block stride.
      padding - Padding
    • compute

      public void compute​(Mat img, MatOfFloat descriptors, Size winStride)
      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
      winStride - Window stride. It must be a multiple of block stride.
    • compute

      public void compute​(Mat img, MatOfFloat descriptors)
      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 - Padding
      searchLocations - 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

      public void detect​(Mat img, MatOfPoint foundLocations, MatOfDouble weights, double hitThreshold)
      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

      public void detect​(Mat img, MatOfPoint foundLocations, MatOfDouble weights)
      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 groupThreshold, 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 - Padding
      scale - Coefficient of the detection window increase.
      groupThreshold - Coefficient to regulate the similarity threshold. When detected, some objects can be covered by many rectangles. 0 means not to perform grouping.
      useMeanshiftGrouping - indicates grouping algorithm
    • detectMultiScale

      public void detectMultiScale​(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights, double hitThreshold, Size winStride, Size padding, double scale, double groupThreshold)
      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
      scale - Coefficient of the detection window increase.
      groupThreshold - Coefficient to regulate the similarity threshold. When detected, some objects can be covered by many rectangles. 0 means not to perform grouping.
    • 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 - Padding
      scale - Coefficient of the detection window increase. by many rectangles. 0 means not to perform grouping.
    • 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 by many rectangles. 0 means not to perform grouping.
    • 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. by many rectangles. 0 means not to perform grouping.
    • 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. by many rectangles. 0 means not to perform grouping.
    • detectMultiScale

      public void detectMultiScale​(Mat img, MatOfRect foundLocations, MatOfDouble foundWeights)
      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. by many rectangles. 0 means not to perform grouping.
    • computeGradient

      public void computeGradient​(Mat img, Mat grad, Mat angleOfs, Size paddingTL, Size paddingBR)
      Computes gradients and quantized gradient orientations.
      Parameters:
      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
    • computeGradient

      public void computeGradient​(Mat img, Mat grad, Mat angleOfs, Size paddingTL)
      Computes gradients and quantized gradient orientations.
      Parameters:
      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
    • computeGradient

      public void computeGradient​(Mat img, Mat grad, Mat angleOfs)
      Computes gradients and quantized gradient orientations.
      Parameters:
      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
    • 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

      public Size get_winSize()
    • get_blockSize

      public Size get_blockSize()
    • get_blockStride

    • get_cellSize

      public Size get_cellSize()
    • get_nbins

      public int get_nbins()
    • get_derivAperture

      public int get_derivAperture()
    • get_winSigma

      public double get_winSigma()
    • get_histogramNormType

      public int get_histogramNormType()
    • get_L2HysThreshold

      public double get_L2HysThreshold()
    • get_gammaCorrection

      public boolean get_gammaCorrection()
    • get_svmDetector

    • get_nlevels

      public int get_nlevels()
    • get_signedGradient

      public boolean get_signedGradient()
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable