def get_image(self, idx: int, camera: str, log_id: Optional[str] = None, load: bool = True) -> Union[str, np.ndarray]: """get image or image path at a specific index (in image index) Args: idx: image based 0-index camera: camera based on camera_stats.CAMERA_LIST log_id: log_id, if not specified will use self.current_log load: whether to return image array (True) or image path (False) Returns: np.array: list of image path (str or np.array)), """ assert self.image_timestamp_list is not None assert self._image_timestamp_list is not None assert self.image_list is not None assert self._image_list is not None if log_id is None: log_id = self.current_log assert idx < len(self._image_timestamp_list[log_id][camera]) image_path = self._image_list[log_id][camera][idx] if load: return load_image(image_path) return image_path
def get_image_at_timestamp( self, timestamp: int, camera: str, log_id: Optional[str] = None, load: bool = True) -> Optional[Union[str, np.ndarray]]: """get image or image path at a specific timestamp Args: timestamp: timestamp camera: camera based on camera_stats.CAMERA_LIST log_id: log_id, if not specified will use self.current_log load: whether to return image array (True) or image path (False) Returns: np.array: list of image path (str or np.array)), """ assert self.timestamp_image_dict is not None assert self._timestamp_image_dict is not None if log_id is None: log_id = self.current_log assert self.timestamp_image_dict is not None try: image_path = self._timestamp_image_dict[log_id][camera][timestamp] except KeyError: logging.error( f"Cannot find {camera} image at timestamp {timestamp} in log {log_id}" ) return None if load: return load_image(image_path) return image_path