(image, top_left, bottom_right, color, radius=10, alpha=0.5)
| 56 | |
| 57 | # 绘制圆角矩形 |
| 58 | def draw_rounded_rectangle(image, top_left, bottom_right, color, radius=10, alpha=0.5): |
| 59 | overlay = image.copy() |
| 60 | x1, y1 = top_left |
| 61 | x2, y2 = bottom_right |
| 62 | |
| 63 | cv2.rectangle(overlay, (x1 + radius, y1), (x2 - radius, y2), color, -1) |
| 64 | cv2.rectangle(overlay, (x1, y1 + radius), (x2, y2 - radius), color, -1) |
| 65 | |
| 66 | cv2.ellipse(overlay, (x1 + radius, y1 + radius), (radius, radius), 180, 0, 90, color, -1) |
| 67 | cv2.ellipse(overlay, (x2 - radius, y1 + radius), (radius, radius), 270, 0, 90, color, -1) |
| 68 | cv2.ellipse(overlay, (x1 + radius, y2 - radius), (radius, radius), 90, 0, 90, color, -1) |
| 69 | cv2.ellipse(overlay, (x2 - radius, y2 - radius), (radius, radius), 0, 0, 90, color, -1) |
| 70 | |
| 71 | cv2.addWeighted(overlay, alpha, image, 1 - alpha, 0, image) |
| 72 | |
| 73 | # 在帧上绘制按键 |
| 74 | def draw_keys_on_frame(frame, keys, key_size=(80, 50), spacing=20, bottom_margin=30): |
no outgoing calls
no test coverage detected