Use local distance array for each mutator check

This commit is contained in:
Mark Hoekveen
2018-08-19 17:28:56 +02:00
parent f4fc9a3500
commit 8a26e2bd24
+3 -2
View File
@@ -187,6 +187,7 @@ void DescriptorManager::similarImages(string image_name, int method, int numImag
//inserts the descriptors of the mutated versions of the image. //inserts the descriptors of the mutated versions of the image.
//Assumes the distances array is filled with the normal distances //Assumes the distances array is filled with the normal distances
void DescriptorManager::insertMutations(string image_name, int method) { void DescriptorManager::insertMutations(string image_name, int method) {
multiset<pair<unsigned long long, string> > local_distance(distances);
fs::ifstream ifs; fs::ifstream ifs;
bitset<64> target; bitset<64> target;
if (descriptors[method].count(image_name)) { //if image exists in map if (descriptors[method].count(image_name)) { //if image exists in map
@@ -207,7 +208,7 @@ void DescriptorManager::insertMutations(string image_name, int method) {
bitset<64> b1(n); bitset<64> b1(n);
unsigned long long d = descriptor_types[method]->distance(target, b1); unsigned long long d = descriptor_types[method]->distance(target, b1);
pair<unsigned long long, string> p(d, mutators[i]->ToString()); pair<unsigned long long, string> p(d, mutators[i]->ToString());
distances.insert(p); local_distance.insert(p);
} }
else { else {
cout << "data not set properly" << endl; cout << "data not set properly" << endl;
@@ -218,7 +219,7 @@ void DescriptorManager::insertMutations(string image_name, int method) {
cout << "..." << endl; cout << "..." << endl;
for (int i = 0; i < numMutations; i++) { for (int i = 0; i < numMutations; i++) {
int j = 0; int j = 0;
for (std::multiset<pair<unsigned long long, string>>::iterator it = distances.begin(); it != distances.end(); ++it) { for (std::multiset<pair<unsigned long long, string>>::iterator it = local_distance.begin(); it != local_distance.end(); ++it) {
//cout << "hey " << endl; //cout << "hey " << endl;
if (it->second == mutators[i]->ToString()) { if (it->second == mutators[i]->ToString()) {
cout << "Hit. On the " << j << "th position: " << endl; cout << "Hit. On the " << j << "th position: " << endl;