Ejemplo n.º 1
0
def main():
    test_img_files = glob.glob("test_images/*.jpg")
    test_images = [read_image_as_rgb(f) for f in test_img_files]
    cameraCalibrator = CameraCalibrator()
    cameraCalibrator.restore('models/camera_calibration_model')
    pipeline = LaneDetectionPipeline(cameraCalibrator)

    img = test_images[0]
    undistorted = pipeline.get_birds_eye_binary(img)
    bet = BirdsEyeViewTransform()
    birds_eye_undistorted = bet.get_birds_eye_view(undistorted)
    crop = trapezoidal_crop(undistorted)
    birds_eye_crop = bet.get_birds_eye_view(crop)

    # fig, ax = plt.subplots(2, 2)
    # ax[0][0].imshow(undistorted, cmap='gray')
    # ax[0][0].set_title("hls and gradient transform")
    # ax[0][0].axis("off")
    # ax[0][1].imshow(birds_eye_undistorted, cmap='gray')
    # ax[0][1].set_title("birds eye")
    # ax[0][1].axis("off")

    # ax[1][0].imshow(crop, cmap='gray')
    # ax[1][0].title("trapeziodal crop")
    # ax[1][0].axis("off")
    # ax[1][1].imshow(birds_eye_crop, cmap='gray')
    # ax[1][1].title("birds eye crop")
    # ax[1][1].axis("off")

    histogram = np.sum(birds_eye_crop, axis=0)
    plt.plot(histogram)
    plt.show()
Ejemplo n.º 2
0
 def __init__(self):
     self.width = 1280
     self.height = 720
     self.left_lines = Line()
     self.right_lines = Line()
     self.s_magnitude_thresh = (175, 255)
     self.sobel_kernel = 7
     self.m_thresh = (14, 255)
     self.d_thresh = (0.0, 0.73)
     self.camera_calibrator = CameraCalibrator()
Ejemplo n.º 3
0
from camera_calibration import CameraCalibrator
from image_utils import *
from lane_detection import LaneDetectionPipeline
from lane_finding_histogram import *
from lanes import *
from glob import glob

cameraCalibrator = CameraCalibrator()
cameraCalibrator.restore('models/camera_calibration_model')
pipeline = LaneDetectionPipeline(cameraCalibrator)

test_images_dir = "test_images"
output_images_dir = "output_images"
input_file_paths = glob(test_images_dir + "/*.jpg")
for input_file_path in input_file_paths:
    output_file_path = input_file_path.replace(test_images_dir, output_images_dir)
    img = read_image_as_rgb(input_file_path)
    out_img = pipeline.process(img)
    out_img = cv2.cvtColor(out_img, cv2.COLOR_RGB2BGR)
    cv2.imwrite(output_file_path, out_img)
    pipeline.reset()

from moviepy.editor import VideoFileClip
test_videos_dir = "test_videos"
output_videos_dir = "output_videos"
video_file_paths = glob(test_videos_dir + "/*.mp4")
for video_file_path in video_file_paths:
    output_file_path = video_file_path.replace(test_videos_dir, output_videos_dir)
    clip = VideoFileClip(video_file_path)
    clip_output = clip.fl_image(pipeline.process)
    clip_output.write_videofile(output_file_path, audio=False)