lane/camera_calibration.py
def calib():
    """
    #--------------------
    # To get an undistorted image, we need camera matrix & distortion coefficient
    # Calculate them with 9*6 20 chessboard images
    #
    """

    # Prepare object points
    # This object points will be the same for all calibration images
    image_files = glob.glob("lane/camera_cal/calibration*.jpg")
    print(image_files)

    objp = np.zeros((6 * 9, 3), np.float32)
    objp[:, :2] = np.mgrid[0:9, 0:6].T.reshape(-1, 2)  # x,y coordinates

    for curr_file in image_files:

        img = mpimg.imread(curr_file)

        # Convert to grayscale
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

        # Find the chessboard corners
        ret, corners = cv2.findChessboardCorners(gray, (9, 6), None)

        # If corners are found, add object points, image points
        if ret == True:
            imgpoints.append(corners)
            objpoints.append(objp)
        else:
            continue

    ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(
        objpoints, imgpoints, gray.shape[::-1], None, None
    )

    return mtx, dist

    #--------------------
    # To get an undistorted image, we need camera matrix & distortion coefficient
    # Calculate them with 9*6 20 chessboard images
    #
    
To get an undistorted image, we need camera matrix & distortion coefficient
Calculate them with 9*6 20 chessboard images
To get an undistorted image we need camera matrix & distortion coefficient Calculate them with 9 * 6 20 chessboard images
def calib():
    image_files = glob.glob("lane/camera_cal/calibration*.jpg")
    print(image_files)
    objp = np.zeros((6 * 9, 3), np.float32)
    objp[:, :2] = np.mgrid[0:9, 0:6].T.reshape(-1, 2)  
    for curr_file in image_files:
        img = mpimg.imread(curr_file)
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        ret, corners = cv2.findChessboardCorners(gray, (9, 6), None)
        if ret == True:
            imgpoints.append(corners)
            objpoints.append(objp)
        else:
            continue
    ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(
        objpoints, imgpoints, gray.shape[::-1], None, None
    )
    return mtx, dist
def calib ( ) : image_files = glob . glob ( "lane/camera_cal/calibration*.jpg" ) print ( image_files ) objp = np . zeros ( ( 6 * 9 , 3 ) , np . float32 ) objp [ : , : 2 ] = np . mgrid [ 0 : 9 , 0 : 6 ] . T . reshape ( - 1 , 2 ) for curr_file in image_files : img = mpimg . imread ( curr_file ) gray = cv2 . cvtColor ( img , cv2 . COLOR_BGR2GRAY ) ret , corners = cv2 . findChessboardCorners ( gray , ( 9 , 6 ) , None ) if ret == True : imgpoints . append ( corners ) objpoints . append ( objp ) else : continue ret , mtx , dist , rvecs , tvecs = cv2 . calibrateCamera ( objpoints , imgpoints , gray . shape [ : : - 1 ] , None , None ) return mtx , dist
To get an undistorted image, we need camera matrix & distortion coefficient
 Calculate them with 9*6 20 chessboard images
To get an undistorted image we need camera matrix & distortion coefficient Calculate them with 9 * 6 20 chessboard images
"""
    #--------------------
    # To get an undistorted image, we need camera matrix & distortion coefficient
    # Calculate them with 9*6 20 chessboard images
    #
    """ # Prepare object points # This object points will be the same for all calibration images # x,y coordinates # Convert to grayscale # Find the chessboard corners # If corners are found, add object points, image points