# --------------------------------------------------------- undistort image undist = undistort_image(img, mtx, dist_coeff) # - convert to hls color space and apply threshold to generate binary image binary = create_binary_image(undist) # ------------------------------------- transform to bird's eye perspective warped, src, dst = do_perspective_transform(binary, Fit()) # ---------------------------------------------------------- fit polynomial leftx_base, rightx_base = find_starting_points(warped) leftx, lefty, rightx, righty, l_left_seg, l_right_seg, output_img =\ find_lane_pixels(warped, leftx_base, rightx_base) # ------------------------------ color detected lane pixels in warped image lane_pix = color_lane_pixels(np.zeros_like(warped), leftx, lefty, rightx, righty) # ------------------------------------------------------------ unwarp image lane_pix_unwarped = warp_image(lane_pix, dst, src) # --------- superpose image of unwarped lane pixels image on original image # ------------------------ and add curvature and offset from middle of lane res_img = final_image(img, lane_pix_unwarped, img.shape[0], leftx, lefty, rightx, righty, l_left_seg, l_right_seg, src, leftx_base, rightx_base) # ------------------------------------------------------------- save images save_result_image(res_img, "../output_images/final", file_name, "-final", True)
import glob import cv2 from perspective_transform import lane_line_mask from visualization import save_result_image # import images # read in all binary images with names with pattern *.jpg images = glob.glob('../output_images/hls/*.jpg') # loop over images and undistort them for file_name in images: # read in example image img = cv2.imread(file_name) # mask the image masked = lane_line_mask(img) # save images save_result_image(masked, "../output_images/Masked", file_name, "-masked", True)
gray = cv2.imread(file_name, 0) # initialize line_fit line_fit = LineFit(img.shape[1], img.shape[0]) # do Hough transform lines = hough_lines_detection(img) # get source and destination points src, dst = find_points(lines, img.shape[1], img.shape[0], line_fit) # Transform image to RGB dots_img = cv2.cvtColor(gray, cv2.COLOR_GRAY2RGB) # draw dot (small circle on image) # source points for i in range(4): dots_img = draw_dots(dots_img, (src[i][0], src[i][1])) dots_img = add_text(dots_img, "["+str(i)+"]", (src[i][0], src[i][1])) # destination points for i in range(4): dots_img = draw_dots(dots_img, (dst[i][0], dst[i][1]), (0, 255, 0)) y_offset = 0 if i == 0 or i == 3 else 20 dots_img = add_text(dots_img, "["+str(i)+"]", (dst[i][0], int(dst[i][1]+y_offset)), color=(0, 255, 0)) # save images save_result_image(dots_img, "../output_images/points", file_name, "-points", True)
import cv2 import glob from perspective_transform import hough_lines_detection from visualization import save_result_image # import images # read in all binary images with names with pattern *.jpg images = glob.glob('../output_images/hls/*.jpg') # loop over images and undistort them for file_name in images: # read in example image img = cv2.imread(file_name) # detect lines using Hough algorithm lines = hough_lines_detection(img) # loop over all the lines and draw them on the image for line in lines: img = cv2.line(img, (line[0][0], line[0][1]), (line[0][2], line[0][3]), (255, 0, 0), 5) # save images save_result_image(img, "../output_images/HoughLines", file_name, "-hough", True)
import glob import cv2 from lane_poly_fit import fit_polynomial, find_lane_pixels,\ find_starting_points from visualization import save_result_image from globals.fits import Fit # read in all binary images with names with pattern *.jpg images = glob.glob('../output_images/warped/*.jpg') # loop over images for file_name in images: img = cv2.imread(file_name) # get starting points of pixel detection leftx_base, rightx_base = find_starting_points(img) # find lane pixels leftx, lefty, rightx, righty, l_left_seg, l_right_seg, img = \ find_lane_pixels(img, leftx_base, rightx_base, True) fit = Fit() left_fit, right_fit, out_img =\ fit_polynomial(leftx, lefty, rightx, righty, fit, True, img) save_result_image(out_img, "../output_images/polynomial", file_name, "-poly", True)
import glob import matplotlib.image as mpimg from camera_calibration import calibrate_camera from undistort import undistort_image from visualization import save_result_image # get calibration matrix mtx, dst = calibrate_camera() # read in all images with names with pattern calibration*.jpg images = glob.glob('../camera_cal/calibration*.jpg') # loop over images and undistort them for file_name in images: # read in image img = mpimg.imread(file_name) # undistort image undist_img = undistort_image(img, mtx, dst) # save resulting image save_result_image(undist_img, "../output_images/undistorted_cal_images", file_name, "-undist")
''' Created on 1 oct. 2019 @author: cbraeuninger ''' import glob import cv2 from hls_select import saturation_select from visualization import save_result_image # import images # read in all images with names with pattern *.jpg images = glob.glob('../output_images/undistorted_images/*.jpg') # loop over images and undistort them for file_name in images: img = cv2.imread(file_name) hls = saturation_select(img, (185, 255), 120) # save images save_result_image(hls, "../output_images/hls", file_name, "-hls", True)
import matplotlib.image as mpimg import glob from gradient import combine_gradient from visualization import save_result_image # import images # read in all images with names with pattern *.jpg images = glob.glob('../test_images/*.jpg') # loop over images and undistort them for file_name in images: img = mpimg.imread(file_name) combined = combine_gradient(img) # save images save_result_image(combined, "../output_images/gradient_images", file_name, "-gradient", True)
import glob import cv2 from perspective_transform import do_perspective_transform from visualization import save_result_image from globals.fits import LineFit # import images # read in all binary images with names with pattern *.jpg images = glob.glob('../output_images/hls/*.jpg') # loop over images and undistort them for file_name in images: img = cv2.imread(file_name) # initialize line_fit line_fit = LineFit(img.shape[1], img.shape[0]) warped, src, dst = do_perspective_transform(img, line_fit) # save images save_result_image(warped, "../output_images/warped", file_name, "-warped", True)
import cv2 import glob from lane_poly_fit import find_starting_points from visualization import draw_dots, save_result_image # import images # read in all binary images with names with pattern *.jpg images = glob.glob('../output_images/warped/*.jpg') # loop over images for file_name in images: # read in example image img = cv2.imread(file_name) leftx_base, right_xbase = find_starting_points(img) points = draw_dots(img, (leftx_base, img.shape[0] - 5)) points = draw_dots(points, (right_xbase, img.shape[0] - 5), (0, 0, 255)) save_result_image(points, "../output_images/starting_points", file_name, "-start", True)