2017-11-03 14 views
0

私は2つの画像を持っています。特定の点については、2つの画像上の座標を知っていますが、どの点でそれらの点の間に線を描き、2つの画像と一致する線を示す図をプロットすることができますか?2つの画像の特定の点の間の線を描く

ここから実際にどこから始めたらいいかわかりませんでした。だから私はまだコードを表示していませんでした。この場合、matplotlibのメリットはありますか?

enter image description here

ありがとう:

EDITこれは私が(画像はhere、から取られる)期待していものの一例です。

+0

予想される結果を見てください** – RomanPerekhrest

+0

確かに、私は例を追加しました。 – Simplicity

+0

2つの画像を2つのサブプロットに表示することをお勧めします。 ['ConnectionPatch'](https://matplotlib.org/api/_as_gen/matplotlib.patches.ConnectionPatch.html#matplotlib.patches.ConnectionPatch)で接続します。あなたはそれを稼ぐことができない場合は、あなたが持っているすべての質問と一緒に行くとここに戻って来ることがあります。 – tom

答えて

0

あなたが探しているものは、あなたの例で直接関数を使用するだけです。一致するものが含まれているかどうかわからない場合は、サンプルを使用して調べることができます。

img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:20], flags=2,outImg = img1) 

私の完全なコード:あなたは、より新しいバージョンのPythonを使用している場合は、CV2の貢献度のバージョンを必要とする

if method is "ORB": 
     #Compute keypoints for both images 
     kp1,des1 = self.computeORB(img1) 
     kp2,des2 = self.computeORB(img2) 
     #=================================================================== 
     # for i,j in zip(kp1,kp2): 
     #  print("KP1:",i.pt) 
     #  print("KP2:",j.pt) 
     #=================================================================== 
     #use brute force matcher for matching descriptor1 and descriptor2 
     bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True) 
     # Match descriptors. 
     matches = bf.match(des1,des2) 

     # Sort them in the order of their distance. 
     matches = sorted(matches, key = lambda x:x.distance) 
     self.filterMatches(matches) 

     # Draw first 10 matches. 
     img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:20], flags=2,outImg = img1) 

     #show result 
     cv2.imshow("Matches",img3) 
     cv2.waitKey(0) 

def computeORB(self,img): 
    #Initiate ORB detector 
    orb = cv2.ORB_create() 

    #find keypoints 
    kp = orb.detect(img,None) 

    #compute despriptor 
    kp, des = orb.compute(img,kp) 
    # draw only keypoints location,not size and orientation 
    img2 = cv2.drawKeypoints(img, kp, None, color=(0,255,0), flags=0) 
    #plt.imshow(img2), plt.show() 

    return kp,des 

ノート。

+0

あなたの答えをありがとう。しかし、私は自分の仕事にOpenCVを使用しようとしていません。 – Simplicity

関連する問題