Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not sure whether i understand your questions correctly. But if you are looking for a sample of matching SURF keypoints, a very simple and basic one is below, which is similar to template matching:</p> <pre><code>import cv2 import numpy as np # Load the images img =cv2.imread('messi4.jpg') # Convert them to grayscale imgg =cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # SURF extraction surf = cv2.SURF() kp, descritors = surf.detect(imgg,None,useProvidedKeypoints = False) # 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) # Now loading a template image and searching for similar keypoints template = cv2.imread('template.jpg') templateg= cv2.cvtColor(template,cv2.COLOR_BGR2GRAY) keys,desc = surf.detect(templateg,None,useProvidedKeypoints = False) for h,des in enumerate(desc): des = np.array(des,np.float32).reshape((1,128)) 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>Below are the results I got (copy pasted template image on original image using paint):</p> <p><img src="https://i.stack.imgur.com/quhvN.jpg" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/MEoXn.jpg" alt="enter image description here"></p> <p>As you can see, <strong>there are some small mistakes</strong>. But for a startup, hope it is OK.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload