Advanced_Lane_Finding_v2.py
def search_around_previous_fit(binary_warped, left_fit, right_fit):
    """
    Implement Lane search strategy by only searching the region around the previous lane
    :param binary_warped: 
    :param left_fit: 
    :param right_fit: 
    :return: 
    """

    # Implementation provided by Udacity

    # Assume you now have a new warped binary image
    # from the next frame of video (also called "binary_warped")
    # It's now much easier to find line pixels!
    nonzero = binary_warped.nonzero()
    nonzeroy = np.array(nonzero[0])
    nonzerox = np.array(nonzero[1])
    margin = 100
    left_lane_inds = ((nonzerox > (left_fit[0]*(nonzeroy**2) + left_fit[1]*nonzeroy + left_fit[2] - margin)) & (nonzerox < (left_fit[0]*(nonzeroy**2) + left_fit[1]*nonzeroy + left_fit[2] + margin)))
    right_lane_inds = ((nonzerox > (right_fit[0]*(nonzeroy**2) + right_fit[1]*nonzeroy + right_fit[2] - margin)) & (nonzerox < (right_fit[0]*(nonzeroy**2) + right_fit[1]*nonzeroy + right_fit[2] + margin)))

    # Again, extract left and right line pixel positions
    leftx = nonzerox[left_lane_inds]
    lefty = nonzeroy[left_lane_inds]
    rightx = nonzerox[right_lane_inds]
    righty = nonzeroy[right_lane_inds]
    # Fit a second order polynomial to each
    left_fit = np.polyfit(lefty, leftx, 2)
    right_fit = np.polyfit(righty, rightx, 2)
    # Generate x and y values for plotting
    ploty = np.linspace(0, binary_warped.shape[0]-1, binary_warped.shape[0] )
    left_fitx = left_fit[0]*ploty**2 + left_fit[1]*ploty + left_fit[2]
    right_fitx = right_fit[0]*ploty**2 + right_fit[1]*ploty + right_fit[2]

    return left_fit, right_fit, ploty, left_fitx, right_fitx

    Implement Lane search strategy by only searching the region around the previous lane
    :param binary_warped: 
    :param left_fit: 
    :param right_fit: 
    :return: 
    
Implement Lane search strategy by only searching the region around the previous lane
Implement Lane search strategy by only searching the region around the previous lane
def search_around_previous_fit(binary_warped, left_fit, right_fit):
    nonzero = binary_warped.nonzero()
    nonzeroy = np.array(nonzero[0])
    nonzerox = np.array(nonzero[1])
    margin = 100
    left_lane_inds = ((nonzerox > (left_fit[0]*(nonzeroy**2) + left_fit[1]*nonzeroy + left_fit[2] - margin)) & (nonzerox < (left_fit[0]*(nonzeroy**2) + left_fit[1]*nonzeroy + left_fit[2] + margin)))
    right_lane_inds = ((nonzerox > (right_fit[0]*(nonzeroy**2) + right_fit[1]*nonzeroy + right_fit[2] - margin)) & (nonzerox < (right_fit[0]*(nonzeroy**2) + right_fit[1]*nonzeroy + right_fit[2] + margin)))
    leftx = nonzerox[left_lane_inds]
    lefty = nonzeroy[left_lane_inds]
    rightx = nonzerox[right_lane_inds]
    righty = nonzeroy[right_lane_inds]
    left_fit = np.polyfit(lefty, leftx, 2)
    right_fit = np.polyfit(righty, rightx, 2)
    ploty = np.linspace(0, binary_warped.shape[0]-1, binary_warped.shape[0] )
    left_fitx = left_fit[0]*ploty**2 + left_fit[1]*ploty + left_fit[2]
    right_fitx = right_fit[0]*ploty**2 + right_fit[1]*ploty + right_fit[2]
    return left_fit, right_fit, ploty, left_fitx, right_fitx
def search_around_previous_fit ( binary_warped , left_fit , right_fit ) : nonzero = binary_warped . nonzero ( ) nonzeroy = np . array ( nonzero [ 0 ] ) nonzerox = np . array ( nonzero [ 1 ] ) margin = 100 left_lane_inds = ( ( nonzerox > ( left_fit [ 0 ] * ( nonzeroy ** 2 ) + left_fit [ 1 ] * nonzeroy + left_fit [ 2 ] - margin ) ) & ( nonzerox < ( left_fit [ 0 ] * ( nonzeroy ** 2 ) + left_fit [ 1 ] * nonzeroy + left_fit [ 2 ] + margin ) ) ) right_lane_inds = ( ( nonzerox > ( right_fit [ 0 ] * ( nonzeroy ** 2 ) + right_fit [ 1 ] * nonzeroy + right_fit [ 2 ] - margin ) ) & ( nonzerox < ( right_fit [ 0 ] * ( nonzeroy ** 2 ) + right_fit [ 1 ] * nonzeroy + right_fit [ 2 ] + margin ) ) ) leftx = nonzerox [ left_lane_inds ] lefty = nonzeroy [ left_lane_inds ] rightx = nonzerox [ right_lane_inds ] righty = nonzeroy [ right_lane_inds ] left_fit = np . polyfit ( lefty , leftx , 2 ) right_fit = np . polyfit ( righty , rightx , 2 ) ploty = np . linspace ( 0 , binary_warped . shape [ 0 ] - 1 , binary_warped . shape [ 0 ] ) left_fitx = left_fit [ 0 ] * ploty ** 2 + left_fit [ 1 ] * ploty + left_fit [ 2 ] right_fitx = right_fit [ 0 ] * ploty ** 2 + right_fit [ 1 ] * ploty + right_fit [ 2 ] return left_fit , right_fit , ploty , left_fitx , right_fitx
Implement Lane search strategy by only searching the region around the previous lane
Implement Lane search strategy by only searching the region around the previous lane
"""
    Implement Lane search strategy by only searching the region around the previous lane
    :param binary_warped: 
    :param left_fit: 
    :param right_fit: 
    :return: 
    """ # Implementation provided by Udacity # Assume you now have a new warped binary image # from the next frame of video (also called "binary_warped") # It's now much easier to find line pixels! # Again, extract left and right line pixel positions # Fit a second order polynomial to each # Generate x and y values for plotting
None
binary_warped
None
left_fit
None
right_fit
None