opencv hog函数调用

转载自 xmucyp
最终编辑 xmucyp

 I'm calling hog->compute() with default HOG parameter settings (
hog.winSize.width = 64; hog.winSize.height = 128; hog.cellSize.width = 8 =
hog.cellSize.height; hog.blockSize.width = 16; hog.blockStride.width = 8;
winStride = Size(8, 8); padding = Size(32, 32); etc. but for training, use
trainingPadding = Size(0,0) ), some excerpt of my code that could interest you:

 

std::vector<float>* calculateDescriptor(Mat img) {
vector<float>* descriptorVector = new std::vector<float>();
vector<Point> locations;
// Calculate the HOG from the image and return them in the descriptor
vector
hog.compute(img, *descriptorVector, winStride, trainingPadding,
locations);
printf("Descriptor vector size: %u", descriptorVector->size());
return descriptorVector;

}

Files: cvaux/cvhog.cpp, samples/peopledetect.cpp

All the functions usefull are given by the class HOGDescriptor. You need to train the detector using compute() and a SVM machine. Already trained classifier exist with getDefaultPeopleDetector() You can detect a people using detect() or detectMultiScale().


 仔细分析了cvhop.cpp中的compute函数,可以直接调用它来获得样本HOG,然后训练得到检测算子

1.制作样本
2.对每一张图片调用
hog.compute(img, descriptors,Size(8,8), Size(0,0));
可以生成hog descriptors,把它保存到文件中
for(int j=0;j<3780;j++)
fprintf(f,"%f,",descriptors[j]);
3.利用SVM进行训练和分类,可得到权重系数,即getDefaultPeopleDetector()函数中调用的
检测 算子 detector[]


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值