13

I am a beginner in openCV and am trying to execute a given piece of code.I am using Python 2.7 with OpenCV3.0.

The previous code was in an earlier version of OpenCV and so it had used KNearest which I modified as cv2.ml.KNearest_create() as suggested by this post OpenCV 3.0.0-beta missing KNN?

Now when I am trying to access the findnearest method, I am getting an error: cv2.ml.knearest object has no attribute find_nearest

Below is the code sample

model = cv2.ml.KNearest_create()

roi = dilate[by:by+bh,bx:bx+bw]
small_roi = cv2.resize(roi,(10,10))
feature = small_roi.reshape((1,100)).astype(np.float32)
ret,results,neigh,dist = model.find_nearest(feature,k=1)

Is there any change in the method name in OpenCV3.0?

Community
  • 1
  • 1
TheFallenOne
  • 1,598
  • 2
  • 23
  • 57

1 Answers1

19

I replaced the find_nearest with findNearest and it worked like a charm.

So I believe findNearest is the version of find_nearest in OpenCV3.0.

TheFallenOne
  • 1,598
  • 2
  • 23
  • 57