Skip to content

Commit 0974c51

Browse files
committed
add gimbal control for find 2025 diansai E
1 parent a2fef67 commit 0974c51

File tree

17 files changed

+893
-840
lines changed

17 files changed

+893
-840
lines changed

a.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import cv2
2+
import numpy as np
3+
import math
4+
import random
5+
6+
7+
def rotate_img(src, angle, scale=1.0):
8+
height, width = src.shape[:2]
9+
radian = math.radians(angle)
10+
11+
# 计算旋转后图像的尺寸
12+
width_rotate = int((abs(width * math.cos(radian)) + abs(height * math.sin(radian))) * scale)
13+
height_rotate = int((abs(width * math.sin(radian)) + abs(height * math.cos(radian))) * scale)
14+
15+
# 获取旋转中心
16+
center = (width / 2.0, height / 2.0)
17+
18+
# 获取旋转矩阵
19+
M = cv2.getRotationMatrix2D(center, angle, scale)
20+
21+
# 平移使得图像在新图中心
22+
M[0, 2] += (width_rotate - width) / 2.0
23+
M[1, 2] += (height_rotate - height) / 2.0
24+
25+
# 进行仿射变换(保留 alpha 通道)
26+
if src.shape[2] == 4:
27+
border_val = (0, 0, 0, 0)
28+
else:
29+
border_val = (0, 0, 0)
30+
31+
dst = cv2.warpAffine(src, M, (width_rotate, height_rotate),
32+
flags=cv2.INTER_LINEAR,
33+
borderMode=cv2.BORDER_CONSTANT,
34+
borderValue=border_val)
35+
return dst
36+
37+
38+
img = cv2.imread("laohu2.png", cv2.IMREAD_UNCHANGED)
39+
40+
target = rotate_img(img, random.randint(0, 360), 1)
41+
print(target.shape)
42+
cv2.imwrite('rotated_result.png', target)

laohu2.png

480 KB
Loading

projects/app_gimbal_laser/README.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

projects/app_gimbal_laser/app.yaml

Lines changed: 0 additions & 13 deletions
This file was deleted.
-785 Bytes
Binary file not shown.
-6.5 KB
Binary file not shown.
-2.88 KB
Binary file not shown.

projects/app_gimbal_laser/face_tracking/servos.py

Lines changed: 0 additions & 227 deletions
This file was deleted.

0 commit comments

Comments
 (0)