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)




你可能感兴趣的:(HOG描述子计算的参数)