lane/line.py
def measure_curvature(left_lane, right_lane):
    """
    #---------------------
    # This function measures curvature of the left and right lane lines
    # in radians.
    # This function is based on code provided in curvature measurement lecture.
    #
    """

    ploty = left_lane.ally

    leftx, rightx = left_lane.allx, right_lane.allx

    leftx = leftx[::-1]  # Reverse to match top-to-bottom in y
    rightx = rightx[::-1]  # Reverse to match top-to-bottom in y

    # Define y-value where we want radius of curvature
    # I'll choose the maximum y-value, corresponding to the bottom of the image
    y_eval = np.max(ploty)

    # U.S. regulations that require a  minimum lane width of 12 feet or 3.7 meters,
    # and the dashed lane lines are 10 feet or 3 meters long each.
    # >> http://onlinemanuals.txdot.gov/txdotmanuals/rdw/horizontal_alignment.htm#BGBHGEGC

    # Below is the calculation of radius of curvature after correcting for scale in x and y
    # Define conversions in x and y from pixels space to meters
    lane_width = abs(right_lane.startx - left_lane.startx)
    ym_per_pix = 30 / 720  # meters per pixel in y dimension
    xm_per_pix = 3.7 * (720 / 1280) / lane_width  # meters per pixel in x dimension

    # Fit new polynomials to x,y in world space
    left_fit_cr = np.polyfit(ploty * ym_per_pix, leftx * xm_per_pix, 2)
    right_fit_cr = np.polyfit(ploty * ym_per_pix, rightx * xm_per_pix, 2)

    # Calculate the new radii of curvature
    left_curverad = (
        (1 + (2 * left_fit_cr[0] * y_eval * ym_per_pix + left_fit_cr[1]) ** 2) ** 1.5
    ) / np.absolute(2 * left_fit_cr[0])
    right_curverad = (
        (1 + (2 * right_fit_cr[0] * y_eval * ym_per_pix + right_fit_cr[1]) ** 2) ** 1.5
    ) / np.absolute(2 * right_fit_cr[0])

    # radius of curvature result
    left_lane.radius_of_curvature = left_curverad
    right_lane.radius_of_curvature = right_curverad

    #---------------------
    # This function measures curvature of the left and right lane lines
    # in radians.
    # This function is based on code provided in curvature measurement lecture.
    #
    
This function measures curvature of the left and right lane lines
in radians.
This function is based on code provided in curvature measurement lecture.
This function measures curvature of the left and right lane lines in radians . This function is based on code provided in curvature measurement lecture .
def measure_curvature(left_lane, right_lane):
    ploty = left_lane.ally
    leftx, rightx = left_lane.allx, right_lane.allx
    leftx = leftx[::-1]  
    rightx = rightx[::-1]  
    y_eval = np.max(ploty)
    lane_width = abs(right_lane.startx - left_lane.startx)
    ym_per_pix = 30 / 720  
    xm_per_pix = 3.7 * (720 / 1280) / lane_width  
    left_fit_cr = np.polyfit(ploty * ym_per_pix, leftx * xm_per_pix, 2)
    right_fit_cr = np.polyfit(ploty * ym_per_pix, rightx * xm_per_pix, 2)
    left_curverad = (
        (1 + (2 * left_fit_cr[0] * y_eval * ym_per_pix + left_fit_cr[1]) ** 2) ** 1.5
    ) / np.absolute(2 * left_fit_cr[0])
    right_curverad = (
        (1 + (2 * right_fit_cr[0] * y_eval * ym_per_pix + right_fit_cr[1]) ** 2) ** 1.5
    ) / np.absolute(2 * right_fit_cr[0])
    left_lane.radius_of_curvature = left_curverad
    right_lane.radius_of_curvature = right_curverad
def measure_curvature ( left_lane , right_lane ) : ploty = left_lane . ally leftx , rightx = left_lane . allx , right_lane . allx leftx = leftx [ : : - 1 ] rightx = rightx [ : : - 1 ] y_eval = np . max ( ploty ) lane_width = abs ( right_lane . startx - left_lane . startx ) ym_per_pix = 30 / 720 xm_per_pix = 3.7 * ( 720 / 1280 ) / lane_width left_fit_cr = np . polyfit ( ploty * ym_per_pix , leftx * xm_per_pix , 2 ) right_fit_cr = np . polyfit ( ploty * ym_per_pix , rightx * xm_per_pix , 2 ) left_curverad = ( ( 1 + ( 2 * left_fit_cr [ 0 ] * y_eval * ym_per_pix + left_fit_cr [ 1 ] ) ** 2 ) ** 1.5 ) / np . absolute ( 2 * left_fit_cr [ 0 ] ) right_curverad = ( ( 1 + ( 2 * right_fit_cr [ 0 ] * y_eval * ym_per_pix + right_fit_cr [ 1 ] ) ** 2 ) ** 1.5 ) / np . absolute ( 2 * right_fit_cr [ 0 ] ) left_lane . radius_of_curvature = left_curverad right_lane . radius_of_curvature = right_curverad
This function measures curvature of the left and right lane lines
 in radians.
This function measures curvature of the left and right lane lines in radians .
"""
    #---------------------
    # This function measures curvature of the left and right lane lines
    # in radians.
    # This function is based on code provided in curvature measurement lecture.
    #
    """ # Reverse to match top-to-bottom in y # Reverse to match top-to-bottom in y # Define y-value where we want radius of curvature # I'll choose the maximum y-value, corresponding to the bottom of the image # U.S. regulations that require a  minimum lane width of 12 feet or 3.7 meters, # and the dashed lane lines are 10 feet or 3 meters long each. # >> http://onlinemanuals.txdot.gov/txdotmanuals/rdw/horizontal_alignment.htm#BGBHGEGC # Below is the calculation of radius of curvature after correcting for scale in x and y # Define conversions in x and y from pixels space to meters # meters per pixel in y dimension # meters per pixel in x dimension # Fit new polynomials to x,y in world space # Calculate the new radii of curvature # radius of curvature result
left_lane
right_lane