text: """
  # !/usr/bin/env python
  # -*- coding: utf-8 -*-
  @Time        : 2022/2/25 17:25
  @Author      : shengdl999links@gmail.com
  @ProjectName : udacity-program_self_driving_car_engineer_v1.0_source.0
  @File        : real_world_solution.py
  """
  
  import numpy as np
  
  
  def generate_data(ym_per_pix, xm_per_pix):
      '''
      Generates fake data to use for calculating lane curvature.
      In your own project, you'll ignore this function and instead
      feed in the output of your lane detection algorithm to
      the lane curvature calculation.
      '''
      # Set random seed number so results are consistent for grader
      # Comment this out if you'd like to see results on different random data!
      np.random.seed(0)
      # Generate some fake data to represent lane-line pixels
      ploty = np.linspace(0, 719, num=720)  # to cover same y-range as image
      quadratic_coeff = 3e-4  # arbitrary quadratic coefficient
      # For each y position generate random x position within +/-50 pix
      # of the line base position in each case (x=200 for left, and x=900 for right)
      leftx = np.array([200 + (y ** 2) * quadratic_coeff + np.random.randint(-50, high=51)
                        for y in ploty])
      rightx = np.array([900 + (y ** 2) * quadratic_coeff + np.random.randint(-50, high=51)
                         for y in ploty])
  
      leftx = leftx[::-1]  # Reverse to match top-to-bottom in y
      rightx = rightx[::-1]  # Reverse to match top-to-bottom in y
  
      # Fit a second order polynomial to pixel positions in each fake lane line
      # 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)
  
      return ploty, left_fit_cr, right_fit_cr
  
  
  def measure_curvature_real():
      '''
      Calculates the curvature of polynomial functions in meters.
      '''
      # Define conversions in x and y from pixels space to meters
      ym_per_pix = 30 / 720  # meters per pixel in y dimension
      xm_per_pix = 3.7 / 700  # meters per pixel in x dimension
  
      # Start by generating our fake example data
      # Make sure to feed in your real data instead in your project!
      ploty, left_fit_cr, right_fit_cr = generate_data(ym_per_pix, xm_per_pix)
  
      # Define y-value where we want radius of curvature
      # We'll choose the maximum y-value, corresponding to the bottom of the image
      y_eval = np.max(ploty)
  
      # Calculation of R_curve (radius 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])
  
      return left_curverad, right_curverad
  
  
  # Calculate the radius of curvature in meters for both lane lines
  left_curverad, right_curverad = measure_curvature_real()
  
  print(left_curverad, 'm', right_curverad, 'm')
  # Should see values of 533.75 and 648.16 here, if using
  # the default `generate_data` function with given seed number
  