module 'cv2' has no attribute 'SURF_create'
时间: 2023-09-10 08:14:14 浏览: 169
This error occurs because the SURF (Speeded Up Robust Features) algorithm is not included in the default installation of OpenCV 4. It has been patented and is not free for commercial use. SIFT (Scale-Invariant Feature Transform) is another feature detection algorithm that is also patented and not included in OpenCV 4.
To use SURF or SIFT, you need to install the opencv-contrib-python package. You can do this using pip:
```
pip install opencv-contrib-python
```
Then, you can import SURF or SIFT from the cv2 module:
```
import cv2
# create SURF object
surf = cv2.xfeatures2d.SURF_create()
# create SIFT object
sift = cv2.xfeatures2d.SIFT_create()
```
Note that the xfeatures2d module contains the non-free feature detection algorithms, including SURF and SIFT.
阅读全文