<jupyter_start><jupyter_text>Camera Calibration Load Original Image<jupyter_code># prepare object points
n_cols = 9
n_rows = 6

# Make a list of calibration images
image_paths = glob.glob('./camera_cal/calibration*.jpg')
img = mpimg.imread(image_paths[4])
plt.imshow(img)<jupyter_output><empty_output><jupyter_text>Finding Corners<jupyter_code># Convert to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Find the chessboard corners
ret, corners = cv2.findChessboardCorners(gray, (n_cols, n_rows), None)

# If found, draw corners
if ret == True:
    # Draw and display the corners
    cv2.drawChessboardCorners(img, (n_cols, n_rows), corners, ret)
    plt.imshow(img)<jupyter_output><empty_output><jupyter_text>Generate Corresponding Points<jupyter_code>objpoints = []
imgpoints = []

objp = np.zeros((n_rows * n_cols, 3), np.float32)
objp[:,:2] = np.mgrid[0:n_cols, 0:n_rows].T.reshape(-1, 2)

for image_path in image_paths:
    # read image from image path
    image = mpimg.imread(image_path)

    # Convert image to grayscale
    gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)

    # Find the chessboard corners
    ret, corners = cv2.findChessboardCorners(gray, (n_cols,n_rows), None)

    if ret == True:
        imgpoints.append(corners)
        objpoints.append(objp)<jupyter_output><empty_output><jupyter_text>Calibrate Camera<jupyter_code>ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None)<jupyter_output><empty_output><jupyter_text>Undistort Image Transformation<jupyter_code>undist = cv2.undistort(img, mtx, dist, None, mtx)
plt.imshow(undist)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12021857923497267, 'fraction_numerical': 0.013964784456587736, 'mean_word_length': 5.866666666666666, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '629888', 'license': 'MIT', 'n_tokens_mistral': 647, 'n_tokens_neox': 620, 'n_words': 120, 'path': 'camera_calibration.ipynb', 'repo_name': 'SiyiDai/advanced_lane_lines_finder', 'size': '1647'}