sift.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:AlphaLogo 作者: gigaflw 项目源码 文件源码
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
    ##########################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号