We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependencies:
sudo apt-get install ipython python-opencv python-scipy \ python-numpy python-pygame python-setuptools python-pip
Install:
sudo pip install svgwrite sudo pip install https://github.com/sightmachine/SimpleCV/zipball/develop sudo pip install orange # takes awhile
from SimpleCV import * import glob class Trainer(): def __init__(self,classes, trainPaths): self.classes = classes self.trainPaths = trainPaths def getExtractors(self): hhfe = HueHistogramFeatureExtractor(10) ehfe = EdgeHistogramFeatureExtractor(10) haarfe = HaarLikeFeatureExtractor(fname='haar.txt') return [hhfe,ehfe,haarfe] def getClassifiers(self,extractors): svm = SVMClassifier(extractors) tree = TreeClassifier(extractors) bayes = NaiveBayesClassifier(extractors) knn = KNNClassifier(extractors) return [svm,tree,bayes,knn] def train(self): self.classifiers = self.getClassifiers(self.getExtractors()) for classifier in self.classifiers: classifier.train(self.trainPaths,self.classes,verbose=False) def test(self,testPaths): for classifier in self.classifiers: print classifier.test(testPaths,self.classes,verbose=False) def visualizeResults(self,classifier,imgs): for img in imgs: className = classifier.classify(img) img.drawText(className,10,10,fontsize=60,color=Color.BLUE) imgs.show() classes = ['chicken','nochicken',] def main(): trainPaths = ['./'+c+'/train/' for c in classes ] testPaths = ['./'+c+'/test/' for c in classes ] trainer = Trainer(classes,trainPaths) trainer.train() tree = trainer.classifiers[1] imgs = ImageSet() for p in testPaths: imgs += ImageSet(p) random.shuffle(imgs) print "Result test" trainer.test(testPaths) print(trainer.visualizeResults(tree,imgs)) tree.save("tree.dat") classifierFile = 'tree.dat' classifier = TreeClassifier.load(classifierFile) for path in glob.glob("*/*/*jpg"): print(path,classifier.classify(Image(path))) main()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Install simplecv + orange
Dependencies:
Install:
Some test code:
The text was updated successfully, but these errors were encountered: