maudzung / SFA3D

Super Fast and Accurate 3D Object Detection based on 3D LiDAR Point Clouds (The PyTorch implementation)
https://github.com/maudzung/Super-Fast-Accurate-3D-Object-Detection
MIT License
1k stars 271 forks source link

principle of makeBEVMap #62

Closed cltdevelop closed 2 years ago

cltdevelop commented 2 years ago

Anyone can help me. I really do not understand the principle of makeBEVMap function, can you explain it step by step. Thank you very much in advance!

def makeBEVMap(PointCloud_, boundary): Height = cnf.BEV_HEIGHT + 1 Width = cnf.BEV_WIDTH + 1

# Discretize Feature Map
PointCloud = np.copy(PointCloud_)
PointCloud[:, 0] = np.int_(np.floor(PointCloud[:, 0] / cnf.DISCRETIZATION))
PointCloud[:, 1] = np.int_(np.floor(PointCloud[:, 1] / cnf.DISCRETIZATION) + Width / 2)

# sort-3times
sorted_indices = np.lexsort((-PointCloud[:, 2], PointCloud[:, 1], PointCloud[:, 0]))
PointCloud = PointCloud[sorted_indices]
_, unique_indices, unique_counts = np.unique(PointCloud[:, 0:2], axis=0, return_index=True, return_counts=True)
PointCloud_top = PointCloud[unique_indices]

# Height Map, Intensity Map & Density Map
heightMap = np.zeros((Height, Width))
intensityMap = np.zeros((Height, Width))
densityMap = np.zeros((Height, Width))

# some important problem is image coordinate is (y,x), not (x,y)
max_height = float(np.abs(boundary['maxZ'] - boundary['minZ']))
heightMap[np.int_(PointCloud_top[:, 0]), np.int_(PointCloud_top[:, 1])] = PointCloud_top[:, 2] / max_height
# try:
#     heightMap[np.int_(PointCloud_top[:, 0]), np.int_(PointCloud_top[:, 1])] = PointCloud_top[:, 2] / max_height
# except:
#     aa = 1

normalizedCounts = np.minimum(1.0, np.log(unique_counts + 1) / np.log(64))
intensityMap[np.int_(PointCloud_top[:, 0]), np.int_(PointCloud_top[:, 1])] = PointCloud_top[:, 3]
densityMap[np.int_(PointCloud_top[:, 0]), np.int_(PointCloud_top[:, 1])] = normalizedCounts

RGB_Map = np.zeros((3, Height - 1, Width - 1))
RGB_Map[2, :, :] = densityMap[:cnf.BEV_HEIGHT, :cnf.BEV_WIDTH]  # r_map
RGB_Map[1, :, :] = heightMap[:cnf.BEV_HEIGHT, :cnf.BEV_WIDTH]  # g_map
RGB_Map[0, :, :] = intensityMap[:cnf.BEV_HEIGHT, :cnf.BEV_WIDTH]  # b_map

return RGB_Map
maudzung commented 2 years ago

Hi @cltdevelop Please refer to section 2.1 in this paper