Example #1
0
 def __init__(self,
              basename,
              viewer=False,
              saver=False,
              binary_warper=None):
     self.frame_ctr = 0
     self.faulty_frames = 0
     self.cache_dict, self.parm_dict = ut.app_init(viewer=viewer,
                                                   saver=saver,
                                                   title="whatever")
     self.vwr = None
     if viewer:
         self.vwr = self.cache_dict['viewer']
         # we create them for video debug but even  then only turn them
         # on when needed
         self.vwr.bce_set_enabled(False)
     self.lane = Lane(self.cache_dict,
                      self.parm_dict,
                      vwr=self.vwr,
                      binary_warper=binary_warper)
     in_path = basename + ".mp4"
     print("processing " + in_path)
     out_path = ut.get_out_dir() + basename + ".mp4"
     video_in = VideoFileClip(in_path)
     rendered_video = video_in.fl_image(self.process_frame_bp)
     rendered_video.write_videofile(out_path, audio=False)
     print("average lane width = %f" %
           (self.lane.sum_lane_widths / self.frame_ctr))
     if self.faulty_frames:
         print(
             "\n\n Total Frames %d, failed to find lane boundaries in %d frames"
             % (self.frame_ctr, self.faulty_frames))
Example #2
0
def analyze_hist(hist):
    # see lesson 7.4
    width = hist.img_data.shape[0]
    midway = width // 2

    left_max_ix = np.argmax(hist.img_data[0:midway])
    right_max_ix = midway + np.argmax(hist.img_data[midway:width])
    print("histo maxen = %d, %d" % (left_max_ix, right_max_ix))


def doit(path="", cd=None, pd=None, vwr=None):
    vwr.flush()
    for path in ut.get_fnames("test_images/", "problem_binary_warped.jpg"):
        img = iu.imRead(path,
                        flags=cv2.IMREAD_GRAYSCALE,
                        reader='cv2',
                        vwr=None)
        ut.brk("wtf?")
        hist = iu.hist(img)
        ut.brk("plot the histogram")
        ut.brk("call get_LR_hist_max_ix()")
        iv._push(vwr, hist)
    vwr.show()


cache_dict, parm_dict = ut.app_init(viewer=True, saver=False, title="whatever")
vwr = cache_dict['viewer']
ut.brk("this unit test is broken")
doit(cd=cache_dict, pd=parm_dict, vwr=vwr)
Example #3
0
#!/usr/bin/env python3
#

import util as ut
import ImgViewer as iv
import cv2
import numpy as np
import ImgUtil as iu
import ImgViewer as iv
import LaneUtils as lu

# our object model
# Lanes:  contain LaneBoundary(s) and attributes common to both boundaries
# LaneBoundary(s): contain attributes for a particular lane bounday
# Windows: are used to calculate lane boundaries

#cd is cache_dict, pd is parm_dict
cd, pd = ut.app_init(viewer=True, saver=True, title="whatever")