AttributeError:'module'对象没有属性'm1'

时间:2016-05-04 16:35:47

标签: python opencv ocr opencv3.0 knn

(cv) pi@raspberrypi:~/Desktop $ python pntc6.py
Traceback (most recent call last):
File "pntc6.py", line 24, in <module>
knn = cv2.m1.KNearest_create()
AttributeError: 'module' object has no attribute 'm1'

我正在尝试按照教程http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_ml/py_knn/py_knn_opencv/py_knn_opencv.html解决此问题OpenCV 3.0.0-beta missing KNN? 我尝试将KNearest替换为cv2.mlcv2.ml,但我得到的只是AttributeError: 'module' object has no attribute 'm1'

(我正在使用覆盆子pi并按照本教程安装open cv http://www.pyimagesearch.com/2015/10/26/how-to-install-opencv-3-on-raspbian-jessie/随后我pip安装了matplotlib)

1 个答案:

答案 0 :(得分:4)

  

我尝试用cv2.ml和cv2.ml替换KNearest但我得到的只是AttributeError:'module'对象没有属性'm1'

knn = cv2.m1.KNearest_create()
           ^
           |__ this needs to be ml, not m1

但是您的代码建议您键入m1(M和数字1),而不是ml(字母M和L,如机器学习中所示)