def construct_feature(self, img, kmeans, centroids): keypoints = StarFeatureDetector().detect(img) keypoints, feature_vectors = compute_sift_features(img, keypoints) labels = kmeans.predict(feature_vectors) feature_vector = np.zeros(self.num_clusters) for i, item in enumerate(feature_vectors): feature_vector[labels[i]] += 1 feature_vector_img = np.reshape(feature_vector, ((1, feature_vector.shape[0]))) return self.normalize(feature_vector_img)
def extract_features(self, img): keypoints = StarFeatureDetector().detect(img) keypoints, feature_vectors = compute_sift_features(img, keypoints) return feature_vectors