コード例 #1
0
def main_one_stop():
    # merge detection results into one .txt
    root_path = r'\\DATACHEWER\shareZ\2020_01_01_KateyCapture\Converted'
    work_path = r'D:\CalibrationData\CameraCalibration\2020_01_01_KateyCapture'
    if not os.path.exists(work_path):
        os.mkdir(work_path)

    configs = Configs()
    configs.num_cams = 16
    configs.frame_range = (0, 3060)
    configs.cam_range = (0, 15)

    Calibrator.detect_opencv_corners_multiprocess(root_path, work_path,
                                                  configs)

    # run only if a folder name has to be changed
    # Parser.change_corner_folder_name(root_path, 'Corners_20200102')

    # for visualizing detected corners
    # Calibrator.save_opencv_corners_on_images(root_path, work_path, configs)
    """
    detection results
    """
    Parser.merge_detection_results(root_path, work_path, configs)

    # """
    # outliers
    # """
    output_path = work_path + '\\CroppedCorners_2'
    if not os.path.exists(output_path):
        os.mkdir(output_path)
    Calibrator.save_ranked_corner_crops(root_path, output_path, configs)
    # Calibrator.determine_corner_outliers(root_path, output_path)
    score_thres = 500
    Calibrator.generate_outliers_txt(root_path,
                                     work_path,
                                     score_thres,
                                     configs,
                                     export=True)
    """
    # initial camera parameters
    # """
    first_cam_setup = False
    if first_cam_setup:
        # if -1: obtain intrinsics for all cameras
        # if c >= 0: copy&paste intrinsic from given camera index, c.
        configs.num_stereo_imgs = 10
        configs.center_cam_idx = 0
        configs.center_img_name = '0500'
        configs.num_single_calib_imgs = 80
        standard_intrinsics_cam = 0
        Calibrator.compute_initial_camera_parameters(root_path, work_path,
                                                     standard_intrinsics_cam,
                                                     configs)
    else:
        from_path = r'D:\CalibrationData\CameraCalibration\191205_16Cams\SingleCalibrations'
        to_path = work_path + '\\SingleCalibrations'
        if not os.path.exists(to_path):
            os.mkdir(to_path)
        Calibrator.copy_intial_camera_parameters(from_path, to_path)
    """
    Bundle adjustment input
    """
    Generator.generate_bund_adj_input(root_path, work_path, configs)
    Generator.generate_bund_adj_initial_values_16cams(root_path, work_path,
                                                      configs)
    options = {'exclude_outliers': True, 'center_region': False}
    Generator.generate_chb_image_points_input(root_path, work_path, configs,
                                              options)