将模块从opencv_contrib添加到OpenCV [英] Adding modules from opencv_contrib to OpenCV

查看:206
本文介绍了将模块从opencv_contrib添加到OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将xfeatures2d模块从opencv_contrib添加到现有的OpenCV/Python项目中.

I'm trying to add the xfeatures2d module from opencv_contrib to an existing OpenCV/Python project.

我已经从 repo 下载了该模块的最新版本,并再次使用以下是其他参数:

I've downloaded the latest version of the module from the repo, and built OpenCV again with the following additional params:

OPENCV_EXTRA_MODULES_PATH=/path/to/opencv_contrib-master/modules
BUILD_opencv_xfeatures2d=ON

摘录自构建日志:

-- Installing: /usr/local/lib/python2.7/site-packages/cv2.so
-- Installing: /usr/local/lib/python3.4/site-packages/cv2.so
-- Installing: /usr/local/lib/libopencv_xfeatures2d.3.0.0.dylib

看来新模块已正确安装.我可以在两个Python版本中导入cv2.但是,它们都无法识别该模块应该添加的新功能.

It appears the new module is installed correctly. I'm able to import cv2 in both Python versions. However neither recognise the new features the module is supposed to add.

>>> cv2.SURF()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SURF'
>>> cv2.xfeatures2d.SURF()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'xfeatures2d'

推荐答案

我遇到了同样的问题.我正在将python 2.7.6和OpenCv 3.0与其他非免费模块一起使用.我确实在可用模块中存在xfeatures2d并可以导入它,但是好像xfeatures2d不包含SIFT或SURF.不管我怎么称呼它都是相同的错误:

I encountered this same issue. I'm using python 2.7.6 and OpenCv 3.0 with the additional non-free modules. I do have xfeatures2d present in available modules and can import it, however it was as though xfeatures2d didn't contain SIFT or SURF. No matter how I called them it was the same Error:

"AttributeError:模块"对象没有属性"SIFT"

"AttributeError: 'module' object has no attribute 'SIFT'

我尝试了建议的不同名称空间,直到最近才注意到此详细信息,并且开始工作!

I tried the different name spaces suggested, and only recently noticed this detail and GOT IT WORKING!

$ python

$ python

>>>导入cv2

>>>帮助(cv2.xfeatures2d)

>>>help(cv2.xfeatures2d)

您会注意到它答复称它现在被称为...

You'll notice that it replies that it is now referred to as...

功能

SIFT_create(...)

SURF_create(...)

非常简单-名称空间是"cv2.SIFT()"或"cv2.xfeatures2d.SIFT",而是

So very simply - the namespace is NOT "cv2.SIFT()" or "cv2.xfeatures2d.SIFT" but rather

cv2.xfeatures2d.SIFT_create()

请尝试一下!

这篇关于将模块从opencv_contrib添加到OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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