我真的需要你的帮助。我尝试使用Cython访问opencv描述符AKAZE和FREAK(直到现在我只是尝试了FREAK)。但每当我尝试编译它时,我得到一条关于730行的错误消息,因为Cython说它不知道向量< ...>类型和一些行不在hpp文件的官方C ++语法中。但我不明白这一点,因为它是官方的opencv标题应该有用。
这是我的错误消息的一部分:
/usr/include/opencv2/features2d/features2d.hpp:1515:35: error: ISO C++ forbids declaration of ‘parameter’ with no type [-fpermissive]
/usr/include/opencv2/features2d/features2d.hpp:1515:41: error: expected ‘,’ or ‘...’ before ‘<’ token
CV_EXPORTS float getRecall( const vector<Point2f>& recallPrecisionCurve, float l_precision );
^
/usr/include/opencv2/features2d/features2d.hpp:1516:39: error: ‘vector’ does not name a type
CV_EXPORTS int getNearestPoint( const vector<Point2f>& recallPrecisionCurve, float l_precision );
这是我的.pxd文件:
cdef extern from "opencv2/core/core.hpp":
cdef int CV_WINDOW_AUTOSIZE
cdef int CV_8UC3
# -------------------------------------Bool Header-------------------------
cdef extern from "stdbool.h":
ctypedef struct bool:
pass
# ------------------------------------Vector Header------------------------
cdef extern from "vector" namespace "std":
cdef cppclass vector [T]:
pass
# -----------------------------------Features2d Header----------------------
cdef extern from "/usr/include/opencv2/features2d/features2d.hpp" namespace "cv":
cdef cppclass FREAK:
FREAK* FREAK( bool orientationNormalized=true, bool scaleNormalized=true, float patternScale=22.0, int nOctaves=4, const vector& selectedPairs=vector<int>()) except *
FREAK* FREAK( const FREAK& rhs )
int descriptorSize()
int descriptorType()
这是我的setup.py文件:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
libdir = ["/usr/include/", "/usr/local/lib"]
incdir = ["/usr/local/lib/", "/usr/include", "/usr/include/opencv2/core"]
ext_modules = [Extension("description",
["description.pyx"],
language="c++",
library_dirs=libdir,
include_dirs=incdir,
libraries=["opencv_features2d", "opencv_core"])]
setup(name="description", ext_modules=cythonize(ext_modules))
错误消息几乎为每个函数抛出错误(我只想访问FREAK构造函数)。希望你能帮帮我。
非常感谢, 利奥