normalized_transforms.py 文件源码

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

项目:mrflow 作者: jswulff 项目源码 文件源码
def old_get_fundamental_mat_normalized(p1,p2,use_ransac=False):
    """
    A small wrapper around cv2.getFundamentalMat, with normalization of
    point locations.

    """
    mu1 = p1.mean(axis=0)
    std1 = p1.std(axis=0)
    mu2 = p2.mean(axis=0)
    std2 = p2.std(axis=0)

    p1_ = (p1 - mu1) / std1
    p2_ = (p2 - mu2) / std2

    if use_ransac:
        F_, inliers = cv2.findFundamentalMat(p1_,p2_,method=cv2.FM_RANSAC,param1=4 * 2.0/(std1+std2).mean())
    else:
        F_,inliers = cv2.findFundamentalMat(p1_,p2_,method=cv2.FM_LMEDS)
    A1 = np.array([[1.0/std1[0], 0.0, -mu1[0]/std1[0]],
                   [0, 1.0/std1[1], -mu1[1]/std1[1]],
                   [0,0,1.0]])
    A2 = np.array([[1.0/std2[0], 0.0, -mu2[0]/std2[0]],
                   [0, 1.0/std2[1], -mu2[1]/std2[1]],
                   [0,0,1.0]])
    F = A2.T.dot(F_).dot(A1)
    #F = A2inv.dot(H_).dot(A1)
    return F,inliers


#
# Normalization functions
#
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号