def plot_lidar(lidar): print(lidar.shape) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') for i in range(len(lidar)): ax.scatter(lidar[i, 0], lidar[i, 1], lidar[i, 2], s=0.01, c=[0.5, 0.5, 0.5]) plt.axis('equal') # ax.set_xlabel('LabelX') # ax.set_ylabel('LabelY') # ax.set_zlabel('LabelZ') # ax.set_xlim(30, 40) # ax.set_ylim(-10, 10) # ax.set_zlim(0, 10) plt.show() lidars = utils.load_velo_scans(['30.bin']) intensity_max = np.max(lidars[0][:, 3]) print('shape: ' + str(lidars[0].shape) + ' intensity max: ' + str(intensity_max)) plot_lidar(lidars[0]) top, top_image = data.lidar_to_top(lidars[0]) cv2.imwrite('30.png', top_image)
def handler_raw(tag): scan = lidar.load(tag) top = data.lidar_to_top(scan) front = p.lidar_to_front_fast(scan) os.makedirs(os.path.join(cfg.RAW_DATA_SETS_DIR, 'top_view', *tag.split('/')[:-1]), exist_ok=True) os.makedirs(os.path.join(cfg.RAW_DATA_SETS_DIR, 'front_view', *tag.split('/')[:-1]), exist_ok=True) np.save(os.path.join(cfg.RAW_DATA_SETS_DIR, 'top_view', tag + '.npy'), top) np.save(os.path.join(cfg.RAW_DATA_SETS_DIR, 'front_view', tag + '.npy'), front) print(tag)
def handler_test(fname): scan = np.fromfile(fname, dtype=np.float32).reshape((-1, 4)) top = data.lidar_to_top(scan) tag = fname.split('/')[-1].split('.')[-2] front = p.lidar_to_front_fast(scan) os.makedirs(os.path.join(base_dataset_path, "testing", "front_view"), exist_ok=True) os.makedirs(os.path.join(base_dataset_path, "testing", "top_view"), exist_ok=True) np.save( os.path.join(base_dataset_path, "testing", "front_view", tag + '.npy'), front) np.save( os.path.join(base_dataset_path, "testing", "top_view", tag + '.npy'), top) print(fname)
def plot_lidar(lidar): print(lidar.shape) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') for i in range(len(lidar)): ax.scatter(lidar[i,0], lidar[i,1], lidar[i,2],s=0.01, c= [0.5,0.5,0.5]) plt.axis('equal') # ax.set_xlabel('LabelX') # ax.set_ylabel('LabelY') # ax.set_zlabel('LabelZ') # ax.set_xlim(30, 40) # ax.set_ylim(-10, 10) # ax.set_zlim(0, 10) plt.show() lidars= utils.load_velo_scans(['30.bin']) intensity_max=np.max(lidars[0][:,3]) print('shape: '+str(lidars[0].shape)+' intensity max: '+str(intensity_max)) plot_lidar(lidars[0]) top, top_image = data.lidar_to_top(lidars[0]) cv2.imwrite('30.png', top_image)
import random import numpy as np from data import lidar_to_top, Preprocess pro = Preprocess() import pycuda.autoinit lidar = np.fromfile( '/home/maxiaojian/data/kitti/object/training/velodyne/007480.bin', dtype=np.float32) lidar = lidar.reshape((-1, 4)) t0 = time.time() top = lidar_to_top_cuda(lidar) t1 = time.time() print('done top, {}'.format(t1 - t0)) top_gt = lidar_to_top(lidar) t2 = time.time() print('done top cpu, {}'.format(t2 - t1)) assert (top.shape == top_gt.shape) assert (np.sum(top[..., 0:25] != top_gt[..., 0:25]) == 0) assert (np.sum(top[..., 26] != top_gt[..., 26]) == 0) from IPython import embed embed() # front = lidar_to_front_cuda(lidar) # t3 = time.time() # print('done front, {}'.format(t3-t2)) # front_gt = pro.lidar_to_front_fast(lidar) # t4 = time.time() # print('done front cpu, {}'.format(t4-t3)) # assert(front.shape == front_gt.shape) # assert(np.sum(front != front_gt) == 0)