我希望能够使用 OpenCV 在 python 中计算 LBP 描述符。据此我需要再次编译openCV。
我更改了 中的elbp()
函数opencv-2.4.6.1/modules/contrib/src/facerec.cpp
,因此它们不再是 statisc 了。现在我必须在 HFile 中声明它们(假设我创建了elbp.hpp
,还是应该将其添加到现有文件中?):
// This is a header file created to expose the elbp (evaluate LBP) functions
#include "opencv2/core/core.hpp"
namespace cv {
Mat elbp(InputArray src, int radius, int neighbors);
Mat elbp(InputArray src, OutputArray dst, int radius, int neighbors);
Mat spatial_histogram(InputArray _src, int numPatterns, int grid_x, int grid_y, bool /*normed*/);
};
为了编译 OpenCV,我按照此处的说明创建了 cv2.so 共享对象。
我的问题是,如何创建 python“包装器”(如果我使用正确的词)能够从 python 调用 elbp() 函数?我觉得我在这里错过了关键的一步。
例如,python 中存在 cv2.HogDescriptor() 函数,我想类似地公开 LBP 描述符。