python围绕点旋转
【摘要】
#点p_x, p_y 围绕center_x, center_y顺时针旋转angle度
import cv2import mathimport numpy as npimport os def get_degree(p1, p0): aaa = math.degrees(math.atan2((p1[1] - p0[1])...
#点p_x, p_y 围绕center_x, center_y顺时针旋转angle度
import cv2
import math
import numpy as np
import os
def get_degree(p1, p0):
aaa = math.degrees(math.atan2((p1[1] - p0[1]), (p1[0] - p0[0])))
if aaa < 0:
aaa = 360 + aaa
aaa = (aaa + 90)
if aaa > 360:
aaa = aaa - 360
return aaa
def rotate_image(box_points, angle, scale=1.):
c_x=box_points[0][0]
c_y=box_points[0][1]
rot_mat = cv2.getRotationMatrix2D((c_x, c_y), angle, scale)
rot_move = np.dot(rot_mat, np.array([0, 0, 0]))
rot_mat[0, 2] += rot_move[0]
rot_mat[1, 2] += rot_move[1]
new_box_points = []
for point in box_points:
new_points = []
p_x, p_y = point[2],point[3]
point1 = np.dot(rot_mat, np.array([p_x, p_y, 1]))
new_points.append((point1))
new_box_points.append(new_points)
return ne
文章来源: blog.csdn.net,作者:AI视觉网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/120028909
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
作者其他文章
评论(0)