python 2.7 - matching error in ORB with opencv 3 -


currently working on opevcv python when use

    kp1 = orb.detect(img1,none)     kp2 = orb.detect(img2,none)     kp1, des1 = orb.compute(img1, kp1)     kp2, des2 = orb.compute(img2, kp2)     matches = matcher.match(des1, des2) 

i error matcher not defined

    matches = matcher.match(des1, des2)     nameerror: name 'matcher' not defined 

, using opencv 3.0.0 python 2.7, can tell me why getting error ?? can use matcher or not python ??

you need create matcher object first. complete example can found on opencv tutorials:

import numpy np import cv2 matplotlib import pyplot plt  img1 = cv2.imread('box.png',0)          # queryimage img2 = cv2.imread('box_in_scene.png',0) # trainimage  # initiate orb detector orb = cv2.orb()  # find keypoints , descriptors orb 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)  # sort them in order of distance. matches = sorted(matches, key = lambda x:x.distance)  # draw first 10 matches. img3 = cv2.drawmatches(img1,kp1,img2,kp2,matches[:10], flags=2)  plt.imshow(img3),plt.show() 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -