(Udacity Learning Note: CarND-Term1 Project 4)
Camera Calibration & Distortion Correction
Two Types of Distortion
- Radial Distortion
- Tangential Distortion
Using OpenCV
- cv2.findChessboardCorners()
- cv2.drawChessboardCorners()
- cv2.calibrateCamera()
- cv2.undistort()
Example
- Finding chessboard corners (for an 8x6 board):
ret, corners = cv2.findChessboardCorners(gray, (8,6), None)
- Drawing detected corners on an image:
img = cv2.drawChessboardCorners(img, (8,6), corners, ret)
- Camera calibration, given object points, image points, and the shape of the grayscale image:
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[:-1], None, None)
- Undistorting a test image:
dst = cv2.undistort(img, mtx, dist, None, mtx)
Perspective Transform
Commonly Used View
- Front-facing View (Normal View)
- Top-down View (Bird-eye View)
Why?
- Because ultimately we want to measure the curvature of the lines, and to do that, we need to transform to a top-down view.
Apply Perpective Transform using OpenCV
- Compute the perspective transform, M, given source and destination points:
M = cv2.getPerspectiveTransform(src, dst)
- Compute the inverse perspective transform:
Minv = cv2.getPerspectiveTransform(dst, src)
- Warp an image using the perspective transform, M: (warp v. 扭曲)
warped = cv2.warpPerspective(img, M, img_size, flags=cv2.INTER_LINEAR)
Gradient Threshold
时间: 2024-10-08 04:36:55