diff --git a/src/python/pose_format/utils/normalization_3d.py b/src/python/pose_format/utils/normalization_3d.py index e7e9d80..0ea6632 100644 --- a/src/python/pose_format/utils/normalization_3d.py +++ b/src/python/pose_format/utils/normalization_3d.py @@ -2,7 +2,6 @@ import numpy as np import numpy.ma as ma -from scipy.spatial.transform import Rotation from pose_format.pose_header import PoseNormalizationInfo @@ -136,8 +135,15 @@ def rotate(self, pose: ma.masked_array, angle: np.ndarray) -> ma.masked_array: ma.masked_array rotated pose """ - r = Rotation.from_euler('z', -angle[..., np.newaxis], degrees=True) # Clockwise rotation - rotated = np.einsum('...ij,...kj->...ik', pose, r.as_matrix()).reshape(pose.shape) + theta = np.radians(-angle) # Clockwise rotation + cos, sin = np.cos(theta), np.sin(theta) + rotation_matrix = np.zeros((*theta.shape, 3, 3)) + rotation_matrix[..., 0, 0] = cos + rotation_matrix[..., 0, 1] = -sin + rotation_matrix[..., 1, 0] = sin + rotation_matrix[..., 1, 1] = cos + rotation_matrix[..., 2, 2] = 1 + rotated = np.einsum('...ij,...kj->...ik', pose, rotation_matrix).reshape(pose.shape) return ma.masked_array(rotated, pose.mask) def scale(self, pose: ma.masked_array) -> ma.masked_array: diff --git a/src/python/pyproject.toml b/src/python/pyproject.toml index 5bcd451..1ed2684 100644 --- a/src/python/pyproject.toml +++ b/src/python/pyproject.toml @@ -11,7 +11,6 @@ authors = [ ] dependencies = [ "numpy", - "scipy", "tqdm", "simple-video-utils", ] @@ -21,6 +20,7 @@ requires-python = ">= 3.8" dev = [ "pylint", "pytest", + "scipy", "opencv-python", "vidgear", "mediapipe<0.10.30",