def prepForPredicting(fileidx, objects_to_suppress): data = np.fromfile(lidar_files.format(fileidx), dtype=np.float32).reshape( (-1, 4))[:, :3] calib_extrinsic = calib_extrinsics[calib_map[fileidx]].copy() calib_extrinsic[2, 3] += 1.65 data = data.dot(calib_extrinsic[:3, :3].T) + calib_extrinsic[:3, 3] # get ground ground = np.load(ground_planes_by_file.format(fileidx)) pts, tileidxs = tilePoints(data, grndstart, grndstep, grndlen) groundTs = planes2Transforms(ground) # get suppressed objects suppress_start, suppress_end = np.searchsorted(objects_to_suppress[:, 0], [fileidx, fileidx + 1]) #pts2suppress = objects_to_suppress[suppress_start:suppress_end, 1:3].copy() pts2suppress = np.zeros((suppress_end - suppress_start, 4)) pts2suppress[:, :2] = objects_to_suppress[suppress_start:suppress_end, 1:3] pts2suppress[:, 2] = np.cos(objects_to_suppress[suppress_start:suppress_end, 0]) pts2suppress[:, 2] = np.sin(objects_to_suppress[suppress_start:suppress_end, 0]) return pts, tileidxs, pts2suppress, groundTs
files2use = np.random.choice(np.arange(training_file_start, training_file_end), nfilesfornegatives, replace=False) objects_to_suppress = np.load(present_boxes_file) #anchoroverlaps = prepLocalNms() globaldetections = np.zeros( (nnegatives, anchorlen[0], anchorlen[1], anchorlen[2]), dtype=bool) detectioncount = 0 for file_idx in files2use: # load relevant data data = np.fromfile(lidar_files.format(file_idx), dtype=np.float32).reshape((-1, 4))[:, :3] calib_extrinsic = calib_extrinsics[calib_map[file_idx]].copy() calib_extrinsic[2, 3] += 1.65 data = data.dot(calib_extrinsic[:3, :3].T) + calib_extrinsic[:3, 3] # get ground ground = np.load(ground_planes_by_file.format(file_idx)) pts, tileidxs = tilePoints(data, grndstart, grndstep, grndlen) groundTs = planes2Transforms(ground) # get suppressed objects suppress_start, suppress_end = np.searchsorted( objects_to_suppress[:, 0], [file_idx, file_idx + 1]) pts2suppress = objects_to_suppress[suppress_start:suppress_end, 1:3].copy()
maxnotscoredcars = maxncars * 2 maxnpoints = estimate_npoints_per_car * maxncars out_pts = np.zeros((maxnpoints, 3)) out_idxs = np.zeros((maxncars, 3), dtype=int) out_positiveboxes = np.zeros((maxnotscoredcars, 7)) ncars = 0 npoints = 0 nnotscoredcars = 0 for file_idx in training_split: if file_idx % 1000 == 0: print("file {:d}".format(file_idx)) calib_extrinsic = calib_extrinsics[calib_map[file_idx]].copy() calib_extrinsic[2, 3] += 1.65 # load relevant data data = np.fromfile(lidar_files.format(file_idx), dtype=np.float32).reshape( (-1, 4))[:, :3] with open(gt_files.format(file_idx), 'r') as fd: gtstr = fd.read() gtstuff = readGroundTruthFile(gtstr, ('Car', 'Van')) gt = [{ 'box': gtstuff[1][gtidx], 'scored': gtstuff[4][gtidx] } for gtidx in xrange(len(gtstuff[0]))] ground = np.load(ground_planes_by_file.format(file_idx)) # get ground full_data_xyz = data.dot(calib_extrinsic[:3, :3].T) + calib_extrinsic[:3, 3] full_data_tiled, data_tile_idxs = tilePoints(full_data_xyz, grndstart, grndstep, grndlen)