如何使用OpenCV匹配拼接成功后获取图像坐标

问题描述 投票:0回答:0

早上好!

我正在尝试获取使用 ORB 成功匹配并使用 cv2.warpPerspective 拼接在一起的两个图像的坐标(角的 x,y)。

我已经通过计算两个 ORB 匹配对的单应性(cv2.findHomography)来尝试这个。

然而,在缝合这些图像后,我正在努力获取每个图像角的坐标。

任何帮助都会很棒。

R

这是我目前正在运行的代码,但我很茫然。甚至不确定这是正确的方法

matchess = np.asarray(good)
                    
            if len(good)>500: # the number here is the number of matches deemed good
                          
                src_pts = np.float32([kp1[m.queryIdx].pt for m in matchess[:,0] ]).reshape(-1,1,2)
                dst_pts = np.float32([kp2[m.trainIdx].pt for m in matchess[:,0] ]).reshape(-1,1,2)
                H, masked = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0)
                
                pts = np.float32([[0,0],[0,-1],[-1,-1],[-1,0]]).reshape(-1,1,2)
                
                dst = cv2.perspectiveTransform(pts,H)
                    
              
                dst = cv2.warpPerspective(img1,H,(img2.shape[1] + img1.shape[1], img2.shape[0])) #wraped image
                
                print("dst 1:", dst)
                
                
                dst[0:img2.shape[0], 0:img2.shape[1]] = img2 #stitched image
                
       
                print("dst 2:",dst)
opencv transform image-stitching
© www.soinside.com 2019 - 2024. All rights reserved.