def draw_matches(self, im1, pos1, im2, pos2, matches, filename="matches.jpg"):
self._log("drawing matches into '%s'..." % filename)
row1, col1 = im1.shape
row2, col2 = im2.shape
im_out = np.zeros((max(row1, row2), col1+col2, 3), dtype=np.uint8)
im_out[:row1, :col1] = np.dstack([im1]*3)
im_out[:row2, col1:] = np.dstack([im2]*3)
l = len(matches)
for ind, (i, j, d) in list(enumerate(matches))[::-1]:
d /= para.descr_match_threshold # map to [0, 1]
_pos1, _pos2 = pos1[i], pos2[j]
color = hsv_to_rgb(int(d * 120 - 120), 1, 1 - d / 3)
color = [int(c * 255) for c in color]
cv2.line(im_out, (_pos1[1], _pos1[0]), (_pos2[1]+col1, _pos2[0]), color, 1)
cv2.imwrite(filename, im_out)
##########################
# Utility
##########################
评论列表
文章目录