def pipeline(img): chessboard_images = glob.glob('../data/main/camera_cal/*.jpg') nx = 9 # chessboard corners in x direction ny = 6 # chessboard corners in y direction calibration_result = calibrate_camera(chessboard_images, (nx, ny)) mtx = calibration_result["mtx"] dist = calibration_result["dist"] undistorted_img = cv2.undistort(img, mtx, dist, None, mtx) binary = find_line_edges(undistorted_img) line_edges = np.dstack((binary, binary, binary)) * 255 return line_edges
def pipeline(img): out = np.array(img, copy=True) chessboard_images = glob.glob('../data/main/camera_cal/*.jpg') nx = 9 # chessboard corners in x direction ny = 6 # chessboard corners in y direction calibration_result = calibrate_camera(chessboard_images, (nx, ny)) mtx = calibration_result["mtx"] dist = calibration_result["dist"] undistorted_img = cv2.undistort(img, mtx, dist, None, mtx) binary = find_line_edges(undistorted_img) l_line, r_line = hough_transformation(binary) cv2.line(out, (l_line.get_x1(), l_line.get_y1()), (l_line.get_x2(), l_line.get_y2()), (250, 0, 0), 10) cv2.line(out, (r_line.get_x1(), r_line.get_y1()), (r_line.get_x2(), r_line.get_y2()), (250, 0, 0), 10) return out
ax10.imshow(lab_l) ax10.set_title('LAB(L channel)') ax11.imshow(lab_a) ax11.set_title('LAB(A channel)') ax12.imshow(lab_b) ax12.set_title('LAB(B channel)') for ax in f.get_axes(): ax.label_outer() plt.show() # Compute the camera calibration matrix and distortion coefficients given a set of chessboard images chessboard_images = glob.glob('../data/main/camera_cal/*.jpg') nx = 9 # chessboard corners in x direction ny = 6 # chessboard corners in y direction calibration_result = calibrate_camera(chessboard_images, (nx, ny)) mtx = calibration_result["mtx"] dist = calibration_result["dist"] img = cv2.imread('../data/main/test_images/test5.jpg') # Apply a distortion correction to raw images undistorted_img = cv2.undistort(img, mtx, dist, None, mtx) # let's try to use RGB,HLS, HSV,LAB color spaces and individual channels to identify the best options display_all_channels_for_color_spaces(undistorted_img) # I will stick to LAB color space (B channel). It gives good results for all test images I work with