diff --git a/Dockerfile b/Dockerfile index 822bbc1..cbb2760 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,7 +53,9 @@ COPY readers_count /shared/readers_count COPY can_read /shared/can_read RUN touch /shared/blockhash RUN touch /shared/dhash -RUN touch /shared/cannydhash +RUN touch /shared/gaussdhash +RUN touch /shared/gauss2dhash +RUN touch /shared/gaussblockhash RUN chmod -R a+w /shared COPY lighttpd-imagesearch.conf /etc/lighttpd/conf-available/30-imagesearch.conf diff --git a/Makefile b/Makefile index 9fd7d74..e96e207 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ all: run run: build - docker rm imagesearch.mzk.cz + -docker rm imagesearch.mzk.cz docker run -i -t -p 8080:80 -v /var/imagesearch:/data --name imagesearch.mzk.cz imagesearch.mzk.cz build: diff --git a/README.md b/README.md index ca35702..871afed 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,9 @@ Uploading is done via POST request, which has following structure: "image_base64": "...", "blockHash": "...", "dHash": "...", - "cannyDHash": "..." + "gaussDHash": "...", + "gauss2DHash": "...", + "gaussBlockHash": "..." }, { "id": "example2", @@ -216,7 +218,9 @@ Uploading is done via POST request, which has following structure: "image_base64": "...", "blockHash": "...", "dHash": "...", - "cannyDHash": "..." + "gaussDHash": "...", + "gauss2DHash": "...", + "gaussBlockHash": "..." } ] ``` @@ -226,7 +230,7 @@ Uploading is done via POST request, which has following structure: * Image data can be send by several ways: - image_url: You can specify url, where the image can be downloaded. - image_base64: You can send image data in base64 format. - - blockHash, dHash, cannyDHash: You can compute hashes by yourselves and send their hexadecimal representations. + - blockHash, dHash, gaussDHash, gauss2DHash, gaussBlockHash: You can compute hashes by yourselves and send their hexadecimal representations. * From listed methods how to upload image data you should choose only one. If you use several methods at once the behaviour is not defined. @@ -329,7 +333,7 @@ You can seach similar images using both GET or POST requests. ##### GET ``` -/v1/searchSimilar?cannyDHash=0f13332927217ada&count=10 +/v1/searchSimilar?gaussDHash=0f13332927217ada&count=10 ``` * By parameter count you can specify how many the most similar images will be returned. diff --git a/fcgi/CannyDHashAlgorithm.h b/fcgi/CannyDHashAlgorithm.h deleted file mode 100644 index 798cd2c..0000000 --- a/fcgi/CannyDHashAlgorithm.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * File: CannyDHash.h - * Author: dudae - * - * Created on Štvrtok, 2015, júla 9, 10:12 - */ - -#ifndef CANNYDHASH_H -#define CANNYDHASH_H - -#include "HashAlgorithm.h" -#include "HashType.h" - - -class CannyDHashAlgorithm : public HashAlgorithm { -public: - virtual ~CannyDHashAlgorithm(); - - virtual std::vector compute(const std::vector* data); - virtual HashType getType(); - virtual size_t getHashSize(); -private: - -}; - -#endif /* CANNYDHASH_H */ - diff --git a/fcgi/Controller.cpp b/fcgi/Controller.cpp index 859c1fc..26d776f 100644 --- a/fcgi/Controller.cpp +++ b/fcgi/Controller.cpp @@ -58,8 +58,14 @@ void Controller::ingestRequest(const Poco::Dynamic::Var& request) { if (json->has("dHash")) { record.getHashes()[DHash] = str2bin(json->getValue("dHash")); } - if (json->has("cannyDHash")) { - record.getHashes()[CannyDHash] = str2bin(json->getValue("cannyDHash")); + if (json->has("gaussDHash")) { + record.getHashes()[GaussDHash] = str2bin(json->getValue("gaussDHash")); + } + if (json->has("gauss2DHash")) { + record.getHashes()[Gauss2DHash] = str2bin(json->getValue("gauss2DHash")); + } + if (json->has("gaussBlockHash")) { + record.getHashes()[GaussBlockHash] = str2bin(json->getValue("gaussBlockHash")); } if (json->has("image_base64")) { image_data = Image::fromBase64(json->getValue("image_base64")); @@ -106,8 +112,14 @@ void Controller::searchIdenticalRequest(std::map& para if (params.count("dHash")) { record.getHashes()[DHash] = str2bin(params["dHash"]); } - if (params.count("cannyDHash")) { - record.getHashes()[CannyDHash] = str2bin(params["cannyDHash"]); + if (params.count("gaussDHash")) { + record.getHashes()[GaussDHash] = str2bin(params["gaussDHash"]); + } + if (params.count("gauss2DHash")) { + record.getHashes()[Gauss2DHash] = str2bin(params["gauss2DHash"]); + } + if (params.count("gaussBlockHash")) { + record.getHashes()[GaussBlockHash] = str2bin(params["gaussBlockHash"]); } if (params.count("url")) { image_data = Image::fromUrl(params["url"]); @@ -142,8 +154,14 @@ void Controller::searchSimilarRequest(std::map& params if (params.count("dHash")) { record.getHashes()[DHash] = str2bin(params["dHash"]); } - if (params.count("cannyDHash")) { - record.getHashes()[CannyDHash] = str2bin(params["cannyDHash"]); + if (params.count("gaussDHash")) { + record.getHashes()[GaussDHash] = str2bin(params["gaussDHash"]); + } + if (params.count("gauss2DHash")) { + record.getHashes()[Gauss2DHash] = str2bin(params["gauss2DHash"]); + } + if (params.count("gaussBlockHash")) { + record.getHashes()[GaussBlockHash] = str2bin(params["gaussBlockHash"]); } if (params.count("url")) { image_data = Image::fromUrl(params["url"]); diff --git a/fcgi/Gauss2DHashAlgorithm.cpp b/fcgi/Gauss2DHashAlgorithm.cpp new file mode 100644 index 0000000..d4080a6 --- /dev/null +++ b/fcgi/Gauss2DHashAlgorithm.cpp @@ -0,0 +1,65 @@ +#include "Gauss2DHashAlgorithm.h" + +#include +#include +#include + +#include +#include + +#include "DHashException.h" + +using namespace std; + +Gauss2DHashAlgorithm::~Gauss2DHashAlgorithm() { +} + +std::vector Gauss2DHashAlgorithm::compute(const std::vector* data) { + cv::Mat image = cv::imdecode(*data, CV_LOAD_IMAGE_GRAYSCALE); + cv::resize(image, image, getKeepRatioSize(image, 512), 0, 0, cv::INTER_LANCZOS4); + + cv::Mat g1, g2; + cv::GaussianBlur(image, g1, cv::Size(3, 3), 0); + cv::GaussianBlur(image, g2, cv::Size(9, 9), 60); + image = g1 - g2; + + std::vector gaussdata; + cv::imencode(".png", image, gaussdata); + + dhash_err* err = dhash_new_err(); + uint64_t hash = dhash_compute_blob(&gaussdata[0], gaussdata.size(), err); + + if (err->err_type != OK) { + ostringstream os; + os << "Error occured during compute dhash: " << err->description; + dhash_free_err(err); + throw DHashException(os.str()); + } + dhash_free_err(err); + + vector result; + result.push_back(hash); + return result; +} + +HashType Gauss2DHashAlgorithm::getType() { + return Gauss2DHash; +} + +size_t Gauss2DHashAlgorithm::getHashSize() { + return 8; +} + +cv::Size Gauss2DHashAlgorithm::getKeepRatioSize(const cv::Mat& image, int size) { + int width = image.cols; + int height = image.rows; + + double ratio; + + if (width < height) { + ratio = size * 1.0 / width; + } else { + ratio = size * 1.0 / height; + } + return cv::Size((int) round(width*ratio), (int) round(height*ratio)); +} \ No newline at end of file diff --git a/fcgi/Gauss2DHashAlgorithm.h b/fcgi/Gauss2DHashAlgorithm.h new file mode 100644 index 0000000..0242e0c --- /dev/null +++ b/fcgi/Gauss2DHashAlgorithm.h @@ -0,0 +1,22 @@ +#ifndef GAUSS2DHASH_H +#define GAUSS2DHASH_H + +#include + +#include "HashAlgorithm.h" +#include "HashType.h" + + +class Gauss2DHashAlgorithm : public HashAlgorithm { +public: + virtual ~Gauss2DHashAlgorithm(); + + virtual std::vector compute(const std::vector* data); + virtual HashType getType(); + virtual size_t getHashSize(); +private: + virtual cv::Size getKeepRatioSize(const cv::Mat& image, int size); +}; + +#endif /* GAUSS2DHASH_H */ + diff --git a/fcgi/GaussBlockHashAlgorithm.cpp b/fcgi/GaussBlockHashAlgorithm.cpp new file mode 100644 index 0000000..4cd0074 --- /dev/null +++ b/fcgi/GaussBlockHashAlgorithm.cpp @@ -0,0 +1,50 @@ +#include "GaussBlockHashAlgorithm.h" + +#include +#include +#include + +#include +#include + +using namespace std; + +GaussBlockHashAlgorithm::~GaussBlockHashAlgorithm() { +} + +std::vector GaussBlockHashAlgorithm::compute(const std::vector* data) { + cv::Mat image = cv::imdecode(*data, CV_LOAD_IMAGE_GRAYSCALE); + cv::resize(image, image, getKeepRatioSize(image, 512), 0, 0, cv::INTER_LANCZOS4); + + cv::Mat g1, g2; + cv::GaussianBlur(image, g1, cv::Size(1, 1), 0); + cv::GaussianBlur(image, g2, cv::Size(3, 3), 60); + image = g1 - g2; + + std::vector gaussdata; + cv::imencode(".png", image, gaussdata); + + return blockhash::compute(gaussdata, 256); +} + +HashType GaussBlockHashAlgorithm::getType() { + return GaussBlockHash; +} + +size_t GaussBlockHashAlgorithm::getHashSize() { + return 32; +} + +cv::Size GaussBlockHashAlgorithm::getKeepRatioSize(const cv::Mat& image, int size) { + int width = image.cols; + int height = image.rows; + + double ratio; + + if (width < height) { + ratio = size * 1.0 / width; + } else { + ratio = size * 1.0 / height; + } + return cv::Size((int) round(width*ratio), (int) round(height*ratio)); +} \ No newline at end of file diff --git a/fcgi/GaussBlockHashAlgorithm.h b/fcgi/GaussBlockHashAlgorithm.h new file mode 100644 index 0000000..ea06dc1 --- /dev/null +++ b/fcgi/GaussBlockHashAlgorithm.h @@ -0,0 +1,22 @@ +#ifndef GAUSSBLOCKHASH_H +#define GAUSSBLOCKHASH_H + +#include + +#include "HashAlgorithm.h" +#include "HashType.h" + + +class GaussBlockHashAlgorithm : public HashAlgorithm { +public: + virtual ~GaussBlockHashAlgorithm(); + + virtual std::vector compute(const std::vector* data); + virtual HashType getType(); + virtual size_t getHashSize(); +private: + virtual cv::Size getKeepRatioSize(const cv::Mat& image, int size); +}; + +#endif /* GAUSSBLOCKHASH_H */ + diff --git a/fcgi/CannyDHashAlgorithm.cpp b/fcgi/GaussDHashAlgorithm.cpp similarity index 57% rename from fcgi/CannyDHashAlgorithm.cpp rename to fcgi/GaussDHashAlgorithm.cpp index 89b847e..023f9db 100644 --- a/fcgi/CannyDHashAlgorithm.cpp +++ b/fcgi/GaussDHashAlgorithm.cpp @@ -1,11 +1,4 @@ -/* - * File: CannyDHash.cpp - * Author: dudae - * - * Created on Štvrtok, 2015, júla 9, 10:12 - */ - -#include "CannyDHashAlgorithm.h" +#include "GaussDHashAlgorithm.h" #include #include @@ -18,39 +11,23 @@ using namespace std; -const int low_threshold = 50; -const int ratio = 3; -const int kernel_size = 3; - -CannyDHashAlgorithm::~CannyDHashAlgorithm() { -} - -cv::Size getKeepRatioSize(const cv::Mat& image, int size) { - int width = image.cols; - int height = image.rows; - - double ratio; - - if (width < height) { - ratio = size * 1.0 / width; - } else { - ratio = size * 1.0 / height; - } - return cv::Size((int) round(width*ratio), (int) round(height*ratio)); +GaussDHashAlgorithm::~GaussDHashAlgorithm() { } -std::vector CannyDHashAlgorithm::compute(const std::vector* data) { +std::vector GaussDHashAlgorithm::compute(const std::vector* data) { cv::Mat image = cv::imdecode(*data, CV_LOAD_IMAGE_GRAYSCALE); - cv::blur(image, image, cv::Size(3, 3)); cv::resize(image, image, getKeepRatioSize(image, 512), 0, 0, cv::INTER_LANCZOS4); - cv::Canny(image, image, low_threshold, low_threshold*ratio, kernel_size); + cv::Mat g1, g2; + cv::GaussianBlur(image, g1, cv::Size(1, 1), 0); + cv::GaussianBlur(image, g2, cv::Size(3, 3), 60); + image = g1 - g2; - std::vector cannydata; - cv::imencode(".png", image, cannydata); + std::vector gaussdata; + cv::imencode(".png", image, gaussdata); dhash_err* err = dhash_new_err(); - uint64_t hash = dhash_compute_blob(&cannydata[0], cannydata.size(), err); + uint64_t hash = dhash_compute_blob(&gaussdata[0], gaussdata.size(), err); if (err->err_type != OK) { ostringstream os; @@ -65,10 +42,24 @@ std::vector CannyDHashAlgorithm::compute(const std::vector* d return result; } -HashType CannyDHashAlgorithm::getType() { - return CannyDHash; +HashType GaussDHashAlgorithm::getType() { + return GaussDHash; } -size_t CannyDHashAlgorithm::getHashSize() { +size_t GaussDHashAlgorithm::getHashSize() { return 8; +} + +cv::Size GaussDHashAlgorithm::getKeepRatioSize(const cv::Mat& image, int size) { + int width = image.cols; + int height = image.rows; + + double ratio; + + if (width < height) { + ratio = size * 1.0 / width; + } else { + ratio = size * 1.0 / height; + } + return cv::Size((int) round(width*ratio), (int) round(height*ratio)); } \ No newline at end of file diff --git a/fcgi/GaussDHashAlgorithm.h b/fcgi/GaussDHashAlgorithm.h new file mode 100644 index 0000000..4100090 --- /dev/null +++ b/fcgi/GaussDHashAlgorithm.h @@ -0,0 +1,22 @@ +#ifndef GAUSSDHASH_H +#define GAUSSDHASH_H + +#include + +#include "HashAlgorithm.h" +#include "HashType.h" + + +class GaussDHashAlgorithm : public HashAlgorithm { +public: + virtual ~GaussDHashAlgorithm(); + + virtual std::vector compute(const std::vector* data); + virtual HashType getType(); + virtual size_t getHashSize(); +private: + virtual cv::Size getKeepRatioSize(const cv::Mat& image, int size); +}; + +#endif /* GAUSSDHASH_H */ + diff --git a/fcgi/HashAlgorithmManager.cpp b/fcgi/HashAlgorithmManager.cpp index 567e06a..2ead7b6 100644 --- a/fcgi/HashAlgorithmManager.cpp +++ b/fcgi/HashAlgorithmManager.cpp @@ -8,8 +8,10 @@ #include "HashAlgorithmManager.h" #include "DHashAlgorithm.h" #include "BlockHashAlgorithm.h" -#include "CannyDHashAlgorithm.h" #include "LogicalException.h" +#include "GaussDHashAlgorithm.h" +#include "Gauss2DHashAlgorithm.h" +#include "GaussBlockHashAlgorithm.h" #include #include @@ -25,7 +27,9 @@ HashAlgorithmManager::HashAlgorithmManager() { identicalHashes.push_back(new DHashAlgorithm()); identicalHashes.push_back(new BlockHashAlgorithm()); - similarHashes.push_back(new CannyDHashAlgorithm()); + similarHashes.push_back(new GaussDHashAlgorithm()); + similarHashes.push_back(new Gauss2DHashAlgorithm()); + similarHashes.push_back(new GaussBlockHashAlgorithm()); } HashAlgorithmManager::~HashAlgorithmManager() { diff --git a/fcgi/HashType.h b/fcgi/HashType.h index 61257b8..9a3a8e6 100644 --- a/fcgi/HashType.h +++ b/fcgi/HashType.h @@ -11,7 +11,9 @@ typedef enum HashType { DHash, BlockHash, - CannyDHash + GaussDHash, + Gauss2DHash, + GaussBlockHash } HashType; #endif /* HASHTYPE_H */ diff --git a/fcgi/MemoryManager.cpp b/fcgi/MemoryManager.cpp index 28789e8..8e6221d 100644 --- a/fcgi/MemoryManager.cpp +++ b/fcgi/MemoryManager.cpp @@ -26,7 +26,9 @@ MemoryManager& MemoryManager::getInstance() { MemoryManager::MemoryManager() { mem_fds[BlockHash] = new Poco::File("/shared/blockhash"); mem_fds[DHash] = new Poco::File("/shared/dhash"); - mem_fds[CannyDHash] = new Poco::File("/shared/cannydhash"); + mem_fds[GaussDHash] = new Poco::File("/shared/gaussdhash"); + mem_fds[Gauss2DHash] = new Poco::File("/shared/gauss2dhash"); + mem_fds[GaussBlockHash] = new Poco::File("/shared/gaussblockhash"); readers_count_fd = new Poco::File("/shared/readers_count"); can_read_fd = new Poco::File("/shared/can_read"); diff --git a/fcgi/OrderedList.cpp b/fcgi/OrderedList.cpp index 5a41a66..844f884 100644 --- a/fcgi/OrderedList.cpp +++ b/fcgi/OrderedList.cpp @@ -18,31 +18,48 @@ OrderedList::OrderedList(const OrderedList& orig) { OrderedList::~OrderedList() { } -void OrderedList::push(const std::pair& item) { +void OrderedList::push(std::pair item) { + if (exists.count(item.first)) { + remove(item.first); + item.second *= exists[item.first]; + } if (!data.empty()) { pair last = data.back(); if (last.second < item.second) { if (data.size() < size) { data.push_back(item); + exists[item.first] = item.second; } else { return; } } } else { data.push_back(item); + exists[item.first] = item.second; return; } for (list >::iterator it = data.begin(); it != data.end(); it++) { if (item.second < it->second) { data.insert(it, item); + exists[item.first] = item.second; break; } } if (data.size() > size) { + exists.erase(data.back().first); data.remove(data.back()); } } const std::list >& OrderedList::getList() const { return data; +} + +void OrderedList::remove(std::string key) { + for (list >::iterator it = data.begin(); it != data.end(); it++) { + if (it->first == key) { + data.erase(it); + break; + } + } } \ No newline at end of file diff --git a/fcgi/OrderedList.h b/fcgi/OrderedList.h index a46cee5..6aae870 100644 --- a/fcgi/OrderedList.h +++ b/fcgi/OrderedList.h @@ -9,6 +9,7 @@ #define ORDEREDLIST_H #include +#include #include class OrderedList { @@ -17,11 +18,14 @@ class OrderedList { OrderedList(const OrderedList& orig); virtual ~OrderedList(); - void push(const std::pair& item); + void push(std::pair item); const std::list >& getList() const; +protected: + void remove(std::string key); private: size_t size; std::list > data; + std::map exists; }; #endif /* ORDEREDLIST_H */ diff --git a/fcgi/RecordManager.cpp b/fcgi/RecordManager.cpp index dbcd458..4b6fb5a 100644 --- a/fcgi/RecordManager.cpp +++ b/fcgi/RecordManager.cpp @@ -34,7 +34,9 @@ RecordManager::RecordManager() { "metadata TEXT," "blockHash BLOB," "dHash BLOB," - "cannyDHash BLOB)", now; + "gaussDHash BLOB," + "gauss2DHash BLOB," + "gaussBlockHash BLOB)", now; } RecordManager::~RecordManager() { @@ -44,22 +46,28 @@ RecordManager::~RecordManager() { void RecordManager::putRecord(const Record& record) { const std::vector& blockHash = record.getHash(BlockHash); const std::vector& dHash = record.getHash(DHash); - const std::vector& cannyDHash = record.getHash(CannyDHash); + const std::vector& gaussDHash = record.getHash(GaussDHash); + const std::vector& gauss2DHash = record.getHash(Gauss2DHash); + const std::vector& gaussBlockHash = record.getHash(GaussBlockHash); Poco::Data::BLOB blockHashBLOB((unsigned char*) &blockHash[0], blockHash.size() * 8); Poco::Data::BLOB dHashBLOB((unsigned char*) &dHash[0], dHash.size() * 8); - Poco::Data::BLOB cannyDHashBLOB((unsigned char*) &cannyDHash[0], cannyDHash.size() * 8); + Poco::Data::BLOB gaussDHashBLOB((unsigned char*) &gaussDHash[0], gaussDHash.size() * 8); + Poco::Data::BLOB gauss2DHashBLOB((unsigned char*) &gauss2DHash[0], gauss2DHash.size() * 8); + Poco::Data::BLOB gaussBlockHashBLOB((unsigned char*) &gaussBlockHash[0], gaussBlockHash.size() * 8); *session << "INSERT OR REPLACE INTO records" - "(id, thumbnail, metadata, blockHash, dHash, cannyDHash)" + "(id, thumbnail, metadata, blockHash, dHash, gaussDHash, gauss2DHash, gaussBlockHash)" "VALUES" - "(?, ?, ?, ?, ?, ?)", + "(?, ?, ?, ?, ?, ?, ?, ?)", useRef(record.getId()), useRef(record.getThumbnail()), useRef(record.getMetadata()), use(blockHashBLOB), use(dHashBLOB), - use(cannyDHashBLOB), + use(gaussDHashBLOB), + use(gauss2DHashBLOB), + use(gaussBlockHashBLOB), now; } @@ -72,16 +80,20 @@ Record RecordManager::getRecord(const std::string& id) { string metadata; Poco::Data::BLOB blockHash; Poco::Data::BLOB dHash; - Poco::Data::BLOB cannyDHash; + Poco::Data::BLOB gaussDHash; + Poco::Data::BLOB gauss2DHash; + Poco::Data::BLOB gaussBlockHash; - *session << "SELECT thumbnail, metadata, blockHash, dHash, cannyDHash " + *session << "SELECT thumbnail, metadata, blockHash, dHash, gaussDHash, gauss2DHash, gaussBlockHash " "FROM records " "WHERE id = ?", into(thumbnail), into(metadata), into(blockHash), into(dHash), - into(cannyDHash), + into(gaussDHash), + into(gauss2DHash), + into(gaussBlockHash), useRef(id), now; @@ -91,14 +103,16 @@ Record RecordManager::getRecord(const std::string& id) { record.setMetadata(metadata); record.getHashes()[BlockHash] = convertTo64Vector(blockHash.rawContent(), blockHash.size()); record.getHashes()[DHash] = convertTo64Vector(dHash.rawContent(), dHash.size()); - record.getHashes()[CannyDHash] = convertTo64Vector(cannyDHash.rawContent(), cannyDHash.size()); + record.getHashes()[GaussDHash] = convertTo64Vector(gaussDHash.rawContent(), gaussDHash.size()); + record.getHashes()[Gauss2DHash] = convertTo64Vector(gauss2DHash.rawContent(), gauss2DHash.size()); + record.getHashes()[GaussBlockHash] = convertTo64Vector(gaussBlockHash.rawContent(), gaussBlockHash.size()); return record; } std::vector RecordManager::getAllRecords() { Poco::Data::Statement select(*session); - select << "SELECT id, thumbnail, metadata, blockHash, dHash, cannyDHash FROM records", now; + select << "SELECT id, thumbnail, metadata, blockHash, dHash, gaussDHash, gauss2DHash, gaussBlockHash FROM records", now; Poco::Data::RecordSet rs(select); @@ -107,7 +121,9 @@ std::vector RecordManager::getAllRecords() { Record record; Poco::Data::BLOB blockHash; Poco::Data::BLOB dHash; - Poco::Data::BLOB cannyDHash; + Poco::Data::BLOB gaussDHash; + Poco::Data::BLOB gauss2DHash; + Poco::Data::BLOB gaussBlockHash; record.setId(it->get(0).extract()); record.setThumbnail(it->get(1).extract()); @@ -115,11 +131,15 @@ std::vector RecordManager::getAllRecords() { blockHash = it->get(3).extract(); dHash = it->get(4).extract(); - cannyDHash = it->get(5).extract(); + gaussDHash = it->get(5).extract(); + gauss2DHash = it->get(6).extract(); + gaussBlockHash = it->get(7).extract(); record.getHashes()[BlockHash] = convertTo64Vector(blockHash.rawContent(), blockHash.size()); record.getHashes()[DHash] = convertTo64Vector(dHash.rawContent(), dHash.size()); - record.getHashes()[CannyDHash] = convertTo64Vector(cannyDHash.rawContent(), cannyDHash.size()); + record.getHashes()[GaussDHash] = convertTo64Vector(gaussDHash.rawContent(), gaussDHash.size()); + record.getHashes()[Gauss2DHash] = convertTo64Vector(gauss2DHash.rawContent(), gauss2DHash.size()); + record.getHashes()[GaussBlockHash] = convertTo64Vector(gaussBlockHash.rawContent(), gaussBlockHash.size()); result.push_back(record); } diff --git a/fcgi/nbproject/Makefile-Debug.mk b/fcgi/nbproject/Makefile-Debug.mk index ecb0362..b2b0d34 100644 --- a/fcgi/nbproject/Makefile-Debug.mk +++ b/fcgi/nbproject/Makefile-Debug.mk @@ -36,9 +36,11 @@ OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} # Object Files OBJECTFILES= \ ${OBJECTDIR}/BlockHashAlgorithm.o \ - ${OBJECTDIR}/CannyDHashAlgorithm.o \ ${OBJECTDIR}/Controller.o \ ${OBJECTDIR}/DHashAlgorithm.o \ + ${OBJECTDIR}/Gauss2DHashAlgorithm.o \ + ${OBJECTDIR}/GaussBlockHashAlgorithm.o \ + ${OBJECTDIR}/GaussDHashAlgorithm.o \ ${OBJECTDIR}/HashAlgorithmManager.o \ ${OBJECTDIR}/HashManager.o \ ${OBJECTDIR}/Image.o \ @@ -79,11 +81,6 @@ ${OBJECTDIR}/BlockHashAlgorithm.o: BlockHashAlgorithm.cpp ${RM} "$@.d" $(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/BlockHashAlgorithm.o BlockHashAlgorithm.cpp -${OBJECTDIR}/CannyDHashAlgorithm.o: CannyDHashAlgorithm.cpp - ${MKDIR} -p ${OBJECTDIR} - ${RM} "$@.d" - $(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/CannyDHashAlgorithm.o CannyDHashAlgorithm.cpp - ${OBJECTDIR}/Controller.o: Controller.cpp ${MKDIR} -p ${OBJECTDIR} ${RM} "$@.d" @@ -94,6 +91,21 @@ ${OBJECTDIR}/DHashAlgorithm.o: DHashAlgorithm.cpp ${RM} "$@.d" $(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/DHashAlgorithm.o DHashAlgorithm.cpp +${OBJECTDIR}/Gauss2DHashAlgorithm.o: Gauss2DHashAlgorithm.cpp + ${MKDIR} -p ${OBJECTDIR} + ${RM} "$@.d" + $(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/Gauss2DHashAlgorithm.o Gauss2DHashAlgorithm.cpp + +${OBJECTDIR}/GaussBlockHashAlgorithm.o: GaussBlockHashAlgorithm.cpp + ${MKDIR} -p ${OBJECTDIR} + ${RM} "$@.d" + $(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/GaussBlockHashAlgorithm.o GaussBlockHashAlgorithm.cpp + +${OBJECTDIR}/GaussDHashAlgorithm.o: GaussDHashAlgorithm.cpp + ${MKDIR} -p ${OBJECTDIR} + ${RM} "$@.d" + $(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/GaussDHashAlgorithm.o GaussDHashAlgorithm.cpp + ${OBJECTDIR}/HashAlgorithmManager.o: HashAlgorithmManager.cpp ${MKDIR} -p ${OBJECTDIR} ${RM} "$@.d" diff --git a/fcgi/nbproject/Makefile-Release.mk b/fcgi/nbproject/Makefile-Release.mk index b25ea8e..2d05bcc 100644 --- a/fcgi/nbproject/Makefile-Release.mk +++ b/fcgi/nbproject/Makefile-Release.mk @@ -36,9 +36,11 @@ OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} # Object Files OBJECTFILES= \ ${OBJECTDIR}/BlockHashAlgorithm.o \ - ${OBJECTDIR}/CannyDHashAlgorithm.o \ ${OBJECTDIR}/Controller.o \ ${OBJECTDIR}/DHashAlgorithm.o \ + ${OBJECTDIR}/Gauss2DHashAlgorithm.o \ + ${OBJECTDIR}/GaussBlockHashAlgorithm.o \ + ${OBJECTDIR}/GaussDHashAlgorithm.o \ ${OBJECTDIR}/HashAlgorithmManager.o \ ${OBJECTDIR}/HashManager.o \ ${OBJECTDIR}/Image.o \ @@ -79,11 +81,6 @@ ${OBJECTDIR}/BlockHashAlgorithm.o: BlockHashAlgorithm.cpp ${RM} "$@.d" $(COMPILE.cc) -O2 -Wall -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/BlockHashAlgorithm.o BlockHashAlgorithm.cpp -${OBJECTDIR}/CannyDHashAlgorithm.o: CannyDHashAlgorithm.cpp - ${MKDIR} -p ${OBJECTDIR} - ${RM} "$@.d" - $(COMPILE.cc) -O2 -Wall -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/CannyDHashAlgorithm.o CannyDHashAlgorithm.cpp - ${OBJECTDIR}/Controller.o: Controller.cpp ${MKDIR} -p ${OBJECTDIR} ${RM} "$@.d" @@ -94,6 +91,21 @@ ${OBJECTDIR}/DHashAlgorithm.o: DHashAlgorithm.cpp ${RM} "$@.d" $(COMPILE.cc) -O2 -Wall -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/DHashAlgorithm.o DHashAlgorithm.cpp +${OBJECTDIR}/Gauss2DHashAlgorithm.o: Gauss2DHashAlgorithm.cpp + ${MKDIR} -p ${OBJECTDIR} + ${RM} "$@.d" + $(COMPILE.cc) -O2 -Wall -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/Gauss2DHashAlgorithm.o Gauss2DHashAlgorithm.cpp + +${OBJECTDIR}/GaussBlockHashAlgorithm.o: GaussBlockHashAlgorithm.cpp + ${MKDIR} -p ${OBJECTDIR} + ${RM} "$@.d" + $(COMPILE.cc) -O2 -Wall -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/GaussBlockHashAlgorithm.o GaussBlockHashAlgorithm.cpp + +${OBJECTDIR}/GaussDHashAlgorithm.o: GaussDHashAlgorithm.cpp + ${MKDIR} -p ${OBJECTDIR} + ${RM} "$@.d" + $(COMPILE.cc) -O2 -Wall -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/GaussDHashAlgorithm.o GaussDHashAlgorithm.cpp + ${OBJECTDIR}/HashAlgorithmManager.o: HashAlgorithmManager.cpp ${MKDIR} -p ${OBJECTDIR} ${RM} "$@.d" diff --git a/fcgi/nbproject/configurations.xml b/fcgi/nbproject/configurations.xml index 6f680ea..592fd97 100644 --- a/fcgi/nbproject/configurations.xml +++ b/fcgi/nbproject/configurations.xml @@ -5,10 +5,12 @@ displayName="Header Files" projectFiles="true"> BlockHashAlgorithm.h - CannyDHashAlgorithm.h Controller.h DHashAlgorithm.h DHashException.h + Gauss2DHashAlgorithm.h + GaussBlockHashAlgorithm.h + GaussDHashAlgorithm.h HashAlgorithm.h HashAlgorithmManager.h HashManager.h @@ -32,9 +34,11 @@ displayName="Source Files" projectFiles="true"> BlockHashAlgorithm.cpp - CannyDHashAlgorithm.cpp Controller.cpp DHashAlgorithm.cpp + Gauss2DHashAlgorithm.cpp + GaussBlockHashAlgorithm.cpp + GaussDHashAlgorithm.cpp HashAlgorithmManager.cpp HashManager.cpp Image.cpp @@ -77,10 +81,6 @@ - - - - @@ -91,6 +91,18 @@ + + + + + + + + + + + + @@ -195,10 +207,6 @@ - - - - @@ -209,6 +217,18 @@ + + + + + + + + + + + +