def getFeatureExtractors(self): hueHistogramFeatureExtractor = HueHistogramFeatureExtractor(10) edgeHistogramFeatureExtractor = EdgeHistogramFeatureExtractor(10) haarLikeFeatureExtractor = HaarLikeFeatureExtractor( fname='/Users/burton/Downloads/SimpleCV/SimpleCV/Features/haar.txt' ) return [ hueHistogramFeatureExtractor, edgeHistogramFeatureExtractor, haarLikeFeatureExtractor ]
def createExtractor(self, extractorName, trainPaths=[]): if (extractorName == 'hue'): extractor = HueHistogramFeatureExtractor(10) elif (extractorName == 'edge'): extractor = EdgeHistogramFeatureExtractor(10) elif (extractorName == 'haar'): extractor = HaarLikeFeatureExtractor(fname='haar.txt') elif (extractorName == 'bof'): extractor = BOFFeatureExtractor() extractor.generate(trainPaths, imgs_per_dir=40) # need to build the vocabuary (feature words) for bag of feature # extractor.generate(trainPaths, imgs_per_dir=40) return extractor
from sklearn.ensemble import AdaBoostClassifier from sklearn import cross_validation from SimpleCV import Image from SimpleCV import HueHistogramFeatureExtractor from SimpleCV import HaarLikeFeatureExtractor from SimpleCV import EdgeHistogramFeatureExtractor import numpy as np from glob import glob import pickle # model to extract feature hhfe = HueHistogramFeatureExtractor(10) ehfe = EdgeHistogramFeatureExtractor(10) haarfe = HaarLikeFeatureExtractor('haar.txt') # Give path of the training folder images = glob('./fruits/*') # Extract features and target labels for training def get_feature_labels(): features = list() labels = list() for im in images: try: img = Image(im) labels.append(im[:-2]) features.append( np.concatenate([
from glob import glob from SimpleCV import Image from SimpleCV import HueHistogramFeatureExtractor from SimpleCV import HaarLikeFeatureExtractor from SimpleCV import EdgeHistogramFeatureExtractor from matplotlib import pyplot as plt import os from Services.MainServices import make_histogram dataDir = os.path.dirname(os.path.abspath(__file__)) haar_file = os.path.join(dataDir, "../data/haar.txt") haarfe = HaarLikeFeatureExtractor(fname=haar_file) hhfe = HueHistogramFeatureExtractor(10) ehfe = EdgeHistogramFeatureExtractor(10) classifier = pickle.load( open(os.path.join(dataDir, "../data/classifier.pkl"), 'rb')) labels = pickle.load(open(os.path.join(dataDir, "../data/featLabel.pkl"), 'rb')) def predictor(): for img in glob('/home/linuxsagar/tempTest/*'): #List to hold the feature of new Image _new_features = []