Quick wip
This commit is contained in:
@@ -57,6 +57,7 @@ DescriptorManager::DescriptorManager(const fs::path & image_path) {
|
|||||||
|
|
||||||
//Returns a pointer to the image mutated by the given method.
|
//Returns a pointer to the image mutated by the given method.
|
||||||
//Either gets it from disk, or calculates it directly.
|
//Either gets it from disk, or calculates it directly.
|
||||||
|
//Deprecated?
|
||||||
Image* DescriptorManager::GetMutated(Image* image, string image_name, int method) {
|
Image* DescriptorManager::GetMutated(Image* image, string image_name, int method) {
|
||||||
return mutators[method]->getMutated(image);
|
return mutators[method]->getMutated(image);
|
||||||
fs::path mutPath(img_path / mutators[method]->ToPath() / image_name);
|
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.
|
//Fills the mutatedFeatures array with all descriptors for the given mutation and image.
|
||||||
void DescriptorManager::LoadMutationFeatures(string image_path, string image_name, int mutation) {
|
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++) {
|
for (int i = 0; i < numDescriptors; i++) {
|
||||||
//First check if we already have this information from the loaded cache
|
//First check if we already have this information from the loaded cache
|
||||||
/*if (mutatedFeatures[i][mutation].count(image_name) > 0) {
|
/*if (mutatedFeatures[i][mutation].count(image_name) > 0) {
|
||||||
continue;
|
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);
|
fs::path featurePath("meta" / descriptor_types[i]->ToPath() / mutators[mutation]->ToPath() / image_name);
|
||||||
|
|
||||||
uint64_t b1;
|
uint64_t b1;
|
||||||
@@ -124,8 +125,8 @@ void DescriptorManager::LoadMutationFeatures(string image_path, string image_nam
|
|||||||
}
|
}
|
||||||
mutatedFeatures_vector[i][mutation].push_back(pair<string, uint64_t>(image_name, b1));
|
mutatedFeatures_vector[i][mutation].push_back(pair<string, uint64_t>(image_name, b1));
|
||||||
mutatedFeatures[i][mutation][image_name] = b1;
|
mutatedFeatures[i][mutation][image_name] = b1;
|
||||||
delete image;
|
|
||||||
}
|
}
|
||||||
|
delete image;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculates all features, mutations and features of mutations.
|
//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
|
//if (!itr->path().has_extension()) continue; //skip directories and such
|
||||||
string image_name = (*itr).filename().generic_string();
|
string image_name = (*itr).filename().generic_string();
|
||||||
string image_path = (*itr).string();
|
string image_path = (*itr).string();
|
||||||
{ //Progress bar
|
if (show_progress) {
|
||||||
filecount++;
|
|
||||||
cout << setw(60) << setfill('*') << "\r" << string(60, ' ') << flush;
|
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
|
//Store all base features in the features array
|
||||||
LoadFeatures(image_path, image_name);
|
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
|
//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.
|
//Saves feature map to disk.
|
||||||
|
|||||||
+3
-1
@@ -46,6 +46,7 @@ public:
|
|||||||
void Init();
|
void Init();
|
||||||
void CopyFeatures();
|
void CopyFeatures();
|
||||||
void CompareFeatures();
|
void CompareFeatures();
|
||||||
|
void ConvertData();
|
||||||
void SaveToDisk();
|
void SaveToDisk();
|
||||||
void LoadFromDisk();
|
void LoadFromDisk();
|
||||||
void rankImages(string image_name, int method);
|
void rankImages(string image_name, int method);
|
||||||
@@ -64,6 +65,7 @@ private:
|
|||||||
Descriptor* descriptor_types[numDescriptors];
|
Descriptor* descriptor_types[numDescriptors];
|
||||||
Mutation* mutators[numMutations];
|
Mutation* mutators[numMutations];
|
||||||
|
|
||||||
|
static const bool show_progress = true;
|
||||||
//mutex mu; //for threading and suchlikes
|
//mutex mu; //for threading and suchlikes
|
||||||
Image* current_image = NULL; //for caching purposes
|
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?
|
//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<string, uint64_t> mutatedFeatures[numDescriptors][numMutations];
|
map<string, uint64_t> mutatedFeatures[numDescriptors][numMutations];
|
||||||
vector<pair<string, uint64_t>> features_vector[numDescriptors];
|
vector<pair<string, uint64_t>> features_vector[numDescriptors];
|
||||||
vector<pair<string, uint64_t>> mutatedFeatures_vector[numDescriptors][numMutations];
|
vector<pair<string, uint64_t>> mutatedFeatures_vector[numDescriptors][numMutations];
|
||||||
vector<fs::path> images;
|
vector<fs::path> images; //List of image paths we still have to check.
|
||||||
multiset<pair<uint64_t, string> > distances; //multiset that stores the distances
|
multiset<pair<uint64_t, string> > distances; //multiset that stores the distances
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user