Ejemplo n.º 1
0
def identify_line(execute):
    if execute:
        img = cv2.imread(utl.fn.test_img1_sxs_trans_nl)
        channel = img[:, :, 0]
        centroids = ll.find_window_centroids(channel)
        print(centroids)
        output = ll.draw_window_centroids(channel, centroids)
        print(output.shape)
        display.imshow(output)
Ejemplo n.º 2
0
def threshold(img, sbl_x_thres_min, sbl_x_thres_max, hls_s_thres_min,
              hls_s_thres_max):
    """
    Detects the edges by ORing the sobel x and hls s channel threshold detects
    """
    sxb = sobel_x_binary(img, sbl_x_thres_min, sbl_x_thres_max)
    hsb = hls_s_binary(img, hls_s_thres_min, hls_s_thres_max)
    cmb = combine_binary(sxb, hsb)
    display.imshow([sxb, hsb, cmb], cmap='gray', show=False)
    return cmb
def transform(execute):
    if execute:
        fn = utl.fn.test_img1_sxs
        img = cv2.imread(fn)
        pt = utl.perspective_transform()
        pt.tl = -60
        pt.tr = 60
        pt.br = 40
        display.imshow(pt.transform_l(img))
        print(pt.src)
        print(pt.dst)
def edge_detect(execute):
    if execute:
        img = cv2.imread(utl.fn.test_img1_undist)
        img_sx_b = ll.sobel_x_binary(img)
        display.imshow(img_sx_b, cmap='gray', show=True)
        img_hls_sb = ll.hls_s_binary(img)
        display.imshow(img_hls_sb, cmap='gray', show=True)
        img_sxb = ll.combine_binary(img_sx_b, img_hls_sb)
        display.imshow(img_sxb, cmap='gray', show=True)
        display.imshow([[img_sx_b,'gray'],])
        display.imshow(utl.bin22color(img_sx_b, img_hls_sb), show=True)
Ejemplo n.º 5
0
    def test(self):
        classes = ['center', 'skew', 'noise']
        testset = CellsDataset('test')
        testloader = torch.utils.data.DataLoader(testset,
                                                 batch_size=self.batch_size,
                                                 shuffle=False,
                                                 num_workers=2)

        dataiter = iter(testloader)
        images, labels = dataiter.next()

        images = images.float()
        labels = labels.long()

        class_correct = list(0. for i in range(3))
        class_total = list(0. for i in range(3))
        correct = 0
        total = 0

        bad_images = []
        bad_labels = []

        with torch.no_grad():
            for data in testloader:
                images, labels = data
                images = images.float()
                labels = labels.long()
                outputs = self.net(images)

                _, predicted = torch.max(outputs.data, 1)

                c = (predicted == labels).squeeze()
                for i in range(len(images)):
                    label = labels[i]
                    class_correct[label] += c[i].item()
                    class_total[label] += 1

                    if c[i].item() == 0:
                        bad_labels += [predicted[i]]
                        bad_images += [images[i]]

                total += labels.size(0)
                correct += (predicted == labels).sum().item()

        print('test accuracy: %d/%d = %.4f' %
              (correct, total, correct / total))
        for i in range(3):
            print('class accuracy of %6s: %.3f' %
                  (classes[i], (class_correct[i]) / (class_total[i] + 1e-100)))

        if self.display:
            display.imshow(torchvision.utils.make_grid(bad_images),
                           [classes[label] for label in bad_labels])
Ejemplo n.º 6
0
    def displaydata(self):
        classes = ['center', 'skew', 'noise']
        trainset = CellsDataset('training')
        trainloader = torch.utils.data.DataLoader(trainset,
                                                  batch_size=self.batch_size,
                                                  shuffle=True,
                                                  num_workers=2)

        dataiter = iter(trainloader)
        images, labels = dataiter.next()
        print(' '.join('%5s' % classes[labels[j]]
                       for j in range(self.batch_size)))
        display.imshow(torchvision.utils.make_grid(images),
                       [classes[labels[j]] for j in range(self.batch_size)])
def main():

    mtx, dist = utl.distort_load(utl.fn.pickle_file)
    src, dst = ll.perspective_transform_values()
    M = ll.perspective_transform_map(src, dst)
    Minv = ll.perspective_transform_map(dst, src)
    fl = ll.find_lane_lines(mtx, dist, src, dst, M, Minv, True)
    for imgfn in utl.fn.testset3:
        print(imgfn)
        img = cv2.imread(imgfn)
        display.imshow(img)
        binary_warped = fl.fll(img)
        #      binary_warped = cv2.imread(utl.fn.test_img1_sxs_trans_nl)[:,:,0]/255
        sub(binary_warped)
        #break

    print('Ended')
def lane_line(execute):
    if execute:
        mtx, dist = utl.distort_load(utl.fn.pickle_file)
        src, dst = ll.perspective_transform_values()
        M = ll.perspective_transform_map(src, dst)
        Minv = ll.perspective_transform_map(dst,src)
        
        combinations = config.get_combinations(1)
        log = utl.log("../../project/img.log")

        for combo in combinations:
            sbl_x_thres_min, sbl_x_thres_max, hls_s_thres_min, hls_s_thres_max = combo  
            fl = ll.find_lane_lines(mtx, dist, src, dst, M, Minv,
                                    sbl_x_thres_min, sbl_x_thres_max, 
                                    hls_s_thres_min, hls_s_thres_max, log)
            for imgfn in utl.fn.testset2:
                img = cv2.imread(imgfn)
                print(imgfn, sbl_x_thres_min, sbl_x_thres_max, 
                      hls_s_thres_min, hls_s_thres_max)
                #display.imshow(img)            
                display.imshow(fl.fll(img))
Ejemplo n.º 9
0
 def show_rgb(self):
     '''Displays RGB visualization of HSI cube'''
     from display import imshow
     idx = np.array([15, 33, 54], dtype=np.uint8)  #blue, green, red
     imshow(self.data[:, :, idx])
Ejemplo n.º 10
0
 def show_rgb(self):
     """Displays RGB visualization of HSI cube"""
     from display import imshow
     idx = np.array([13,19,27], dtype=np.uint8)
     imshow(self.data[:,:,idx])
Ejemplo n.º 11
0
def undistort1(fn, mtx, dist, execute):
    if execute:
        img_dist = cv2.imread(fn)
        img_undist = ll.undistort(img_dist, mtx, dist)
        display.imshow([img_dist, img_undist])