Example #1
0
def create_tracking_kitti_info(files: dict, index):

    calib = parse_calib(read_lines(files['calib']))

    label_lines = read_lines(files['label'])

    selected_frame_lines = []

    for line in label_lines:

        parts = line.split(' ')
        frame = int(parts[0])

        if frame == index and parts[1] != '-1':
            selected_frame_lines.append(' '.join(parts[2:]))

    label = get_label_anno(selected_frame_lines)

    result = {
        'image_idx': index,
        'velodyne_path': files['velodyne'][index],
        'img_path': files['image'][index],
        # 'img_shape': None,
        'calib/P0': calib['P'][0],
        'calib/P1': calib['P'][1],
        'calib/P2': calib['P'][2],
        'calib/P3': calib['P'][3],
        'calib/R0_rect': calib['R0_rect'],
        'calib/Tr_velo_to_cam': calib['Tr_velo_to_cam'],
        'calib/Tr_imu_to_velo': calib['Tr_velo_to_cam'],
        'annos': label
    }

    return result
Example #2
0
def create_detection_kitti_info(files: dict, index):
    
    calib = parse_calib(
        read_lines(files['calib'])
    )

    label = get_label_anno(
        read_lines(files['label'])
    )


    result = {
        'image_idx': index,
        'velodyne_path': files['velodyne'],
        'img_path': files['image'],
        # 'img_shape': None,
        'calib/P0': calib['P'][0],
        'calib/P1': calib['P'][1],
        'calib/P2': calib['P'][2],
        'calib/P3': calib['P'][3],
        'calib/R0_rect': calib['R0_rect'],
        'calib/Tr_velo_to_cam': calib['Tr_velo_to_cam'],
        'calib/Tr_imu_to_velo': calib['Tr_velo_to_cam'],
        'annos': label
    }

    return result
Example #3
0
def get_compare_detection_annotation(method, index):
    file_name = (compare_results_detection['root'] + '/' + method + '/' +
                 selected_split + '/' + '{:06d}'.format(index) + '.txt')

    lines = []

    if os.path.exists(file_name):
        lines = read_lines(file_name)

    label = get_label_anno(lines)

    return label
Example #4
0
def get_compare_tracking_annotation(method, group, index):

    annotation_format = compare_results_tracking['format']

    if annotation_format == "ab3dmot":

        type_by_number = {1: 'Pedestrian', 2: 'Car', 3: 'Cyclist'}

        file_name = (compare_results_tracking['root'] + '/' + method + '/' +
                     selected_split + '/' + '{:04d}'.format(group) + '.txt')

        lines = []

        if os.path.exists(file_name):
            lines = read_lines(file_name)
            selected_lines = []

            for i in range(len(lines)):
                line = lines[i]
                elements = line.replace('\n', '').split(',')

                if len(elements) <= 1:
                    continue

                (id, t, a1, a2, a3, a4, b, c1, c2, c3, c4, c5, c6, alpha,
                 beta) = elements

                new_elements = [
                    type_by_number[int(t)], 0, 0, beta, a1, a2, a3, a4, c1, c2,
                    c3, c4, c5, c6, alpha, b
                ]

                new_line = " ".join([str(a) for a in new_elements])

                current_index = int(id)

                if index == current_index:
                    selected_lines.append(new_line)

            lines = selected_lines

        label = get_label_anno(lines)

        return label
    else:
        raise ValueError("Unsupported tracking format: " + annotation_format)