63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
import os
|
|
import cv2
|
|
|
|
|
|
camera_names = ["front", "back", "left", "right"]
|
|
|
|
# --------------------------------------------------------------------
|
|
# (shift_width, shift_height): 鸟瞰图在水平和垂直方向上超出标定图案的距离
|
|
shift_w = 100
|
|
shift_h = 100
|
|
|
|
|
|
# 标定图案与车辆之间在水平和垂直方向上的间隙大小
|
|
inn_shift_w = 20
|
|
inn_shift_h = 20
|
|
|
|
# 拼接图像的总宽度/高度
|
|
total_w = 300 + 2 * shift_w
|
|
total_h = 350 + 2 * shift_h
|
|
|
|
|
|
# 计算车辆在全景图中的位置
|
|
xl = shift_w + 45 + inn_shift_w
|
|
xr = total_w - xl
|
|
print(xl, xr)
|
|
yt = shift_h + 60 + 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 + 0, shift_h),
|
|
(shift_w + 300, shift_h),
|
|
(shift_w + 0, shift_h + 60),
|
|
(shift_w + 300, shift_h + 60)],
|
|
|
|
"back": [(shift_w + 0, shift_h),
|
|
(shift_w + 300, shift_h),
|
|
(shift_w + 0, shift_h + 80),
|
|
(shift_w + 300, shift_h + 80)],
|
|
|
|
"left": [(shift_h + 0, shift_w),
|
|
(shift_h + 350, shift_w),
|
|
(shift_h + 0, shift_w + 50),
|
|
(shift_h + 350, shift_w + 50)],
|
|
|
|
"right": [(shift_h + 0, shift_w),
|
|
(shift_h + 350, shift_w),
|
|
(shift_h + 0, shift_w + 50),
|
|
(shift_h + 350, shift_w + 50)]
|
|
}
|
|
|
|
car_image = cv2.imread(os.path.join(os.getcwd(), "images", "car.png"))
|
|
car_image = cv2.resize(car_image, (xr - xl, yb - yt))
|