在Python中从OpenCV公开LBP描述符 [英] Exposing the LBP descriptors from OpenCV in Python

查看:122
本文介绍了在Python中从OpenCV公开LBP描述符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用OpenCV在python中计算LBP描述符. 根据,我需要再次编译openCV.

I want to be able to calculate the LBP discriptor in python using OpenCV. According to this I need to compile openCV again.

我更改了opencv-2.4.6.1/modules/contrib/src/facerec.cpp中的elbp()函数,因此它们不再是静态的. 现在,我必须在HFile中声明它们(假设我创建了elbp.hpp,还是应该将其添加到现有文件中?):

I changed the elbp() functions in opencv-2.4.6.1/modules/contrib/src/facerec.cpp, so they won't be statisc anymore. Now I have to declare them in an HFile (let's say i created elbp.hpp, or should I add this to an existing file?):

// 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共享对象.

In order to compile OpenCV I followed instructions here, and created the cv2.so shared object.

我的问题是,如何创建python包装器"(如果我使用正确的单词)以能够从python调用elbp()函数?我觉得我错过了关键的一步.

例如,cv2.HogDescriptor()函数存在于python中,我想同样地公开LBP描述符.

For example, the cv2.HogDescriptor() function exists in python, I want to similarly expose the LBP descriptor.

推荐答案

这实际上是与 ctypes

This is actually the same problem, if not the same question, as how to call a dll in python - But you can use either ctypes or swig however since there is already a python interface into OpenCV your best bet is to take a look to see how the existing one is done.

也许值得一看的 pyopencv 它提供了基于Boost 的界面.

It may also be worth taking a look at pyopencv which provides a Boost based interface.

要了解当前系统的工作方式,请查看opencv/modules/python中的CMakeLists.txt,您会发现opencv/modules/python/src2/gen2.py创建了许多生成的标头-您将需要花一些时间来查看这两个标头文件.

To see how the current system does things take a look at CMakeLists.txt in opencv/modules/python and you will find that a number of generated headers are created by opencv/modules/python/src2/gen2.py - you will need to spend some time looking at these two files.

这篇关于在Python中从OpenCV公开LBP描述符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆