update HOGDescriptor documentation

pull/21606/head
Suleyman TURKMEN 3 years ago
parent 1620a1e014
commit 44db2eea70
  1. 22
      modules/objdetect/include/opencv2/objdetect.hpp
  2. 12
      modules/objdetect/src/hog.cpp

@ -376,7 +376,7 @@ public:
}; };
enum { DEFAULT_NLEVELS = 64 //!< Default nlevels value. enum { DEFAULT_NLEVELS = 64 //!< Default nlevels value.
}; };
/**@brief Creates the HOG descriptor and detector with default params. /**@brief 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, 1 ) aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9, 1 )
*/ */
@ -412,6 +412,8 @@ public:
{} {}
/** @overload /** @overload
Creates the HOG descriptor and detector and loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file.
@param filename the file name containing HOGDescriptor properties and coefficients of the trained classifier @param filename the file name containing HOGDescriptor properties and coefficients of the trained classifier
*/ */
CV_WRAP HOGDescriptor(const String& filename) CV_WRAP HOGDescriptor(const String& filename)
@ -450,24 +452,24 @@ public:
*/ */
CV_WRAP virtual void setSVMDetector(InputArray _svmdetector); CV_WRAP virtual void setSVMDetector(InputArray _svmdetector);
/** @brief Reads HOGDescriptor parameters from a file node. /** @brief Reads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file node.
@param fn File node @param fn File node
*/ */
virtual bool read(FileNode& fn); virtual bool read(FileNode& fn);
/** @brief Stores HOGDescriptor parameters in a file storage. /** @brief Stores HOGDescriptor parameters and coefficients for the linear SVM classifier in a file storage.
@param fs File storage @param fs File storage
@param objname Object name @param objname Object name
*/ */
virtual void write(FileStorage& fs, const String& objname) const; virtual void write(FileStorage& fs, const String& objname) const;
/** @brief loads coefficients for the linear SVM classifier from a file /** @brief loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file
@param filename Name of the file to read. @param filename Name of the file to read.
@param objname The optional name of the node to read (if empty, the first top-level node will be used). @param objname The optional name of the node to read (if empty, the first top-level node will be used).
*/ */
CV_WRAP virtual bool load(const String& filename, const String& objname = String()); CV_WRAP virtual bool load(const String& filename, const String& objname = String());
/** @brief saves coefficients for the linear SVM classifier to a file /** @brief saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file
@param filename File name @param filename File name
@param objname Object name @param objname Object name
*/ */
@ -535,13 +537,14 @@ public:
@param winStride Window stride. It must be a multiple of block stride. @param winStride Window stride. It must be a multiple of block stride.
@param padding Padding @param padding Padding
@param scale Coefficient of the detection window increase. @param scale Coefficient of the detection window increase.
@param finalThreshold Final threshold @param groupThreshold Coefficient to regulate the similarity threshold. When detected, some objects can be covered
by many rectangles. 0 means not to perform grouping.
@param useMeanshiftGrouping indicates grouping algorithm @param useMeanshiftGrouping indicates grouping algorithm
*/ */
CV_WRAP virtual void detectMultiScale(InputArray img, CV_OUT std::vector<Rect>& foundLocations, CV_WRAP virtual void detectMultiScale(InputArray img, CV_OUT std::vector<Rect>& foundLocations,
CV_OUT std::vector<double>& foundWeights, double hitThreshold = 0, CV_OUT std::vector<double>& foundWeights, double hitThreshold = 0,
Size winStride = Size(), Size padding = Size(), double scale = 1.05, Size winStride = Size(), Size padding = Size(), double scale = 1.05,
double finalThreshold = 2.0,bool useMeanshiftGrouping = false) const; double groupThreshold = 2.0, bool useMeanshiftGrouping = false) const;
/** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list
of rectangles. of rectangles.
@ -553,13 +556,14 @@ public:
@param winStride Window stride. It must be a multiple of block stride. @param winStride Window stride. It must be a multiple of block stride.
@param padding Padding @param padding Padding
@param scale Coefficient of the detection window increase. @param scale Coefficient of the detection window increase.
@param finalThreshold Final threshold @param groupThreshold Coefficient to regulate the similarity threshold. When detected, some objects can be covered
by many rectangles. 0 means not to perform grouping.
@param useMeanshiftGrouping indicates grouping algorithm @param useMeanshiftGrouping indicates grouping algorithm
*/ */
virtual void detectMultiScale(InputArray img, CV_OUT std::vector<Rect>& foundLocations, virtual void detectMultiScale(InputArray img, CV_OUT std::vector<Rect>& foundLocations,
double hitThreshold = 0, Size winStride = Size(), double hitThreshold = 0, Size winStride = Size(),
Size padding = Size(), double scale = 1.05, Size padding = Size(), double scale = 1.05,
double finalThreshold = 2.0, bool useMeanshiftGrouping = false) const; double groupThreshold = 2.0, bool useMeanshiftGrouping = false) const;
/** @brief Computes gradients and quantized gradient orientations. /** @brief Computes gradients and quantized gradient orientations.
@param img Matrix contains the image to be computed @param img Matrix contains the image to be computed

@ -1884,7 +1884,7 @@ static bool ocl_detectMultiScale(InputArray _img, std::vector<Rect> &found_locat
void HOGDescriptor::detectMultiScale( void HOGDescriptor::detectMultiScale(
InputArray _img, std::vector<Rect>& foundLocations, std::vector<double>& foundWeights, InputArray _img, std::vector<Rect>& foundLocations, std::vector<double>& foundWeights,
double hitThreshold, Size winStride, Size padding, double hitThreshold, Size winStride, Size padding,
double scale0, double finalThreshold, bool useMeanshiftGrouping) const double scale0, double groupThreshold, bool useMeanshiftGrouping) const
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
@ -1910,7 +1910,7 @@ void HOGDescriptor::detectMultiScale(
CV_OCL_RUN(_img.dims() <= 2 && _img.type() == CV_8UC1 && scale0 > 1 && winStride.width % blockStride.width == 0 && CV_OCL_RUN(_img.dims() <= 2 && _img.type() == CV_8UC1 && scale0 > 1 && winStride.width % blockStride.width == 0 &&
winStride.height % blockStride.height == 0 && padding == Size(0,0) && _img.isUMat(), winStride.height % blockStride.height == 0 && padding == Size(0,0) && _img.isUMat(),
ocl_detectMultiScale(_img, foundLocations, levelScale, hitThreshold, winStride, finalThreshold, oclSvmDetector, ocl_detectMultiScale(_img, foundLocations, levelScale, hitThreshold, winStride, groupThreshold, oclSvmDetector,
blockSize, cellSize, nbins, blockStride, winSize, gammaCorrection, L2HysThreshold, (float)getWinSigma(), free_coef, signedGradient)); blockSize, cellSize, nbins, blockStride, winSize, gammaCorrection, L2HysThreshold, (float)getWinSigma(), free_coef, signedGradient));
std::vector<Rect> allCandidates; std::vector<Rect> allCandidates;
@ -1931,21 +1931,21 @@ void HOGDescriptor::detectMultiScale(
std::copy(tempWeights.begin(), tempWeights.end(), back_inserter(foundWeights)); std::copy(tempWeights.begin(), tempWeights.end(), back_inserter(foundWeights));
if ( useMeanshiftGrouping ) if ( useMeanshiftGrouping )
groupRectangles_meanshift(foundLocations, foundWeights, foundScales, finalThreshold, winSize); groupRectangles_meanshift(foundLocations, foundWeights, foundScales, groupThreshold, winSize);
else else
groupRectangles(foundLocations, foundWeights, (int)finalThreshold, 0.2); groupRectangles(foundLocations, foundWeights, (int)groupThreshold, 0.2);
clipObjects(imgSize, foundLocations, 0, &foundWeights); clipObjects(imgSize, foundLocations, 0, &foundWeights);
} }
void HOGDescriptor::detectMultiScale(InputArray img, std::vector<Rect>& foundLocations, void HOGDescriptor::detectMultiScale(InputArray img, std::vector<Rect>& foundLocations,
double hitThreshold, Size winStride, Size padding, double hitThreshold, Size winStride, Size padding,
double scale0, double finalThreshold, bool useMeanshiftGrouping) const double scale0, double groupThreshold, bool useMeanshiftGrouping) const
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
std::vector<double> foundWeights; std::vector<double> foundWeights;
detectMultiScale(img, foundLocations, foundWeights, hitThreshold, winStride, detectMultiScale(img, foundLocations, foundWeights, hitThreshold, winStride,
padding, scale0, finalThreshold, useMeanshiftGrouping); padding, scale0, groupThreshold, useMeanshiftGrouping);
} }
template<typename _ClsName> struct RTTIImpl template<typename _ClsName> struct RTTIImpl

Loading…
Cancel
Save