Пример #1
0
def _config_camera_calibrator(show_plots):
    plot = get_plotter()
    calibrator = camera_calibration.CameraCalibration(plot)

    if os.path.exists(CAMERA_CALIBRATION_PICKLE_PATH):
        calibrator.from_pickle(CAMERA_CALIBRATION_PICKLE_PATH)

    return calibrator
Пример #2
0
def pickle_camera_calibration(path=None):
    if not path:
        path = CAMERA_CALIBRATION_PICKLE_PATH

    init_logging()
    plot = get_plotter(False)

    calibrator = camera_calibration.CameraCalibration(plot)
    calibrator.config()
    calibrator.to_pickle(path)
Пример #3
0
def test_calibrate_camera():
    init_logging()
    plot = get_plotter()

    calibrator = camera_calibration.CameraCalibration(plot)
    calibrator.config()

    PLOT.show_plots = True
    img = cv2.cvtColor(cv2.imread('test_images/straight_lines1.jpg'), cv2.COLOR_BGR2RGB)
    calibrator.undistort(img)
Пример #4
0
def vehicle_detect_single_image(img_path=None):
    if not img_path:
        img_path = 'test_images/test1.jpg'

    init_logging()

    clf = classifier.Classifier()
    clf.from_pickle(VEHICLE_DETECTION_CLASSIFIER_PATH)

    detect = detector.Detector(clf)

    img = image.load_img(img_path)

    calibrator = camera_calibration.CameraCalibration(get_plotter())
    calibrator.config()

    undisorted = calibrator.undistort(img)
    output = detect.identify_vehicles(undisorted)

    plotter.Plotter(True).plot_images(output)
Пример #5
0
def vehicle_detect_full_run(video_path=None):
    if not video_path:
        video_path = 'test_video.mp4'

    init_logging()

    clf = classifier.Classifier()
    clf.from_pickle(VEHICLE_DETECTION_CLASSIFIER_PATH)

    detect = detector.Detector(clf)

    calibrator = camera_calibration.CameraCalibration(get_plotter())

    log.debug(f'Processing video {video_path}')
    clip = VideoFileClip(video_path)
    updated = clip.fl_image(
        lambda img: _vehicle_detect_full_run_wrapper(img, detect, calibrator))

    split_path = video_path.split('.')
    new_file = "".join([split_path[0], '_output.', split_path[1]])
    updated.write_videofile(new_file, audio=False)