62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
import os
|
|
import cv2
|
|
|
|
|
|
camera_names = ["front", "back", "left", "right"]
|
|
|
|
# --------------------------------------------------------------------
|
|
# (shift_width, shift_height): 鸟瞰图在水平和垂直方向上超出标定图案的距离
|
|
shift_w = 300
|
|
shift_h = 300
|
|
|
|
# 标定图案与车辆之间在水平和垂直方向上的间隙大小
|
|
inn_shift_w = 20
|
|
inn_shift_h = 50
|
|
|
|
# 拼接图像的总宽度/高度
|
|
total_w = 600 + 2 * shift_w
|
|
total_h = 1000 + 2 * shift_h
|
|
|
|
# 车辆所占矩形区域的四个角点
|
|
# 左上角 (x_left, y_top),右下角 (x_right, y_bottom)
|
|
xl = shift_w + 180 + inn_shift_w
|
|
xr = total_w - xl
|
|
yt = shift_h + 200 + 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)
|
|
}
|
|
|
|
# pixel locations of the four points to be chosen.
|
|
# you must click these pixels in the same order when running
|
|
# the get_projection_map.py script
|
|
project_keypoints = {
|
|
"front": [(shift_w + 120, shift_h),
|
|
(shift_w + 480, shift_h),
|
|
(shift_w + 120, shift_h + 160),
|
|
(shift_w + 480, shift_h + 160)],
|
|
|
|
"back": [(shift_w + 120, shift_h),
|
|
(shift_w + 480, shift_h),
|
|
(shift_w + 120, shift_h + 160),
|
|
(shift_w + 480, shift_h + 160)],
|
|
|
|
"left": [(shift_h + 280, shift_w),
|
|
(shift_h + 840, shift_w),
|
|
(shift_h + 280, shift_w + 160),
|
|
(shift_h + 840, shift_w + 160)],
|
|
|
|
"right": [(shift_h + 160, shift_w),
|
|
(shift_h + 720, shift_w),
|
|
(shift_h + 160, shift_w + 160),
|
|
(shift_h + 720, shift_w + 160)]
|
|
}
|
|
|
|
car_image = cv2.imread(os.path.join(os.getcwd(), "images", "car.png"))
|
|
car_image = cv2.resize(car_image, (xr - xl, yb - yt))
|