import os import cv2 # 摄像头名称列表 camera_names = ["front", "back", "left", "right"] # 标定布向外扩展的尺寸,单位为像素,默认不修改 shift_w = 300 shift_h = 300 # 标定布的长和宽 cal_w = 3000 cal_h = 3500 # 标定布四角的长和宽 conner_w = 1000 conner_h = 1000 # 车辆的长和宽 car_w = 300 car_h = 550 # 车辆与标定布指定四角之间的间隙 inn_shift_w = (cal_w - 2 * conner_w - car_w)//2 inn_shift_h = (cal_h - 2 * conner_h - car_h)//2 # 图片的总宽度和总高度 total_w = cal_w + 2 * shift_w total_h = cal_h + 2 * shift_h # 车辆所占矩形区域的四个角坐标 # 左上角 (x_left, y_top),右下角 (x_right, y_bottom) xl = shift_w + conner_w + inn_shift_w xr = total_w - xl yt = shift_h + conner_h + inn_shift_h yb = total_h - yt # -------------------------------------------------------------------- # 各摄像头投影区域的尺寸 project_shapes = { "front": (total_w, yt), # 前摄像头:(宽度, 高度) "back": (total_w, yt), # 后摄像头:(宽度, 高度) "left": (total_h, xl), # 左摄像头:(宽度, 高度) "right": (total_h, xl) # 右摄像头:(宽度, 高度) } # 待选择的四个点的像素位置 # 运行 get_projection_map.py 脚本时,必须按相同顺序点击这些像素 project_keypoints = { "front": [(shift_w + 200, shift_h), # 前摄像头的四个关键点坐标 (shift_w + 2800, shift_h), (shift_w + 200, shift_h + 800), (shift_w + 2800, shift_h + 800)], "back": [(shift_w + 80, shift_h), # 后摄像头的四个关键点坐标 (shift_w + 320, shift_h), (shift_w + 80, shift_h + 200), (shift_w + 320, shift_h + 200)], "left": [(shift_w + 80, shift_h), # 左摄像头的四个关键点坐标 (shift_w + 320, shift_h), (shift_w + 80, shift_h + 200), (shift_w + 320, shift_h + 200)], "right": [(shift_h + 240, shift_w), # 右摄像头的四个关键点坐标 (shift_h + 560, shift_w), (shift_h + 240, shift_w + 120), (shift_h + 560, shift_w + 120)], } # 读取车辆图片并调整尺寸以匹配车辆所在区域 car_image = cv2.imread(os.path.join(os.getcwd(), "images", "car.png")) car_image = cv2.resize(car_image, (xr - xl, yb - yt)) # 输出所有参数 print("--------------------------------------------------------------------") print(f"总宽度:{total_w}") print(f"总高度:{total_h}") print(f"车辆宽度:{car_w}") print(f"车辆高度:{car_h}") print(f"标定布宽度:{cal_w}") print(f"标定布高度:{cal_h}") print(f"标定布内四角宽度:{conner_w}") print(f"标定布内四角高度:{conner_h}") print(f"标定布外扩展宽度:{shift_w}") print(f"标定布外扩展高度:{shift_h}") print(f"车辆所在区域内间隙宽度:{inn_shift_w}") print(f"车辆所在区域内间隙高度:{inn_shift_h}") print(f"车辆所在区域左上角:({xl}, {yt})") print(f"车辆所在区域右下角:({xr}, {yb})") print(f"车辆所在区域四角坐标:{project_keypoints}") print(f"投影区域尺寸:{project_shapes}") print("--------------------------------------------------------------------")