Get pixel coordinates from Brute Force Matching in OpenCV Python -


i pixel coordinates of query , train image using opencv in python.

the code is:

import numpy np import cv2  img1 = cv2.imread('qimg.png',0)          # queryimage img2 = cv2.imread('timg.png',0)          # trainimage  # initiate sift detector orb = cv2.orb()  # find keypoints , descriptors sift kp1, des1 = orb.detectandcompute(img1,none) kp2, des2 = orb.detectandcompute(img2,none)  # create bfmatcher object bf = cv2.bfmatcher(cv2.norm_hamming, crosscheck=true)  # match descriptors. matches = bf.match(des1,des2) 

i want pixel coordinates each dmatch object.

how do that?

you can using commands:

src_pts = np.float32([ kp1[m.queryidx].pt m in matches ]).reshape(-1,1,2) dst_pts = np.float32([ kp2[m.trainidx].pt m in matches ]).reshape(-1,1,2) 

where

  • m.trainidx - index of descriptor in train descriptors and
  • m.queryidx - index of descriptor in query descriptors

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -