def get_frame_hog(ctrans_tosearch):
        ch1 = ctrans_tosearch[:, :, 0]
        ch2 = ctrans_tosearch[:, :, 1]
        ch3 = ctrans_tosearch[:, :, 2]

        # Compute individual channel HOG features for the entire image
        # Y channel
        hog1 = FeatureExtraction.get_hog_features(ch1, folder="../buffer/hog-features/")
        # Cr  channel
        hog2 = FeatureExtraction.get_hog_features(ch2)
        # Cb channel
        hog3 = FeatureExtraction.get_hog_features(ch3)
        return hog1, hog2, hog3
예제 #2
0
    def extract_single_img_features(img):
        """
        combine spatial bin, color histogram and gradient histogram features for a single image
        """
        # Create a list to append feature vectors to
        features = []

        # apply color conversion if other than 'RGB'
        feature_image = Helper.change_cspace(img)

        # get hog features for either specific channel or for all channels
        if config["hog_channel"] == 'ALL':
            hog_features = []
            channels = feature_image.shape[2]
            # get features for all 3 channels
            for channel in range(channels):
                hog_features.append(
                    FeatureExtraction.get_hog_features(feature_image[:, :,
                                                                     channel],
                                                       feature_vec=True))
                hog_features = np.ravel(hog_features)
        else:
            # get features for specific channel
            hog_features = FeatureExtraction.get_hog_features(
                feature_image[:, :, config["hog_channel"]], feature_vec=True)

        # Apply bin_spatial() to get spatial color features
        bin_features = FeatureExtraction.bin_spatial(feature_image,
                                                     config["spatial_size"])

        # Apply color_hist() to get color histogram features
        color_hist_features = FeatureExtraction.color_hist(
            feature_image, config["hist_bins"])

        # concatenate all 3 types of features
        feature = np.concatenate(
            (bin_features, color_hist_features, hog_features), axis=0)

        # Append the new feature vector to the features list
        features.append(feature)

        # Return list of feature vectors
        return features