opencv3.0 the cv2 no this method
Closed this issue · 7 comments
File "/Users/telescopeman/project/simple-ocr-opencv/classification.py", line 47, in init
self.knn= cv2.KNearest()
AttributeError: 'module' object has no attribute 'KNearest'
Did you try the opencv3 branch?
On 25/03/16 04:30, guoyonggang178 wrote:
File
"/Users/telescopeman/project/simple-ocr-opencv/classification.py",
line 47, in init
self.knn= cv2.KNearest()
AttributeError: 'module' object has no attribute 'KNearest'—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#9
Did you get to try this?
I'm closing this, feel free to open another issue if you are still having problems
in OpenCV3, please use cv2.ml.KNearest_create() instead.
@Django-27 Isn't that already done in the branch? classification.py:46
Might not be the case at that time (2016) but now with a opencv 4 version, I got the issue cause condition is ==3
class KNNClassifier(Classifier):
def __init__(self, k=1, debug=False):
if get_opencv_version() == 3:
self.knn = cv2.ml.KNearest_create()
else:
self.knn = cv2.KNearest()
self.k = k
self.debug = debug
How to install OpenCV 4?