#!/usr/bin/env python3 import cv2 import sys import os # 添加父目录到路径,以便能够导入utils sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from utils.decode_arrow import detect_arrow_direction, visualize_arrow_detection def main(): # 检查命令行参数 if len(sys.argv) < 2: print("使用方法: python test_arrow.py <图像路径>") sys.exit(1) # 获取图像路径 image_path = sys.argv[1] # 检查文件是否存在 if not os.path.exists(image_path): print(f"错误: 文件 '{image_path}' 不存在") sys.exit(1) print(f"正在处理图像: {image_path}") # 检测箭头方向 direction = detect_arrow_direction(image_path) print(f"检测到的箭头方向: {direction}") # 可视化检测过程 visualize_arrow_detection(image_path) if __name__ == "__main__": main()