def update_gui(force_slide=False):
    global index
    original = mpimg.imread(images[index])
    undisorted, thresholded, transformed, detected_lines, projected, left_curverad, right_curverad, position_of_the_car = process_image(
        original,
        sobel_thresh_min=sobel_thresh_min,
        sobel_thresh_max=sobel_thresh_max,
        s_thresh_min=s_thresh_min,
        s_thresh_max=s_thresh_max,
        force_sliding=force_slide)

    original = Image.fromarray(resize_image(original))
    undisorted = Image.fromarray(resize_image(undisorted))
    thresholded = Image.fromarray(resize_image(thresholded))
    transformed = Image.fromarray(resize_image(transformed))
    detected_lines = Image.fromarray(resize_image(detected_lines))
    projected = Image.fromarray(resize_image(projected))

    originalPhotoImage = PhotoImage(original)
    undistortedPhotoImage = PhotoImage(undisorted)
    binaryPhotoImage = PhotoImage(thresholded)
    birdViewPhotoImage = PhotoImage(transformed)
    detectedLinesPhotoImage = PhotoImage(detected_lines)
    projectedPhotoImage = PhotoImage(projected)

    window.originalPhotoImage.configure(image=originalPhotoImage)
    window.originalPhotoImage.image = originalPhotoImage

    window.undistortedPhotoImage.configure(image=undistortedPhotoImage)
    window.undistortedPhotoImage.image = undistortedPhotoImage

    window.binaryPhotoImage.configure(image=binaryPhotoImage)
    window.binaryPhotoImage.image = binaryPhotoImage

    window.birdViewPhotoImage.configure(image=birdViewPhotoImage)
    window.birdViewPhotoImage.image = birdViewPhotoImage

    window.detectedLinesPhotoImage.configure(image=detectedLinesPhotoImage)
    window.detectedLinesPhotoImage.image = detectedLinesPhotoImage

    window.projectedPhotoImage.configure(image=projectedPhotoImage)
    window.projectedPhotoImage.image = projectedPhotoImage
Exemplo n.º 2
0
def process_video(video):
    return pipeline.process_image(video, False)
Exemplo n.º 3
0
from moviepy.editor import VideoFileClip

import train
import pipeline

from conts import *

if "__main__" == __name__:

    _train = False
    _test = False
    _video = True

    if _train:
        svc, X_scaler = train.run(params, max_sample_size=6000, save=True)

    if _test:
        for fname in [
                os.path.join(TEST_IMAGES_DIR, f)
                for f in os.listdir(TEST_IMAGES_DIR)
        ]:
            if "" in fname:
                img = plt.imread(fname)
                draw_img = pipeline.process_image(img, fname=fname, save=True)

    if _video:
        white_output = 'project_video_out_v2.mp4'
        clip1 = VideoFileClip("project_video.mp4")
        white_clip = clip1.fl_image(pipeline.process_image)
        white_clip.write_videofile(white_output, audio=False)
import cv2
import glob
from os.path import basename, splitext
from pipeline import process_image

TEST_IMG_DIR = './test_images/'
OUTPUT_IMG_DIR = './output_images/'
images = glob.glob(TEST_IMG_DIR + 'test*.jpg')

for idx, fname in enumerate(images):
    img = cv2.imread(fname)
    result, warpage, warped, preprocessImage, undistorted = process_image(
        img, debug=True)
    base_name = basename(fname)

    write_name = OUTPUT_IMG_DIR + splitext(base_name)[0] + '_undistorted.jpg'
    cv2.imwrite(write_name, undistorted)

    write_name = OUTPUT_IMG_DIR + splitext(base_name)[0] + '_binary.jpg'
    cv2.imwrite(write_name, preprocessImage)

    write_name = OUTPUT_IMG_DIR + splitext(base_name)[0] + '_warped.jpg'
    cv2.imwrite(write_name, warped)

    write_name = OUTPUT_IMG_DIR + splitext(base_name)[0] + '_warpape.jpg'
    cv2.imwrite(write_name, warpage)

    write_name = OUTPUT_IMG_DIR + splitext(base_name)[0] + '_result.jpg'
    cv2.imwrite(write_name, result)
Exemplo n.º 5
0
import os
import cv2
from moviepy.editor import VideoFileClip
from pipeline import process_image
from calibration import calibrate

#challenge_output = 'challenge_out.mp4'
#clip = VideoFileClip('challenge_video.mp4').subclip(0,5)
#challenge_clip = clip.fl_image(process_image)
#challenge_clip.write_videofile(challenge_output, audio=False)

cal_images_dir = './camera_cal/calibration*.jpg'
ret, mtx, dist, rvecs, tvecs = calibrate(cal_images_dir)

for img_name in os.listdir("test_images/"):
    print(img_name)
    img = cv2.imread("test_images/" + img_name)
    out = process_image(img, mtx, dist)
    cv2.imwrite(img_name[:-4] + "_out.jpg", out)