优化main.py,移除冗余的日志输出和注释掉的测试代码,简化代码结构。更新test_image.py,移除未使用的自动检测模式和石板路模式的相关代码,提升代码可读性。
This commit is contained in:
parent
dfb114257d
commit
f8980287e2
27
logs/robot_2025-06-01.log
Normal file
27
logs/robot_2025-06-01.log
Normal file
@ -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
|
5
main.py
5
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)
|
||||
|
@ -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()
|
Loading…
x
Reference in New Issue
Block a user