Compare commits

...

2 commits

Author SHA1 Message Date
b2f88ababc 在scripts目录中存放开发用的脚本
All checks were successful
ci/woodpecker/push/check_format Pipeline was successful
2025-07-01 22:38:53 +08:00
caf44b22f2 避免滑动轨迹过大的加速度 2025-07-01 22:38:15 +08:00
4 changed files with 68 additions and 2 deletions

2
.gitignore vendored
View file

@ -214,3 +214,5 @@ MAA
*.ipynb
.rgignore
*.mp4

View file

View file

@ -0,0 +1,66 @@
import cv2
import numpy as np
from mower.utils.device.human_cursor import HumanizeMouseTrajectory
# 初始化视频写入器 (60fps)
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
video = cv2.VideoWriter(
"mouse_trajectory_video.mp4", fourcc, 60.0, (1920, 1080), isColor=True
)
points = []
points += HumanizeMouseTrajectory((1700, 500), (1000, 500), 0.5).generate_curve(
sample_rate=120
)
points += HumanizeMouseTrajectory((1000, 500), (1000, 200), 0.2).generate_curve(
sample_rate=120
)
# 创建彩色空白帧
frame = np.zeros((1080, 1920, 3), dtype=np.uint8)
for _ in range(5):
video.write(frame)
# 定义三种颜色 (BGR格式)
colors = [
(0, 0, 255),
(0, 255, 0),
(255, 255, 0),
(255, 255, 255),
]
for total in range(4):
current_color = colors[total]
# 绘制5次轨迹,每次偏移并保留之前轨迹
for iteration in range(5):
# 生成新轨迹点并偏移
new_points = []
offset_x = -150 * iteration
offset_y = 150 * iteration
new_points += HumanizeMouseTrajectory(
(1700, 400), (1000, 400), 0.3
).generate_curve(sample_rate=120)
new_points += HumanizeMouseTrajectory(
(1000, 400), (1000, 200), 0.2
).generate_curve(sample_rate=120)
new_points = [(x + offset_x, y + offset_y) for x, y in new_points]
# 每帧绘制2个点
for i in range(0, len(new_points), 2):
x, y = new_points[i]
cv2.circle(frame, (x, y), 8, current_color, 3)
video.write(frame)
if i + 1 < len(new_points):
x, y = new_points[i + 1]
cv2.circle(frame, (x, y), 8, current_color, 3)
video.write(frame)
# 每次轨迹完成后等待0.5秒(30帧)
for _ in range(30):
video.write(frame)
# 释放视频写入器
video.release()
print("60fps视频已保存为 mouse_trajectory_video.mp4")

View file

@ -107,9 +107,7 @@ class HumanizeMouseTrajectory:
[
pytweening.linear,
pytweening.easeInOutSine,
pytweening.easeInOutQuad,
pytweening.easeOutSine,
pytweening.easeOutQuad,
]
)
offset_boundary_x = random.choice(range(8, 20))