コード例 #1
0
    def test_02_trainingse_nont(self):
        images = glob.glob('train_imgs/non-vehicles/*/*.png')
        (clf, scaler) = class_train.load()
        counter = 0
        for i in images:
            img = cnst.img_read_f(i)
            test_img = cv2.resize(img, (64, 64))
            features = single_img_features(test_img,
                                           color_space=cnst.color_space,
                                           spatial_size=cnst.spatial_size,
                                           hist_bins=cnst.hist_bins,
                                           orient=cnst.orient,
                                           pix_per_cell=cnst.pix_per_cell,
                                           cell_per_block=cnst.cell_per_block,
                                           hog_channel=cnst.hog_channel,
                                           spatial_feat=cnst.spatial_feat,
                                           hist_feat=cnst.hist_feat,
                                           hog_feat=cnst.hog_feat)

            test_features = scaler.transform(np.array(features).reshape(1, -1))
            #test_features = features
            prediction = clf.predict(test_features)
            if (prediction > 0.0):
                print("Prediction " + str(prediction) + " for " + i)
                counter = counter + 1

        print((len(images) - counter) / len(images))
コード例 #2
0
 def xtest_02_load(self):
     r = class_train.load()
     self.assertEqual(2, len(r))
     print(type(r[0]))
     print(type(r[1]))
     self.assertIs(type(r[0]), sklearn.svm.classes.LinearSVC)
     self.assertIs(type(r[1]), sklearn.preprocessing.data.StandardScaler)
コード例 #3
0
    def test_01_multi(self):
        (svc, X_scaler) = class_train.load()

        image = cnst.img_read_f('test_images/test6.jpg')

        draw_image = np.copy(image)

        (hw, di) = hot_windows.multi_hot_wins(image, draw_image, svc, X_scaler,
                                              cnst.sizes)
        print(hw)
        mpimg.imsave("unit_test/test6_multi.jpg", di)
コード例 #4
0
    def test_01_ev(self):
        (svc, X_scaler) = class_train.load()

        image = cnst.img_read_f('test_images/test6.jpg')
        for s in sizes:
            draw_image = np.copy(image)

            (hw, di) = hot_windows.hot_wins(image,
                                            draw_image,
                                            svc,
                                            X_scaler,
                                            xy_window=(s, s))
            print(hw)
            mpimg.imsave("unit_test/test6_" + str(s) + ".jpg", di)
コード例 #5
0
 def test_01_trainingset(self):
     images = glob.glob('train_imgs/vehicles/GTI_Far/image0000.png')
     (clf, scaler) = class_train.load()
     for i in images:
         img = cnst.img_read_f(i)
         test_img = cv2.resize(img, (64, 64))
         features = single_img_features(test_img,
                                        color_space=cnst.color_space,
                                        spatial_size=cnst.spatial_size,
                                        hist_bins=cnst.hist_bins,
                                        orient=cnst.orient,
                                        pix_per_cell=cnst.pix_per_cell,
                                        cell_per_block=cnst.cell_per_block,
                                        hog_channel=cnst.hog_channel,
                                        spatial_feat=cnst.spatial_feat,
                                        hist_feat=cnst.hist_feat,
                                        hog_feat=cnst.hog_feat)
         print(features.shape)
         print(features)
         print(len(features))
         test_features = scaler.transform(np.array(features).reshape(1, -1))
         #test_features = features
         prediction = clf.predict(test_features)
         print(str(prediction) + " : " + i)
コード例 #6
0
import numpy as np
import cv2
import class_train
import class_load
import hot_windows
import cv2
import matplotlib.image as mpimg
import numpy as np

import sys
import cnst

IMG_DIR = "project_video.mp4"
TEST_OUT = "unit_test"

(svc, X_scaler) = class_train.load()


class TestVideo(unittest.TestCase):
    def test_pipe(self):

        uut.process(IMG_DIR, TEST_OUT + "/L" + IMG_DIR, cb_ok)  #,subC=(12,18))


def cb(img):
    return img


def cb_ok(image):
    draw_image = np.copy(image)
    # image = image.astype(np.float32)/255