-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline.py
74 lines (43 loc) · 1.54 KB
/
pipeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from moviepy.editor import VideoFileClip
import pickle
import myplot
import lane_find
import cam_correct
import warp
f = open('results.p', 'rb')
results = pickle.load(f)
def undistort_image(img):
undist = cam_correct.undistort(img, results)
#myplot.plot_double(img, processed, 'original', 'undistorted')
return undist
def undistort_movie():
clip = VideoFileClip('project_video.mp4')
corrected = clip.fl_image(undistort_image)
corrected.write_videofile('project_corrected.mp4', audio=False)
# Debugging function for inspecting specific frames of a video.
def load_frame_at_time(time):
clip = VideoFileClip('challenge_video.mp4')
frame = clip.get_frame(time)
undist = cam_correct.undistort(frame, results)
warped = warp.warp_to_top_down(frame)
#myplot.plot(frame)
# myplot.plot_double(frame, warped, 'original', 'top-down')
def process_images(in_img):
warped = warp.warp_to_top_down(in_img)
img = lane_find.process(warped, in_img)
return img
def do_it(input, output):
clip = VideoFileClip(input).subclip(t_start=0)
clip = clip.fl_image(process_images)
clip.write_videofile(output, progress_bar=True, audio=False)
#cam_correct.undistort_single()
# undistort_movie()
#load_frame_at_time(16)
#do_it(input='harder_challenge_video.mp4', output='pipeline_extra_challenge.mp4')
# prof = pprofile.Profile()
# with prof():
#
do_it(input='project_corrected.mp4', output='./temp_output/project_fixing_frame_bug.mp4')
# prof.print_stats()
# f = open('cachegrind.out', 'w')
# prof.callgrind(f)