From f8980287e29af0d0bfe15d5345b7c3c32662bd24 Mon Sep 17 00:00:00 2001 From: Havoc <2993167370@qq.com> Date: Sun, 1 Jun 2025 16:27:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96main.py=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=86=97=E4=BD=99=E7=9A=84=E6=97=A5=E5=BF=97=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E5=92=8C=E6=B3=A8=E9=87=8A=E6=8E=89=E7=9A=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BB=A3=E7=A0=81=EF=BC=8C=E7=AE=80=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BB=93=E6=9E=84=E3=80=82=E6=9B=B4=E6=96=B0test=5Fim?= =?UTF-8?q?age.py=EF=BC=8C=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8B=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=92=8C=E7=9F=B3=E6=9D=BF=E8=B7=AF=E6=A8=A1=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=8F=90=E5=8D=87?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=8F=AF=E8=AF=BB=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logs/robot_2025-06-01.log | 27 +++++++++++++++++++++ main.py | 5 ---- test/test_image.py | 49 +-------------------------------------- 3 files changed, 28 insertions(+), 53 deletions(-) create mode 100644 logs/robot_2025-06-01.log diff --git a/logs/robot_2025-06-01.log b/logs/robot_2025-06-01.log new file mode 100644 index 0000000..ccde4b1 --- /dev/null +++ b/logs/robot_2025-06-01.log @@ -0,0 +1,27 @@ +2025-06-01 15:46:38 | DEBUG | utils.log_helper - 🐞 步骤1: 创建黄色掩码 +2025-06-01 15:46:39 | DEBUG | utils.log_helper - 🐞 步骤1.5: 底部区域掩码 +2025-06-01 15:46:40 | DEBUG | utils.log_helper - 🐞 步骤2: 边缘检测 (底部ROI) +2025-06-01 15:46:41 | DEBUG | utils.log_helper - 🐞 步骤3: 检测到 36 条直线 +2025-06-01 15:46:42 | DEBUG | utils.log_helper - 🐞 步骤3.2: 筛选出 18 条垂直候选线 (合并前) +2025-06-01 15:46:43 | DEBUG | utils.log_helper - 🐞 步骤3.5: 合并筛选出 6 条垂直候选线 (合并后) +2025-06-01 15:46:44 | DEBUG | utils.log_helper - 🐞 步骤4: 找到 6 条垂直线 +2025-06-01 15:46:45 | DEBUG | utils.log_helper - 🐞 左侧候选线数量: 3, 右侧候选线数量: 3 +2025-06-01 15:46:46 | DEBUG | utils.log_helper - 🐞 选择最佳线对,评分: -1.00 +2025-06-01 15:46:52 | DEBUG | utils.log_helper - 🐞 步骤1: 创建黄色掩码 +2025-06-01 15:46:53 | DEBUG | utils.log_helper - 🐞 步骤1.5: 底部区域掩码 +2025-06-01 15:46:54 | DEBUG | utils.log_helper - 🐞 步骤2: 边缘检测 (底部ROI) +2025-06-01 15:46:55 | DEBUG | utils.log_helper - 🐞 步骤3: 检测到 36 条直线 +2025-06-01 15:46:56 | DEBUG | utils.log_helper - 🐞 步骤3.2: 筛选出 18 条垂直候选线 (合并前) +2025-06-01 15:46:57 | DEBUG | utils.log_helper - 🐞 步骤3.5: 合并筛选出 6 条垂直候选线 (合并后) +2025-06-01 15:46:59 | DEBUG | utils.log_helper - 🐞 步骤4: 找到 6 条垂直线 +2025-06-01 15:47:00 | DEBUG | utils.log_helper - 🐞 左侧候选线数量: 3, 右侧候选线数量: 3 +2025-06-01 15:47:01 | DEBUG | utils.log_helper - 🐞 选择最佳线对,评分: -1.00 +2025-06-01 15:47:05 | DEBUG | utils.log_helper - 🐞 步骤1: 创建黄色掩码 +2025-06-01 15:47:07 | DEBUG | utils.log_helper - 🐞 步骤1.5: 底部区域掩码 +2025-06-01 15:47:08 | DEBUG | utils.log_helper - 🐞 步骤2: 边缘检测 (底部ROI) +2025-06-01 15:47:09 | DEBUG | utils.log_helper - 🐞 步骤3: 检测到 36 条直线 +2025-06-01 15:47:10 | DEBUG | utils.log_helper - 🐞 步骤3.2: 筛选出 18 条垂直候选线 (合并前) +2025-06-01 15:47:11 | DEBUG | utils.log_helper - 🐞 步骤3.5: 合并筛选出 6 条垂直候选线 (合并后) +2025-06-01 15:47:12 | DEBUG | utils.log_helper - 🐞 步骤4: 找到 6 条垂直线 +2025-06-01 15:47:13 | DEBUG | utils.log_helper - 🐞 左侧候选线数量: 3, 右侧候选线数量: 3 +2025-06-01 15:47:14 | DEBUG | utils.log_helper - 🐞 选择最佳线对,评分: -1.00 diff --git a/main.py b/main.py index f048a54..dc335c4 100644 --- a/main.py +++ b/main.py @@ -50,15 +50,10 @@ def main(): Ctrl.base_msg.stand_up() Ctrl.base_msg.stop() # BUG 垃圾指令 for eat - # time.sleep(100) # TEST, run_task_1(Ctrl, msg, time_sleep=TIME_SLEEP) arrow_direction = run_task_2(Ctrl, msg, xy_flag=False) - # arrow_direction = 'right' # TEST - info(f"识别到箭头方向: {arrow_direction}", "info") - info(f"识别到箭头方向: {arrow_direction}", "info") - info(f"识别到箭头方向: {arrow_direction}", "info") info(f"识别到箭头方向: {arrow_direction}", "info") info(f"识别到箭头方向: {arrow_direction}", "info") run_task_2_5(Ctrl, msg, direction=arrow_direction) diff --git a/test/test_image.py b/test/test_image.py index ae03804..eec9daa 100644 --- a/test/test_image.py +++ b/test/test_image.py @@ -6,7 +6,7 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) project_root = os.path.dirname(current_dir) sys.path.append(project_root) -from utils.detect_dual_track_lines import detect_dual_track_lines, auto_detect_dual_track_lines +from utils.detect_dual_track_lines import detect_dual_track_lines # 图片路径 # image_path = "res/path/image_20250514_024347.png" @@ -34,50 +34,3 @@ if center_info: print(f"轨道宽度: {center_info['track_width']:.2f}") else: print("普通模式检测失败") - - -exit(0) - - -# 再尝试石板路模式 -print("\n正在使用石板路模式检测...") -center_info, left_track_info, right_track_info = detect_dual_track_lines( - image_path, - observe=True, - delay=2000, - save_log=True, - stone_path_mode=True -) - -if center_info: - print("\n石板路模式检测结果:") - print(f"中心点: {center_info['point']}") - print(f"偏差: {center_info['deviation']:.2f}") - print(f"斜率: {center_info['slope']:.2f}") - print(f"轨道宽度: {center_info['track_width']:.2f}") -else: - print("石板路模式检测失败") - -# 最后尝试自动检测模式 -print("\n正在使用自动检测模式...") -center_info, left_track_info, right_track_info = auto_detect_dual_track_lines( - image_path, - observe=True, - delay=2000, - save_log=True -) - -if center_info: - print("\n自动检测模式结果:") - print(f"中心点: {center_info['point']}") - print(f"偏差: {center_info['deviation']:.2f}") - print(f"斜率: {center_info['slope']:.2f}") - print(f"轨道宽度: {center_info['track_width']:.2f}") - print(f"使用石板路模式: {center_info['stone_path_mode']}") -else: - print("自动检测模式失败") - -# 等待用户按键关闭窗口 -print("\n按任意键退出...") -cv2.waitKey(0) -cv2.destroyAllWindows() \ No newline at end of file