示例#1
0
    def extract_img_features(self, img):
        img_for_hog = pp.convert_img_for_hog(img)
        hog = pp.extract_hog_features(img_for_hog)

        if config.USE_SPATIAL or config.USE_COLOR_HIST:
            other = pp.extract_other_features(img)
            return np.concatenate((hog, other))
        return hog
示例#2
0
    def test_hog_multi_channel(self):
        """
        Test getting a hog layer from a single channel image.
            :param self:
        """
        dummy = np.zeros((64, 64, 2))

        hog = pp.extract_hog_features(dummy)
        self.assertGreater(len(hog), 3000)
示例#3
0
    def test_hog_single_channel(self):
        """
        Test getting a hog layer from a single channel image.
            :param self:
        """
        dummy = np.zeros((64, 64, 1))

        hog = pp.extract_hog_features(dummy)
        # This number will depend on the number of blocks per cell.
        self.assertGreater(len(hog), 1000)
示例#4
0
 def process_image(self, img):
     '''Returns the set of feature vectors to classify from this subimage'''
     img_for_hog = pp.convert_img_for_hog(img)
     hogs_list = pp.extract_hog_features(img_for_hog, feature_vector=False)
     hogs = np.array(hogs_list)
     shape = np.shape(hogs)
     window_width = shape[1]
     img_width_in_blocks = shape[2]
     start_col = 0
     while (img_width_in_blocks - start_col >= window_width):
         hogs_subsample = hogs[:, :,
                               start_col:start_col + window_width, :, :, ]
         self.feature_windows.append((start_col, hogs_subsample.ravel()))
         start_col += config.HOG_BLOCK_STEPS
    def test_sliding_windows(self):
        """
        Test extracting scaled regions from the image.
            :param self:
        """
        dummy = np.zeros((64, 64, 3), np.uint8)
        img_for_hog = pp.convert_img_for_hog(dummy)
        dummy_hog = pp.extract_hog_features(img_for_hog)
        dummy_shape = np.shape(dummy_hog)

        img = np.zeros((64, 1280, 3), np.uint8)
        # just test with one channel
        sliding_window = SlidingWindowHog()
        sliding_window.process_image(img)
        for start_col, sub_image in sliding_window.feature_windows:
            self.assertEqual(np.shape(sub_image), dummy_shape)