OpenCV 3.0 - HOGDescriptor :: compute()代码示例

时间:2015-11-08 14:59:04

标签: opencv

这些是OpenCV3.0中HOGDescriptor C'tor和方法compute()的签名:

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


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

有没有人有一个示例代码或如何计算整个图像的一个向量?

1 个答案:

答案 0 :(得分:4)

以下一小部分内容可以解决您的问题:

// create descriptor object and set the size of the hog descriptor to image size
cv::HOGDescriptor hog;        
hog.winSize = grayImg.size(); 
// set the descriptor position to the middle of the image
std::vector<cv::Point> positions; 
positions.push_back(cv::Point(grayImg.cols / 2, grayImg.rows / 2));
std::vector<float> descriptor;
hog.compute(grayImg,descriptor,cv::Size(),cv::Size(),positions);

但请注意,此描述符将大于Dalal和Triggs用于检测行人的最佳建议描述符。