IMFNet
IMFNet copied to clipboard
I've got some problem understanding the code in transform_estimation.py
def est_quad_linear_robust(pts0, pts1, weight=None): pts0_curr = pts0 trans = torch.eye(4)
par = 1.0 if weight is None: weight = torch.ones(pts0.size()[0], 1)
for i in range(20): if i > 0 and i % 5 == 0: par /= 2.0
A, b = build_linear_system(pts0_curr, pts1, weight) x = solve_linear_system(A, b) trans_curr = get_trans(x) pts0_curr = update_pcd(pts0_curr, trans_curr) weight = compute_weights(pts0_curr, pts1, par) trans = trans_curr.mm(trans)return trans
As shown above, I couldn't get the point why we can attain the transformation matrix by iteration. The code of solve_linear system seems to be complicated. Can someone help me solve my confusion?
def build_linear_system(pts0, pts1, weight): npts0 = pts0.shape[0] A0 = torch.zeros((npts0, 6)) A1 = torch.zeros((npts0, 6)) A2 = torch.zeros((npts0, 6)) A0[:, 1] = pts0[:, 2] A0[:, 2] = -pts0[:, 1] A0[:, 3] = 1 A1[:, 0] = -pts0[:, 2] A1[:, 2] = pts0[:, 0] A1[:, 4] = 1 A2[:, 0] = pts0[:, 1] A2[:, 1] = -pts0[:, 0] A2[:, 5] = 1 ww1 = weight.repeat(3, 6) ww2 = weight.repeat(3, 1) A = ww1 * torch.cat((A0, A1, A2), 0) b = ww2 * torch.cat( (pts1[:, 0] - pts0[:, 0], pts1[:, 1] - pts0[:, 1], pts1[:, 2] - pts0[:, 2]), 0, ).unsqueeze(1) return A, b
def solve_linear_system(A, b): temp = torch.inverse(A.t().mm(A)) return temp.mm(A.t()).mm(b)