import numpy as np import math from models.pose_estimator.pose_estimator_model_setup import get_pose_estimation def over_rotation(filepath, pose_pred=None, diver_detector=None, pose_model=None): if pose_pred is None and filepath != "": diver_box, pose_pred = get_pose_estimation(filepath, diver_detector=diver_detector, pose_model=pose_model) if pose_pred is not None: pose_pred = np.array(pose_pred)[0] vector1 = [(pose_pred[0][0] - pose_pred[2][0]), 0-(pose_pred[0][1] - pose_pred[2][1])] vector2 = [-1, 0] unit_vector_1 = vector1 / np.linalg.norm(vector1) unit_vector_2 = vector2 / np.linalg.norm(vector2) dot_product = np.dot(unit_vector_1, unit_vector_2) angle = math.degrees(np.arccos(dot_product)) return angle else: # print('pose_pred is None') return None