Files
ADAS360/surround_view/param_settings copy.py
2025-10-28 18:46:04 +08:00

66 lines
2.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
import cv2
camera_names = ["front", "back", "left", "right"]
# --------------------------------------------------------------------
# (shift_width, shift_height): 鸟瞰图超出标定布的横向和纵向范围
# 适配桌面环境,确保总范围不超过桌面尺寸
shift_w = 50 # 左右方向各扩展10cm
shift_h = 50 # 前后方向各扩展10cm
# 标定布与车身之间的间隙(横向和纵向)
inn_shift_w = 5 # 左右方向间隙
inn_shift_h = 8 # 前后方向间隙
# 标定布主体尺寸(宽×高)
calib_width = 60 # 标定布宽度60cm
calib_height = 100 # 标定布高度100cm
# 拼接后图像的总尺寸
total_w = calib_width + 2 * shift_w # 60 + 2×10 = 80cm
total_h = calib_height + 2 * shift_h # 100 + 2×10 = 120cm
# 车身占据的矩形区域四角坐标
# 确保与小车实际尺寸匹配宽12cm长20cm
xl = shift_w + (calib_width - 12) // 2 + inn_shift_w # 10 + 24 + 5 = 39
xr = xl + 12 # 右侧坐标确保宽度12cm
yt = shift_h + (calib_height - 20) // 2 + inn_shift_h # 10 + 40 + 8 = 58
yb = yt + 20 # 底部坐标确保长度20cm
# --------------------------------------------------------------------
project_shapes = {
"front": (total_w, yt), # 前相机投影区域宽80cm × 高58cm
"back": (total_w, total_h - yb), # 后相机投影区域宽80cm × 高42cm
"left": (total_h, xl), # 左相机投影区域高120cm × 宽39cm
"right": (total_h, total_w - xr) # 右相机投影区域高120cm × 宽29cm
}
# 四个标记点的像素位置运行get_projection_map.py时需按相同顺序点击
project_keypoints = {
"front": [(shift_w + 12, shift_h), # 前标定板左上
(shift_w + 48, shift_h), # 前标定板右上
(shift_w + 12, shift_h + 16), # 前标定板左下
(shift_w + 48, shift_h + 16)], # 前标定板右下
"back": [(shift_w + 12, shift_h), # 后标定板左上
(shift_w + 48, shift_h), # 后标定板右上
(shift_w + 12, shift_h + 16), # 后标定板左下
(shift_w + 48, shift_h + 16)], # 后标定板右下
"left": [(shift_h + 28, shift_w), # 左标定板左上
(shift_h + 64, shift_w), # 左标定板右上
(shift_h + 28, shift_w + 12), # 左标定板左下
(shift_h + 68, shift_w + 12)], # 左标定板右下
"right": [(shift_h + 28, shift_w), # 右标定板左上
(shift_h + 64, shift_w), # 右标定板右上
(shift_h + 28, shift_w + 12), # 右标定板左下
(shift_h + 68, shift_w + 12)] # 右标定板右下
}
# 加载并调整车身图标大小以匹配车身区域
car_image = cv2.imread(os.path.join(os.getcwd(), "images", "car.png"))
car_image = cv2.resize(car_image, (xr - xl, yb - yt)) # 调整为12×20cm的车身大小