本文整理汇总了C++中ImageLoader::LoadImages方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageLoader::LoadImages方法的具体用法?C++ ImageLoader::LoadImages怎么用?C++ ImageLoader::LoadImages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageLoader
的用法示例。
在下文中一共展示了ImageLoader::LoadImages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
//std::string path("D:/GitHub/Image-Understanding-Classification/Image-Understanding02/101_ObjectCategories");
std::string path("../101_ObjectCategories");
ImageLoader LoadImages = ImageLoader(path);
FeatureExtractor GetFeatures;
DecisionMaker GetClassification;
std::vector<cv::Mat> trainingImages;
std::vector<int> trainingLabels;
std::vector<cv::Mat> testImages;
std::vector<int> testLabels;
std::vector<std::vector< cv::Mat >> FeatureVectorsTraining;
cv::Mat ReshapedFeatureVectorsTraining;
cv::Mat ReducedFeatureVectorsTraining;
std::vector<std::vector< cv::Mat >> FeatureVectorsTest;
cv::Mat ReshapedFeatureVectorsTest;
cv::Mat ReducedFeatureVectorsTest;
std::vector<int> ResultsTest;
std::vector<int> ResultsTraining;
std::vector<std::string> classNames;
int NumberOfSamples;
int NumberOfClasses;
std::vector<std::string> folders;
folders.push_back("accordion");
//folders.push_back("airplanes");
folders.push_back("anchor");
folders.push_back("ant");
folders.push_back("barrel");
folders.push_back("bass");
folders.push_back("beaver");
folders.push_back("binocular");
folders.push_back("bonsai");
for (int i = 0; i < 10; ++i)
{
//LoadImages.LoadImagesFromSubfolders(folders);
LoadImages.LoadImages();
LoadImages.getTrainingData(trainingImages, trainingLabels);
LoadImages.getTestData(testImages, testLabels);
FeatureVectorsTraining.clear();
FeatureVectorsTraining.resize(trainingImages.size());
GetFeatures.computeHOGFeatures(trainingImages, FeatureVectorsTraining);
//GetFeatures.computeColorFeatures(trainingImages, FeatureVectorsTraining);
GetClassification.ReshapeFeatures(FeatureVectorsTraining, ReshapedFeatureVectorsTraining);
//GetClassification.constructPCA(ReshapedFeatureVectorsTraining);
//GetClassification.reduceFeaturesPCA(ReshapedFeatureVectorsTraining, ReducedFeatureVectorsTraining);
//GetClassification.TrainRandomTrees(ReshapedFeatureVectorsTraining, trainingLabels);
GetClassification.TrainSVM(ReshapedFeatureVectorsTraining, trainingLabels);
std::cout << "Training done." << std::endl;
//GetClassification.PredictRandomTrees(ReshapedFeatureVectorsTraining, ResultsTraining);
GetClassification.PredictSVM(ReshapedFeatureVectorsTraining, ResultsTraining);
FeatureVectorsTest.clear();
FeatureVectorsTest.resize(testImages.size());
GetFeatures.computeHOGFeatures(testImages, FeatureVectorsTest);
//GetFeatures.computeColorFeatures(testImages, FeatureVectorsTest);
GetClassification.ReshapeFeatures(FeatureVectorsTest, ReshapedFeatureVectorsTest);
//GetClassification.reduceFeaturesPCA(ReshapedFeatureVectorsTest, ReducedFeatureVectorsTest);
//GetClassification.PredictRandomTrees(ReshapedFeatureVectorsTest, ResultsTest);
GetClassification.PredictSVM(ReshapedFeatureVectorsTest, ResultsTest);
LoadImages.getClassNames(classNames);
NumberOfClasses = classNames.size();
LoadImages.getSampleSize(NumberOfSamples);
EvaluationUnit GetTrainingEvaluation(trainingLabels, NumberOfClasses, NumberOfSamples);
double TrainingPercent = GetTrainingEvaluation.EvaluateResultSimple(ResultsTraining);
std::cout << " Training Data Simple Percentage: " + std::to_string(TrainingPercent) << std::endl;
std::vector<double> classPercentageTraining;
std::vector<std::vector<int>> TrainingStatistics;
GetTrainingEvaluation.EvaluateResultComplex(ResultsTraining, classPercentageTraining, TrainingStatistics);
//for (int i = 0; i < classPercentageTraining.size(); i++)
//{
// std::cout << " " + classNames[i] + ": " + std::to_string(classPercentageTraining[i]) << std::endl;
//}
EvaluationUnit GetTestEvaluation(testLabels, NumberOfClasses, NumberOfSamples);
double TestPercent = GetTestEvaluation.EvaluateResultSimple(ResultsTest);
std::cout << " Test Data Simple Percentage: " + std::to_string(TestPercent) << std::endl;
/*std::vector<double> classPercentageTest;
std::vector<std::vector<int>> TestStatistics;
GetTestEvaluation.EvaluateResultComplex(ResultsTest, classPercentageTest, TestStatistics);
//.........这里部分代码省略.........