Beispiel #1
0
def update_rotation_error(self, 
                          prediction, 
                          ground_truth, 
                          meta_data=None, 
                          logger=None,
                          name_str='',
                          style='euler'
                          ):
    """
    Get rotation error between two 3D point clouds. 
    """    
    num_data = len(prediction)
    prediction = prediction.reshape(num_data, -1, 3)
    ground_truth = ground_truth.reshape(num_data, -1, 3)
    if style == 'euler':
        results = -np.ones((num_data, 3))
    for data_idx in range(num_data):
        R, T = ltr.compute_rigid_transform(prediction[data_idx].T, 
                                           ground_truth[data_idx].T
                                           )
        if style == 'euler':
            results[data_idx] = np.abs(Rotation.from_matrix(R).as_euler('xyz', 
                                                                        degrees=True
                                                                        )
                                       )
        else:
            raise NotImplementedError
    update_statistics(self, results, num_data, name_str)
    return
Beispiel #2
0
def kpts_to_euler(template, prediction):
    """
    Convert the predicted cuboid representation to euler angles.
    """    
    # estimate roll, pitch, yaw of the prediction by comparing with a 
    # reference bounding box
    # prediction and template of shape [3, N_points]
    R, T = ltr.compute_rigid_transform(template, prediction)
    # in the order of yaw, pitch and roll
    angles = Rotation.from_matrix(R).as_euler('yxz', degrees=False)
    # re-order in the order of x, y and z
    angles = angles[[1,0,2]]
    return angles, T