title: How would I use Orb detector with image homography?
body: <p>I'm wanting to use orb detectors to draw a bounding box around a found image, similarly to the example here, which is using sift detectors: <a href="https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_feature_homography/py_feature_homography.html" rel="noreferrer">SIFT Refrence</a></p>
  
  <p>The Linked example uses a FlannBasedMatcher. My Code uses a BFMatcher. I have no preference in the Matcher used.</p>
  
  <pre><code>        MIN_MATCH_COUNT = 10
  
          img1 = cv2.imread('box.png',0)
          img2 = cv2.imread('box_in_scene.png',0)
  
          orb = cv2.ORB_create()
  
          kp1, des1 = orb.detectAndCompute(img1,None)
          kp2, des2 = orb.detectAndCompute(img2,None)
  
          bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
          matches = bf.match(des1,des2)
  </code></pre>
  
  <p>How would I continue this code to use homography to draw around the box_in_scene image?</p>
  
  <p><strong>EDIT:</strong> I tried the following, but the output wasn't as expected.</p>
  
  <pre><code>src_pts = np.float32([ kp1[m.queryIdx].pt for m in matches[:50] ]).reshape(-1,1,2)
  dst_pts = np.float32([ kp2[m.trainIdx].pt for m in matches[:50] ]).reshape(-1,1,2)
  M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)
  matchesMask = mask.ravel().tolist()
  h,w = img1.shape
  pts = np.float32([ [0,0],[0,h-1],[w-1,h-1],[w-1,0] ]).reshape(-1,1,2)
  dst = cv2.perspectiveTransform(pts,M)
  </code></pre>