From d28128009bd6905a809e080c4c8927c0f99d1fc0 Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Sat, 20 Jul 2019 15:26:07 +0200 Subject: [PATCH] Quick wip --- DescriptorManager.cpp | 14 +++++++------- DescriptorManager.h | 4 +++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/DescriptorManager.cpp b/DescriptorManager.cpp index b55ffa4..18a1248 100644 --- a/DescriptorManager.cpp +++ b/DescriptorManager.cpp @@ -57,6 +57,7 @@ DescriptorManager::DescriptorManager(const fs::path & image_path) { //Returns a pointer to the image mutated by the given method. //Either gets it from disk, or calculates it directly. +//Deprecated? Image* DescriptorManager::GetMutated(Image* image, string image_name, int method) { return mutators[method]->getMutated(image); fs::path mutPath(img_path / mutators[method]->ToPath() / image_name); @@ -101,13 +102,13 @@ void DescriptorManager::LoadFeatures(string image_path, string image_name) { //Fills the mutatedFeatures array with all descriptors for the given mutation and image. void DescriptorManager::LoadMutationFeatures(string image_path, string image_name, int mutation) { + if (!current_image) current_image->read(image_path); + Image* image = mutators[mutation]->getMutated(current_image); for (int i = 0; i < numDescriptors; i++) { //First check if we already have this information from the loaded cache /*if (mutatedFeatures[i][mutation].count(image_name) > 0) { continue; }*/ - if (!current_image) current_image->read(image_path); - Image* image = GetMutated(current_image, image_name, i); fs::path featurePath("meta" / descriptor_types[i]->ToPath() / mutators[mutation]->ToPath() / image_name); uint64_t b1; @@ -124,8 +125,8 @@ void DescriptorManager::LoadMutationFeatures(string image_path, string image_nam } mutatedFeatures_vector[i][mutation].push_back(pair(image_name, b1)); mutatedFeatures[i][mutation][image_name] = b1; - delete image; } + delete image; } //Calculates all features, mutations and features of mutations. @@ -147,10 +148,9 @@ void DescriptorManager::Init() { //if (!itr->path().has_extension()) continue; //skip directories and such string image_name = (*itr).filename().generic_string(); string image_path = (*itr).string(); - { //Progress bar - filecount++; + if (show_progress) { cout << setw(60) << setfill('*') << "\r" << string(60, ' ') << flush; - cout << setfill('*') << setw(60) << right<< "\rProgress: " << filecount*100/numImages << "% - (" << filecount << "/" << numImages << "): " << image_name << flush; + cout << setfill('*') << setw(60) << right<< "\rProgress: " << ++filecount*100/numImages << "% - (" << filecount << "/" << numImages << "): " << image_name << flush; } //Store all base features in the features array LoadFeatures(image_path, image_name); @@ -195,7 +195,7 @@ void DescriptorManager::CompareFeatures() { //No need to check for mutated features, because they are always calculated and saved together } } - cout << "IMAGES: " << images.size() << endl; + cout << "Images left to check: " << images.size() << endl; } //Saves feature map to disk. diff --git a/DescriptorManager.h b/DescriptorManager.h index 2ffaf27..51c855d 100644 --- a/DescriptorManager.h +++ b/DescriptorManager.h @@ -46,6 +46,7 @@ public: void Init(); void CopyFeatures(); void CompareFeatures(); + void ConvertData(); void SaveToDisk(); void LoadFromDisk(); void rankImages(string image_name, int method); @@ -64,6 +65,7 @@ private: Descriptor* descriptor_types[numDescriptors]; Mutation* mutators[numMutations]; + static const bool show_progress = true; //mutex mu; //for threading and suchlikes Image* current_image = NULL; //for caching purposes //TODO: Are maps the best container for us? Logarithmic random access is bad, but otherwise it might be fine? @@ -71,7 +73,7 @@ private: map mutatedFeatures[numDescriptors][numMutations]; vector> features_vector[numDescriptors]; vector> mutatedFeatures_vector[numDescriptors][numMutations]; - vector images; + vector images; //List of image paths we still have to check. multiset > distances; //multiset that stores the distances };