http://www.cnblogs.com/huangshiyu13/p/6647375.html
http://blog.csdn.net/xiaojidan2011/article/details/39205309
g++ hog.cpp $(pkg-config --libs opencv --cflags) -o hog
hog.cpp:
#include <sstream>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
string numToStr(int numn){
stringstream ss;
ss << numn;
string s2;
ss>>s2;
return s2;
}
int main(int argc, char **argv) {
CascadeClassifier cascade;
const float scale_factor(1.2f);
const int min_neighbors(3);
if (cascade.load("./data/hogcascades/hogcascade_pedestrians.xml")) {
Mat img = imread("1.jpg", CV_LOAD_IMAGE_GRAYSCALE);
equalizeHist(img, img);
vector<Rect> objs;
vector<int> reject_levels;
vector<double> level_weights;
cascade.detectMultiScale(img, objs, reject_levels, level_weights, scale_factor, min_neighbors, 0, Size(), Size(), true);
Mat img_color = imread("1.jpg", CV_LOAD_IMAGE_COLOR);
for (int n = 0; n < objs.size(); n++) {
rectangle(img_color, objs[n], Scalar(255,0,0), 8);
cout << level_weights[n] << endl;
// putText(img_color, numToStr(level_weights[n]*100),
// Point(objs[n].x, objs[n].y), 1, 1, Scalar(0,0,255));
}
// imshow("VJ Face Detector", img_color);
// waitKey(0);
}
return 0;
}