From 8d47b17cb9e3b11685db15e179fa8de616cec9fa Mon Sep 17 00:00:00 2001 From: zdd Date: Sun, 9 Apr 2017 22:58:26 +0800 Subject: [PATCH] remove boost from gui demo --- gui/SketchSearchDemo/SketchSearchDemo.pro | 1 - gui/SketchSearchDemo/mainwindow.cpp | 4 +--- gui/SketchSearchDemo/sketchsearcher.cpp | 14 +++++++------- gui/SketchSearchDemo/sketchsearcher.h | 12 +----------- opensse.h | 3 ++- opensse.pro | 7 +------ sse/CMakeLists.txt | 1 + sse/io/json_parser.cpp | 2 +- sse/io/json_parser.h | 14 ++++++++++++++ sse/opensse.h | 3 ++- tools/vocabulary.cpp | 1 + 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/gui/SketchSearchDemo/SketchSearchDemo.pro b/gui/SketchSearchDemo/SketchSearchDemo.pro index d436371..a673509 100644 --- a/gui/SketchSearchDemo/SketchSearchDemo.pro +++ b/gui/SketchSearchDemo/SketchSearchDemo.pro @@ -42,7 +42,6 @@ INCLUDEPATH += $$PWD \ LIBS += -L/usr/local/lib/ \ -lopencv_core -lopencv_imgproc -lopencv_imgcodecs -lopencv_highgui -lopencv_features2d -lopencv_ml \ - -lboost_thread -lboost_system \ -lopensse } diff --git a/gui/SketchSearchDemo/mainwindow.cpp b/gui/SketchSearchDemo/mainwindow.cpp index f348ecf..ee41c89 100644 --- a/gui/SketchSearchDemo/mainwindow.cpp +++ b/gui/SketchSearchDemo/mainwindow.cpp @@ -29,9 +29,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { - PropertyTree_t config; - - boost::property_tree::read_json("/tmp/SketchSearchDemo/config.json", config); // + Json config = Json("/tmp/SketchSearchDemo/config.json"); // searchEngine = new SketchSearcher(config); setupMenuBar(); diff --git a/gui/SketchSearchDemo/sketchsearcher.cpp b/gui/SketchSearchDemo/sketchsearcher.cpp index 2747cec..1896fab 100644 --- a/gui/SketchSearchDemo/sketchsearcher.cpp +++ b/gui/SketchSearchDemo/sketchsearcher.cpp @@ -17,13 +17,13 @@ #include "sketchsearcher.h" using namespace sse; -SketchSearcher::SketchSearcher(const PropertyTree_t ¶meters) - : _indexFile(parse(parameters, "searcher.indexfile", "/tmp/SketchSearchDemo/data/model_indexfile")) - , _vocabularyFile(parse(parameters, "searcher.vocabulary", "/tmp/SketchSearchDemo/data/vocabulary")) - , _rootdir(parse(parameters, "searcher.rootdir", "/tmp/SketchSearchDemo/")) - , _fileList(parse(parameters, "searcher.filelist", "/tmp/SketchSearchDemo/data/model_filelist")) - , _numOfResults(parse(parameters, "searcher.results_num", 25)) - , _numOfViews(parse(parameters, "searcher.views_num", 1)) +SketchSearcher::SketchSearcher(Json &config) + : _indexFile(config.getValue("searcher$indexfile", "/tmp/SketchSearchDemo/data/model_indexfile")) + , _vocabularyFile(config.getValue("searcher$vocabulary", "/tmp/SketchSearchDemo/data/vocabulary")) + , _rootdir(config.getValue("searcher$rootdir", "/tmp/SketchSearchDemo/")) + , _fileList(config.getValue("searcher$filelist", "/tmp/SketchSearchDemo/data/model_filelist")) + , _numOfResults(convert(config.getValue("searcher$results_num", "25"), UINT)) + , _numOfViews(convert(config.getValue("searcher$views_num", "1"), UINT)) { index = new InvertedIndex(); index->load(_indexFile); diff --git a/gui/SketchSearchDemo/sketchsearcher.h b/gui/SketchSearchDemo/sketchsearcher.h index 12d9f2d..82219ac 100644 --- a/gui/SketchSearchDemo/sketchsearcher.h +++ b/gui/SketchSearchDemo/sketchsearcher.h @@ -21,20 +21,10 @@ #include "opensse/opensse.h" -#include -#include -typedef boost::property_tree::ptree PropertyTree_t; -template -inline T parse(const PropertyTree_t &p, const std::string &path, const T &defaultValue) -{ - T value = p.get(path, defaultValue); - return value; -} - class SketchSearcher : public SearchEngine { public: - SketchSearcher(const PropertyTree_t ¶meters); + SketchSearcher(Json &config); virtual ~SketchSearcher(); void query(const std::string &fileName, QueryResults &results); diff --git a/opensse.h b/opensse.h index 689679b..04ca89a 100644 --- a/opensse.h +++ b/opensse.h @@ -7,8 +7,9 @@ #include "sse/index/invertedindex.h" #include "sse/io/filelist.h" #include "sse/io/reader_writer.h" +#include "sse/io/json_parser.h" #include "sse/quantize/quantizer.h" #include "sse/vocabulary/kmeans_init.h" -#include "sse/vocabulary/kmeans.h" +// #include "sse/vocabulary/kmeans.h" #endif diff --git a/opensse.pro b/opensse.pro index e17edd7..005c8a1 100644 --- a/opensse.pro +++ b/opensse.pro @@ -18,10 +18,5 @@ TEMPLATE = subdirs SUBDIRS += \ #opensse.pri \ - tests/test_galif \ - tests/test_reader_and_writer \ - gui/SketchSearchDemo \ - tests/test_similarity \ - tests/stat_vocab \ - tests/test_search + gui/SketchSearchDemo diff --git a/sse/CMakeLists.txt b/sse/CMakeLists.txt index 77b65f4..d0af383 100644 --- a/sse/CMakeLists.txt +++ b/sse/CMakeLists.txt @@ -2,6 +2,7 @@ set( SOURCES io/filelist.cpp io/reader_writer.cpp + io/json_parser.cpp features/util.cpp features/generator.cpp features/detector.cpp diff --git a/sse/io/json_parser.cpp b/sse/io/json_parser.cpp index cabaafa..d8f844c 100644 --- a/sse/io/json_parser.cpp +++ b/sse/io/json_parser.cpp @@ -71,4 +71,4 @@ Json::Json(const string &filename) const string& Json::getValue(const string &key, const string &defaultValue) { return values[key].empty() ? defaultValue : values[key]; -} +} \ No newline at end of file diff --git a/sse/io/json_parser.h b/sse/io/json_parser.h index f4d2e59..5477b3b 100644 --- a/sse/io/json_parser.h +++ b/sse/io/json_parser.h @@ -7,6 +7,20 @@ #include using namespace std; +enum VALUE_TYPE { + UINT +}; + +template +T convert(const string &value, VALUE_TYPE type) +{ + if (type == UINT) { + char *end; + return static_cast(strtol(value.c_str(), &end, 10)); + } + return T(0); +}; + class Json { public: Json(const string &filename); diff --git a/sse/opensse.h b/sse/opensse.h index 3367570..a838e45 100644 --- a/sse/opensse.h +++ b/sse/opensse.h @@ -7,8 +7,9 @@ #include "opensse/index/invertedindex.h" #include "opensse/io/filelist.h" #include "opensse/io/reader_writer.h" +#include "opensse/io/json_parser.h" #include "opensse/quantize/quantizer.h" #include "opensse/vocabulary/kmeans_init.h" -#include "opensse/vocabulary/kmeans.h" +// #include "opensse/vocabulary/kmeans.h" #endif \ No newline at end of file diff --git a/tools/vocabulary.cpp b/tools/vocabulary.cpp index c618326..6d4a43c 100644 --- a/tools/vocabulary.cpp +++ b/tools/vocabulary.cpp @@ -19,6 +19,7 @@ using namespace std; #include "opensse/opensse.h" +#include "vocabulary/kmeans.h" using namespace sse;