scripts/detection_pipeline.py
def detect_lanes_pipeline(actual_image):
  """
  Runs the lane-detection pipeline on a given image.
  :param actual_image:  Image in which the lanes have to be found.
  :return:  Image having marked lanes.
  """
  height,width,num_channels = actual_image.shape

  # Get grayscale image.
  gray = du.grayscale(actual_image)

  # Plotting the histogram gives us an idea about the gradient intensities which helps us to set the lower/upper
  # thresholds of the Canny filter.
  # hist_image = plt.hist(gray.ravel(),256,[0,256])

  # Remove noise using Gaussian blur.
  gray_denoised = du.gaussian_blur(gray, th.GAUSSIAN_BLUR_KERNEL_SIZE)

  # Get image containing edges.
  edges = du.canny(gray_denoised, th.CANNY_LOW_THRESHOLD, th.CANNY_HIGH_THRESHOLD)

  # Clip the region containing the current lane.
  clipped_image = du.region_of_interest(edges,
                                        np.array([[(th.ROI_BOTTOM_LEFT_X,height), th.ROI_TOP_LEFT, th.ROI_TOP_RIGHT,
                                        (th.ROI_BOTTOM_RIGHT_X,height)]], dtype=np.int32))

  # Run a Hough transform on the image containing the edges to find line segments belonging to the lane's lines.
  line_segments = du.hough_lines(clipped_image, th.HOUGH_RHO, th.HOUGH_THETA, th.HOUGH_NUM_VOTES_THRESHOLD,
                         th.HOUGH_MIN_LINE_LENGTH, th.HOUGH_MAX_LINE_GAP)

  # Draw Hough-lines on the actual image.
  lane_image = du.draw_lane(clipped_image, line_segments)

  # Return an image with lane-lines, if found, overlayed on the actual image.
  if lane_image is not None:
    return du.weighted_img(lane_image, actual_image)
  else:
    return actual_image

  Runs the lane-detection pipeline on a given image.
  :param actual_image:  Image in which the lanes have to be found.
  :return:  Image having marked lanes.
  
Runs the lane-detection pipeline on a given image.
Runs the lane - detection pipeline on a given image .
def detect_lanes_pipeline(actual_image):
  height,width,num_channels = actual_image.shape
  gray = du.grayscale(actual_image)
  gray_denoised = du.gaussian_blur(gray, th.GAUSSIAN_BLUR_KERNEL_SIZE)
  edges = du.canny(gray_denoised, th.CANNY_LOW_THRESHOLD, th.CANNY_HIGH_THRESHOLD)
  clipped_image = du.region_of_interest(edges,
                                        np.array([[(th.ROI_BOTTOM_LEFT_X,height), th.ROI_TOP_LEFT, th.ROI_TOP_RIGHT,
                                        (th.ROI_BOTTOM_RIGHT_X,height)]], dtype=np.int32))
  line_segments = du.hough_lines(clipped_image, th.HOUGH_RHO, th.HOUGH_THETA, th.HOUGH_NUM_VOTES_THRESHOLD,
                         th.HOUGH_MIN_LINE_LENGTH, th.HOUGH_MAX_LINE_GAP)
  lane_image = du.draw_lane(clipped_image, line_segments)
  if lane_image is not None:
    return du.weighted_img(lane_image, actual_image)
  else:
    return actual_image
def detect_lanes_pipeline ( actual_image ) : height , width , num_channels = actual_image . shape gray = du . grayscale ( actual_image ) gray_denoised = du . gaussian_blur ( gray , th . GAUSSIAN_BLUR_KERNEL_SIZE ) edges = du . canny ( gray_denoised , th . CANNY_LOW_THRESHOLD , th . CANNY_HIGH_THRESHOLD ) clipped_image = du . region_of_interest ( edges , np . array ( [ [ ( th . ROI_BOTTOM_LEFT_X , height ) , th . ROI_TOP_LEFT , th . ROI_TOP_RIGHT , ( th . ROI_BOTTOM_RIGHT_X , height ) ] ] , dtype = np . int32 ) ) line_segments = du . hough_lines ( clipped_image , th . HOUGH_RHO , th . HOUGH_THETA , th . HOUGH_NUM_VOTES_THRESHOLD , th . HOUGH_MIN_LINE_LENGTH , th . HOUGH_MAX_LINE_GAP ) lane_image = du . draw_lane ( clipped_image , line_segments ) if lane_image is not None : return du . weighted_img ( lane_image , actual_image ) else : return actual_image
Runs the lane-detection pipeline on a given image.
Runs the lane - detection pipeline on a given image .
"""
  Runs the lane-detection pipeline on a given image.
  :param actual_image:  Image in which the lanes have to be found.
  :return:  Image having marked lanes.
  """ # Get grayscale image. # Plotting the histogram gives us an idea about the gradient intensities which helps us to set the lower/upper # thresholds of the Canny filter. # hist_image = plt.hist(gray.ravel(),256,[0,256]) # Remove noise using Gaussian blur. # Get image containing edges. # Clip the region containing the current lane. # Run a Hough transform on the image containing the edges to find line segments belonging to the lane's lines. # Draw Hough-lines on the actual image. # Return an image with lane-lines, if found, overlayed on the actual image.
Image having marked lanes.
Image having marked lanes .
actual_image
Image in which the lanes have to be found.
Image in which the lanes have to be found .