[英]OpenCV wrong position off keypoints
I do not know what's wrong here, the points drawn from the function(cv2.drawMatchesKnn) are in a good position but points drawn from the loop are in a bad position. 我不知道这里出了什么问题,从函数(cv2.drawMatchesKnn)绘制的点处于良好位置,但从循环绘制的点处于不良位置。 In the picture you can see it well.
在图片中您可以很好地看到它。 I know that there may be a small shift but it completely misses them.
我知道可能会有一点变化,但是完全错过了他们。
if len(self.frame_kps) > 0:
if self.t_matcher == "flann":
matches = self.matcher.knnMatch(self.base_desc,self.frame_desc,k=2)
goodMatch=[]
good_without_list = []
for m,n in matches:
if(m.distance<matcher_dist*n.distance):
goodMatch.append([m])
good_without_list.append(n)
if(len(goodMatch)>=self.MIN_MATCH):
self.matches = cv2.drawMatchesKnn(self.base_gray,self.base_kps,gray,self.frame_kps,goodMatch,None,flags=2)
for g in good_without_list:
keyPoint = self.frame_kps[g.queryIdx]
(x1,y1) = keyPoint.pt
cv2.circle(self.matches, (int(x1),int(y1)), 4, (255, 0, 0), 1)
What is wrong here? 怎么了
https://i.stack.imgur.com/FIziK.png https://i.stack.imgur.com/FIziK.png
You will need to add the width of base_gray width to the x coordinates of frame_kps to get it right in the final display. 您需要将base_gray width的宽度添加到frame_kps的x坐标中,以使其在最终显示中正确显示。
This is because your the draw matches combines 2 images together which changes the final position of the points in display. 这是因为您的抽签匹配将2张图像合并在一起,从而更改了显示点的最终位置。
h, w = numpy.shape(self.base_gray)
for g in goodMatch:
keyPoint = self.frame_kps[g.trainIdx]
(x1,y1) = keyPoint.pt
x1 = x1 + w
cv2.circle(self.matches, (int(x1),int(y1)), 4, (255, 0, 0), 1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.