<opencv for android>HOG描述子计算的参数

直接用JAVA的API调用opencv4android比结合C++的方法在配置上要简单很多,还是比较适合我这种初学者,之后再学习JNI的方法吧。

在做的识别程序里面有个HOG+SVM进行识别的部分,这个用C++做的比较多,用java的话用法有一点点差别。。。(JAVA没学好)

HOG.compute函数参数介绍:

void compute(Mat img, MatOfFloat descriptors, Size winStride, Size padding, MatOfPoint locations)


Mat img

输入图像


MatOfFloat descriptors
输出的描述子向量,C++中是建立Vector,这边类型是MatOfFloat.

output vector of descriptors, one for each window in the sliding window search. in c++ it is an vector treated as an array, that is all descriptors are in descriptors[0] in one long array. You need to know the descriptor size to get back each descriptor: Hog.getDescriptorSize() .


Size winStride
滑动窗口的大小。size.width = the amount of overlap in the x direction for the sliding window search;
size.height= the amount of overlap in the y direction for the sliding window search;
So if you set it to 1,1 it will check a window centered on every pixel. However this will be slow, so you can set it to the cell-size for a good trade-off.

Size padding

This adds a border around the image, such that the detector can find things near to the edges. without this the first point of detection will half the window size into the image, thus a good choice would be to set it to the window size or half the window size, or some order of the cell size.

MatOfPoint locations
This is a list of locations that you can pre-specify, for instance if you only want descriptors for certain locations. Leave it empty to do a full search.

使用示例的思路:


disclaimer: may not be proper java, but should give you an idea what the parameters do...
Extract some Hogs

    MatOfFloat descriptors(0) //an empty vector of descriptors
    Size winStride(Hog.width/2,Hog.height/2) //50% overlap in the sliding window
    Size padding(0,0) //no padding around the image
    MatOfPoint locations(0) an empty vector of locations, so perform full search        
    compute(img , descriptors, winStride, padding, locations)




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值