Skip to content

Commit 1b44351

Browse files
committed
camera to vehicle by point selecting.
1 parent fd501fa commit 1b44351

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

GEMstack/offboard/calibration/lidar_to_camera_manual.py renamed to GEMstack/offboard/calibration/camera_to_vehicle_manual.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
import matplotlib.pyplot as plt
55
import numpy as np
66

7-
rgb_path = '/mount/wp/GEMstack/data/color21.png'
8-
depth_path = '/mount/wp/GEMstack/data/depth21.tif'
9-
lidar_path = '/mount/wp/GEMstack/data/lidar21.npz'
7+
N = 4 #how many point pairs you want to select
8+
rgb_path = '/mount/wp/GEMstack/data/color20.png'
9+
depth_path = '/mount/wp/GEMstack/data/depth20.tif'
10+
lidar_path = '/mount/wp/GEMstack/data/lidar20.npz'
11+
# rgb_path = '/mount/wp/GEMstack/data/color25.png'
12+
# depth_path = '/mount/wp/GEMstack/data/depth25.tif'
13+
# lidar_path = '/mount/wp/GEMstack/data/lidar25.npz'
1014

1115
img = cv2.imread(rgb_path, cv2.IMREAD_UNCHANGED)
1216

1317
lidar_points = np.load(lidar_path)['arr_0']
1418
lidar_points = lidar_points[~np.all(lidar_points== 0, axis=1)] # remove (0,0,0)'s
1519

1620
rx,ry,rz = 0.006898647163954201, 0.023800082245145304, -0.025318355743942974
17-
<<<<<<< HEAD
18-
tx,ty,tz = 1.1, 0.03773044170906172, 1.9525244316515322
19-
=======
2021
tx,ty,tz = 1.1, 0.037735827433173136, 1.953202227766785
21-
>>>>>>> 3891eedef59a3b450d8beaead04b7309d36517be
2222
rot = R.from_euler('xyz',[rx,ry,rz]).as_matrix()
2323
lidar_ex = np.hstack([rot,[[tx],[ty],[tz]]])
2424
lidar_ex = np.vstack([lidar_ex,[0,0,0,1]])
@@ -29,7 +29,6 @@
2929
[ 0. , 0. , 1. ]
3030
], dtype=np.float32)
3131

32-
N = 8
3332

3433
#%%
3534
# blurred = cv2.GaussianBlur(img, (5, 5), 0)
@@ -91,7 +90,7 @@ def crop(pc,ix=None,iy=None,iz=None):
9190

9291

9392
lidar_post = np.pad(lidar_points,((0,0),(0,1)),constant_values=1) @ lidar_ex.T[:,:3]
94-
lidar_post = crop(lidar_post,ix=(0,8),iy=(-5,5))
93+
lidar_post = crop(lidar_post,ix=(0,10),iy=(-5,5))
9594
vis(notebook=True).add_pc(lidar_post).show()
9695

9796
#%%
@@ -188,10 +187,18 @@ def depth_to_points(depth_img: np.ndarray, intrinsics: np.ndarray):
188187
depth_img = cv2.imread(depth_path, cv2.IMREAD_UNCHANGED)
189188
camera_points = depth_to_points(depth_img, camera_in)
190189

191-
v=vis(notebook=False)
192-
v.add_pc(np.pad(lidar_points,((0,0),(0,1)),constant_values=1)@lidar_ex.T@T.T[:,:3],color='blue')
193-
v.add_pc(camera_points,color='red')
190+
#%%
191+
v2c = T
192+
print('vehicle->camera:',l2c)
193+
c2v = np.linalg.inv(l2c)
194+
print('camera->vehicle:',c2l)
195+
196+
v=vis(notebook=True)
197+
v.add_pc(lidar_post,color='blue')
198+
v.add_pc(np.pad(camera_points,((0,0),(0,1)),constant_values=1)@c2v.T[:,:3],color='red')
194199
v.show()
195200

196-
#%%
197-
print(np.vstack([(lidar_ex.T@T.T[:,:3]).T,[0,0,0,1]]))
201+
v=vis(notebook=True)
202+
v.add_pc(np.pad(lidar_post,((0,0),(0,1)),constant_values=1)@v2c.T[:,:3],color='blue')
203+
v.add_pc(camera_points,color='red')
204+
v.show()

0 commit comments

Comments
 (0)