def morph(): mf = MorphologyFeatureExtractor() mf.setThresholdOperation(myBinaryFunc) a = np.array(mf.extract(watchman.imgbank[0])) if len(watchman.imgbank) > 1: b = np.array(mf.extract(watchman.imgbank[1])) else: b = np.array(mf.extract(watchman.imgbank[0])) AandB = np.sum(np.square(a-b)) return AandB
def morph(): mf = MorphologyFeatureExtractor() mf.setThresholdOperation(myBinaryFunc) a = np.array(mf.extract(watchman.imgbank[0])) if len(watchman.imgbank) > 1: b = np.array(mf.extract(watchman.imgbank[1])) else: b = np.array(mf.extract(watchman.imgbank[0])) AandB = np.sum(np.square(a - b)) return AandB
from SimpleCV import * from numpy import * from SimpleCV.Display import Display, pg from SimpleCV import MorphologyFeatureExtractor #we pass this methods as our threshold operation def thresholdOp(in_image): return in_image.binarize(thresh=70).invert().dilate(2) # extract only morphology morph_extractor = MorphologyFeatureExtractor() morph_extractor.setThresholdOperation(thresholdOp) extractors = [morph_extractor] #setup the paths to our data nuts_path = "./data/nuts/" bolts_path = "./data/bolts/" path = [nuts_path, bolts_path] classes = ['washer', 'bolt'] props = { 'KernelType': 'Linear', #default is a RBF Kernel 'SVMType': 'C', #default is C 'nu': None, # NU for SVM NU 'c': None, #C for SVM C - the slack variable 'degree': None, #degree for poly kernels - defaults to 3 'coef': None, #coef for Poly/Sigmoid defaults to 0 'gamma': None, #kernel param for poly/rbf/sigma - default is 1/#samples } # flag if we need to train the SVM