AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d'
kayleeliyx opened this issue · comments
## Flow ##
Sampled 522 frame pairs.
Resizing flow to (224, 384)
Traceback (most recent call last):
File "main.py", line 20, in <module>
dp.process()
File "/home/ubuntu/Downloads/cvd2/process.py", line 234, in process
return self.pipeline()
File "/home/ubuntu/Downloads/cvd2/process.py", line 171, in pipeline
self.compute_flow()
File "/home/ubuntu/Downloads/cvd2/process.py", line 135, in compute_flow
self.flow.compute_flow(frame_pairs, self.params.flow_model)
File "/home/ubuntu/Downloads/cvd2/flow.py", line 124, in compute_flow
optical_flow_homography.process(args)
File "/home/ubuntu/Downloads/cvd2/optical_flow_homography.py", line 269, in process
flow = infer(args, OFlowModel, DEVICE, im1, im2)
File "/home/ubuntu/Downloads/cvd2/optical_flow_homography.py", line 177, in infer
img1, img2, img2_reg, H_BA = getimage(img1_name, img2_name)
File "/home/ubuntu/Downloads/cvd2/optical_flow_homography.py", line 149, in getimage
(kpsA, featuresA) = detectAndDescribe(frame1)
File "/home/ubuntu/Downloads/cvd2/optical_flow_homography.py", line 69, in detectAndDescribe
descriptor = cv2.xfeatures2d.SURF_create()
AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d'
>>> import cv2
>>> print(cv2.__version__)
4.5.2
>>> cv2.xfeatures2d.SURF_create()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d'
Personally, I found that this works for me:
pip install opencv-python==3.4.2.17
pip install opencv-contrib-python==3.4.2.17
Thank you for letting us know the solution!