'function' object has no attribute 'LBPHFaceRecognizer_create'
时间: 2023-04-03 09:04:05 浏览: 220
这个问题可能是关于编程的,我可以回答。这个错误可能是因为你没有正确导入OpenCV库。你需要确保你已经正确安装了OpenCV,并且在代码中正确导入了它。你可以尝试使用以下代码导入OpenCV库:
import cv2
如果你已经正确导入了OpenCV库,但仍然遇到这个错误,你可以尝试使用以下代码创建LBPHFaceRecognizer对象:
recognizer = cv2.face.LBPHFaceRecognizer_create()
希望这可以帮助你解决问题。
相关问题
AttributeError: 'function' object has no attribute 'SURF_create'
This error occurs when you try to call the `SURF_create` function on a regular function object, rather than on an instance of the `cv2.xfeatures2d.SURF` class.
To fix this error, you need to create an instance of the `SURF` class first, and then call the `SURF_create` method on that instance. Here's an example:
```
import cv2
# create an instance of the SURF class
surf = cv2.xfeatures2d.SURF_create()
# call the SURF_create method on the instance
surf_keypoints, surf_descriptors = surf.detectAndCompute(image, None)
```
In this example, `surf_keypoints` and `surf_descriptors` are the output of the `detectAndCompute` method, which uses the SURF feature detector to extract keypoints and descriptors from an image.
AttributeError: 'function' object has no attribute 'SIFT_create'怎么改
这个错误通常是因为你使用的是OpenCV 4.x版本,而在该版本中,`SIFT_create`已经被移除了。你可以尝试使用以下代码来创建SIFT对象:
```
sift = cv2.xfeatures2d.SIFT_create()
```
如果你仍然收到类似的错误,请确保你已经正确安装了OpenCV-contrib模块。你可以使用以下命令安装:
```
pip install opencv-contrib-python
```
阅读全文