summaryrefslogtreecommitdiff
path: root/macros/trainImageCategoryClassifier.sci
blob: 46ccce880de29cc5534189477d7587e566d2271a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function classifier = trainImageCategoryClassifier(imgSets, bag)
// This function is used to train an image classifier.
//
// Calling Sequence
// classifier = trainImageCategoryClassifier(imgSets, bag)
//
// Parameters
// classifier: Image category classifier
// imgSets: Input imageSet to train the classifier on
// bag: The bagOfFeatures of the imageSet provided
//
// Description
// This function trains an image category classifier which can be used to predict categories of images given to it as input using the predict() function.
//
// Examples
// imgSet = imageSet(directory,'recursive');
// [trainingSet testSet] = partition(imgSet,[0.8]);
// bag = bagOfFeatures(trainingSet);
// categoryClassifier = trainImageCategoryClassifier(trainingSet, bag);
//
// Authors
//  Rohit Suri
//  Umang Agrawal	
	bag_list = bagStructToList(bag);
	
	imgSets_list = imageSetToList(imgSets);
	temp = opencv_trainImageCategoryClassifier(imgSets_list, bag_list);
	
	classifier = struct("ClassifierLocation", temp(2), "BagofFeaturesLocation", temp(3), "Description", temp(4))
	
endfunction