sift_image.py 文件源码

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

项目:ocular 作者: wolfd 项目源码 文件源码
def correspondences(self, other):
        # find corresponding points in the input image and the template image
        bf = cv2.BFMatcher()
        matches = bf.knnMatch(self.des, other.des, k=2)

        # Apply Lowe Ratio Test to the keypoints
        # this should weed out unsure matches
        good_keypoints = []
        for m, n in matches:
            if m.distance < self.good_thresh * n.distance:
                good_keypoints.append(m)

        if DEBUG_SIFT:
            draw_matches(
                self.image, self.kp,
                other.image, other.kp,
                good_keypoints[-50:]
            )

        # put keypoints from own image in self_pts
        # transform the keypoint data into arrays for homography check
        # grab precomputed points
        self_pts = np.float32(
            [self.kp[m.queryIdx].pt for m in good_keypoints]
        ).reshape(-1, 2)

        # put corresponding keypoints from other image in other_pts
        other_pts = np.float32(
            [other.kp[m.trainIdx].pt for m in good_keypoints]
        ).reshape(-1, 2)

        return (self_pts, other_pts)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号