78 lines
2.4 KiB
C++
78 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <iostream>
|
|
#include <iomanip>
|
|
#include <bitset>
|
|
#include <climits>
|
|
#include <set>
|
|
#include <thread>
|
|
#include <mutex>
|
|
|
|
#include <boost/filesystem.hpp>
|
|
#include <boost/system/error_code.hpp>
|
|
#include <boost/filesystem/fstream.hpp>
|
|
#include <boost/archive/binary_oarchive.hpp>
|
|
#include <boost/archive/binary_iarchive.hpp>
|
|
#include <boost/serialization/map.hpp>
|
|
#include <boost/serialization/bitset.hpp>
|
|
#include <boost/serialization/string.hpp>
|
|
|
|
#include <chrono> //Debug, for measuring execution times
|
|
|
|
#include <Magick++.h>
|
|
#include <string>
|
|
#include "Descriptor.h"
|
|
#include "Mutation.h"
|
|
|
|
using namespace std;
|
|
using namespace chrono;
|
|
using namespace Magick;
|
|
|
|
//ENUM_STRING(descriptorss, (totalColors)(averageColor)(numDescriptors))
|
|
|
|
namespace fs = boost::filesystem;
|
|
namespace ar = boost::archive;
|
|
|
|
//Manager class for descriptors.
|
|
//Contains functions to load, store, process
|
|
//all images, descriptors and mutations
|
|
class DescriptorManager {
|
|
public:
|
|
DescriptorManager();
|
|
DescriptorManager(const fs::path & image_path);
|
|
void LoadFeatures(string image_path, string image_name);
|
|
void LoadMutationFeatures(string image_path, string image_name, int mutation);
|
|
Image* GetMutated(Image* image, string image_name, int method);
|
|
void Init();
|
|
void CopyFeatures();
|
|
void CompareFeatures();
|
|
void SaveToDisk();
|
|
void LoadFromDisk();
|
|
void rankImages(string image_name, int method);
|
|
multiset<pair<uint64_t, string>> rankMutations(string image_name, int method);
|
|
void runExperiments();
|
|
void test(int method);
|
|
void generatePreviews(string imagename);
|
|
void outputMap(int a);
|
|
void outputMap();
|
|
void outputRank(string imagename, int method);
|
|
private:
|
|
fs::path img_path;
|
|
int numImages;
|
|
static const int numDescriptors = 8;
|
|
static const int numMutations = 8;
|
|
Descriptor* descriptor_types[numDescriptors];
|
|
Mutation* mutators[numMutations];
|
|
|
|
//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?
|
|
map<string, uint64_t> features[numDescriptors]; //array of maps that will hold the descriptors
|
|
map<string, uint64_t> mutatedFeatures[numDescriptors][numMutations];
|
|
vector<pair<string, uint64_t>> features_vector[numDescriptors];
|
|
vector<pair<string, uint64_t>> mutatedFeatures_vector[numDescriptors][numMutations];
|
|
vector<fs::path> images;
|
|
multiset<pair<uint64_t, string> > distances; //multiset that stores the distances
|
|
};
|
|
|