[DEV] update recorder

This commit is contained in:
Edouard DUPIN 2016-08-30 22:36:12 +02:00
parent 62e176efd6
commit 11d1ee76d8
3 changed files with 34 additions and 1 deletions

View File

@ -47,12 +47,23 @@ std::vector<vec2> dollar::rotateToZero(const std::vector<vec2>& _points) {
return rotateBy(_points, -rotation); return rotateBy(_points, -rotation);
} }
float maxKeepAspectRatio = 5.5f;
// TODO : Rework this to have a correct scale with keeping aspect ration ... or not ... // TODO : Rework this to have a correct scale with keeping aspect ration ... or not ...
std::vector<vec2> dollar::scaleToOne(const std::vector<vec2>& _points, bool _keepAspectRation) { std::vector<vec2> dollar::scaleToOne(const std::vector<vec2>& _points, bool _keepAspectRation) {
dollar::Rectangle box(_points); dollar::Rectangle box(_points);
std::vector<vec2> out; std::vector<vec2> out;
vec2 scale(1.0f/box.getSize().x(), 1.0f/box.getSize().y()); vec2 scale(1.0f/box.getSize().x(), 1.0f/box.getSize().y());
vec2 offset(0,0); 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) { if (_keepAspectRation == true) {
float val = 1; float val = 1;
offset = box.getSize() * val; offset = box.getSize() * val;
@ -79,6 +90,15 @@ std::vector<std::vector<vec2>> dollar::scaleToOne(const std::vector<std::vector<
std::vector<std::vector<vec2>> out; std::vector<std::vector<vec2>> out;
vec2 scale(1.0f/box.getSize().x(), 1.0f/box.getSize().y()); vec2 scale(1.0f/box.getSize().x(), 1.0f/box.getSize().y());
vec2 offset(0,0); 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) { if (_keepAspectRation == true) {
float val = 1; float val = 1;
offset = box.getSize() * val; offset = box.getSize() * val;

View File

@ -165,6 +165,11 @@ bool testCorpus(const std::string& _srcCorpus) {
if (etk::end_with(it, ".json") == true) { if (etk::end_with(it, ".json") == true) {
std::vector<std::string> path = etk::split(it, '/'); std::vector<std::string> path = etk::split(it, '/');
std::string elemName = etk::split(path[path.size()-1],'_')[0]; 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()) { if (std::find(listOfElementInCorpus.begin(), listOfElementInCorpus.end(), elemName) == listOfElementInCorpus.end()) {
listOfElementInCorpus.push_back(elemName); listOfElementInCorpus.push_back(elemName);
} }
@ -183,11 +188,17 @@ bool testCorpus(const std::string& _srcCorpus) {
TEST_PRINT("-- Generate FOR: '" << itTypeOfCorpus << "'"); TEST_PRINT("-- Generate FOR: '" << itTypeOfCorpus << "'");
TEST_PRINT("---------------------------------------------------------------------------"); TEST_PRINT("---------------------------------------------------------------------------");
std::vector<std::string> fileFiltered; std::vector<std::string> fileFiltered;
std::string fileNameIt = itTypeOfCorpus;
if (fileNameIt == "/") {
fileNameIt = "slash";
} else if (fileNameIt == "\\") {
fileNameIt = "back-slash";
}
for (auto &it : files) { for (auto &it : files) {
if (etk::end_with(it, ".json") == true) { if (etk::end_with(it, ".json") == true) {
std::vector<std::string> path = etk::split(it, '/'); std::vector<std::string> path = etk::split(it, '/');
std::string filename = path[path.size()-1]; 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); fileFiltered.push_back(it);
} }
} }

View File

@ -85,6 +85,8 @@ void appl::widget::TextAreaRecognition::store(const std::string& _userName, cons
fileName = "HOME:DOLLAR/corpus/"; fileName = "HOME:DOLLAR/corpus/";
if (_value == "/") { if (_value == "/") {
fileName += "slash"; fileName += "slash";
} else if (_value == "\\") {
fileName += "back-slash";
} else { } else {
fileName += _value; fileName += _value;
} }