def __getitem__(self, idx): self._curr_counter = idx # Get the next dataset if frame number is more than table count if self._frame_counter == -1 or not len(self._dataset_nums) or self._frame_counter >= self._dataset_nums[self._file_counter]-1: self.current_file = self.__file_names.pop() # get one filename dataset = WaymoDataFileReader(self.current_file) # get Dataloader self._sample_list = dataset.get_record_table() # get number of record table self._dataset_itr = iter(dataset) # Get next record iterator if self._frame_counter == -1: self._file_counter +=1 self._dataset_nums.append(len(self._sample_list)) self._frame_counter = 1 else: self._frame_counter+=1 self._num_frames+=1 self._idx_to_frame.append((self._file_counter, self._frame_counter)) return next(self.dataset_itr) # Send next frame from record
def export_file(filename): print('[{}] Porting: {}'.format(threading.get_ident(), filename)) head, tail = os.path.split(filename) m = re.search('(.*)(_with_camera_labels)?\.tfrecord$', tail) if m is None: exit(1) filename_without_tfrecord = m.group(1) _start_time = time.time() # waymo data file reader datafile = WaymoDataFileReader(filename) # Generate a table of the offset of all frame records in the file. table = datafile.get_record_table() print("There are %d frames in this file." % len(table)) # Loop through the whole file ## and display 3D labels. frame_id = 0 for frame in datafile: camera_name = dataset_pb2.CameraName.FRONT camera_calibration = utils.get(frame.context.camera_calibrations, camera_name) camera = utils.get(frame.images, camera_name) camera_labels = None if len(frame.camera_labels) != 0: camera_labels = utils.get(frame.camera_labels, camera_name) camera_labels = camera_labels.labels exporter.export(camera_calibration, camera, frame.laser_labels, camera_labels, frame_id=frame_id, sequence_id=filename_without_tfrecord) frame_id += 1 print('[{}] Processed file in {}'.format(threading.get_ident(), time.time() - _start_time))
def parse_record( output_dir: str, save_images: bool, use_lidar_labels: bool, record_name: str, ) -> Tuple[List[Frame], List[FrameGroup]]: """Parse data into List of Scalabel format annotations.""" datafile = WaymoDataFileReader(record_name) table = datafile.get_record_table() frames, groups = [], [] for frame_id, offset in enumerate(table): # jump to correct place, read frame datafile.seek(offset) frame = datafile.read_record() # add images and annotations to coco frame, group = parse_frame(frame, frame_id, output_dir, save_images, use_lidar_labels) frames.extend(frame) groups.extend(group) return frames, groups
# Draw a circle for each point. for i in range(proj_pcl.shape[0]): cv2.circle(img, (int(proj_pcl[i,0]),int(proj_pcl[i,1])), 1, coloured_intensity[i]) if len(sys.argv) != 2: print("""Usage: python display_laser_on_image.py <datafile> Display the groundtruth 3D bounding boxes and LIDAR points on the front camera video stream.""") sys.exit(0) # Open a .tfrecord filename = sys.argv[1] datafile = WaymoDataFileReader(filename) # Generate a table of the offset of all frame records in the file. table = datafile.get_record_table() print("There are %d frames in this file." % len(table)) # Loop through the whole file ## and display 3D labels. for frameno,frame in enumerate(datafile): # Get the top laser information laser_name = dataset_pb2.LaserName.TOP laser = utils.get(frame.lasers, laser_name) laser_calibration = utils.get(frame.context.laser_calibrations, laser_name) # Parse the top laser range image and get the associated projection. ri, camera_projection, range_image_pose = utils.parse_range_image_and_camera_projection(laser)