Exemple #1
0
def runcalibrate(width, height, imagePoints, nimages, imageSize, flags=None):
    if flags is None:
        flags = cv2.CALIB_FIX_ASPECT_RATIO + cv2.CALIB_ZERO_TANGENT_DIST + cv2.CALIB_SAME_FOCAL_LENGTH + cv2.CALIB_FIX_K3 + cv2.CALIB_FIX_K4 + cv2.CALIB_FIX_K5
    objectPoints = []
    patternPoints = cvtools.createPatternPoints(width, height)
    for i in range(0, nimages):
        objectPoints.append(patternPoints)
    return cv2.calibrateCamera(objectPoints, imagePoints, imageSize, flags=flags)
Exemple #2
0
def stereoCalibrate(imageDir, K, D, width, height, debug=False, flags=cv2.CALIB_FIX_INTRINSIC):
    """
        width:棋牌的宽
        height:棋牌的高
        debug:输出调试信息
        flags:参考opencv的stereoCalibrate函数
        """
    imagePoints, nimages, imageSize = loadImagePoints(imageDir, width, height, debug)
    objectPoints = []
    patternPoints = cvtools.createPatternPoints(width, height)
    imagePoints1 = []
    imagePoints2 = []
    for i in range(0, len(imagePoints)):
        if i % 2 == 0:
            imagePoints1.append(imagePoints[i])
        else:
            imagePoints2.append(imagePoints[i])
    for i in range(0, nimages / 2):
        objectPoints.append(patternPoints)
    return cv2.stereoCalibrate(objectPoints, imagePoints1, imagePoints2, imageSize,K,D,K,D,criteria=(cv2.TERM_CRITERIA_COUNT+cv2.TERM_CRITERIA_EPS, 100, 1e-5),flags=flags)