Esempio n. 1
0
def merge_records_lidar(
    records_lidar_list: List[Optional[kapture.RecordsLidar]]
) -> kapture.RecordsLidar:
    """
    Merge several lidar records lists. For lidar record with the same timestamp and sensor identifier,
     keep only the first one.

    :param records_lidar_list: list of lidar records
    :return: merged lidar records
    """
    assert len(records_lidar_list) > 0

    merged_records_lidar = kapture.RecordsLidar()
    for records_lidar in records_lidar_list:
        if records_lidar is None:
            continue
        for timestamp, sensor_id, filename in kapture.flatten(records_lidar):
            if (timestamp, sensor_id) in merged_records_lidar:
                continue
            merged_records_lidar[(timestamp, sensor_id)] = filename
    return merged_records_lidar
Esempio n. 2
0
def records_lidar_from_file(
        filepath: str,
        lidar_ids: Optional[Set[str]] = None
) -> kapture.RecordsLidar:
    """
    Reads records_lidar from CSV file.

    :param filepath: input file path
    :param lidar_ids: input set of valid device ids. Any record of other than the given ones will be ignored.
                            If omitted, then it loads all devices.
    :return: Lidar records
    """
    records_lidar = kapture.RecordsLidar()
    with open(filepath) as file:
        table = table_from_file(file)
        # timestamp, device_id, point_cloud_path
        for timestamp, device_id, point_cloud_path in table:
            if lidar_ids is not None and device_id not in lidar_ids:
                # just ignore
                continue
            records_lidar[(int(timestamp), str(device_id))] = point_cloud_path
    return records_lidar
Esempio n. 3
0
def merge_records_lidar(
        records_lidar_list: List[Optional[kapture.RecordsLidar]],
        sensor_mappings: List[Dict[str, str]]) -> kapture.RecordsLidar:
    """
    Merge several lidar records list into one list with new identifiers for the sensors.

    :param records_lidar_list: list of lidar records to merge
    :param sensor_mappings: mapping of the sensor identifiers to their new identifiers
    :return: merged lidar records
    """
    assert len(records_lidar_list) > 0
    assert len(records_lidar_list) == len(sensor_mappings)

    merged_records_lidar = kapture.RecordsLidar()
    for records_lidar, sensor_mapping in zip(records_lidar_list,
                                             sensor_mappings):
        if records_lidar is None:
            continue
        for timestamp, sensor_id, filename in kapture.flatten(records_lidar):
            new_sensor_id = sensor_mapping[sensor_id]
            merged_records_lidar[(timestamp, new_sensor_id)] = filename
    return merged_records_lidar
Esempio n. 4
0
 def test_init_lidar(self):
     records_lidar = kapture.RecordsLidar()
Esempio n. 5
0
 def test_init_lidar(self):
     records_lidar = kapture.RecordsLidar()
     self.assertIsNotNone(records_lidar, "Records Lidar created")