pref: 20 cm adapter

This commit is contained in:
2026-06-04 15:58:07 +08:00
parent 1a0bfd54f7
commit 860f9c84c3
5 changed files with 14 additions and 13 deletions

View File

@@ -535,7 +535,7 @@ def detect_circle_v3(frame, laser_point=None, img_cv=None):
logger.debug(f"[detect_circle_v3] begin {datetime.now()}")
# -- 1. 缩图加速(与三角形路径保持一致)
h_orig, w_orig = img_cv.shape[:2]
MAX_DET_DIM = 320
MAX_DET_DIM = 480
long_side = max(h_orig, w_orig)
if long_side > MAX_DET_DIM:
det_scale = MAX_DET_DIM / long_side
@@ -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 <= 30:
if ar <= 10:
continue
pr = cv2.arcLength(cnt_r, True)
if pr <= 0 or (4 * np.pi * ar) / (pr * pr) <= 0.4:
if pr <= 0 or (4 * np.pi * ar) / (pr * pr) <= 0.3:
continue
if len(cnt_r) >= 5:
(xr, yr), (wr, hr), _ = cv2.fitEllipse(cnt_r)
@@ -599,13 +599,13 @@ def detect_circle_v3(frame, laser_point=None, img_cv=None):
valid_targets = []
for cnt_yellow in contours_yellow:
area = cv2.contourArea(cnt_yellow)
if area <= 50:
if area <= 15:
continue
perimeter = cv2.arcLength(cnt_yellow, True)
if perimeter <= 0:
continue
circularity = (4 * np.pi * area) / (perimeter * perimeter)
if circularity <= 0.7:
if circularity <= 0.5:
continue
if logger:
logger.info(f"[target] -> 面积:{area:.1f}, 圆度:{circularity:.2f}")