コード例 #1
0
def run_tests(config, output_dir, corners_dir):
    # pylint:disable=too-many-locals

    _make_dir_if_needed(output_dir)
    _make_dir_if_needed(corners_dir)

    all_r_errors = []
    all_t_errors = []
    for test_name, test_info in config.items():
        click.echo(test_name)

        test_dir = path.join(output_dir, test_name)
        _make_dir_if_needed(test_dir, 1)

        grayscale_seq = frameseq.read_grayscale_f32(test_info.rgb)

        inf_errors = np.full((len(grayscale_seq),), np.inf)
        all_r_errors.append(inf_errors)
        all_t_errors.append(inf_errors)

        corner_storage = _load_or_calculate_corners(grayscale_seq, test_name,
                                                    test_dir, corners_dir)
        if not corner_storage:
            continue

        ground_truth = _read_ground_truth(test_info.ground_truth)
        track, point_cloud = _do_tracking(test_info, ground_truth,
                                          corner_storage, test_dir)
        if not track:
            continue

        _write_poses(track, path.join(test_dir, 'track.yml'))
        _write_point_cloud(point_cloud, path.join(test_dir, 'point_cloud.yml'))

        r_errors, t_errors = cmptrack.calc_errors(ground_truth, track)
        all_r_errors[-1] = r_errors
        all_t_errors[-1] = t_errors
        click.echo('  rotation error (degrees): median={}, max={}'.format(
            np.median(np.degrees(r_errors)),
            np.degrees(r_errors).max()
        ))
        click.echo('  translation error: median={}, max={}'.format(
            np.median(t_errors),
            t_errors.max()
        ))
        click.echo('  overall error measure: {}'.format(
            cmptrack.calc_vol_under_surface(r_errors, t_errors)
        ))

    all_r_errors = np.concatenate(all_r_errors)
    all_t_errors = np.concatenate(all_t_errors)
    error_measure = cmptrack.calc_vol_under_surface(all_r_errors, all_t_errors)

    click.echo('total error measure: {}'.format(error_measure))
    _write_error_measure(error_measure,
                         path.join(output_dir, 'error_measure.yml'))
コード例 #2
0
def run_tests(config, output_dir, corners_dir, corners_config, min_track_len):
    _make_dir_if_needed(output_dir)
    _make_dir_if_needed(corners_dir)

    all_r_errors = []
    all_t_errors = []
    for test_name, test_info in config.items():
        click.echo(test_name)

        test_dir = path.join(output_dir, test_name)
        _make_dir_if_needed(test_dir, 1)

        grayscale_seq = frameseq.read_grayscale_f32(test_info.rgb)

        inf_errors = np.full((len(grayscale_seq), ), np.inf)
        all_r_errors.append(inf_errors)
        all_t_errors.append(inf_errors)

        corner_storage = _load_or_calculate_corners(grayscale_seq, test_name,
                                                    test_dir, corners_dir,
                                                    corners_config,
                                                    min_track_len)
        if not corner_storage:
            continue

        track, point_cloud = _do_tracking(test_info, corner_storage, test_dir)
        if not track:
            continue

        _write_poses(track, path.join(test_dir, 'track.yml'))
        _write_point_cloud(point_cloud, path.join(test_dir, 'point_cloud.yml'))

        ground_truth = _read_ground_truth(test_info.ground_truth)
        r_errors, t_errors = cmp.calc_errors(ground_truth, track)
        all_r_errors[-1] = r_errors
        all_t_errors[-1] = t_errors
        click.echo('  error measure: {}'.format(
            cmp.calc_vol_under_surface(r_errors, t_errors)))

    all_r_errors = np.concatenate(all_r_errors)
    all_t_errors = np.concatenate(all_t_errors)
    error_measure = cmp.calc_vol_under_surface(all_r_errors, all_t_errors)

    click.echo('overall error measure: {}'.format(error_measure))
    _write_error_measure(error_measure,
                         path.join(output_dir, 'error_measure.yml'))
コード例 #3
0
def run_tests(config, output_dir, corners_dir):
    # pylint:disable=too-many-locals

    _make_dir_if_needed(output_dir)
    _make_dir_if_needed(corners_dir)

    corners_ok_count = 0
    tracking_ok_count = 0
    all_r_errors = []
    all_t_errors = []
    for test_name, test_info in config.items():
        click.echo(test_name)

        test_dir = path.join(output_dir, test_name)
        _make_dir_if_needed(test_dir, 1)

        grayscale_seq = frameseq.read_grayscale_f32(test_info.rgb)

        inf_errors = np.full((len(grayscale_seq), ), np.inf)
        all_r_errors.append(inf_errors)
        all_t_errors.append(inf_errors)

        corner_storage = _load_or_calculate_corners(grayscale_seq, test_name,
                                                    test_dir, corners_dir)
        if not corner_storage:
            click.echo('  corner tracking failed')
            continue

        corners_ok_count += _describe_and_check_corners(corner_storage)

        ground_truth = _read_ground_truth(test_info.ground_truth)
        track, point_cloud = _do_tracking(test_info, ground_truth,
                                          corner_storage, test_dir)
        if not track:
            click.echo('  camera tracking failed')
            continue

        _write_poses(track, path.join(test_dir, 'track.yml'))
        _write_point_cloud(point_cloud, path.join(test_dir, 'point_cloud.yml'))

        r_errors, t_errors = cmptrack.calc_errors(ground_truth, track)
        all_r_errors[-1] = r_errors
        all_t_errors[-1] = t_errors

        tracking_ok_count += _describe_and_check_camera_track_errors(
            r_errors, t_errors, test_info.translation_error_allowed,
            test_info.rotation_deg_error_allowed)

    all_r_errors = np.concatenate(all_r_errors)
    all_t_errors = np.concatenate(all_t_errors)
    error_measure = cmptrack.calc_vol_under_surface(all_r_errors, all_t_errors)

    click.echo('corners OK: {}/{}'.format(corners_ok_count, len(config)))
    click.echo('tracking OK: {}/{}'.format(tracking_ok_count, len(config)))
    click.echo('total error measure: {}'.format(error_measure))
    _write_error_measure(error_measure,
                         path.join(output_dir, 'error_measure.yml'))
コード例 #4
0
def _describe_and_check_camera_track_errors(r_errors, t_errors,
                                            translation_error_allowed,
                                            rotation_deg_error_allowed):
    r_errors_deg = np.degrees(r_errors)
    max_r_error_deg = r_errors_deg.max()
    max_t_error = t_errors.max()

    click.echo('    rotation error (degrees): median={}, max={}'.format(
        np.median(r_errors_deg), max_r_error_deg))
    click.echo('    translation error: median={}, max={}'.format(
        np.median(t_errors), t_errors.max()))
    click.echo('    overall error measure: {}'.format(
        cmptrack.calc_vol_under_surface(r_errors, t_errors)))

    solution_ok = max_r_error_deg <= rotation_deg_error_allowed and \
        max_t_error <= translation_error_allowed
    click.echo('    {}'.format('OK' if solution_ok else 'LOW QUALITY'))

    return solution_ok