mirror of
https://github.com/azaion/gps-denied-desktop.git
synced 2026-04-22 22:06:36 +00:00
2.1 KiB
2.1 KiB
Image Rotation Utils Helper
Interface Definition
Interface Name: IImageRotationUtils
Interface Methods
class IImageRotationUtils(ABC):
@abstractmethod
def rotate_image(self, image: np.ndarray, angle: float, center: Optional[Tuple[int, int]] = None) -> np.ndarray:
pass
@abstractmethod
def calculate_rotation_from_points(self, src_points: np.ndarray, dst_points: np.ndarray) -> float:
pass
@abstractmethod
def normalize_angle(self, angle: float) -> float:
pass
@abstractmethod
def compute_rotation_matrix(self, angle: float, center: Tuple[int, int]) -> np.ndarray:
pass
Component Description
Image rotation operations, angle calculations from point shifts.
API Methods
rotate_image(image: np.ndarray, angle: float, center: Optional[Tuple[int, int]] = None) -> np.ndarray
Description: Rotates image around center.
Implementation: Uses cv2.getRotationMatrix2D + cv2.warpAffine
Parameters:
- angle: Degrees (0-360)
- center: Rotation center (default: image center)
Returns: Rotated image (same dimensions)
calculate_rotation_from_points(src_points: np.ndarray, dst_points: np.ndarray) -> float
Description: Calculates rotation angle from point correspondences.
Input: (N, 2) arrays of matching points
Algorithm:
- Compute centroids
- Calculate angle from centroid shifts
- Return angle in degrees
Use Case: Extract precise angle from LiteSAM homography
normalize_angle(angle: float) -> float
Description: Normalizes angle to 0-360 range.
Formula:
angle = angle % 360
if angle < 0:
angle += 360
compute_rotation_matrix(angle: float, center: Tuple[int, int]) -> np.ndarray
Description: Computes 2D rotation matrix.
Returns: 2×3 affine transformation matrix
Dependencies
External: opencv-python, numpy
Test Cases
- Rotate 90° → image rotated correctly
- Calculate angle from points → accurate angle
- Normalize 370° → 10°
- Rotation matrix → correct transformation