Ejemplo n.º 1
0
            sys.exit(6)

    # set up diagnostic pipeline options if requested
    if valid:
        scrType = args.diag
        if (scrType & 3) > 0:
            debug = True
        if not args.notext:
            scrType = scrType | 4

        # initialization
        # load or perform camera calibrations
        camCal = CameraCal('camera_cal', 'camera_cal/calibrationdata.p')

        # initialize road manager and its managed pipeline components/modules
        roadMgr = RoadManager(camCal, debug=debug)

        # initialize diag manager and its managed diagnostics components
        if debug:
            diagMgr = DiagManager(roadMgr)
        else:
            diagMgr = None

        # Image only?
        if image is not None:
            print("image processing %s..." % (args.infilename))
            imageout = process_image(image)
            cv2.imwrite(args.outfilename,
                        cv2.cvtColor(imageout, cv2.COLOR_RGB2BGR))
            print("done image processing %s..." % (args.infilename))
Ejemplo n.º 2
0
            diagScreen, 'Road Horizon: %d    Vanishing Point: %d' %
            (imgFtr.roadhorizon, projMgr.lane_info[7][1]), (30, 180), font, 1,
            (255, 255, 255), 2)
    else:
        cv2.putText(diagScreen, 'Road Horizon: NOT FOUND!', (30, 180), font, 1,
                    (255, 255, 0), 2)
    cv2.putText(
        diagScreen, 'Road Gradient: %d   slope: %d' %
        (projMgr.curGradient, projMgr.curGradient - projMgr.gradient0),
        (30, 210), font, 1, (255, 255, 255), 2)
    return diagScreen


def process_diagnostic_image(image):
    global roadMgr
    # NOTE: The output you return should be a color image (3 channel) for processing video below
    # TODO: put your pipeline here,
    # you should return the final output (image with lines are drawn on lanes)
    result = diagnostic_process_image(image, roadMgr)
    return result


camCal = CameraCal('camera_cal', 'camera_cal/calibrationdata.p')
roadMgr = RoadManager(camCal, debug=True)

videoout = 'project_video_diagnostics_test_filter18.mp4'
clip1 = VideoFileClip("project_video.mp4")
video_clip = clip1.fl_image(
    process_diagnostic_image)  #NOTE: this function expects color images!!
video_clip.write_videofile(videoout, audio=False)
Ejemplo n.º 3
0
from p4lib.roadManager import RoadManager
from p4lib.diagManager import DiagManager
from moviepy.editor import VideoFileClip


def process_road_image(img, roadMgr):
    # Run the functions
    roadMgr.findLanes(img)
    roadMgr.drawLaneStats()
    return roadMgr.final


def process_image(image):
    global roadMgr
    global diagMgr
    # NOTE: The output you return should be a color image (3 channel) for processing video below
    # TODO: put your pipeline here,
    # you should return the final output (image with lines are drawn on lanes)
    result = process_road_image(image, roadMgr)
    return result


camCal = CameraCal('camera_cal', 'camera_cal/calibrationdata.p')
roadMgr = RoadManager(camCal)

videoout = 'project_video_diagnostics_test_filter28.mp4'
clip1 = VideoFileClip("project_video.mp4")
video_clip = clip1.fl_image(
    process_image)  #NOTE: this function expects color images!!
video_clip.write_videofile(videoout, audio=False)