fix: rm yolo

This commit is contained in:
2026-06-04 09:00:10 +08:00
parent c46cf5c567
commit 1a0bfd54f7
6 changed files with 17 additions and 15 deletions

View File

@@ -570,8 +570,8 @@ def detect_circle_v3(frame, laser_point=None, img_cv=None):
# -- 3. 红色掩码:在循环外只算一次
mask_red = cv2.bitwise_or(
cv2.inRange(hsv, np.array([0, 80, 0]), np.array([10, 255, 255])),
cv2.inRange(hsv, np.array([170, 80, 0]), np.array([180, 255, 255])),
cv2.inRange(hsv, np.array([0, 50, 40]), np.array([10, 255, 255])),
cv2.inRange(hsv, np.array([170, 50, 40]), np.array([180, 255, 255])),
)
kernel_red = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (5, 5))
mask_red = cv2.morphologyEx(mask_red, cv2.MORPH_CLOSE, kernel_red)
@@ -580,10 +580,10 @@ def detect_circle_v3(frame, laser_point=None, img_cv=None):
red_candidates = []
for cnt_r in contours_red:
ar = cv2.contourArea(cnt_r)
if ar <= 50:
if ar <= 30:
continue
pr = cv2.arcLength(cnt_r, True)
if pr <= 0 or (4 * np.pi * ar) / (pr * pr) <= 0.6:
if pr <= 0 or (4 * np.pi * ar) / (pr * pr) <= 0.4:
continue
if len(cnt_r) >= 5:
(xr, yr), (wr, hr), _ = cv2.fitEllipse(cnt_r)
@@ -625,7 +625,7 @@ def detect_circle_v3(frame, laser_point=None, img_cv=None):
ddx = yellow_center[0] - rc["center"][0]
ddy = yellow_center[1] - rc["center"][1]
dist_centers = math.hypot(ddx, ddy)
if dist_centers < yellow_radius * 1.5 and rc["radius"] > yellow_radius * 0.8:
if dist_centers < yellow_radius * 1.5 and rc["radius"] > yellow_radius * 0.7:
if logger:
logger.info(f"[target] -> 找到匹配的红圈: 黄心({yellow_center}), "
f"红心({rc['center']}), 距离:{dist_centers:.1f}, "