From 11d1ee76d8164bd249a1b73f3434ca379e00e4bd Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 30 Aug 2016 22:36:12 +0200 Subject: [PATCH] [DEV] update recorder --- dollar/tools.cpp | 20 +++++++++++++++++++ tool/generate-form/main.cpp | 13 +++++++++++- .../appl/widget/TextAreaRecognition.cpp | 2 ++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/dollar/tools.cpp b/dollar/tools.cpp index 8128d78..689cf62 100644 --- a/dollar/tools.cpp +++ b/dollar/tools.cpp @@ -47,12 +47,23 @@ std::vector dollar::rotateToZero(const std::vector& _points) { return rotateBy(_points, -rotation); } +float maxKeepAspectRatio = 5.5f; + // TODO : Rework this to have a correct scale with keeping aspect ration ... or not ... std::vector dollar::scaleToOne(const std::vector& _points, bool _keepAspectRation) { dollar::Rectangle box(_points); std::vector out; vec2 scale(1.0f/box.getSize().x(), 1.0f/box.getSize().y()); vec2 offset(0,0); + /* + float aspectRatio = box.getSize().x() / box.getSize().y(); + if (aspectRatio < 1.0f) { + aspectRatio = 1.0f / aspectRatio; + } + if (aspectRatio > maxKeepAspectRatio) { + _keepAspectRation = true; + } + */ if (_keepAspectRation == true) { float val = 1; offset = box.getSize() * val; @@ -79,6 +90,15 @@ std::vector> dollar::scaleToOne(const std::vector> out; vec2 scale(1.0f/box.getSize().x(), 1.0f/box.getSize().y()); vec2 offset(0,0); + /* + float aspectRatio = box.getSize().x() / box.getSize().y(); + if (aspectRatio < 1.0f) { + aspectRatio = 1.0f / aspectRatio; + } + if (aspectRatio > maxKeepAspectRatio) { + _keepAspectRation = true; + } + */ if (_keepAspectRation == true) { float val = 1; offset = box.getSize() * val; diff --git a/tool/generate-form/main.cpp b/tool/generate-form/main.cpp index fffd59a..2a5ce31 100644 --- a/tool/generate-form/main.cpp +++ b/tool/generate-form/main.cpp @@ -165,6 +165,11 @@ bool testCorpus(const std::string& _srcCorpus) { if (etk::end_with(it, ".json") == true) { std::vector path = etk::split(it, '/'); std::string elemName = etk::split(path[path.size()-1],'_')[0]; + if (elemName == "slash") { + elemName = "/"; + }if (elemName == "back-slash") { + elemName = "\\"; + } if (std::find(listOfElementInCorpus.begin(), listOfElementInCorpus.end(), elemName) == listOfElementInCorpus.end()) { listOfElementInCorpus.push_back(elemName); } @@ -183,11 +188,17 @@ bool testCorpus(const std::string& _srcCorpus) { TEST_PRINT("-- Generate FOR: '" << itTypeOfCorpus << "'"); TEST_PRINT("---------------------------------------------------------------------------"); std::vector fileFiltered; + std::string fileNameIt = itTypeOfCorpus; + if (fileNameIt == "/") { + fileNameIt = "slash"; + } else if (fileNameIt == "\\") { + fileNameIt = "back-slash"; + } for (auto &it : files) { if (etk::end_with(it, ".json") == true) { std::vector path = etk::split(it, '/'); std::string filename = path[path.size()-1]; - if (etk::start_with(filename, itTypeOfCorpus + "_") == true) { + if (etk::start_with(filename, fileNameIt + "_") == true) { fileFiltered.push_back(it); } } diff --git a/tool/recorder/appl/widget/TextAreaRecognition.cpp b/tool/recorder/appl/widget/TextAreaRecognition.cpp index abe4380..17700f5 100644 --- a/tool/recorder/appl/widget/TextAreaRecognition.cpp +++ b/tool/recorder/appl/widget/TextAreaRecognition.cpp @@ -85,6 +85,8 @@ void appl::widget::TextAreaRecognition::store(const std::string& _userName, cons fileName = "HOME:DOLLAR/corpus/"; if (_value == "/") { fileName += "slash"; + } else if (_value == "\\") { + fileName += "back-slash"; } else { fileName += _value; }