Ask Your Question
0

How can I solve this problem? module 'cv2.cv2' has no attribute 'SURF'

asked 2020-11-28 13:48:49 -0600

Fred Yang gravatar image

I run "surf=cv2.SURF(hessian)' in Python, and got AttributeError: module 'cv2.cv2' has no attribute 'SURF'.

how can I solve?

Thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-11-28 14:02:25 -0600

berak gravatar image

updated 2020-11-30 03:19:02 -0600

you probably installed cv2 via pip, which does not contain any nonfree modules (SURF is still patented).

the only way to get cv2.xfeatures.SURF running is to build from src with the contrib modules and the OPENCV_ENABLE_NONFREE cmake flag set.

then, your code is simply wrong / outdated, you would have to invoke it like:

surf = cv2.xfeatures2d.SURF_create(500)

[edit]

besides, the SIFT patent expired, so from opencv4.4.0 or 3.4.11 on you can use cv2.features2d.SIFT_create() as a good alternative to SURF

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-11-28 13:48:49 -0600

Seen: 21,551 times

Last updated: Nov 30 '20