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

猜你喜欢

转载自blog.csdn.net/weixin_51229250/article/details/121961858