Finding Lane Lines on the Road


In this project, you will use the tools you learned about in the lesson to identify lane lines on the road. You can develop your pipeline on a series of individual images, and later apply the result to a video stream (really just a series of images). Check out the video clip "raw-lines-example.mp4" (also contained in this repository) to see what the output should look like after using the helper functions below.

Once you have a result that looks roughly like "raw-lines-example.mp4", you'll need to get creative and try to average and/or extrapolate the line segments you've detected to map out the full extent of the lane lines. You can see an example of the result you're going for in the video "P1_example.mp4". Ultimately, you would like to draw just one line for the left side of the lane, and one for the right.


Let's have a look at our first image called 'test_images/solidWhiteRight.jpg'. Run the 2 cells below (hit Shift-Enter or the "play" button above) to display the image.

Note If, at any point, you encounter frozen display windows or other confounding issues, you can always start again with a clean slate by going to the "Kernel" menu above and selecting "Restart & Clear Output".


The tools you have are color selection, region of interest selection, grayscaling, Gaussian smoothing, Canny Edge Detection and Hough Tranform line detection. You are also free to explore and try other techniques that were not presented in the lesson. Your goal is piece together a pipeline to detect the line segments in the image, then average/extrapolate them and draw them onto the image for display (as below). Once you have a working pipeline, try it out on the video stream below.


Your output should look something like this (above) after detecting line segments using the helper functions below

Your goal is to connect/average/extrapolate line segments to get output like this


In [2]:
#importing some useful packages
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
%matplotlib inline

In [3]:
#reading in an image
image = mpimg.imread('test_images/solidWhiteRight.jpg')
#printing out some stats and plotting
print('This image is:', type(image), 'with dimesions:', image.shape)
plt.imshow(image)  #call as plt.imshow(gray, cmap='gray') to show a grayscaled image


This image is: <class 'numpy.ndarray'> with dimesions: (540, 960, 3)
Out[3]:
<matplotlib.image.AxesImage at 0x7f752c2ca7b8>

Some OpenCV functions (beyond those introduced in the lesson) that might be useful for this project are:

cv2.inRange() for color selection
cv2.fillPoly() for regions selection
cv2.line() to draw lines on an image given endpoints
cv2.addWeighted() to coadd / overlay two images cv2.cvtColor() to grayscale or change color cv2.imwrite() to output images to file
cv2.bitwise_and() to apply a mask to an image

Check out the OpenCV documentation to learn about these and discover even more awesome functionality!

Below are some helper functions to help get you started. They should look familiar from the lesson!


In [22]:
import math

def grayscale(img):
    """Applies the Grayscale transform
    This will return an image with only one color channel
    but NOTE: to see the returned image as grayscale
    you should call plt.imshow(gray, cmap='gray')"""
    return cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    
def canny(img, low_threshold, high_threshold):
    """Applies the Canny transform"""
    return cv2.Canny(img, low_threshold, high_threshold)

def gaussian_blur(img, kernel_size):
    """Applies a Gaussian Noise kernel"""
    return cv2.GaussianBlur(img, (kernel_size, kernel_size), 0)

def region_of_interest(img, vertices):
    """
    Applies an image mask.
    
    Only keeps the region of the image defined by the polygon
    formed from `vertices`. The rest of the image is set to black.
    """
    #defining a blank mask to start with
    mask = np.zeros_like(img)   
    
    #defining a 3 channel or 1 channel color to fill the mask with depending on the input image
    if len(img.shape) > 2:
        channel_count = img.shape[2]  # i.e. 3 or 4 depending on your image
        ignore_mask_color = (255,) * channel_count
    else:
        ignore_mask_color = 255
        
    #filling pixels inside the polygon defined by "vertices" with the fill color    
    cv2.fillPoly(mask, vertices, ignore_mask_color)
    
    #returning the image only where mask pixels are nonzero
    masked_image = cv2.bitwise_and(img, mask)
    return masked_image


def draw_lines(img, lines, color=[255, 0, 0], thickness=2):
    """
    NOTE: this is the function you might want to use as a starting point once you want to 
    average/extrapolate the line segments you detect to map out the full
    extent of the lane (going from the result shown in raw-lines-example.mp4
    to that shown in P1_example.mp4).  
    
    Think about things like separating line segments by their 
    slope ((y2-y1)/(x2-x1)) to decide which segments are part of the left
    line vs. the right line.  Then, you can average the position of each of 
    the lines and extrapolate to the top and bottom of the lane.
    
    This function draws `lines` with `color` and `thickness`.    
    Lines are drawn on the image inplace (mutates the image).
    If you want to make the lines semi-transparent, think about combining
    this function with the weighted_img() function below
    """
    for line in lines:
        for x1,y1,x2,y2 in line:
            cv2.line(img, (x1, y1), (x2, y2), color, thickness)
            
def dist(x1,x2,y1,y2): 
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

# Global variable, param w and b updated through time
global_w_left = -1
global_b_left = 1
global_w_right = 1
global_b_right = 1
Global_First_Frame = True # for video test, when it is the first frame, we need to initilize param w and b
def fit_lines(img, lines, slope_th=0.5, line_len_ratio=0.08, alpha_w=0.1, alpha_b=0.1):
    global global_w_left
    global global_b_left
    global global_w_right
    global global_b_right
    global Global_First_Frame
    # define the position parameters
    ysize = img.shape[0]
    xsize = img.shape[1]
    y_bottom = ysize-1
    x_left = xsize*0.5
    x_right = xsize*0.5
    length_th = line_len_ratio*ysize
    # assign the lines to left and right according to their positions
    left_lines_x = []
    left_lines_y = []
    left_len = 0
    right_lines_x = []
    right_lines_y = []
    right_len = 0
    for line in lines:
        x1 = line[0][0]
        y1 = line[0][1]
        x2 = line[0][2]
        y2 = line[0][3]
        if x1<x_left and x2<x_left:
            slope = (y2-y1)/(x2-x1)
            if slope < -abs(slope_th): # note the origin is on the left top
                left_lines_x.append(x1)
                left_lines_x.append(x2)
                left_lines_y.append(y1)
                left_lines_y.append(y2)
                left_len += dist(x1,x2,y1,y2)
        elif x1>x_right and x2>x_right:
            slope = (y2-y1)/(x2-x1)
            if slope > abs(slope_th):
                right_lines_x.append(x1)
                right_lines_x.append(x2)
                right_lines_y.append(y1)
                right_lines_y.append(y2)
                right_len += dist(x1,x2,y1,y2)
    # define the top positions of the lines
    #y_top_left = min(left_lines_y)
    #y_top_right = min(right_lines_y)
    y_top_left = ysize/2+50
    y_top_right = ysize/2+50
    #
    left_line = np.array([[0,0,0,0]])
    right_line = np.array([[0,0,0,0]])
    # fit the left points with line
    if Global_First_Frame == True:
        z = np.polyfit(left_lines_x, left_lines_y, 1)  # y=z[0]x+z[1] --> x=(y-z[1])/z[0]
        global_w_left = z[1]
        global_b_left = z[0]
    elif left_len>length_th:
        z = np.polyfit(left_lines_x, left_lines_y, 1)  # y=z[0]x+z[1] --> x=(y-z[1])/z[0]
        if  z[0]<-abs(slope_th):
            global_w_left = (1-alpha_w)*global_w_left + alpha_w*z[1] # adapt w
            global_b_left = (1-alpha_b)*global_b_left + alpha_b*z[0] # adapt b
    left_line[0][0] = (y_top_left-global_w_left)/global_b_left
    left_line[0][1] = y_top_left
    left_line[0][2] = (y_bottom-global_w_left)/global_b_left
    left_line[0][3] = y_bottom
    # fit the right points with line
#     print(right_lines_x)
    if Global_First_Frame == True:
        z = np.polyfit(right_lines_x, right_lines_y, 1)  # y=z[0]x+z[1] --> x=(y-z[1])/z[0]
        global_w_right = z[1]
        global_b_right = z[0]
    elif right_len>length_th:
        z = np.polyfit(right_lines_x, right_lines_y, 1)  # y=z[0]x+z[1] --> x=(y-z[1])/z[0]
        if  z[0]>abs(slope_th):
            global_w_right = (1-alpha_w)*global_w_right + alpha_w*z[1] # adapt w
            global_b_right = (1-alpha_b)*global_b_right + alpha_b*z[0] # adapt w
    right_line[0][0] =(y_top_left-global_w_right)/global_b_right
    right_line[0][1] = y_top_right
    right_line[0][2] =  (y_bottom-global_w_right)/global_b_right
    right_line[0][3] = y_bottom
    #
    Global_First_Frame = False
    return left_line, right_line
    
def hough_lines(img, rho, theta, threshold, min_line_len, max_line_gap):
    """
    `img` should be the output of a Canny transform.
        
    Returns an image with hough lines drawn.
    """
    lines = cv2.HoughLinesP(img, rho, theta, threshold, np.array([]), minLineLength=min_line_len, maxLineGap=max_line_gap)
    left_line, right_line = fit_lines(img, lines)
    line_img = np.zeros((*img.shape, 3), dtype=np.uint8)
    draw_lines(line_img, np.array([left_line, right_line]), thickness=5)
    return line_img

# Python 3 has support for cool math symbols.

def weighted_img(img, initial_img, α=0.8, β=1., λ=0.):
    """
    `img` is the output of the hough_lines(), An image with lines drawn on it.
    Should be a blank image (all black) with lines drawn on it.
    
    `initial_img` should be the image before any processing.
    
    The result image is computed as follows:
    
    initial_img * α + img * β + λ
    NOTE: initial_img and img must be the same shape!
    """
    return cv2.addWeighted(initial_img, α, img, β, λ)

Test on Images

Now you should build your pipeline to work on the images in the directory "test_images"
You should make sure your pipeline works well on these images before you try the videos.


In [19]:
import os
imgdir = "test_images/"
os.listdir(imgdir)
for filename in os.listdir(imgdir):
    img = mpimg.imread(os.path.join(imgdir, filename))
    plt.figure()
    plt.imshow(img)
    #
    gray = grayscale(img)
    blur = gaussian_blur(gray, 3)
    edge = canny(blur, 50, 130)
    #
    ysize = img.shape[0]
    xsize = img.shape[1]
    vertices = np.array([[(xsize*0.13,ysize*0.9),(xsize*0.87, ysize*0.9), (xsize/2+20, ysize/2+40), (xsize/2-20, ysize/2+40)]], dtype=np.int32)
    roi_edge = region_of_interest(edge, vertices)
    plt.figure()
    plt.imshow(roi_edge, cmap='gray')
    #
    rho = 1 # distance resolution in pixels of the Hough grid
    theta = 1*np.pi/180 # angular resolution in radians of the Hough grid
    threshold = 15     # minimum number of votes (intersections in Hough grid cell)
    min_line_len = 20 #minimum number of pixels making up a line
    max_line_gap = 20    # maximum gap in pixels between connectable line segments
    Global_First_Frame = True
    line_img = hough_lines(roi_edge, rho, theta, threshold, min_line_len, max_line_gap)
    #
    result_img = weighted_img(line_img, img, α=0.8, β=1., λ=0.)
    plt.figure()
    plt.imshow(result_img)


run your solution on all test_images and make copies into the test_images directory).

Test on Videos

You know what's cooler than drawing lanes over images? Drawing lanes over video!

We can test our solution on two provided videos:

solidWhiteRight.mp4

solidYellowLeft.mp4


In [7]:
# Import everything needed to edit/save/watch video clips
from moviepy.editor import VideoFileClip
from IPython.display import HTML

In [8]:
def process_image(img):
    # NOTE: The output you return should be a color image (3 channel) for processing video below
    # TODO: put your pipeline here,
    # you should return the final output (image with lines are drawn on lanes)
    gray = grayscale(img)
    blur = gaussian_blur(gray, 3)
    edge = canny(blur, 50, 130)
#     plt.figure()
#     plt.imshow(edge, cmap='gray')
    #
    ysize = img.shape[0]
    xsize = img.shape[1]
    vertices = np.array([[(xsize*0.13,ysize*0.9),(xsize*0.87, ysize*0.9), (xsize/2+20, ysize/2+40), (xsize/2-20, ysize/2+40)]], dtype=np.int32)
    roi_edge = region_of_interest(edge, vertices)
#     plt.figure()
#     plt.imshow(roi_edge, cmap='gray')
    #
    rho = 1 # distance resolution in pixels of the Hough grid
    theta = 1*np.pi/180 # angular resolution in radians of the Hough grid
    threshold = 10     # minimum number of votes (intersections in Hough grid cell)
    min_line_len = 15 #minimum number of pixels making up a line
    max_line_gap = 25    # maximum gap in pixels between connectable line segments
    line_img = hough_lines(roi_edge, rho, theta, threshold, min_line_len, max_line_gap)
    #
    result = weighted_img(line_img, img, α=0.8, β=1., λ=0.)
#     plt.figure()
#     plt.imshow(result)
    return result

Let's try the one with the solid white lane on the right first ...


In [9]:
white_output = 'white.mp4'
clip1 = VideoFileClip("solidWhiteRight.mp4")
Global_First_Frame = True
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!
%time white_clip.write_videofile(white_output, audio=False)


[MoviePy] >>>> Building video white.mp4
[MoviePy] Writing video white.mp4
100%|█████████▉| 221/222 [00:13<00:00, 14.59it/s]
[MoviePy] Done.
[MoviePy] >>>> Video ready: white.mp4 

CPU times: user 36.8 s, sys: 1.5 s, total: 38.3 s
Wall time: 14.7 s

Play the video inline, or if you prefer find the video in your filesystem (should be in the same directory) and play it in your video player of choice.


In [10]:
HTML("""
<video width="960" height="540" controls>
  <source src="{0}">
</video>
""".format(white_output))


Out[10]:

At this point, if you were successful you probably have the Hough line segments drawn onto the road, but what about identifying the full extent of the lane and marking it clearly as in the example video (P1_example.mp4)? Think about defining a line to run the full length of the visible lane based on the line segments you identified with the Hough Transform. Modify your draw_lines function accordingly and try re-running your pipeline.

Now for the one with the solid yellow lane on the left. This one's more tricky!


In [11]:
yellow_output = 'yellow.mp4'
clip2 = VideoFileClip('solidYellowLeft.mp4')
Global_First_Frame = True
yellow_clip = clip2.fl_image(process_image)
%time yellow_clip.write_videofile(yellow_output, audio=False)


[MoviePy] >>>> Building video yellow.mp4
[MoviePy] Writing video yellow.mp4
100%|█████████▉| 681/682 [00:45<00:00, 14.81it/s]
[MoviePy] Done.
[MoviePy] >>>> Video ready: yellow.mp4 

CPU times: user 2min 4s, sys: 4.45 s, total: 2min 9s
Wall time: 46.8 s

In [12]:
HTML("""
<video width="960" height="540" controls>
  <source src="{0}">
</video>
""".format(yellow_output))


Out[12]:

Reflections

Congratulations on finding the lane lines! As the final step in this project, we would like you to share your thoughts on your lane finding pipeline... specifically, how could you imagine making your algorithm better / more robust? Where will your current algorithm be likely to fail?

Please add your thoughts below, and if you're up for making your pipeline more robust, be sure to scroll down and check out the optional challenge video below!

Reflections: Here, I use the traditional image processing methods to detect the lines. The pipeline is Grayscale --> Gaussian Blur --> Canny Edge Detection --> ROI --> Hough Transform Line Detection --> Fit Lines With Slope. The fore stages should guarantee that all lines be detected, and the later stages should remove the noise as much as possibile. It is useful in simple situations. But when in more complex scenes such as occlusions, bent roads, snowy or rainy weather, there will be more noises which may lead to failure. I imagine the temporal infomation can help to reduce the noisy and overcome the occlusions to make the detection more smooth temporally. Besides, there are too many hyperparameters here, which limits the generation ability of the methods. I think the data-driven machine learning method or other adaptive can solve it.

Submission

If you're satisfied with your video outputs it's time to submit! Submit this ipython notebook for review.

Optional Challenge

Try your lane finding pipeline on the video below. Does it still work? Can you figure out a way to make it more robust? If you're up for the challenge, modify your pipeline so it works with this video and submit it along with the rest of your project!


In [23]:
challenge_output = 'extra.mp4'
clip2 = VideoFileClip('challenge.mp4')
Global_First_Frame = True
# myclip = VideoFileClip("challenge.mp4").subclip(4, 5) 
challenge_clip = clip2.fl_image(process_image)
%time challenge_clip.write_videofile(challenge_output, audio=False)


[MoviePy] >>>> Building video extra.mp4
[MoviePy] Writing video extra.mp4
  0%|          | 0/251 [00:00<?, ?it/s]
  1%|          | 3/251 [00:00<00:11, 22.00it/s]
  2%|▏         | 6/251 [00:00<00:10, 22.53it/s]
  4%|▎         | 9/251 [00:00<00:10, 22.50it/s]
  5%|▍         | 12/251 [00:00<00:10, 22.68it/s]
  6%|▌         | 14/251 [00:00<00:11, 21.30it/s]
  7%|▋         | 17/251 [00:00<00:10, 22.07it/s]
  8%|▊         | 20/251 [00:00<00:10, 22.00it/s]
  9%|▉         | 23/251 [00:01<00:10, 22.26it/s]
 10%|█         | 26/251 [00:01<00:09, 22.69it/s]
 12%|█▏        | 29/251 [00:01<00:09, 23.01it/s]
 13%|█▎        | 32/251 [00:01<00:09, 23.11it/s]
 14%|█▍        | 35/251 [00:01<00:09, 23.03it/s]
 15%|█▌        | 38/251 [00:01<00:09, 22.97it/s]
 16%|█▋        | 41/251 [00:01<00:09, 23.15it/s]
 18%|█▊        | 44/251 [00:01<00:08, 23.25it/s]
 19%|█▊        | 47/251 [00:02<00:11, 17.95it/s]
 20%|█▉        | 49/251 [00:02<00:10, 18.44it/s]
 20%|██        | 51/251 [00:02<00:11, 17.35it/s]
 21%|██        | 53/251 [00:02<00:14, 13.64it/s]
 22%|██▏       | 55/251 [00:02<00:15, 12.76it/s]
 23%|██▎       | 57/251 [00:02<00:15, 12.47it/s]
 24%|██▎       | 59/251 [00:03<00:16, 11.66it/s]
 24%|██▍       | 61/251 [00:03<00:21,  8.97it/s]
 25%|██▌       | 63/251 [00:03<00:21,  8.90it/s]
 25%|██▌       | 64/251 [00:03<00:20,  9.13it/s]
 26%|██▋       | 66/251 [00:03<00:17, 10.57it/s]
 27%|██▋       | 68/251 [00:04<00:25,  7.23it/s]
 28%|██▊       | 70/251 [00:04<00:21,  8.52it/s]
 29%|██▊       | 72/251 [00:04<00:20,  8.69it/s]
 29%|██▉       | 74/251 [00:05<00:21,  8.37it/s]
 30%|███       | 76/251 [00:05<00:19,  8.94it/s]
 31%|███       | 77/251 [00:05<00:31,  5.46it/s]
 31%|███       | 78/251 [00:05<00:29,  5.94it/s]
 31%|███▏      | 79/251 [00:05<00:25,  6.72it/s]
 32%|███▏      | 80/251 [00:05<00:24,  7.09it/s]
 33%|███▎      | 82/251 [00:06<00:21,  7.89it/s]
 33%|███▎      | 83/251 [00:06<00:20,  8.18it/s]
 33%|███▎      | 84/251 [00:06<00:21,  7.72it/s]
 34%|███▍      | 86/251 [00:06<00:18,  8.73it/s]
 35%|███▍      | 87/251 [00:06<00:20,  7.96it/s]
 35%|███▌      | 88/251 [00:06<00:19,  8.41it/s]
 36%|███▌      | 90/251 [00:07<00:17,  9.00it/s]
 36%|███▋      | 91/251 [00:07<00:18,  8.86it/s]
 37%|███▋      | 92/251 [00:07<00:22,  6.93it/s]
 37%|███▋      | 93/251 [00:07<00:23,  6.80it/s]
 37%|███▋      | 94/251 [00:07<00:23,  6.57it/s]
 38%|███▊      | 96/251 [00:07<00:24,  6.43it/s]
 39%|███▊      | 97/251 [00:08<00:22,  6.81it/s]
 39%|███▉      | 98/251 [00:08<00:22,  6.93it/s]
 39%|███▉      | 99/251 [00:08<00:23,  6.44it/s]
 40%|███▉      | 100/251 [00:08<00:22,  6.80it/s]
 40%|████      | 101/251 [00:08<00:22,  6.59it/s]
 41%|████      | 102/251 [00:08<00:20,  7.28it/s]
 41%|████      | 103/251 [00:08<00:21,  6.97it/s]
 42%|████▏     | 105/251 [00:09<00:18,  8.01it/s]
 43%|████▎     | 107/251 [00:09<00:18,  7.98it/s]
 43%|████▎     | 108/251 [00:09<00:17,  8.29it/s]
 44%|████▍     | 110/251 [00:09<00:14,  9.50it/s]
 45%|████▍     | 112/251 [00:10<00:18,  7.33it/s]
 45%|████▌     | 114/251 [00:10<00:16,  8.46it/s]
 46%|████▌     | 116/251 [00:10<00:20,  6.55it/s]
 47%|████▋     | 117/251 [00:10<00:20,  6.62it/s]
 47%|████▋     | 118/251 [00:10<00:18,  7.21it/s]
 47%|████▋     | 119/251 [00:11<00:19,  6.83it/s]
 48%|████▊     | 120/251 [00:11<00:20,  6.46it/s]
 48%|████▊     | 121/251 [00:11<00:19,  6.71it/s]
 49%|████▊     | 122/251 [00:11<00:18,  7.15it/s]
 49%|████▉     | 123/251 [00:11<00:16,  7.77it/s]
 49%|████▉     | 124/251 [00:11<00:20,  6.18it/s]
 50%|████▉     | 125/251 [00:12<00:19,  6.33it/s]
 50%|█████     | 126/251 [00:12<00:18,  6.59it/s]
 51%|█████     | 127/251 [00:12<00:18,  6.75it/s]
 51%|█████▏    | 129/251 [00:12<00:19,  6.41it/s]
 52%|█████▏    | 131/251 [00:12<00:15,  7.75it/s]
 53%|█████▎    | 133/251 [00:12<00:13,  8.73it/s]
 54%|█████▍    | 135/251 [00:13<00:13,  8.66it/s]
 54%|█████▍    | 136/251 [00:13<00:15,  7.27it/s]
 55%|█████▍    | 137/251 [00:13<00:22,  5.10it/s]
 55%|█████▍    | 138/251 [00:13<00:19,  5.83it/s]
 55%|█████▌    | 139/251 [00:13<00:17,  6.42it/s]
 56%|█████▌    | 140/251 [00:14<00:17,  6.30it/s]
 56%|█████▌    | 141/251 [00:14<00:15,  6.90it/s]
 57%|█████▋    | 142/251 [00:14<00:16,  6.72it/s]
 57%|█████▋    | 143/251 [00:14<00:20,  5.25it/s]
 58%|█████▊    | 145/251 [00:14<00:17,  6.01it/s]
 58%|█████▊    | 146/251 [00:15<00:16,  6.55it/s]
 59%|█████▊    | 147/251 [00:15<00:14,  7.16it/s]
 59%|█████▉    | 149/251 [00:15<00:12,  7.88it/s]
 60%|█████▉    | 150/251 [00:15<00:18,  5.46it/s]
 60%|██████    | 151/251 [00:15<00:15,  6.30it/s]
 61%|██████    | 153/251 [00:15<00:12,  7.61it/s]
 61%|██████▏   | 154/251 [00:16<00:13,  6.94it/s]
 62%|██████▏   | 155/251 [00:16<00:13,  7.29it/s]
 62%|██████▏   | 156/251 [00:16<00:13,  6.96it/s]
 63%|██████▎   | 158/251 [00:16<00:14,  6.39it/s]
 64%|██████▎   | 160/251 [00:16<00:12,  7.45it/s]
 64%|██████▍   | 161/251 [00:16<00:12,  7.27it/s]
 65%|██████▍   | 163/251 [00:17<00:10,  8.34it/s]
 65%|██████▌   | 164/251 [00:17<00:10,  8.06it/s]
 66%|██████▌   | 165/251 [00:17<00:14,  6.04it/s]
 66%|██████▌   | 166/251 [00:17<00:14,  5.78it/s]
 67%|██████▋   | 167/251 [00:17<00:12,  6.55it/s]
 67%|██████▋   | 169/251 [00:18<00:11,  6.93it/s]
 68%|██████▊   | 170/251 [00:18<00:12,  6.44it/s]
 68%|██████▊   | 171/251 [00:18<00:12,  6.38it/s]
 69%|██████▊   | 172/251 [00:18<00:16,  4.77it/s]
 69%|██████▉   | 174/251 [00:19<00:14,  5.22it/s]
 70%|██████▉   | 175/251 [00:19<00:14,  5.23it/s]
 70%|███████   | 176/251 [00:19<00:13,  5.65it/s]
 71%|███████   | 177/251 [00:19<00:12,  5.83it/s]
 71%|███████   | 178/251 [00:19<00:13,  5.34it/s]
 71%|███████▏  | 179/251 [00:19<00:12,  5.72it/s]
 72%|███████▏  | 180/251 [00:20<00:10,  6.47it/s]
 72%|███████▏  | 181/251 [00:20<00:13,  5.12it/s]
 73%|███████▎  | 183/251 [00:20<00:11,  5.75it/s]
 73%|███████▎  | 184/251 [00:20<00:11,  5.69it/s]
 74%|███████▎  | 185/251 [00:20<00:12,  5.36it/s]
 75%|███████▍  | 187/251 [00:21<00:09,  6.47it/s]
 75%|███████▌  | 189/251 [00:21<00:10,  5.91it/s]
 76%|███████▌  | 191/251 [00:21<00:09,  6.33it/s]
 76%|███████▋  | 192/251 [00:21<00:09,  6.54it/s]
 77%|███████▋  | 193/251 [00:22<00:08,  6.89it/s]
 77%|███████▋  | 194/251 [00:22<00:08,  6.76it/s]
 78%|███████▊  | 195/251 [00:22<00:07,  7.47it/s]
 78%|███████▊  | 196/251 [00:22<00:07,  7.22it/s]
 78%|███████▊  | 197/251 [00:22<00:10,  5.09it/s]
 79%|███████▉  | 198/251 [00:22<00:09,  5.81it/s]
 80%|███████▉  | 200/251 [00:23<00:07,  7.01it/s]
 80%|████████  | 202/251 [00:23<00:05,  8.20it/s]
 81%|████████▏ | 204/251 [00:23<00:07,  6.68it/s]
 82%|████████▏ | 206/251 [00:23<00:06,  7.35it/s]
 82%|████████▏ | 207/251 [00:24<00:06,  6.44it/s]
 83%|████████▎ | 208/251 [00:24<00:07,  5.39it/s]
 84%|████████▎ | 210/251 [00:24<00:07,  5.57it/s]
 84%|████████▍ | 211/251 [00:24<00:06,  5.95it/s]
 84%|████████▍ | 212/251 [00:24<00:06,  6.34it/s]
 85%|████████▍ | 213/251 [00:25<00:05,  6.65it/s]
 85%|████████▌ | 214/251 [00:25<00:05,  6.50it/s]
 86%|████████▌ | 215/251 [00:25<00:06,  5.72it/s]
 86%|████████▌ | 216/251 [00:25<00:05,  5.99it/s]
 86%|████████▋ | 217/251 [00:25<00:05,  6.33it/s]
 87%|████████▋ | 218/251 [00:25<00:04,  6.63it/s]
 87%|████████▋ | 219/251 [00:26<00:05,  5.55it/s]
 88%|████████▊ | 220/251 [00:26<00:04,  6.25it/s]
 88%|████████▊ | 221/251 [00:26<00:04,  6.78it/s]
 89%|████████▉ | 223/251 [00:26<00:04,  6.32it/s]
 89%|████████▉ | 224/251 [00:26<00:04,  6.08it/s]
 90%|████████▉ | 225/251 [00:26<00:03,  6.88it/s]
 90%|█████████ | 226/251 [00:27<00:03,  6.82it/s]
 90%|█████████ | 227/251 [00:27<00:03,  6.60it/s]
 91%|█████████ | 228/251 [00:27<00:03,  6.83it/s]
 91%|█████████ | 229/251 [00:27<00:03,  6.38it/s]
 92%|█████████▏| 230/251 [00:27<00:03,  6.91it/s]
 92%|█████████▏| 231/251 [00:27<00:03,  5.71it/s]
 93%|█████████▎| 233/251 [00:28<00:02,  6.51it/s]
 93%|█████████▎| 234/251 [00:28<00:02,  6.42it/s]
 94%|█████████▍| 236/251 [00:28<00:02,  6.34it/s]
 94%|█████████▍| 237/251 [00:28<00:01,  7.12it/s]
 95%|█████████▍| 238/251 [00:28<00:01,  7.50it/s]
 95%|█████████▌| 239/251 [00:29<00:01,  7.26it/s]
 96%|█████████▌| 240/251 [00:29<00:01,  6.60it/s]
 96%|█████████▌| 241/251 [00:29<00:01,  6.68it/s]
 96%|█████████▋| 242/251 [00:29<00:01,  7.11it/s]
 97%|█████████▋| 243/251 [00:29<00:01,  7.28it/s]
 97%|█████████▋| 244/251 [00:29<00:00,  7.72it/s]
 98%|█████████▊| 245/251 [00:29<00:00,  7.46it/s]
 98%|█████████▊| 246/251 [00:29<00:00,  7.92it/s]
 98%|█████████▊| 247/251 [00:30<00:00,  8.05it/s]
 99%|█████████▉| 248/251 [00:30<00:00,  4.97it/s]
100%|█████████▉| 250/251 [00:30<00:00,  5.79it/s]
100%|██████████| 251/251 [00:30<00:00,  6.56it/s]
[MoviePy] Done.
[MoviePy] >>>> Video ready: extra.mp4 

CPU times: user 1min 15s, sys: 2.8 s, total: 1min 18s
Wall time: 32.4 s

In [24]:
HTML("""
<video width="960" height="540" controls>
  <source src="{0}">
</video>
""".format(challenge_output))


Out[24]:

In [ ]:


In [ ]: