Python cv2 模块,CALIB_ZERO_TANGENT_DIST 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用cv2.CALIB_ZERO_TANGENT_DIST

项目:calcam    作者:euratom-software    | 项目源码 | 文件源码
def get_fitflags(self,field=0):

        if self.model[field] == 'perspective':
            fitflags = cv2.CALIB_USE_INTRINSIC_GUESS

            if self.fixaspectratio[field]:
                    fitflags = fitflags + cv2.CALIB_FIX_ASPECT_RATIO
            if self.fixk1[field]:
                    fitflags = fitflags + cv2.CALIB_FIX_K1
            if self.fixk2[field]:
                    fitflags = fitflags + cv2.CALIB_FIX_K2
            if self.fixk3[field]:
                    fitflags = fitflags + cv2.CALIB_FIX_K3
            if self.disabletangentialdist[field]:
                    fitflags = fitflags + cv2.CALIB_ZERO_TANGENT_DIST
            if self.fixcc[field]:
                fitflags = fitflags + cv2.CALIB_FIX_PRINCIPAL_POINT

        elif self.model[field] == 'fisheye':

            fitflags = cv2.fisheye.CALIB_RECOMPUTE_EXTRINSIC + cv2.fisheye.CALIB_USE_INTRINSIC_GUESS + cv2.fisheye.CALIB_FIX_SKEW

            if self.fixk1[field]:
                fitflags = fitflags + cv2.fisheye.CALIB_FIX_K1
            if self.fixk2[field]:
                fitflags = fitflags + cv2.fisheye.CALIB_FIX_K2
            if self.fixk3[field]:
                fitflags = fitflags + cv2.fisheye.CALIB_FIX_K3
            if self.fixk4[field]:
                fitflags = fitflags + cv2.fisheye.CALIB_FIX_K4

        return fitflags


    # Get a list of human-readable strings saying what fitting options are anebled. 
    # Output: list of strings, each string describes an enabled fit option.
项目:cvcalib    作者:Algomorph    | 项目源码 | 文件源码
def calibrate_intrinsics(camera, image_points,
                         object_points,
                         use_rational_model=True,
                         use_tangential=False,
                         use_thin_prism=False,
                         fix_radial=False,
                         fix_thin_prism=False,
                         max_iterations=30,
                         use_existing_guess=False,
                         test=False):
    flags = 0
    if test:
        flags = flags | cv2.CALIB_USE_INTRINSIC_GUESS
        # fix everything
        flags = flags | cv2.CALIB_FIX_PRINCIPAL_POINT
        flags = flags | cv2.CALIB_FIX_ASPECT_RATIO
        flags = flags | cv2.CALIB_FIX_FOCAL_LENGTH
        # apparently, we can't fix the tangential distance. What the hell? Zero it out.
        flags = flags | cv2.CALIB_ZERO_TANGENT_DIST
        flags = fix_radial_flags(flags)
        flags = flags | cv2.CALIB_FIX_S1_S2_S3_S4
        criteria = (cv2.TERM_CRITERIA_MAX_ITER, 1, 0)
    else:
        if fix_radial:
            flags = fix_radial_flags(flags)
        if fix_thin_prism:
            flags = flags | cv2.CALIB_FIX_S1_S2_S3_S4
        criteria = (cv2.TERM_CRITERIA_MAX_ITER + cv2.TERM_CRITERIA_EPS, max_iterations,
                    2.2204460492503131e-16)
    if use_existing_guess:
        flags = flags | cv2.CALIB_USE_INTRINSIC_GUESS
    if not use_tangential:
        flags = flags | cv2.CALIB_ZERO_TANGENT_DIST
    if use_rational_model:
        flags = flags | cv2.CALIB_RATIONAL_MODEL
        if len(camera.intrinsics.distortion_coeffs) < 8:
            camera.intrinsics.distortion_coeffs.resize((8,))
    if use_thin_prism:
        flags = flags | cv2.CALIB_THIN_PRISM_MODEL
        if len(camera.intrinsics.distortion_coeffs) != 12:
            camera.intrinsics.distortion_coeffs = np.resize(camera.intrinsics.distortion_coeffs, (12,))
    return __calibrate_intrinsics(camera, image_points, object_points, flags, criteria)