AttributeError: module ‘cv2’ has no attribute ‘SIFT’
When encountering this problem, most netizens suggest to add a package, that is, PIP install opencv contrib python.
I made the following error again after completing the repair:
opencv (3.4.3) C:: <projects/opencv Python/opencv_ contrib\modules\xfeatures2d\src\sift. cpp:1207 : error: (- 213: the function/feature is not implemented) this algorithm is patented and is excluded in this configuration; Set OPENCV_ ENABLE_ Nonfree cmake option and rebuild the library in function ‘CV:: xfeatures2d:: sift:: create’
it can be solved by backing the opencv version to 3.4.2, unloading the previous package ( PIP install opencv Python
), and then
PIP install opencv python = = 3.4.2.16
PIP install opencv contrib python = = 3.4.2.16
note that the above two commands = = no spaces are left and right
Error again:
‘module’ object has no attribute ‘xfeatures2d’
Reason: opencv integrates sift and other algorithms into xfeatures 2D set
siftDetector=cv2.SIFT()
Changed to
siftDetector= cv2.xfeatures2d.SIFT_create()
then report another error:
TypeError: Required argument ‘outImage’ (pos 3) not found
im=cv2.drawKeypoints(img_RGB,kp,flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
change to im=cv2.drawKeypoints(img_RGB,kp,img,flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
SURF:
import cv2
img = cv2.imread(‘cat.jpg’)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
surf = cv2.xfeatures2d.SURF_create()
kp = surf.detect(gray, None)
img = cv2.drawKeypoints(gray, kp, img)
cv2.imshow(“img”, img)
k = cv2.waitKey(0)
if k & 0xff == 27:
cv2.destroyAllWindows()
Similar Posts:
- [Solved] Opencv3.4.0 Install error: fatal error: opencv2/xfeatures2d/cuda.hpp: No such file or directory
- Consider using the `–user` option or check the permissions.
- Opencv learning notes 05 face detection and recognition attributeerror: module ‘CV2’ has no attribute ‘face’
- MAC OS Install opencv ModuleNotFoundError: No module named ‘cv2’
- Error reporting in Ubuntu apt get upgrade [How to Solve]
- [Solved] Lego-loam Error: opencv fatal error: cv.h: No such file or directory
- Problem solved successfully in Python: attributeerror: ‘module’ object has no attribute ‘loadimage‘
- How to Solve Opencv error: assertion failed + error: (- 215)
- [record a problem] Linux + opencv + cuvid decodes 1080p video. When using CUDA kernel function, it will crash
- No matching function call to ‘pthread_create’ [How to Solve]