Example #1
0
 def forward(self, theta, P, R_gt, t_gt, C_gt):
     if self.gamma > 0.0:
         R = geo.angle_axis_to_rotation_matrix(theta[..., :3])
         t = theta[..., 3:]
         losses = torch.cat((
             correspondenceLoss(P, C_gt).view(1),
             rotationLoss(R, R_gt).view(1), # [0, pi]
             translationLoss(t, t_gt).view(1), # [0, inf)
             ))
         loss = losses[0] + self.gamma * (losses[1] + losses[2])
     else:
         losses = correspondenceLoss(P, C_gt).view(1)
         loss = losses[0]
     return loss, losses
Example #2
0
 def forward(self, theta, P, R_gt, t_gt, C_gt, p2d, p3d, num_points_2d, num_points_3d):
     # Weight proportionally to the point-set size:
     b, m, n = P.size()
     weights = torch.min(num_points_2d, num_points_3d).float() / float(min(m, n)) # linear
     weights = (2.0 * weights).tanh() # nonlinear
     weights = weights.to(device=P.device)
     if self.gamma > 0.0:
         R = geo.angle_axis_to_rotation_matrix(theta[..., :3])
         t = theta[..., 3:]
         losses = torch.cat((
             weightedCorrespondenceLoss(P, C_gt, weights).view(1),
             weightedRotationLoss(R, R_gt, weights).view(1), # [0, pi]
             weightedTranslationLoss(t, t_gt, weights).view(1), # [0, inf)
             ))
         loss = losses[0] + self.gamma * (losses[1] + losses[2])
     else:
         losses = weightedCorrespondenceLoss(P, C_gt, weights).view(1)
         loss = losses[0]
     return loss, losses
Example #3
0
def reprojectionErrorsTheta(theta, p2d, p3d, P, eps=1e-7):
    R = geo.angle_axis_to_rotation_matrix(theta[..., :3])
    t = theta[..., 3:]
    return reprojectionErrors(R, t, p2d, p3d, P, eps)
Example #4
0
def rotationErrorsTheta(theta, R_gt, eps=1e-7):
    R = geo.angle_axis_to_rotation_matrix(theta[..., :3])
    return rotationErrors(R, R_gt, eps)
Example #5
0
def numInliersTheta(theta, p2d, p3d, threshold):
    R = geo.angle_axis_to_rotation_matrix(theta[..., :3])
    t = theta[..., 3:]
    return numInliers(R, t, p2d, p3d, threshold)
Example #6
0
def correspondenceMatricesTheta(theta, p2d, p3d, threshold):
    R = geo.angle_axis_to_rotation_matrix(theta[..., :3])
    t = theta[..., 3:]
    return correspondenceMatrices(R, t, p2d, p3d, threshold)