model.py
def estimate_t(self, p0, p1, maxiter=5, xtol=1.0e-7, p0_zero_mean=True, p1_zero_mean=True):
        """
        give two point clouds, estimate the T by using IC algorithm
        :param p0: point cloud
        :param p1: point cloud
        :param maxiter: maximum iteration
        :param xtol: a threshold for early stop of transformation estimation
        :param p0_zero_mean: True: normanize p0 before IC algorithm
        :param p1_zero_mean: True: normanize p1 before IC algorithm
        :return: feature-metric projection error (r), encoder-decoder loss (loss_ende)
        """
        a0 = torch.eye(4).view(1, 4, 4).expand(p0.size(0), 4, 4).to(p0)  # [B, 4, 4]
        a1 = torch.eye(4).view(1, 4, 4).expand(p1.size(0), 4, 4).to(p1)  # [B, 4, 4]
        # normalization
        if p0_zero_mean:
            p0_m = p0.mean(dim=1)  # [B, N, 3] -> [B, 3]
            a0 = a0.clone()
            a0[:, 0:3, 3] = p0_m
            q0 = p0 - p0_m.unsqueeze(1)
        else:
            q0 = p0
        if p1_zero_mean:
            p1_m = p1.mean(dim=1)  # [B, N, 3] -> [B, 3]
            a1 = a1.clone()
            a1[:, 0:3, 3] = -p1_m
            q1 = p1 - p1_m.unsqueeze(1)
        else:
            q1 = p1

        # use IC algorithm to estimate the transformation
        g0 = torch.eye(4).to(q0).view(1, 4, 4).expand(q0.size(0), 4, 4).contiguous()
        r, g, loss_ende = self.ic_algo(g0, q0, q1, maxiter, xtol, is_test=self.isTest)
        self.g = g

        # re-normalization
        if p0_zero_mean or p1_zero_mean:
            # output' = trans(p0_m) * output * trans(-p1_m)
            #        = [I, p0_m;] * [R, t;] * [I, -p1_m;]
            #          [0, 1    ]   [0, 1 ]   [0,  1    ]
            est_g = self.g
            if p0_zero_mean:
                est_g = a0.to(est_g).bmm(est_g)
            if p1_zero_mean:
                est_g = est_g.bmm(a1.to(est_g))
            self.g = est_g

            est_gs = self.g_series  # [M, B, 4, 4]
            if p0_zero_mean:
                est_gs = a0.unsqueeze(0).contiguous().to(est_gs).matmul(est_gs)
            if p1_zero_mean:
                est_gs = est_gs.matmul(a1.unsqueeze(0).contiguous().to(est_gs))
            self.g_series = est_gs

        return r, loss_ende

        give two point clouds, estimate the T by using IC algorithm
        :param p0: point cloud
        :param p1: point cloud
        :param maxiter: maximum iteration
        :param xtol: a threshold for early stop of transformation estimation
        :param p0_zero_mean: True: normanize p0 before IC algorithm
        :param p1_zero_mean: True: normanize p1 before IC algorithm
        :return: feature-metric projection error (r), encoder-decoder loss (loss_ende)
        
give two point clouds, estimate the T by using IC algorithm
give two point clouds estimate the T by using IC algorithm
def estimate_t(self, p0, p1, maxiter=5, xtol=1.0e-7, p0_zero_mean=True, p1_zero_mean=True):
        a0 = torch.eye(4).view(1, 4, 4).expand(p0.size(0), 4, 4).to(p0)  
        a1 = torch.eye(4).view(1, 4, 4).expand(p1.size(0), 4, 4).to(p1)  
        if p0_zero_mean:
            p0_m = p0.mean(dim=1)  
            a0 = a0.clone()
            a0[:, 0:3, 3] = p0_m
            q0 = p0 - p0_m.unsqueeze(1)
        else:
            q0 = p0
        if p1_zero_mean:
            p1_m = p1.mean(dim=1)  
            a1 = a1.clone()
            a1[:, 0:3, 3] = -p1_m
            q1 = p1 - p1_m.unsqueeze(1)
        else:
            q1 = p1
        g0 = torch.eye(4).to(q0).view(1, 4, 4).expand(q0.size(0), 4, 4).contiguous()
        r, g, loss_ende = self.ic_algo(g0, q0, q1, maxiter, xtol, is_test=self.isTest)
        self.g = g
        if p0_zero_mean or p1_zero_mean:
            est_g = self.g
            if p0_zero_mean:
                est_g = a0.to(est_g).bmm(est_g)
            if p1_zero_mean:
                est_g = est_g.bmm(a1.to(est_g))
            self.g = est_g
            est_gs = self.g_series  
            if p0_zero_mean:
                est_gs = a0.unsqueeze(0).contiguous().to(est_gs).matmul(est_gs)
            if p1_zero_mean:
                est_gs = est_gs.matmul(a1.unsqueeze(0).contiguous().to(est_gs))
            self.g_series = est_gs
        return r, loss_ende
def estimate_t ( self , p0 , p1 , maxiter = 5 , xtol = 1.0e-7 , p0_zero_mean = True , p1_zero_mean = True ) : a0 = torch . eye ( 4 ) . view ( 1 , 4 , 4 ) . expand ( p0 . size ( 0 ) , 4 , 4 ) . to ( p0 ) a1 = torch . eye ( 4 ) . view ( 1 , 4 , 4 ) . expand ( p1 . size ( 0 ) , 4 , 4 ) . to ( p1 ) if p0_zero_mean : p0_m = p0 . mean ( dim = 1 ) a0 = a0 . clone ( ) a0 [ : , 0 : 3 , 3 ] = p0_m q0 = p0 - p0_m . unsqueeze ( 1 ) else : q0 = p0 if p1_zero_mean : p1_m = p1 . mean ( dim = 1 ) a1 = a1 . clone ( ) a1 [ : , 0 : 3 , 3 ] = - p1_m q1 = p1 - p1_m . unsqueeze ( 1 ) else : q1 = p1 g0 = torch . eye ( 4 ) . to ( q0 ) . view ( 1 , 4 , 4 ) . expand ( q0 . size ( 0 ) , 4 , 4 ) . contiguous ( ) r , g , loss_ende = self . ic_algo ( g0 , q0 , q1 , maxiter , xtol , is_test = self . isTest ) self . g = g if p0_zero_mean or p1_zero_mean : est_g = self . g if p0_zero_mean : est_g = a0 . to ( est_g ) . bmm ( est_g ) if p1_zero_mean : est_g = est_g . bmm ( a1 . to ( est_g ) ) self . g = est_g est_gs = self . g_series if p0_zero_mean : est_gs = a0 . unsqueeze ( 0 ) . contiguous ( ) . to ( est_gs ) . matmul ( est_gs ) if p1_zero_mean : est_gs = est_gs . matmul ( a1 . unsqueeze ( 0 ) . contiguous ( ) . to ( est_gs ) ) self . g_series = est_gs return r , loss_ende
give two point clouds, estimate the T by using IC algorithm
give two point clouds estimate the T by using IC algorithm
"""
        give two point clouds, estimate the T by using IC algorithm
        :param p0: point cloud
        :param p1: point cloud
        :param maxiter: maximum iteration
        :param xtol: a threshold for early stop of transformation estimation
        :param p0_zero_mean: True: normanize p0 before IC algorithm
        :param p1_zero_mean: True: normanize p1 before IC algorithm
        :return: feature-metric projection error (r), encoder-decoder loss (loss_ende)
        """ # [B, 4, 4] # [B, 4, 4] # normalization # [B, N, 3] -> [B, 3] # [B, N, 3] -> [B, 3] # use IC algorithm to estimate the transformation # re-normalization # output' = trans(p0_m) * output * trans(-p1_m) #        = [I, p0_m;] * [R, t;] * [I, -p1_m;] #          [0, 1    ]   [0, 1 ]   [0,  1    ] # [M, B, 4, 4]
feature-metric projection error (r), encoder-decoder loss (loss_ende)
feature - metric projection error ( r ) encoder - decoder loss ( loss_ende )
self
p0
None
p1
None
maxiter
None
xtol
a threshold for early stop of transformation estimation
a threshold for early stop of transformation estimation
p0_zero_mean
normanize p0 before IC algorithm
normanize p0 before IC algorithm
p1_zero_mean
normanize p1 before IC algorithm
normanize p1 before IC algorithm