From e03fd68fd9083ba0bd22c677be9b8ac65e7fda0e Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Sun, 3 Mar 2019 11:21:40 +0100 Subject: [PATCH] Process results into files --- DescriptorManager.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/DescriptorManager.cpp b/DescriptorManager.cpp index b4bd79e..fe4cd21 100644 --- a/DescriptorManager.cpp +++ b/DescriptorManager.cpp @@ -196,11 +196,34 @@ multiset> DescriptorManager::rankMutations(stri //Needs to be called after Init(). //Takes all the calculated features and rankes void DescriptorManager::runExperiments() { + fs::ofstream ofs; for (int i = 0; i < numDescriptors; i++) { for (map>::iterator it = features[i].begin(); it != features[i].end(); ++it) { - cout << "=== " << descriptor_types[i]->ToString() << ": " << it->first << " ===" << endl; + //cout << "=== " << descriptor_types[i]->ToString() << ": " << it->first << " ===" << endl; rankImages(it->first, i); - rankMutations(it->first, i); + multiset> local_distance = rankMutations(it->first, i); + + //Now we can draw some conclusions from the received data: + //Put all results in some useful files in the results directory: + fs::path resultFolder("results" / descriptor_types[i]->ToPath()); + if (!fs::is_directory(resultFolder)) //TODO: Create all folders in Init() + fs::create_directory(resultFolder); + for (int i = 0; i < numMutations; i++) { + int j = 0; + fs::path resultPath(resultFolder / mutators[i]->ToPath()); + ofs.open(resultPath, ofstream::out | ofstream::app); + for (std::multiset>::iterator it = local_distance.begin(); it != local_distance.end(); ++it) { + if (it->second == mutators[i]->ToString()) { + double percentile = (j + 1) / (double)(numImages+numMutations); + + ofs << (int)(percentile*100) << endl; + //cout << "(" << it->first << ", " << it->second << ")" << endl; + } + j++; + } + ofs.close(); + } + } } }