def main(): from core.kitti import KITTI, ALL_OBJECTS, CARS_ONLY DS_DIR = '/home/salam/datasets/KITTI/training' reader = KITTI(DS_DIR, CARS_ONLY) ids = reader.get_ids('train') for t in [ids[4]]: img = reader.get_image(t) pts, ref = reader.get_velo(t, use_fov_filter=False) boxes_2D = reader.get_boxes_2D(t) boxes_3D = reader.get_boxes_3D(t) P2 = reader.get_calib(t)[2] for b in boxes_3D: b.text = f"{np.random.uniform(0.0, 1.0, (1,))[0]:0.2f}" imshow(bev(pts, pred_boxes=boxes_3D, title="GT"))
# Training BATCH_SIZE = configs['hyperparams']['batch_size'] LEARNING_RATE = configs['hyperparams']['lr'] EPOCHS = configs['hyperparams']['epochs'] NUM_THREADS = configs['hyperparams']['num_threads'] MAX_Q_SIZE = configs['hyperparams']['max_q_size'] # Create dirs OUTPUTS_DIR = os.path.join('new_outputs') CKPTS_DIR = os.path.join(OUTPUTS_DIR, configs['ckpts_dir']) for d in [OUTPUTS_DIR, CKPTS_DIR]: print("Creating directory: " + d) os.makedirs(d, exist_ok=True) kitti = KITTI(DS_DIR, configs['training_target']) train_ids = kitti.get_ids('train') val_ids = kitti.get_ids('val') micro_ids = kitti.get_ids('micro') pc_encoder = configs['pc_encoder'] target_encoder = configs['target_encoder'] pprint.pprint(configs['stats']) logdir = "{0}/logs/".format(CKPTS_DIR) + datetime.now().strftime( "%m-%d-%H-%M") + configs['exp_name'] scalar_logdir = logdir + "/scalars/" file_writer = tf.summary.create_file_writer(scalar_logdir)
# Training BATCH_SIZE = configs['hyperparams']['batch_size'] LEARNING_RATE = configs['hyperparams']['lr'] EPOCHS = configs['hyperparams']['epochs'] NUM_THREADS = configs['hyperparams']['num_threads'] MAX_Q_SIZE = configs['hyperparams']['max_q_size'] # Create dirs OUTPUTS_DIR = os.path.join('outputs') CKPTS_DIR = os.path.join(OUTPUTS_DIR, configs['ckpts_dir']) for d in [OUTPUTS_DIR, CKPTS_DIR]: print("Creating directory: " + d) os.makedirs(d, exist_ok=True) kitti = KITTI(DS_DIR, configs['training_target']) train_ids = kitti.get_ids('train') val_ids = kitti.get_ids('val') micro_ids = kitti.get_ids('micro') pprint.pprint(configs['stats']) logdir = "{0}/logs/".format(CKPTS_DIR) + datetime.now().strftime("%m-%d-%H-%M") scalar_logdir = logdir + "/scalars/" file_writer = tf.summary.create_file_writer(scalar_logdir) file_writer.set_as_default() imgs_logdir = logdir + "/images/" img_writer = tf.summary.create_file_writer(imgs_logdir)
device_name = tf.test.gpu_device_name() os.system('clear') print('Conncted to Device:', device_name) # Point Cloud Encoder INPUT_SHAPE = configs['input_shape'] # Training BATCH_SIZE = configs['hyperparams']['batch_size'] LEARNING_RATE = configs['hyperparams']['lr'] EPOCHS = configs['hyperparams']['epochs'] NUM_THREADS = configs['hyperparams']['num_threads'] MAX_Q_SIZE = configs['hyperparams']['max_q_size'] kitti = KITTI(DS_DIR, configs['training_target']) train_ids = kitti.get_ids('train') val_ids = kitti.get_ids('val') micro_ids = kitti.get_ids('micro') def bev2world(idx, jdx, bev_width, bev_length, world_width, world_length): disc_factor_w, disc_factor_l = world_width / bev_width, world_length / bev_length x = idx * disc_factor_w - world_width / 2. z = (bev_length - jdx) * disc_factor_l return np.array([x, 0.5, z]) def get_nearest_neighbour(pt_cloud, bev_width,
''' https://stackoverflow.com/questions/21037241/how-to-determine-a-point-is-inside-or-outside-a-cube https://math.stackexchange.com/questions/1472049/check-if-a-point-is-inside-a-rectangular-shaped-area-3d https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect https://stackoverflow.com/questions/1211212/how-to-calculate-an-angle-from-three-points https://stackoverflow.com/questions/20677795/how-do-i-compute-the-intersection-point-of-two-lines https://www.cs.hmc.edu/ACM/lectures/intersections.html https://docs.yoyogames.com/source/dadiospice/002_reference/movement%20and%20collisions/collisions/rectangle_in_triangle.html https://math.stackexchange.com/questions/3210769/how-do-i-check-if-a-3d-point-is-between-2-other-3d-points https://math.stackexchange.com/questions/208577/find-if-three-points-in-3-dimensional-space-are-collinear https://forum.thegamecreators.com/thread/179559# ''' DS_DIR = '/home/salam/datasets/KITTI/training' reader = KITTI(DS_DIR, CARS_ONLY) ids = reader.get_ids('train') def check_colinear(a, b, c): ab = b - a ac = c - a cross = np.cross(ab, ac) if cross.all() < 1e-12: # print(cross) # print(a, b, c) return True return False
# Training BATCH_SIZE = configs['hyperparams']['batch_size'] LEARNING_RATE = configs['hyperparams']['lr'] EPOCHS = configs['hyperparams']['epochs'] NUM_THREADS = configs['hyperparams']['num_threads'] MAX_Q_SIZE = configs['hyperparams']['max_q_size'] # Create dirs OUTPUTS_DIR = os.path.join('outputs') CKPTS_DIR = os.path.join(OUTPUTS_DIR, configs['ckpts_dir']) for d in [OUTPUTS_DIR, CKPTS_DIR]: print("Creating directory: " + d) os.makedirs(d, exist_ok=True) kitti = KITTI(DS_DIR, configs['training_target']) train_ids = kitti.get_ids('train') val_ids = kitti.get_ids('val') micro_ids = kitti.get_ids('micro') pc_encoder = configs['pc_encoder'] target_encoder = configs['target_encoder'] pprint.pprint(configs['stats']) logdir = "{0}/logs/".format(CKPTS_DIR) + datetime.now().strftime("%m-%d-%H-%M") scalar_logdir = logdir + "/scalars/" file_writer = tf.summary.create_file_writer(scalar_logdir) file_writer.set_as_default()