刚刚从opencv-2.4.11升级,KNearest似乎缺失了
In [27]: import cv2
In [28]: print(cv2.__version__)
3.0.0-beta
In [29]: cv2.KNearest()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-29-d2ea29abad59> in <module>()
----> 1 cv2.KNearest()
AttributeError: 'module' object has no attribute 'KNearest'
In [30]: cv2.K
cv2.KAZE_DIFF_CHARBONNIER cv2.KAZE_DIFF_WEICKERT cv2.KMEANS_RANDOM_CENTERS cv2.KeyPoint
cv2.KAZE_DIFF_PM_G1 cv2.KAZE_create cv2.KMEANS_USE_INITIAL_LABELS cv2.KeyPoint_convert
cv2.KAZE_DIFF_PM_G2 cv2.KMEANS_PP_CENTERS cv2.KalmanFilter cv2.KeyPoint_overlap
答案 0 :(得分:36)
实际上,<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body></body>
已移至opencv3中的模块KNearest
,您必须致电cv2.ml
才能使用knn。
cv2.ml.KNearest_create()
有关详细信息,请运行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
。
享受:)
答案 1 :(得分:3)
许多模块已从OpenCV核心中删除并标记为非自由。这些模块具有单独的存储库,必须单独构建。
中找到了相关信息