The input video is a color image. When I print shape of first frame of clip1, it gives proper result. However inside the function clip1.fl_image, it fails at getting the shape for the frame. Not sure how to fix this.
white_output = '/Users/SandeepGangundi/Documents/Courses/Udacity/Self_Driving_Car_ND/Term1/Udacity-CarND-Advanced-Lane-Lines/project_video_output.mp4'
clip1 = VideoFileClip("/Users/SandeepGangundi/Documents/Courses/Udacity/Self_Driving_Car_ND/Term1/Udacity-CarND-Advanced-Lane-Lines/project_video.mp4")
print(clip1.get_frame(0).shape)
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!
%time white_clip.write_videofile(white_output, audio=False)
(720, 1280, 3)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-8-0f763fa3ae4f> in <module>() 4 white_output = '/Users/SandeepGangundi/Documents/Courses/Udacity/Self_Driving_Car_ND/Term1/Udacity-CarND-Advanced-Lane-Lines/project_video_output.mp4'
5 clip1 = VideoFileClip("/Users/SandeepGangundi/Documents/Courses/Udacity/Self_Driving_Car_ND/Term1/Udacity-CarND-Advanced-Lane-Lines/project_video.mp4")
----> 6
white_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!
7 get_ipython().magic('time white_clip.write_videofile(white_output, audio=False)')
/Users/SandeepGangundi/anaconda/envs/carnd-term1/lib/python3.5/site-packages/moviepy/video/VideoClip.py in fl_image(self, image_func, apply_to) 511 `get_frame(t)` by another frame,
`image_func(get_frame(t))`
512 """ --> 513 return self.fl(lambda gf, t: image_func(gf(t)), apply_to)
514
515 # --------------------------------------------------------------
/Users/SandeepGangundi/anaconda/envs/carnd-term1/lib/python3.5/site-packages/moviepy/Clip.py in fl(self, fun, apply_to, keep_duration) 134
135 #mf = copy(self.make_frame)
--> 136
newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
137
138 if not keep_duration:
<decorator-gen-178> in set_make_frame(self, mf) /Users/SandeepGangundi/anaconda/envs/carnd-term1/lib/python3.5/site-packages/moviepy/decorators.py in outplace(f, clip, *a, **k) 12 """ Applies f(clip.copy(), *a, **k) and returns clip.copy()"""
13 newclip = clip.copy()
---> 14
f(newclip, *a, **k)
15 return newclip
16
/Users/SandeepGangundi/anaconda/envs/carnd-term1/lib/python3.5/site-packages/moviepy/video/VideoClip.py in set_make_frame(self, mf) 651 """ 652 self.make_frame = mf
--> 653
self.size = self.get_frame(0).shape[:2][::-1]
654
655
AttributeError: 'NoneType' object has no attribute 'shape'
My best guess: does your function "process_image" actually return an image (instead of just modifying the image in-place) ?
Yes it does, below is the function definition:
def process_image(image):
undistorted_image = undistort_image(image, camera_objpoints, camera_imgpoints)
binary_thresh_image = color_threshold(undistorted_image)
binary_warped_image, Minv = transform_perspective(binary_thresh_image)
left_fit, right_fit = fit_lane_lines(binary_warped_image)
left_rad, right_rad = get_radius_curvature(binary_warped_image, left_fit, right_fit)
inv_persp_image = transform_inv_perspective(undistorted_image, binary_warped_image, left_fit, right_fit, Minv)
dist_off_center_str = get_off_center_distance(binary_warped_image)
final_image = add_data_to_image(inv_persp_image, dist_off_center_str, left_rad, right_rad)
return final_image
I think you are right, my final function inside process_image failed to return proper color image that I expected it to.
Thanks a lot for the quick reply and help.
can we close this issue?
Hi, yes please close this issue.
Awesome! This helped
Most helpful comment
My best guess: does your function "process_image" actually return an image (instead of just modifying the image in-place) ?