grad_color_stack, img = color_gradient_threshold_pipeline(image, img_processor) birds_eye, M, Minv = calibration.perspective_transform(img, src, dst) undist = calibration.undistort(image) search, left_fitx, right_fitx, ploty, image_final = find_lane_lines.find(birds_eye, undist, Minv, left_line, right_line) return image_final #__main__ # Camera Calibration img = mpimg.imread('camera_cal/calibration1.jpg') img_size = (img.shape[1], img.shape[0]) calibration = CameraCalibration(chessboard_images_dir='camera_cal', pattern_size=(9,6)) calibration.calibrate_camera(img_size) # Image Processor img_processor = ImageProcessor() # src and dst for perspective transform test_img = mpimg.imread('test_images/straight_lines2.jpg') test_img_size = (test_img.shape[1], test_img.shape[0]) src = np.float32([[580,460], [710,460], [1150,720], [150,720]]) offset = 200 dst = np.float32([ [offset, 0], [test_img_size[0]-offset, 0], [test_img_size[0]-offset, test_img_size[1]-0], [offset, test_img_size[1]-0] ])
def scaled_sobel(abs_sobel): return np.uint8(255 * abs_sobel / np.max(abs_sobel)) @staticmethod def create_binary(image): return np.zeros_like(image) @staticmethod def region_of_interest(img, vertices): mask = np.zeros_like(img) if len(img.shape) > 2: channel_count = img.shape[2] ignore_mask_color = (255, ) * channel_count else: ignore_mask_color = 255 cv2.fillPoly(mask, vertices, ignore_mask_color) masked_image = cv2.bitwise_and(img, mask) return masked_image run = False if run: camcal = CameraCalibration() camcal.calibrate_camera() det = LaneLineDetector(camcal) output = 'harder_challenge_video_submit.mp4' clip1 = VideoFileClip('harder_challenge_video.mp4') clip = clip1.fl_image(det.pipeline) clip.write_videofile(output, audio=False)