OpenCV Python绑定脚本找不到基类
我目前正在为OpenCV 3.0创建一个模块,并试图使其在Python中工作。我想我发现了OpenCV如何创建Python绑定的问题,但我不知道解决这个问题的最佳方法是什么 我的问题如下: 我的模块文件夹中有两个类(标题位于OpenCV Python绑定脚本找不到基类,python,opencv,cmake,Python,Opencv,Cmake,我目前正在为OpenCV 3.0创建一个模块,并试图使其在Python中工作。我想我发现了OpenCV如何创建Python绑定的问题,但我不知道解决这个问题的最佳方法是什么 我的问题如下: 我的模块文件夹中有两个类(标题位于modules/xvideo/include/opencv2/xvideo),它们是:parentClass.hpp和childClass.hpp。当然ChildClass继承自ParentClass(名称仅为示例)。但是脚本gen2.py(位于modules/python/
modules/xvideo/include/opencv2/xvideo
),它们是:parentClass.hpp
和childClass.hpp
。当然ChildClass
继承自ParentClass
(名称仅为示例)。但是脚本gen2.py
(位于modules/python/src2
中)试图在ParentClass
之前创建ChildClass
,结果出现错误:
Generator error: unable to resolve base xvideo_ParentClass for xvideo_ChildClass
这似乎是因为类是按照脚本的gen
函数中变量srcfiles
的给定顺序生成的:
def gen(self, srcfiles, output_path):
self.clear()
self.parser = hdr_parser.CppHeaderParser()
# step 1: scan the headers and build more descriptive maps of classes, consts, functions
#print(srcfiles) ##matthieu
for hdr in srcfiles:
decls = self.parser.parse(hdr)
if len(decls) == 0:
#print(hdr + '0') ##matthieu
continue
#else: ##matthieu
#print(hdr) ##matthieu
self.code_include.write( '#include "{0}"\n'.format(hdr[hdr.rindex('opencv2/'):]) )
for decl in decls:
name = decl[0]
if name.startswith("struct") or name.startswith("class"):
# class/struct
p = name.find(" ")
stype = name[:p]
name = name[p+1:].strip()
self.add_class(stype, name, decl)
...
所以我去上游寻找这个列表是如何创建的。该列表似乎是每个模块的子列表的串联,其中每个子列表由第626行的CMake文件CMake/OpenCVModule.CMake
创建:
file(GLOB lib_hdrs
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h"
)
但是你可能知道文件(GLOB)
有一个。这就是为什么我的子类在该列表中位于父类之前,并最终引发了一个错误
所以我想问的是,是否有人知道绕过这个问题的最佳方法?
有没有办法把自己列在名单上?还是我只是忘了写点什么?请告诉我^^如果您想问这个问题,它的维护者(mshabunin)可能会找到更好的机会it@berak,谢谢,我会的。