diff --git a/app.yaml b/app.yaml index 60ebd40..19e38c1 100644 --- a/app.yaml +++ b/app.yaml @@ -1,6 +1,6 @@ id: t11 name: t11 -version: 2.15.6 +version: 2.15.8 author: t11 icon: '' desc: t11 diff --git a/config.py b/config.py index a1e5195..d389df4 100644 --- a/config.py +++ b/config.py @@ -260,7 +260,7 @@ TRIANGLE_SAMPLE_RADIUS_CM = 15.0 TRIANGLE_SAMPLE_ANGLES_DEG = (0, 90, 180, 270) TRIANGLE_SAMPLE_PATCH_HALF_PX = 2 # 开机阶段预加载 YOLO detector;detect 使用 dual_buff=False,避免返回上一帧结果。 -TRIANGLE_YOLO_PRELOAD_ON_BOOT = True +TRIANGLE_YOLO_PRELOAD_ON_BOOT = False # ── 第二段 YOLO:仅在 Stage1 裁切出的靶环图上推理(与合成 stage2 训练数据一致)→ 子框内传统算法取直角点 ── # Stage1 靶环裁切内如何找黑三角标记(对比耗时时可切换): diff --git a/test/test_decect.py b/test/test_decect.py index f1a566d..2c33f50 100644 --- a/test/test_decect.py +++ b/test/test_decect.py @@ -71,8 +71,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) @@ -81,10 +81,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) @@ -125,7 +125,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: print(f"[target] -> 找到匹配的红圈: 黄心({yellow_center}), " f"红心({rc['center']}), 距离:{dist_centers:.1f}, " f"黄半径:{yellow_radius}, 红半径:{rc['radius']}") @@ -279,8 +279,8 @@ def run_offline_test(image_path): result_img.draw_string(0, 0, info_str, color=color_black, scale=1.0) # 5. 保存结果图片 - output_path = image_path.replace(".bmp", "_result.bmp") - output_path = image_path.replace(".jpg", "_result.jpg") + base, ext = os.path.splitext(image_path) + output_path = f"{base}_result{ext}" try: result_img.save(output_path, quality=100) print(f"[SUCCESS] 结果已保存至: {output_path}") diff --git a/version.md b/version.md index e5ed277..d402359 100644 --- a/version.md +++ b/version.md @@ -17,3 +17,5 @@ # 2.15.4 更新版本号 # 2.15.5 打印ota进度 # 2.15.6 更新版本号 +# 2.15.7 更新版本号 +# 2.15.8 启动不加载预加载yolo \ No newline at end of file diff --git a/version.py b/version.py index 8562a3a..e0e438b 100644 --- a/version.py +++ b/version.py @@ -4,6 +4,6 @@ 应用版本号 每次 OTA 更新时,只需要更新这个文件中的版本号 """ -VERSION = '2.15.6' +VERSION = '2.15.7' diff --git a/vision.py b/vision.py index d4fba86..50cd9ee 100644 --- a/vision.py +++ b/vision.py @@ -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}, "