AttributeError: 'module' object has no attribute 'm1'

AttributeError: 'module' object has no attribute 'm1'

(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 and had this problem 我试图用 cv2.mlcv2.ml 替换 KNearest 但我得到的只是 AttributeError: 'module' object has no attribute 'm1'

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

I tried to replace KNearest with cv2.ml and cv2.ml but all i get is AttributeError: 'module' object has no attribute 'm1'

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

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