In fact, KNearest been moved to the cv2.ml module in opencv3, and you have to call cv2.ml.KNearest_create() to use knn.
In [1]: import cv2 In [2]: cv2.__version__ Out[2]: '3.0.0' In [3]: cv2.ml.KNea cv2.ml.KNearest_BRUTE_FORCE cv2.ml.KNearest_create cv2.ml.KNearest_KDTREE In [3]: cv2.ml.KNearest_create
For more information, run help(cv2.ml.KNearest_create()) .
Enjoy :)
source share