2
(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'

i am trying to follow the tutorial 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 OpenCV 3.0.0-beta missing KNN? i tried to replace KNearest with cv2.ml and cv2.ml but all i get is AttributeError: 'module' object has no attribute 'm1'

(i am using a raspberry pi and followed this tutorial to install open cv http://www.pyimagesearch.com/2015/10/26/how-to-install-opencv-3-on-raspbian-jessie/ subsequently i pip installed matplotlib)

Community
  • 1
  • 1
joe
  • 155
  • 1
  • 9

1 Answers1

4

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

But your code suggests you typed m1 (M and number 1), not ml (letters M and L, as in Machine Learning)

bakkal
  • 54,350
  • 12
  • 131
  • 107