new
This commit is contained in:
BIN
images/left.png
BIN
images/left.png
Binary file not shown.
|
Before Width: | Height: | Size: 4.5 MiB After Width: | Height: | Size: 4.9 MiB |
@@ -180,6 +180,7 @@ def main():
|
||||
else:
|
||||
img = buffer_manager.get_device(device).get().image
|
||||
if img is None:
|
||||
|
||||
print("读取本地相机帧失败")
|
||||
break
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import os
|
||||
import cv2
|
||||
|
||||
|
||||
# 摄像头名称列表
|
||||
camera_names = ["front", "back", "left", "right"]
|
||||
|
||||
@@ -22,8 +21,8 @@ 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
|
||||
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
|
||||
@@ -39,34 +38,34 @@ yb = total_h - yt
|
||||
|
||||
# 各摄像头投影区域的尺寸
|
||||
project_shapes = {
|
||||
"front": (total_w, yt), # 前摄像头:(宽度, 高度)
|
||||
"back": (total_w, yt), # 后摄像头:(宽度, 高度)
|
||||
"left": (total_h, xl), # 左摄像头:(宽度, 高度)
|
||||
"right": (total_h, xl) # 右摄像头:(宽度, 高度)
|
||||
"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), # 前摄像头的四个关键点坐标
|
||||
"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)],
|
||||
"back": [(shift_w + 200, shift_h),
|
||||
(shift_w + 2800, shift_h),
|
||||
(shift_w + 200, shift_h + 500),
|
||||
(shift_w + 2800, shift_h + 500)],
|
||||
|
||||
"left": [(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 + 300, shift_h),
|
||||
(shift_w + 3200, shift_h),
|
||||
(shift_w + 300, shift_h + 700),
|
||||
(shift_w + 3200, shift_h + 700)],
|
||||
|
||||
"right": [(shift_h + 240, shift_w), # 右摄像头的四个关键点坐标
|
||||
(shift_h + 560, shift_w),
|
||||
(shift_h + 240, shift_w + 120),
|
||||
(shift_h + 560, shift_w + 120)],
|
||||
"right": [(shift_h + 500, shift_w),
|
||||
(shift_h + 3300, shift_w),
|
||||
(shift_h + 500, shift_w + 600),
|
||||
(shift_h + 3300, shift_w + 600)],
|
||||
}
|
||||
|
||||
# 读取车辆图片并调整尺寸以匹配车辆所在区域
|
||||
|
||||
@@ -45,24 +45,11 @@ class PointSelector(object):
|
||||
self.window_width = image.shape[1]
|
||||
self.window_height = image.shape[0]
|
||||
self.scale = 1.0 # 缩放比例
|
||||
self.last_window_size = (self.window_width, self.window_height)
|
||||
|
||||
def draw_image(self):
|
||||
"""
|
||||
Display the selected keypoints and draw the convex hull.
|
||||
"""
|
||||
# 检查窗口大小是否改变
|
||||
current_width = cv2.getWindowImageRect(self.title)[2] if cv2.getWindowProperty(self.title, cv2.WND_PROP_VISIBLE) >= 1 else self.window_width
|
||||
current_height = cv2.getWindowImageRect(self.title)[3] if cv2.getWindowProperty(self.title, cv2.WND_PROP_VISIBLE) >= 1 else self.window_height
|
||||
|
||||
if current_width != self.last_window_size[0] or current_height != self.last_window_size[1]:
|
||||
self.window_width = current_width
|
||||
self.window_height = current_height
|
||||
self.last_window_size = (current_width, current_height)
|
||||
# 计算新的缩放比例
|
||||
self.scale = min(current_width / self.original_image.shape[1],
|
||||
current_height / self.original_image.shape[0])
|
||||
|
||||
# 基于当前缩放比例调整点坐标
|
||||
scaled_keypoints = [
|
||||
(int(x * self.scale), int(y * self.scale))
|
||||
@@ -104,6 +91,14 @@ class PointSelector(object):
|
||||
print(f"click ({orig_x}, {orig_y}) (scaled: ({x}, {y}))")
|
||||
self.keypoints.append((orig_x, orig_y))
|
||||
self.draw_image()
|
||||
# 窗口大小改变事件
|
||||
elif event == cv2.EVENT_RESIZE:
|
||||
self.window_width = x
|
||||
self.window_height = y
|
||||
# 计算新的缩放比例
|
||||
self.scale = min(x / self.original_image.shape[1],
|
||||
y / self.original_image.shape[0])
|
||||
self.draw_image()
|
||||
|
||||
def loop(self):
|
||||
"""
|
||||
|
||||
@@ -4,14 +4,14 @@ camera_matrix: !!opencv-matrix
|
||||
rows: 3
|
||||
cols: 3
|
||||
dt: d
|
||||
data: [ 9.1359191618490445e+02, 0., 1.2635952283523022e+03, 0.,
|
||||
9.3632218470618568e+02, 7.3904470142576406e+02, 0., 0., 1. ]
|
||||
data: [ 8.6085837664709743e+02, 0., 1.2610909633324620e+03, 0.,
|
||||
8.5916628062781513e+02, 7.4679605390407391e+02, 0., 0., 1. ]
|
||||
dist_coeffs: !!opencv-matrix
|
||||
rows: 4
|
||||
cols: 1
|
||||
dt: d
|
||||
data: [ -2.5688204048403651e-01, 1.5654636330056526e-01,
|
||||
-1.7971288175677119e-01, 8.7103625346845376e-02 ]
|
||||
data: [ -1.9840720995187411e-01, 4.4909756045077721e-02,
|
||||
-2.1701148356244541e-02, 5.2723437035547662e-03 ]
|
||||
resolution: !!opencv-matrix
|
||||
rows: 2
|
||||
cols: 1
|
||||
@@ -21,10 +21,10 @@ project_matrix: !!opencv-matrix
|
||||
rows: 3
|
||||
cols: 3
|
||||
dt: d
|
||||
data: [ -2.9179778642686394e-01, -7.4241907296046106e-01,
|
||||
7.9539195878902456e+02, -1.6965639676084780e-02,
|
||||
-1.1036320216549194e+00, 8.9754354771952148e+02,
|
||||
-2.1693275673820841e-05, -1.5407635352890023e-03, 1. ]
|
||||
data: [ -1.6630244936572751e+00, -2.6235622379961145e+00,
|
||||
3.5016508426417076e+03, -9.6185827770920898e-02,
|
||||
-2.4771954637838691e+00, 2.6363684218350554e+03,
|
||||
-5.3720940146215687e-05, -1.4862196717814050e-03, 1. ]
|
||||
scale_xy: !!opencv-matrix
|
||||
rows: 2
|
||||
cols: 1
|
||||
|
||||
@@ -4,14 +4,14 @@ camera_matrix: !!opencv-matrix
|
||||
rows: 3
|
||||
cols: 3
|
||||
dt: d
|
||||
data: [ 912.97883483233306, 0., 1153.06231788181, 0.,
|
||||
934.30332152657456, 703.22316308984716, 0., 0., 1. ]
|
||||
data: [ 8.6726608019452317e+02, 0., 1.1654823547060421e+03, 0.,
|
||||
8.6642315489461635e+02, 7.0829791670122563e+02, 0., 0., 1. ]
|
||||
dist_coeffs: !!opencv-matrix
|
||||
rows: 4
|
||||
cols: 1
|
||||
dt: d
|
||||
data: [ -0.22262094222158474, 0.091910107741035543,
|
||||
-0.11125663233319319, 0.05256364519765256 ]
|
||||
data: [ -2.0351195680457176e-01, 7.2366975794859609e-02,
|
||||
-6.7931513547321534e-02, 2.7753672462015658e-02 ]
|
||||
resolution: !!opencv-matrix
|
||||
rows: 2
|
||||
cols: 1
|
||||
@@ -21,16 +21,17 @@ project_matrix: !!opencv-matrix
|
||||
rows: 3
|
||||
cols: 3
|
||||
dt: d
|
||||
data: [ -5.4156645669996912, -9.3442896959392545, 7401.7924039391992,
|
||||
0.29915864114461999, -10.301469369661787, 5333.8769633702723,
|
||||
2.208437292348208e-05, -0.0050239538618510439, 1. ]
|
||||
data: [ -1.7621178147029364e+00, -3.1225515440046361e+00,
|
||||
3.6879628012831586e+03, 6.4441326643723845e-02,
|
||||
-3.2973218330573513e+00, 3.0848594829140279e+03,
|
||||
2.7252094566955889e-05, -1.6884773289497907e-03, 1. ]
|
||||
scale_xy: !!opencv-matrix
|
||||
rows: 2
|
||||
cols: 1
|
||||
dt: f
|
||||
data: [ 0.699999988, 0.800000012 ]
|
||||
data: [ 6.99999988e-01, 8.00000012e-01 ]
|
||||
shift_xy: !!opencv-matrix
|
||||
rows: 2
|
||||
cols: 1
|
||||
dt: f
|
||||
data: [ -150., -500. ]
|
||||
data: [ -150., -100. ]
|
||||
|
||||
@@ -4,14 +4,14 @@ camera_matrix: !!opencv-matrix
|
||||
rows: 3
|
||||
cols: 3
|
||||
dt: d
|
||||
data: [ 9.0580569362933545e+02, 0., 1.2526625521235414e+03, 0.,
|
||||
9.0650948172469225e+02, 6.5033182889464206e+02, 0., 0., 1. ]
|
||||
data: [ 8.6972545879267147e+02, 0., 1.2731530414558019e+03, 0.,
|
||||
8.6863876700165883e+02, 6.9832870386138904e+02, 0., 0., 1. ]
|
||||
dist_coeffs: !!opencv-matrix
|
||||
rows: 4
|
||||
cols: 1
|
||||
dt: d
|
||||
data: [ -2.2164953330895090e-01, 4.4177658648078696e-02,
|
||||
-1.9393499331826249e-02, 6.6005226176948407e-03 ]
|
||||
data: [ -1.8948663835610799e-01, 1.9444291732014014e-02,
|
||||
-3.0028660958549623e-03, 9.1632974594709046e-04 ]
|
||||
resolution: !!opencv-matrix
|
||||
rows: 2
|
||||
cols: 1
|
||||
@@ -21,10 +21,10 @@ project_matrix: !!opencv-matrix
|
||||
rows: 3
|
||||
cols: 3
|
||||
dt: d
|
||||
data: [ -5.0581752299581340e-01, -1.3713554452799930e+00,
|
||||
1.3568685515624798e+03, 1.3945277219985447e-02,
|
||||
-9.3798987988477867e-01, 6.5516461320394853e+02,
|
||||
-4.0658856622034665e-07, -1.7343355065690702e-03, 1. ]
|
||||
data: [ -2.0521737883395668e+00, -3.7532420536911584e+00,
|
||||
4.2596358822851871e+03, -2.4577314766587831e-03,
|
||||
-3.3960994301950915e+00, 3.0045527363823876e+03,
|
||||
-8.1924382555303808e-06, -1.9197310294567422e-03, 1. ]
|
||||
scale_xy: !!opencv-matrix
|
||||
rows: 2
|
||||
cols: 1
|
||||
|
||||
@@ -4,14 +4,14 @@ camera_matrix: !!opencv-matrix
|
||||
rows: 3
|
||||
cols: 3
|
||||
dt: d
|
||||
data: [ 9.0277823073247305e+02, 0., 1.2536850522335756e+03, 0.,
|
||||
8.9630980881437813e+02, 6.5471986586202775e+02, 0., 0., 1. ]
|
||||
data: [ 8.7001377715765227e+02, 0., 1.2520202319593454e+03, 0.,
|
||||
8.6893992064850067e+02, 6.5329143283312703e+02, 0., 0., 1. ]
|
||||
dist_coeffs: !!opencv-matrix
|
||||
rows: 4
|
||||
cols: 1
|
||||
dt: d
|
||||
data: [ -2.1511756060462653e-01, 2.0035463501247644e-02,
|
||||
9.5960604184571630e-03, -4.4510596773296362e-03 ]
|
||||
data: [ -1.8480348724697190e-01, 3.6776710909225533e-03,
|
||||
1.9908231938694565e-02, -8.8681518371373363e-03 ]
|
||||
resolution: !!opencv-matrix
|
||||
rows: 2
|
||||
cols: 1
|
||||
@@ -21,10 +21,10 @@ project_matrix: !!opencv-matrix
|
||||
rows: 3
|
||||
cols: 3
|
||||
dt: d
|
||||
data: [ -4.4842873174953890e-01, -1.2747192546497945e+00,
|
||||
1.1617447668040295e+03, 6.6242519223062351e-03,
|
||||
-1.0531016668903570e+00, 6.7139498427549870e+02,
|
||||
1.7957623585927813e-05, -1.9558863991643110e-03, 1. ]
|
||||
data: [ -1.9401318142117736e+00, -3.9568680582533751e+00,
|
||||
4.3374250732845567e+03, 2.2553918190428280e-02,
|
||||
-3.0113755118912739e+00, 2.8156665747361490e+03,
|
||||
-1.5310504337675217e-05, -1.7968437058381963e-03, 1. ]
|
||||
scale_xy: !!opencv-matrix
|
||||
rows: 2
|
||||
cols: 1
|
||||
|
||||
Reference in New Issue
Block a user