Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BerensRWU authored Sep 19, 2022
1 parent d8bc196 commit 9743351
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def lidar2cam(self, pts_3d_lidar):
return pts_3d_cam_rec

# From Camera Coordinate system to Image frame
def rect2Img(self, rect_pts):
def rect2Img(self, rect_pts, img_width, img_height):
n = rect_pts.shape[0]
points_hom = np.hstack((rect_pts, np.ones((n,1))))
points_2d = np.dot(points_hom, np.transpose(self.P)) # nx3
points_2d[:,0] /= points_2d[:,2]
points_2d[:,1] /= points_2d[:,2]

mask = (points_2d[:,0] >= 0) & (points_2d[:,0] <= 1242) & (points_2d[:,1] >= 0) & (points_2d[:,1] <= 375)
mask = (points_2d[:,0] >= 0) & (points_2d[:,0] <= img_width) & (points_2d[:,1] >= 0) & (points_2d[:,1] <= img_height)
mask = mask & (rect_pts[:,2] > 2)
return points_2d[mask,0:2], mask

Expand All @@ -68,7 +68,7 @@ def rect2Img(self, rect_pts):
# From LiDAR coordinate system to Camera Coordinate system
lidar_rect = calib.lidar2cam(lidar[:,0:3])
# From Camera Coordinate system to Image frame
lidarOnImage, mask = calib.rect2Img(lidar_rect)
lidarOnImage, mask = calib.rect2Img(lidar_rect, img.shape[1], img.shape[0])
# Concatenate LiDAR position with the intesity (3), with (2) we would have the depth
lidarOnImage = np.concatenate((lidarOnImage, lidar_rect[mask,2].reshape(-1,1)), 1)

Expand Down

0 comments on commit 9743351

Please sign in to comment.