def pipeline(img, isVideo=False): # Image Preprocessing undst, binary, binary_warped = PreProcessing.preprocess_image(img) # Lane Detection Code Start lanes, leftx, lefty, rightx, righty, ploty = LaneFinding.get_lane_lines( binary_warped, isVideo) lcurve, rcurve = Support.get_real_lanes_curvature(ploty, leftx, lefty, rightx, righty) output = draw_lane_area(undst, binary_warped, ploty, leftx, lefty, rightx, righty, isVideo) left_fit, right_fit, dummy = Support.fit_polylines(binary_warped.shape[0], leftx, lefty, rightx, righty, x_scale_factor=1, y_scale_factor=1) left_fitx, right_fitx = Support.get_polylines_points( ploty, left_fit, right_fit) if (isVideo is True): lcurve, rcurve = getSmoothedCurveData(lcurve, rcurve) left_fitx, right_fitx = getSmoothedLanesData(left_fitx, right_fitx) shiftFromLaneCenter_m, side = calculate_shift_from_lane_center( binary_warped, left_fitx, right_fitx) Font = cv2.FONT_HERSHEY_SIMPLEX color = (255, 255, 255) cv2.putText(output, 'curve = ' + str((lcurve + rcurve) / 2) + ' m', (10, 100), Font, 1, color, 2, cv2.LINE_AA) cv2.putText( output, 'Vehicle is ' + str(shiftFromLaneCenter_m) + ' (m) ' + side + ' of lane center', (10, 150), Font, 1, color, 2, cv2.LINE_AA) # Lane Detection Code End # Vehicle Detection Code Start cars_boxs = get_classified_cars_boxs(undst) classified_boxs = Visualisation.draw_boxes(undst, cars_boxs, color=(0, 0, 255), thick=6) filtered_boxs, heat_map = get_heat_map_boxs(cars_boxs, undst, isVideo) output = Visualisation.draw_boxes(output, filtered_boxs, color=(0, 0, 255), thick=6) # Vehicle Detection Code End return undst, classified_boxs, heat_map, output