title: Input samples must be floating-point matrix in function CvKNearest::find_nearest
body: <p>I am trying to execute the code from this <a href="https://stackoverflow.com/questions/13379909/compare-similarity-of-images-using-opencv-with-python?lq=1">URL</a></p>
  
  <p>However, I started getting this error:</p>
  
  <pre><code>error: ..\..\..\..\opencv\modules\ml\src\knearest.cpp:370: error: (-5) Input samples must be floating-point matrix (&lt;num_samples&gt;x&lt;var_count&gt;) in function CvKNearest::find_nearest
  </code></pre>
  
  <p>I have not made any major changes though. But will paste what I did:</p>
  
  <pre><code>import scipy as sp
  import numpy as np
  import cv2
  
  # Load the images
  img =cv2.imread("image1.png")
  
  # Convert them to grayscale
  imgg =cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  
  # SURF extraction
  surf = cv2.FeatureDetector_create("SURF")
  surfDescriptorExtractor = cv2.DescriptorExtractor_create("SURF")
  kp = surf.detect(imgg)
  kp, descritors = surfDescriptorExtractor.compute(imgg,kp)
  
  # Setting up samples and responses for kNN
  samples = np.array(descritors)
  responses = np.arange(len(kp),dtype = np.float32)
  
  
  # kNN training
  knn = cv2.KNearest()
  knn.train(samples,responses)
  
  modelImages = ["image2.png"]
  
  
  for modelImage in modelImages:
  
      # Now loading a template image and searching for similar keypoints
      template = cv2.imread(modelImage)
      templateg= cv2.cvtColor(template,cv2.COLOR_BGR2GRAY)
      keys = surf.detect(templateg)
  
      keys,desc = surfDescriptorExtractor.compute(templateg, keys)
  
      for h,des in enumerate(desc):
          #debug
          print(des.shape)
          des = np.array(des,np.float32).reshape(64L)
          retval, results, neigh_resp, dists = knn.find_nearest(des,1)
          res,dist =  int(results[0][0]),dists[0][0]
  
          if dist&lt;0.1: # draw matched keypoints in red color
              color = (0,0,255)
  
          else:  # draw unmatched in blue color
              #print dist
              color = (255,0,0)
  
          #Draw matched key points on original image
          x,y = kp[res].pt
          center = (int(x),int(y))
          cv2.circle(img,center,2,color,-1)
  
          #Draw matched key points on template image
          x,y = keys[h].pt
          center = (int(x),int(y))
          cv2.circle(template,center,2,color,-1)
  
  
  
      cv2.imshow('img',img)
      cv2.imshow('tm',template)
      cv2.waitKey(0)
      cv2.destroyAllWindows()
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>Thanks in advance!</p>