本文整理匯總了Python中transforms3d.euler.euler2mat方法的典型用法代碼示例。如果您正苦於以下問題:Python euler.euler2mat方法的具體用法?Python euler.euler2mat怎麽用?Python euler.euler2mat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類transforms3d.euler
的用法示例。
在下文中一共展示了euler.euler2mat方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: find_errors
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def find_errors(gt_pose, final_pose):
# Simple euler distand between translation part.
gt_position = gt_pose[0:3]
predicted_position = final_pose[0:3]
translation_error = np.sqrt(np.sum(np.square(gt_position - predicted_position)))
# Convert euler angles rotation matrix.
gt_euler = gt_pose[3:6]
pt_euler = final_pose[3:6]
gt_mat = t3d.euler2mat(gt_euler[2],gt_euler[1],gt_euler[0],'szyx')
pt_mat = t3d.euler2mat(pt_euler[2],pt_euler[1],pt_euler[0],'szyx')
# Multiply inverse of one rotation matrix with another rotation matrix.
error_mat = np.dot(pt_mat,np.linalg.inv(gt_mat))
_,angle = transforms3d.axangles.mat2axangle(error_mat) # Convert matrix to axis angle representation and that angle is error.
return translation_error, abs(angle*(180/np.pi))
# Store all the results.
# if not os.path.exists(LOG_DIR): os.mkdir(LOG_DIR)
示例2: find_errors
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def find_errors(self, gt_pose, final_pose):
import transforms3d
gt_position = gt_pose[0,0:3]
predicted_position = final_pose[0,0:3]
translation_error = np.sqrt(np.sum(np.square(gt_position - predicted_position)))
print("Translation Error: {}".format(translation_error))
gt_euler = gt_pose[0,3:6]
pt_euler = final_pose[0,3:6]
gt_mat = t3d.euler2mat(gt_euler[2],gt_euler[1],gt_euler[0],'szyx')
pt_mat = t3d.euler2mat(pt_euler[2],pt_euler[1],pt_euler[0],'szyx')
error_mat = np.dot(pt_mat,np.linalg.inv(gt_mat))
_,angle = transforms3d.axangles.mat2axangle(error_mat)
print("Rotation Error: {}".format(abs(angle*(180/np.pi))))
return translation_error, angle*(180/np.pi)
示例3: find_models
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def find_models(category, model, templates, case):
# model: No of models to be stored for a particular category.
# category: Name of the category to be stored.
# templates: Array having templates (BxNx3)
# case: Which files to be used? (test/train)
if case == 'test':
FILES = TEST_FILES
if case == 'train':
FILES = TRAIN_FILES
print(FILES)
count = 0 # Counter to find number of models.
for train_idx in range(len(FILES)): # Loop over all the training files from ModelNet40 data.
current_data, current_label = provider.loadDataFile(FILES[train_idx]) # Load data of from a file.
for i in range(current_data.shape[0]):
if count<model and shapes.index(category)==current_label[i]:
# import transforms3d.euler as t3d
# rot = t3d.euler2mat(0*np.pi/1 80, 0*np.pi/180, 90*np.pi/180, 'szyx')
# templates.append((np.dot(rot, current_data[i].T).T))
templates.append(current_data[i]/2.0) # Append data if it belongs to the category and less than given number of models.
count += 1
return templates
示例4: find_errors
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def find_errors(gt_pose, final_pose):
# Simple euler distand between translation part.
gt_position = gt_pose[0:3]
predicted_position = final_pose[0:3]
translation_error = np.sqrt(np.sum(np.square(gt_position - predicted_position)))
# Convert euler angles rotation matrix.
gt_euler = gt_pose[3:6]
pt_euler = final_pose[3:6]
gt_mat = t3d.euler2mat(gt_euler[2],gt_euler[1],gt_euler[0],'szyx')
pt_mat = t3d.euler2mat(pt_euler[2],pt_euler[1],pt_euler[0],'szyx')
# Multiply inverse of one rotation matrix with another rotation matrix.
error_mat = np.dot(pt_mat,np.linalg.inv(gt_mat))
_,angle = transforms3d.axangles.mat2axangle(error_mat) # Convert matrix to axis angle representation and that angle is error.
return translation_error, abs(angle*(180/np.pi))
示例5: inverse_pose
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def inverse_pose(pose):
transformation_pose = np.zeros((4,4))
transformation_pose[3,3]=1
transformation_pose[0:3,0:3] = t3d.euler2mat(pose[5], pose[4], pose[3], 'szyx')
transformation_pose[0,3] = pose[0]
transformation_pose[1,3] = pose[1]
transformation_pose[2,3] = pose[2]
transformation_pose = np.linalg.inv(transformation_pose)
pose_inv = np.zeros((1,6))[0]
pose_inv[0] = transformation_pose[0,3]
pose_inv[1] = transformation_pose[1,3]
pose_inv[2] = transformation_pose[2,3]
orient_inv = t3d.mat2euler(transformation_pose[0:3,0:3], 'szyx')
pose_inv[3] = orient_inv[2]
pose_inv[4] = orient_inv[1]
pose_inv[5] = orient_inv[0]
return pose_inv
###################### Shuffling Operations #########################
# Randomly shuffle given array of poses for training procedure.
示例6: get_cam_corners_and_edge
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def get_cam_corners_and_edge( input_array ):
center = input_array[:3]
edge_lengths = input_array[-3:]
axis = transforms3d.euler.euler2mat( *input_array[3:6], axes='sxyz' )
y = axis[0] * edge_lengths[0] / 2
x = axis[1] * edge_lengths[1] / 2
z = axis[2] * edge_lengths[2] / 2
corners_for_cam = np.empty((8,3))
corners_for_cam[0] = center - x - y - z
corners_for_cam[1] = center - x - y + z
corners_for_cam[2] = center - x + y - z
corners_for_cam[3] = center - x + y + z
corners_for_cam[4] = center + x - y - z
corners_for_cam[5] = center + x - y + z
corners_for_cam[6] = center + x + y - z
corners_for_cam[7] = center + x + y + z
return corners_for_cam, edge_lengths
示例7: get_cam_corners_and_edge_ordered
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def get_cam_corners_and_edge_ordered( input_array ):
center = input_array[:3]
edge_lengths = input_array[-3:]
axis = transforms3d.euler.euler2mat( *input_array[3:6], axes='sxyz' )
y = axis[0] * edge_lengths[0] / 2
x = axis[1] * edge_lengths[1] / 2
z = axis[2] * edge_lengths[2] / 2
corners_for_cam = np.empty((8,3))
corners_for_cam[0] = center - x + y - z
corners_for_cam[1] = center + x + y - z
corners_for_cam[2] = center + x - y - z
corners_for_cam[3] = center - x - y - z
corners_for_cam[4] = center - x + y + z
corners_for_cam[5] = center + x + y + z
corners_for_cam[6] = center + x - y + z
corners_for_cam[7] = center - x - y + z
return corners_for_cam, edge_lengths
示例8: get_xforms
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def get_xforms(xform_num, rotation_range=(0, 0, 0, 'u'), scaling_range=(0.0, 0.0, 0.0, 'u'), order='rxyz'):
xforms = np.empty(shape=(xform_num, 3, 3))
rotations = np.empty(shape=(xform_num, 3, 3))
for i in range(xform_num):
rx = rotation_angle(rotation_range[0], rotation_range[3])
ry = rotation_angle(rotation_range[1], rotation_range[3])
rz = rotation_angle(rotation_range[2], rotation_range[3])
rotation = euler2mat(rx, ry, rz, order)
sx = scaling_factor(scaling_range[0], scaling_range[3])
sy = scaling_factor(scaling_range[1], scaling_range[3])
sz = scaling_factor(scaling_range[2], scaling_range[3])
scaling = np.diag([sx, sy, sz])
xforms[i, :] = scaling * rotation
rotations[i, :] = rotation
return xforms, rotations
示例9: set_motion
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def set_motion(self, motion):
if self.name == 'root':
self.coordinate = np.reshape(np.array(motion['root'][:3]), [3, 1])
rotation = np.deg2rad(motion['root'][3:])
self.matrix = self.C.dot(euler2mat(*rotation)).dot(self.Cinv)
else:
idx = 0
rotation = np.zeros(3)
for axis, lm in enumerate(self.limits):
if not np.array_equal(lm, np.zeros(2)):
rotation[axis] = motion[self.name][idx]
idx += 1
rotation = np.deg2rad(rotation)
self.matrix = self.parent.matrix.dot(self.C).dot(euler2mat(*rotation)).dot(self.Cinv)
self.coordinate = self.parent.coordinate + self.length * self.matrix.dot(self.direction)
for child in self.children:
child.set_motion(motion)
示例10: getRotationMatrix
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def getRotationMatrix(angle_x, angle_y, angle_z):
"""
Get rotation matrix
:param angle_x: angle around x-axis in deg
:param angle_y: angle around y-axis in deg
:param angle_z: angle around z-axis in deg
:return: 4x4 rotation matrix
"""
alpha_x = angle_x * numpy.pi / 180.
alpha_y = angle_y * numpy.pi / 180.
alpha_z = angle_z * numpy.pi / 180.
R = numpy.eye(4)
from transforms3d.euler import euler2mat
R[:3, :3] = euler2mat(alpha_x, alpha_y, alpha_z, 'rxyz')
return R
示例11: apply_random_rotation
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def apply_random_rotation(templates):
# templates: Array of templates or point clouds (BxNx3)
templates = np.array(templates)
for i in range(templates.shape[0]):
# Random rotation in range [-45, 45] degrees.
rot = t3d.euler2mat((np.pi/2)*np.random.random_sample()-np.pi/4, (np.pi/2)*np.random.random_sample()-np.pi/4, (np.pi/2)*np.random.random_sample()-np.pi/4, 'szyx')
templates[i,:,:] = np.dot(rot, templates[i,:,:].T).T
return templates
示例12: get_camera_matrix
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def get_camera_matrix( view_dict, flip_xy=False ):
position = view_dict[ 'camera_location' ]
rotation_euler = view_dict[ 'camera_rotation_final' ]
R = transforms3d.euler.euler2mat( *rotation_euler, axes='sxyz' )
camera_matrix = transforms3d.affines.compose( position, R, np.ones(3) )
if flip_xy:
# For some reason the x and y are flipped in room layout
temp = np.copy(camera_matrix[0,:])
camera_matrix[0,:] = camera_matrix[1,:]
camera_matrix[1,:] = -temp
return camera_matrix
示例13: rotate_quat_by_euler
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def rotate_quat_by_euler(xyzw, e_x, e_y, e_z):
"""
wxyz: transforms3s array format
xyzw: pybullet format
"""
wxyz = PhysicsObject.quatXyzwToWxyz(xyzw)
rot_mat = euler.euler2mat(e_x, e_y, e_z)
wxyz = quaternions.qmult(rot_mat, wxyz)
return PhysicsObject.quatWxyzToXyzw(wxyz)
示例14: get_random_transformation
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def get_random_transformation():
T = [0, np.random.uniform(-8, 8), np.random.uniform(-8, 8)]
R = euler2mat(np.random.uniform(-5, 5) / 180.0 * np.pi, 0, 0, 'sxyz')
Z = [1, np.random.uniform(0.9, 1.1), np.random.uniform(0.9, 1.1)]
A = compose(T, R, Z)
return A
示例15: read_label
# 需要導入模塊: from transforms3d import euler [as 別名]
# 或者: from transforms3d.euler import euler2mat [as 別名]
def read_label(path, is_training=True):
seg = nib.load(glob.glob(os.path.join(path, '*_seg.nii.gz'))[0]).get_data().astype(np.float32)
# Crop to 128*128*64
crop_size = (128, 128, 64)
crop = [int((seg.shape[0] - crop_size[0]) / 2), int((seg.shape[1] - crop_size[1]) / 2),
int((seg.shape[2] - crop_size[2]) / 2)]
seg = seg[crop[0] : crop[0] + crop_size[0], crop[1] : crop[1] + crop_size[1], crop[2] : crop[2] + crop_size[2]]
label = np.zeros((seg.shape[0], seg.shape[1], seg.shape[2], 3), dtype=np.float32)
label[seg == 1, 0] = 1
label[seg == 2, 1] = 1
label[seg == 4, 2] = 1
final_label = np.empty((16, 16, 16, 3), dtype=np.float32)
for z in range(label.shape[3]):
final_label[..., z] = resize(label[..., z], (16, 16, 16), mode='constant')
# Augmentation
if is_training:
im_size = final_label.shape[:-1]
translation = [np.random.uniform(-2, 2), np.random.uniform(-2, 2), np.random.uniform(-2, 2)]
rotation = euler2mat(0, 0, np.random.uniform(-5, 5) / 180.0 * np.pi, 'sxyz')
scale = [1, 1, 1]
warp_mat = compose(translation, rotation, scale)
tform_coords = get_tform_coords(im_size)
w = np.dot(warp_mat, tform_coords)
w[0] = w[0] + im_size[0] / 2
w[1] = w[1] + im_size[1] / 2
w[2] = w[2] + im_size[2] / 2
warp_coords = w[0:3].reshape(3, im_size[0], im_size[1], im_size[2])
for z in range(label.shape[3]):
final_label[..., z] = warp(final_label[..., z], warp_coords)
return final_label