Reputation: 12178
These are the signatures of HOGDescriptor
C'tor and method compute()
in OpenCV3.0:
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
Does anyone have an example code or an idea of how to compute one vector for THE WHOLE image?
Upvotes: 2
Views: 7258
Reputation: 2830
The following small piece of could should work for your problem:
// 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);
but please note that this descriptor will be larger than the descriptor used proposed to be optimal by Dalal and Triggs for detecting pedestrians.
Upvotes: 4