|
|
|
|
|
""" |
|
|
创建测试用的小鼠图像 |
|
|
""" |
|
|
|
|
|
import cv2 |
|
|
import numpy as np |
|
|
import os |
|
|
|
|
|
def create_test_mouse_image(): |
|
|
"""创建一个简单的测试小鼠图像""" |
|
|
|
|
|
|
|
|
img = np.ones((640, 640, 3), dtype=np.uint8) * 50 |
|
|
|
|
|
|
|
|
center_x, center_y = 320, 320 |
|
|
|
|
|
|
|
|
body_width, body_height = 120, 60 |
|
|
cv2.ellipse(img, (center_x, center_y), (body_width//2, body_height//2), 0, 0, 360, (150, 150, 150), -1) |
|
|
|
|
|
|
|
|
head_x, head_y = center_x - 80, center_y |
|
|
head_radius = 35 |
|
|
cv2.circle(img, (head_x, head_y), head_radius, (160, 160, 160), -1) |
|
|
|
|
|
|
|
|
left_ear = (head_x - 20, head_y - 25) |
|
|
right_ear = (head_x + 20, head_y - 25) |
|
|
cv2.circle(img, left_ear, 10, (140, 140, 140), -1) |
|
|
cv2.circle(img, right_ear, 10, (140, 140, 140), -1) |
|
|
|
|
|
|
|
|
nose_pos = (head_x - 30, head_y) |
|
|
cv2.circle(img, nose_pos, 3, (100, 100, 100), -1) |
|
|
|
|
|
|
|
|
left_leg = (center_x - 30, center_y + 40) |
|
|
right_leg = (center_x + 30, center_y + 40) |
|
|
cv2.circle(img, left_leg, 8, (130, 130, 130), -1) |
|
|
cv2.circle(img, right_leg, 8, (130, 130, 130), -1) |
|
|
|
|
|
|
|
|
tail_base = (center_x + 60, center_y) |
|
|
tail_tip = (center_x + 120, center_y - 20) |
|
|
cv2.line(img, tail_base, tail_tip, (140, 140, 140), 8) |
|
|
cv2.circle(img, tail_base, 5, (135, 135, 135), -1) |
|
|
cv2.circle(img, tail_tip, 3, (135, 135, 135), -1) |
|
|
|
|
|
|
|
|
noise = np.random.randint(-20, 20, img.shape, dtype=np.int16) |
|
|
img = np.clip(img.astype(np.int16) + noise, 0, 255).astype(np.uint8) |
|
|
|
|
|
|
|
|
for _ in range(50): |
|
|
x = np.random.randint(0, 640) |
|
|
y = np.random.randint(0, 640) |
|
|
cv2.circle(img, (x, y), 1, (np.random.randint(30, 70),) * 3, -1) |
|
|
|
|
|
return img |
|
|
|
|
|
def main(): |
|
|
"""主函数""" |
|
|
print("正在创建测试小鼠图像...") |
|
|
|
|
|
|
|
|
test_image = create_test_mouse_image() |
|
|
|
|
|
|
|
|
cv2.imwrite("test_mouse.jpg", test_image) |
|
|
print("✅ 测试图像已保存为 test_mouse.jpg") |
|
|
|
|
|
|
|
|
print(f"图像尺寸: {test_image.shape}") |
|
|
print("您现在可以使用这个图像来测试小鼠姿态检测系统") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |