Exemplo n.º 1
0
def processing(img, object_points, img_points, M, Minv, left_line, right_line):
    #camera calibration, image distortion correction
    undist = utils.cal_undistort(img, object_points, img_points)
    #get the thresholded binary image
    thresholded = thresholding(undist)
    #perform perspective  transform
    thresholded_wraped = cv2.warpPerspective(thresholded,
                                             M,
                                             img.shape[1::-1],
                                             flags=cv2.INTER_LINEAR)

    #perform detection
    if left_line.detected and right_line.detected:
        left_fit, right_fit, left_lane_inds, right_lane_inds = utils.find_line_by_previous(
            thresholded_wraped, left_line.current_fit, right_line.current_fit)
    else:
        left_fit, right_fit, left_lane_inds, right_lane_inds = utils.find_line(
            thresholded_wraped)
    left_line.update(left_fit)
    right_line.update(right_fit)

    #draw the detected laneline and the information
    area_img = utils.draw_area(undist, thresholded_wraped, Minv, left_fit,
                               right_fit)
    curvature, pos_from_center = utils.calculate_curv_and_pos(
        thresholded_wraped, left_fit, right_fit)
    result = utils.draw_values(area_img, curvature, pos_from_center)

    return result
Exemplo n.º 2
0
def processing(img, object_points, img_points, M, Minv, left_line, right_line):
    undist = utils.cal_undistort(img, object_points, img_points)
    thresholded = thresholding(undist)
    thresholded_wraped = cv2.warpPerspective(thresholded,
                                             M,
                                             img.shape[1::-1],
                                             flags=cv2.INTER_LINEAR)
    if left_line.detected and right_line.detected:
        left_fit, right_fit, left_lane_inds, right_lane_inds = utils.find_line_by_previous(
            thresholded_wraped, left_line.current_fit, right_line.current_fit)
    else:
        left_fit, right_fit, left_lane_inds, right_lane_inds = utils.find_line(
            thresholded_wraped)
    left_line.update(left_fit)
    right_line.update(right_fit)

    area_img = utils.draw_area(undist, thresholded_wraped, Minv, left_fit,
                               right_fit)

    curvature, pos_from_center = utils.calculate_curv_and_pos(
        thresholded_wraped, left_fit, right_fit)
    result = utils.draw_values(area_img, curvature, pos_from_center)
    return result
Exemplo n.º 3
0
import cv2
import utils
import matplotlib.pyplot as plt
import numpy as np

#script mainly use for drawing the demo picture

cal_imgs = utils.get_images_by_dir('camera_cal')
object_points,img_points = utils.calibrate(cal_imgs,grid=(9,6))

#test_imgs = utils.get_images_by_dir('test_images')
test_imgs = utils.get_images_by_dir('new_test')

undistorted = []
for img in test_imgs:
    img = utils.cal_undistort(img,object_points,img_points)
    undistorted.append(img)

trans_on_test=[]
for img in undistorted:
    src = np.float32([[(203, 720), (585, 460), (695, 460), (1127, 720)]])
    dst = np.float32([[(320, 720), (320, 0), (960, 0), (960, 720)]])
    M = cv2.getPerspectiveTransform(src, dst)
    trans = cv2.warpPerspective(img, M, img.shape[1::-1], flags=cv2.INTER_LINEAR)
    trans_on_test.append(trans)
    
thresh = []
binary_wrapeds = []
histogram = []
for img in undistorted:
    x_thresh = utils.abs_sobel_thresh(img, orient='x', thresh_min=55, thresh_max=100)
Exemplo n.º 4
0
import cv2
import utils
import matplotlib.pyplot as plt
import numpy as np

#script mainly use for drawing the demo picture

cal_imgs = utils.get_images_by_dir('camera_cal')
object_points, img_points = utils.calibrate(cal_imgs, grid=(9, 6))

test_imgs = utils.get_images_by_dir('test_images1')
#test_imgs = utils.get_images_by_dir('new_test')

undistorted = []
for img in test_imgs:
    img = utils.cal_undistort(img, object_points, img_points)
    undistorted.append(img)

trans_on_test = []
for img in undistorted:
    src = np.float32([[(203, 720), (585, 460), (695, 460), (1127, 720)]])
    dst = np.float32([[(320, 720), (320, 0), (960, 0), (960, 720)]])
    M = cv2.getPerspectiveTransform(src, dst)
    trans = cv2.warpPerspective(img,
                                M,
                                img.shape[1::-1],
                                flags=cv2.INTER_LINEAR)
    trans_on_test.append(trans)

thresh = []
binary_wrapeds = []