π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Merge branch 'master' into update_docs_2
Edgar Riba91d915b2e5e2
diff --cc torchgeometry/conversions.pyindex ae2b1df5a,e69f4acaa..f795574d0--- a/torchgeometry/conversions.py+++ b/torchgeometry/conversions.py@@@ -172,18 -169,19 +198,26 @@@ def rotation_matrix_to_angle_axis(rotatreturn quaternion_to_angle_axis(quaternion)- def rotation_matrix_to_quaternion(rotation_matrix):+ # def rotation_matrix_to_angle_axis_torch(rotation_matrix):+ # '''+ # Convert 4x4 rotation matrix to 4d quaternion vector+ # '''+ # quaternion = rotation_matrix_to_quaternion_torch(rotation_matrix)+ # return quaternion_to_angle_axis_torch(quaternion)+++ def rotation_matrix_to_quaternion_numpy(rotation_matrix):'''Convert 4x4 rotation matrix to 4d quaternion vector++ Args:+ rotation_matrix (Tensor): rotation matrix of size (4, 4).++ Returns:+ Tensor: quaternion representation of rotation of size (1, 4).+'''- quaternion = torch.zeros(4)+ quaternion = np.zeros(4, np.float32)trace = rotation_matrix[0, 0] + \rotation_matrix[1, 1] + rotation_matrix[2, 2]if trace >= 0.0:@@@ -218,16 -216,11 +252,16 @@@ def quaternion_to_angle_axis_numpy(quat'''Convert quaternion vector to angle axis of rotationAdapted from ceres C++ library: ceres-solver/include/ceres/rotation.h- :param quaternion: Tensor vector of length 4- :return: angle axis of rotation (vector of length 3)++ Args:+ quaternion (Tensor): quaternion rotation vector of length 4++ Returns:+ Tensor: axis-angle rotation of size (1, 3).+'''- assert quaternion.size(0) == 4, 'Input must be a vector of length 4'- normalizer = 1 / torch.norm(quaternion)+ assert quaternion.shape[-1] == 4, 'Input must be a vector of length 4'+ normalizer = 1 / np.linalg.norm(quaternion)q1 = quaternion[1] * normalizerq2 = quaternion[2] * normalizerq3 = quaternion[3] * normalizerdiff --cc torchgeometry/utils.pyindex 3a422d008,1870d1f27..a0b5bd9d5--- a/torchgeometry/utils.py+++ b/torchgeometry/utils.py@@@ -1,5 -1,7 +1,8 @@@+ import cv2+ import numpy as npimport torch+import numpy as np+ import torchgeometry as tgm__all__ = ["tensor_to_image",