-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (34 loc) · 1.24 KB
/
main.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
import LaneDetection as ld
from moviepy.editor import VideoFileClip
import cv2
counter = 0
def process_image(img):
# pipeline
#img = cv2.imread('./straight_lines1.jpg') # ADD! take image from video
global counter
counter+=1
undistorted = lf.undistort(img)
binary = lf.combinedBinary(undistorted)
# masked_binary = lf.maskBinary(binary)
warped = lf.prespectiveTransform(binary,lf.M)
# warped = lf.prespectiveTransform(masked_binary,lf.M)
mid = int(img.shape[1]/2)
leftx, lefty = lf.findLane(warped[:,:mid],leftLane)
rightx, righty = lf.findLane(warped[:,mid:],rightLane,mid)
rightx += mid
leftLane.addLane(leftx,lefty)
rightLane.addLane(rightx,righty)
lf.checkDetection(leftLane,rightLane)
leftLane.updateHistory()
rightLane.updateHistory()
leftLane.deriveGoodFit()
rightLane.deriveGoodFit()
processed_img = lf.drawImage(undistorted,leftLane,rightLane,mid)
return processed_img
lf = ld.LanesFinder()
leftLane = ld.Lane()
rightLane = ld.Lane()
vid_output = './output_videos/project_video.mp4'
clip1 = VideoFileClip('./project_video.mp4')
proj_clip = clip1.fl_image(process_image) #NOTE: this function expects color images!!
proj_clip.write_videofile(vid_output, audio=False)