AttributeError: module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘解决方法

运行一段关于图像拼接的代码时,出现问题 AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d'

def __init__(self):
	self.surf = cv2.xfeatures2d.SURF_create()
	FLANN_INDEX_KDTREE = 0
	index_params = dict(algorithm=0, trees=5)
	search_params = dict(checks=50)
	self.flann = cv2.FlannBasedMatcher(index_params, search_params)

查找资料发现 'xfeatures2d'只有在opencv-contrib中才有,解决方法:

pip install opencv-contrib-python

AttributeError: module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘解决方法_第1张图片

 

你可能感兴趣的:(Python,深度学习,pytorch,python)