[DEV] continue removing stl

This commit is contained in:
Edouard DUPIN 2017-08-28 00:09:45 +02:00
parent 7fb415f696
commit 5982126e82
30 changed files with 431 additions and 431 deletions

View File

@ -28,10 +28,10 @@ size_t dollar::Engine::getNumberResult() {
} }
bool dollar::Engine::loadPath(const std::string& _path) { bool dollar::Engine::loadPath(const etk::String& _path) {
DOLLAR_INFO("Load Path: " << _path); DOLLAR_INFO("Load Path: " << _path);
etk::FSNode path(_path); etk::FSNode path(_path);
std::vector<std::string> files = path.folderGetSub(false, true, "*.json"); etk::Vector<etk::String> files = path.folderGetSub(false, true, "*.json");
for (auto &it : files) { for (auto &it : files) {
if (etk::end_with(it, ".json") == true) { if (etk::end_with(it, ".json") == true) {
loadGesture(it); loadGesture(it);
@ -41,16 +41,16 @@ bool dollar::Engine::loadPath(const std::string& _path) {
} }
dollar::Results dollar::Engine::recognize(const std::vector<vec2>& _points) { dollar::Results dollar::Engine::recognize(const etk::Vector<vec2>& _points) {
std::vector<std::vector<vec2>> tmp; etk::Vector<etk::Vector<vec2>> tmp;
tmp.push_back(_points); tmp.pushBack(_points);
return recognize2(tmp); return recognize2(tmp);
} }
dollar::Results dollar::Engine::recognize(const std::vector<std::vector<vec2>>& _points) { dollar::Results dollar::Engine::recognize(const etk::Vector<etk::Vector<vec2>>& _points) {
return recognize2(_points); return recognize2(_points);
} }
ememory::SharedPtr<dollar::Engine> dollar::createEngine(const std::string& _method) { ememory::SharedPtr<dollar::Engine> dollar::createEngine(const etk::String& _method) {
if ( _method == "$N" if ( _method == "$N"
|| _method == "$1") { || _method == "$1") {
return ememory::makeShared<dollar::EngineN>(false); return ememory::makeShared<dollar::EngineN>(false);

View File

@ -12,7 +12,7 @@
#include <ememory/memory.hpp> #include <ememory/memory.hpp>
#include <limits> #include <limits>
#include <iostream> #include <iostream>
#include <string> #include <etk/String.hpp>
/** /**
* @brief dollar library main namespace * @brief dollar library main namespace
@ -27,17 +27,17 @@ namespace dollar {
public: public:
Engine(); Engine();
virtual ~Engine() = default; virtual ~Engine() = default;
dollar::Results recognize(const std::vector<vec2>& _paths); dollar::Results recognize(const etk::Vector<vec2>& _paths);
dollar::Results recognize(const std::vector<std::vector<vec2>>& _paths); dollar::Results recognize(const etk::Vector<etk::Vector<vec2>>& _paths);
protected: protected:
virtual dollar::Results recognize2(const std::vector<std::vector<vec2>>& _paths) = 0; virtual dollar::Results recognize2(const etk::Vector<etk::Vector<vec2>>& _paths) = 0;
public: public:
virtual bool loadPath(const std::string& _path); virtual bool loadPath(const etk::String& _path);
virtual bool loadGesture(const std::string& _filename) = 0; virtual bool loadGesture(const etk::String& _filename) = 0;
virtual void addGesture(ememory::SharedPtr<dollar::Gesture> _gesture) = 0; virtual void addGesture(ememory::SharedPtr<dollar::Gesture> _gesture) = 0;
}; };
ememory::SharedPtr<dollar::Engine> createEngine(const std::string& _method="$N"); ememory::SharedPtr<dollar::Engine> createEngine(const etk::String& _method="$N");
} }

View File

@ -41,7 +41,7 @@ static float angleBetweenUnitVectors(const vec2& _vect1, const vec2& _vect2) {
return std::acos(n); // arc cosine of the vector dot product return std::acos(n); // arc cosine of the vector dot product
} }
static float pathDistance(const std::vector<vec2>& _path1, const std::vector<vec2>& _path2) { static float pathDistance(const etk::Vector<vec2>& _path1, const etk::Vector<vec2>& _path2) {
// assumes pts1.size == pts2.size // assumes pts1.size == pts2.size
float distance = 0.0; float distance = 0.0;
if (_path1.size() != _path2.size()) { if (_path1.size() != _path2.size()) {
@ -81,7 +81,7 @@ size_t dollar::EngineN::getNumberPointInGesture() {
return m_numPointsInGesture; return m_numPointsInGesture;
} }
float dollar::EngineN::distanceAtBestAngle(const std::vector<vec2>& _points, const std::vector<vec2>& _reference) { float dollar::EngineN::distanceAtBestAngle(const etk::Vector<vec2>& _points, const etk::Vector<vec2>& _reference) {
float startRange = -m_angleRange; float startRange = -m_angleRange;
float endRange = m_angleRange; float endRange = m_angleRange;
float x1 = MAGIC_RATIO * startRange + (1.0 - MAGIC_RATIO) * endRange; float x1 = MAGIC_RATIO * startRange + (1.0 - MAGIC_RATIO) * endRange;
@ -104,11 +104,11 @@ float dollar::EngineN::distanceAtBestAngle(const std::vector<vec2>& _points, con
f2 = pathDistance(dollar::rotateBy(_points, x2), _reference); f2 = pathDistance(dollar::rotateBy(_points, x2), _reference);
} }
} }
return std::min(f1, f2); return etk::min(f1, f2);
} }
float dollar::EngineN::optimalCosineDistance(const std::vector<vec2>& _vect1, const std::vector<vec2>& _vect2) { float dollar::EngineN::optimalCosineDistance(const etk::Vector<vec2>& _vect1, const etk::Vector<vec2>& _vect2) {
if (_vect1.size() != _vect2.size()) { if (_vect1.size() != _vect2.size()) {
DOLLAR_ERROR("Vector have not the same size: " << _vect1.size() << " != " << _vect2.size()); DOLLAR_ERROR("Vector have not the same size: " << _vect1.size() << " != " << _vect2.size());
return M_PI; return M_PI;
@ -138,7 +138,7 @@ void dollar::EngineN::setRotationInvariance(bool _ignoreRotation) {
} }
} }
bool dollar::EngineN::loadGesture(const std::string& _filename) { bool dollar::EngineN::loadGesture(const etk::String& _filename) {
ememory::SharedPtr<dollar::Gesture> ref = ememory::makeShared<dollar::GestureN>(); ememory::SharedPtr<dollar::Gesture> ref = ememory::makeShared<dollar::GestureN>();
DOLLAR_DEBUG("Load Gesture: " << _filename); DOLLAR_DEBUG("Load Gesture: " << _filename);
if (ref->load(_filename) == true) { if (ref->load(_filename) == true) {
@ -152,16 +152,16 @@ void dollar::EngineN::addGesture(ememory::SharedPtr<dollar::Gesture> _gesture) {
ememory::SharedPtr<dollar::GestureN> gest = ememory::dynamicPointerCast<dollar::GestureN>(_gesture); ememory::SharedPtr<dollar::GestureN> gest = ememory::dynamicPointerCast<dollar::GestureN>(_gesture);
if (gest != nullptr) { if (gest != nullptr) {
gest->configure(m_numPointsInGesture/RATIO_START_VECTOR, m_numPointsInGesture, m_paramterIgnoreRotation); gest->configure(m_numPointsInGesture/RATIO_START_VECTOR, m_numPointsInGesture, m_paramterIgnoreRotation);
m_gestures.push_back(gest); m_gestures.pushBack(gest);
} }
} }
dollar::Results dollar::EngineN::recognize2(const std::vector<std::vector<vec2>>& _strokes) { dollar::Results dollar::EngineN::recognize2(const etk::Vector<etk::Vector<vec2>>& _strokes) {
std::vector<vec2> points = dollar::combineStrokes(_strokes); etk::Vector<vec2> points = dollar::combineStrokes(_strokes);
points = dollar::normalizePath(points, m_numPointsInGesture, m_paramterIgnoreRotation, false); points = dollar::normalizePath(points, m_numPointsInGesture, m_paramterIgnoreRotation, false);
vec2 startv = dollar::getStartVector(points, m_numPointsInGesture/RATIO_START_VECTOR); vec2 startv = dollar::getStartVector(points, m_numPointsInGesture/RATIO_START_VECTOR);
std::vector<vec2> vector = normalyse(points); etk::Vector<vec2> vector = normalyse(points);
// Keep maximum 5 results ... // Keep maximum 5 results ...
float bestDistance[m_nbResult]; float bestDistance[m_nbResult];
int32_t indexOfBestMatch[m_nbResult]; int32_t indexOfBestMatch[m_nbResult];

View File

@ -13,7 +13,7 @@
#include <dollar/GestureN.hpp> #include <dollar/GestureN.hpp>
#include <limits> #include <limits>
#include <iostream> #include <iostream>
#include <string> #include <etk/String.hpp>
namespace dollar { namespace dollar {
class EngineN : public dollar::Engine { class EngineN : public dollar::Engine {
@ -30,15 +30,15 @@ namespace dollar {
void setNumberPointInGesture(size_t _value); void setNumberPointInGesture(size_t _value);
size_t getNumberPointInGesture(); size_t getNumberPointInGesture();
protected: protected:
std::vector<ememory::SharedPtr<dollar::GestureN>> m_gestures; //!< List of all loaded gesture in the engine etk::Vector<ememory::SharedPtr<dollar::GestureN>> m_gestures; //!< List of all loaded gesture in the engine
public: public:
EngineN(bool _protractor); EngineN(bool _protractor);
dollar::Results recognize2(const std::vector<std::vector<vec2>>& _points) override; dollar::Results recognize2(const etk::Vector<etk::Vector<vec2>>& _points) override;
bool loadGesture(const std::string& _filename) override; bool loadGesture(const etk::String& _filename) override;
void addGesture(ememory::SharedPtr<dollar::Gesture> _gesture) override; void addGesture(ememory::SharedPtr<dollar::Gesture> _gesture) override;
protected: protected:
float distanceAtBestAngle(const std::vector<vec2>& _points, const std::vector<vec2>& _reference); float distanceAtBestAngle(const etk::Vector<vec2>& _points, const etk::Vector<vec2>& _reference);
float optimalCosineDistance(const std::vector<vec2>& _vect1, const std::vector<vec2>& _vect2); float optimalCosineDistance(const etk::Vector<vec2>& _vect1, const etk::Vector<vec2>& _vect2);
}; };
} }

View File

@ -57,8 +57,8 @@ bool dollar::EngineP::getScaleKeepRatio() {
return m_scaleKeepRatio; return m_scaleKeepRatio;
} }
static float cloudDistance(const std::vector<vec2>& _points1, const std::vector<vec2>& _points2, size_t _start) { static float cloudDistance(const etk::Vector<vec2>& _points1, const etk::Vector<vec2>& _points2, size_t _start) {
std::vector<bool> matched; etk::Vector<bool> matched;
matched.resize(_points1.size(), false); matched.resize(_points1.size(), false);
float out = 0; float out = 0;
size_t iii = _start; size_t iii = _start;
@ -84,7 +84,7 @@ static float cloudDistance(const std::vector<vec2>& _points1, const std::vector<
} }
//Greedy-Cloud-Match //Greedy-Cloud-Match
static float calculateBestDistance(const std::vector<vec2>& _points, const std::vector<vec2>& _reference) { static float calculateBestDistance(const etk::Vector<vec2>& _points, const etk::Vector<vec2>& _reference) {
float out = MAX_FLOAT; float out = MAX_FLOAT;
float si = 0.5f; float si = 0.5f;
float step = pow(_points.size(), si-1); float step = pow(_points.size(), si-1);
@ -95,13 +95,13 @@ static float calculateBestDistance(const std::vector<vec2>& _points, const std::
for (size_t iii=0; iii<_points.size(); iii+=int32_t(step)) { for (size_t iii=0; iii<_points.size(); iii+=int32_t(step)) {
float d1 = cloudDistance(_points, _reference, iii); float d1 = cloudDistance(_points, _reference, iii);
float d2 = cloudDistance(_reference, _points, iii); float d2 = cloudDistance(_reference, _points, iii);
out = std::min(out, std::min(d1,d2)); out = etk::min(out, etk::min(d1,d2));
} }
return out; // Distance to the nearest point must be < 2.0 (maximum distance visible) return out; // Distance to the nearest point must be < 2.0 (maximum distance visible)
} }
bool dollar::EngineP::loadGesture(const std::string& _filename) { bool dollar::EngineP::loadGesture(const etk::String& _filename) {
ememory::SharedPtr<dollar::Gesture> ref = ememory::makeShared<dollar::GestureP>(); ememory::SharedPtr<dollar::Gesture> ref = ememory::makeShared<dollar::GestureP>();
DOLLAR_DEBUG("Load Gesture: " << _filename); DOLLAR_DEBUG("Load Gesture: " << _filename);
if (ref->load(_filename) == true) { if (ref->load(_filename) == true) {
@ -115,12 +115,12 @@ void dollar::EngineP::addGesture(ememory::SharedPtr<dollar::Gesture> _gesture) {
ememory::SharedPtr<dollar::GestureP> gest = ememory::dynamicPointerCast<dollar::GestureP>(_gesture); ememory::SharedPtr<dollar::GestureP> gest = ememory::dynamicPointerCast<dollar::GestureP>(_gesture);
if (gest != nullptr) { if (gest != nullptr) {
gest->configure(m_numPointsInGesture); gest->configure(m_numPointsInGesture);
m_gestures.push_back(gest); m_gestures.pushBack(gest);
} }
} }
dollar::Results dollar::EngineP::recognize2(const std::vector<std::vector<vec2>>& _strokes) { dollar::Results dollar::EngineP::recognize2(const etk::Vector<etk::Vector<vec2>>& _strokes) {
std::vector<vec2> points = dollar::combineStrokes(_strokes); etk::Vector<vec2> points = dollar::combineStrokes(_strokes);
points = dollar::normalizePath(points, m_numPointsInGesture, false, m_scaleKeepRatio); points = dollar::normalizePath(points, m_numPointsInGesture, false, m_scaleKeepRatio);
// Keep maximum 5 results ... // Keep maximum 5 results ...
float bestDistance[m_nbResult]; float bestDistance[m_nbResult];
@ -168,7 +168,7 @@ dollar::Results dollar::EngineP::recognize2(const std::vector<std::vector<vec2>>
Results res; Results res;
for (size_t iii=0; iii<m_nbResult; ++iii) { for (size_t iii=0; iii<m_nbResult; ++iii) {
if (-1 != indexOfBestMatch[iii]) { if (-1 != indexOfBestMatch[iii]) {
//float score = std::max((2.0 - bestDistance[iii])/2.0, 0.0); //float score = etk::max((2.0 - bestDistance[iii])/2.0, 0.0);
float score = bestDistance[iii]; float score = bestDistance[iii];
res.addValue(m_gestures[indexOfBestMatch[iii]]->getName(), score); res.addValue(m_gestures[indexOfBestMatch[iii]]->getName(), score);
} }

View File

@ -12,7 +12,7 @@
#include <dollar/GestureP.hpp> #include <dollar/GestureP.hpp>
#include <limits> #include <limits>
#include <iostream> #include <iostream>
#include <string> #include <etk/String.hpp>
namespace dollar { namespace dollar {
class EngineP : public dollar::Engine { class EngineP : public dollar::Engine {
@ -27,11 +27,11 @@ namespace dollar {
void setNumberPointInGesture(size_t _value); void setNumberPointInGesture(size_t _value);
size_t getNumberPointInGesture(); size_t getNumberPointInGesture();
protected: protected:
std::vector<ememory::SharedPtr<dollar::GestureP>> m_gestures; //!< List of all loaded gesture in the engine etk::Vector<ememory::SharedPtr<dollar::GestureP>> m_gestures; //!< List of all loaded gesture in the engine
public: public:
EngineP(); EngineP();
dollar::Results recognize2(const std::vector<std::vector<vec2>>& _paths) override; dollar::Results recognize2(const etk::Vector<etk::Vector<vec2>>& _paths) override;
bool loadGesture(const std::string& _filename) override; bool loadGesture(const etk::String& _filename) override;
void addGesture(ememory::SharedPtr<dollar::Gesture> _gesture) override; void addGesture(ememory::SharedPtr<dollar::Gesture> _gesture) override;
}; };
} }

View File

@ -94,13 +94,13 @@ float dollar::EnginePPlus::getPenalityAspectRatio() {
} }
float dollar::EnginePPlus::calculatePPlusDistanceSimple(const std::vector<vec2>& _points, float dollar::EnginePPlus::calculatePPlusDistanceSimple(const etk::Vector<vec2>& _points,
const std::vector<vec2>& _reference, const etk::Vector<vec2>& _reference,
std::vector<std::pair<int32_t, int32_t>>& _dataDebug) { etk::Vector<etk::Pair<int32_t, int32_t>>& _dataDebug) {
std::vector<float> distance; // note: use square distance (faster, we does not use std::sqrt()) etk::Vector<float> distance; // note: use square distance (faster, we does not use std::sqrt())
distance.resize(_points.size(), MAX_FLOAT); distance.resize(_points.size(), MAX_FLOAT);
// point Id that is link on the reference. // point Id that is link on the reference.
std::vector<int32_t> usedId; etk::Vector<int32_t> usedId;
usedId.resize(_points.size(), -1); usedId.resize(_points.size(), -1);
for (size_t iii=0; iii<_points.size(); iii++) { for (size_t iii=0; iii<_points.size(); iii++) {
float bestDistance = MAX_FLOAT; float bestDistance = MAX_FLOAT;
@ -144,7 +144,7 @@ float dollar::EnginePPlus::calculatePPlusDistanceSimple(const std::vector<vec2>&
for (size_t kkk=0; kkk<usedId.size(); ++kkk) { for (size_t kkk=0; kkk<usedId.size(); ++kkk) {
if (usedId[kkk] != -1) { if (usedId[kkk] != -1) {
_dataDebug.push_back(std::make_pair(kkk, usedId[kkk])); _dataDebug.pushBack(etk::makePair(kkk, usedId[kkk]));
} }
} }
DOLLAR_DEBUG("test distance : " << fullDistance << " nbTestNotUsed=" << nbTestNotUsed << " nbReferenceNotUsed=" << nbReferenceNotUsed); DOLLAR_DEBUG("test distance : " << fullDistance << " nbTestNotUsed=" << nbTestNotUsed << " nbReferenceNotUsed=" << nbReferenceNotUsed);
@ -152,15 +152,15 @@ float dollar::EnginePPlus::calculatePPlusDistanceSimple(const std::vector<vec2>&
} }
float dollar::EnginePPlus::calculatePPlusDistance(const std::vector<vec2>& _points, float dollar::EnginePPlus::calculatePPlusDistance(const etk::Vector<vec2>& _points,
const std::vector<vec2>& _reference, const etk::Vector<vec2>& _reference,
std::vector<std::pair<int32_t, int32_t>>& _dataDebug, etk::Vector<etk::Pair<int32_t, int32_t>>& _dataDebug,
float _inputAspectRatio, float _inputAspectRatio,
float _referenceAspectRatio) { float _referenceAspectRatio) {
std::vector<float> distance; // note: use square distance (faster, we does not use std::sqrt()) etk::Vector<float> distance; // note: use square distance (faster, we does not use std::sqrt())
distance.resize(_points.size(), MAX_FLOAT); distance.resize(_points.size(), MAX_FLOAT);
// point Id that is link on the reference. // point Id that is link on the reference.
std::vector<int32_t> usedId; etk::Vector<int32_t> usedId;
usedId.resize(_reference.size(), -1); usedId.resize(_reference.size(), -1);
for (int32_t iii=0; iii<int32_t(_points.size()); iii++) { for (int32_t iii=0; iii<int32_t(_points.size()); iii++) {
if (distance[iii] < 100.0) { if (distance[iii] < 100.0) {
@ -224,7 +224,7 @@ float dollar::EnginePPlus::calculatePPlusDistance(const std::vector<vec2>& _poin
for (size_t kkk=0; kkk<usedId.size(); ++kkk) { for (size_t kkk=0; kkk<usedId.size(); ++kkk) {
if (usedId[kkk] != -1) { if (usedId[kkk] != -1) {
_dataDebug.push_back(std::make_pair(usedId[kkk], kkk)); _dataDebug.pushBack(etk::makePair(usedId[kkk], kkk));
} }
} }
DOLLAR_DEBUG("test distance : " << fullDistance << " nbTestNotUsed=" << nbTestNotUsed << " nbReferenceNotUsed=" << nbReferenceNotUsed); DOLLAR_DEBUG("test distance : " << fullDistance << " nbTestNotUsed=" << nbTestNotUsed << " nbReferenceNotUsed=" << nbReferenceNotUsed);
@ -233,7 +233,7 @@ float dollar::EnginePPlus::calculatePPlusDistance(const std::vector<vec2>& _poin
bool dollar::EnginePPlus::loadGesture(const std::string& _filename) { bool dollar::EnginePPlus::loadGesture(const etk::String& _filename) {
ememory::SharedPtr<dollar::Gesture> ref = ememory::makeShared<dollar::GesturePPlus>(); ememory::SharedPtr<dollar::Gesture> ref = ememory::makeShared<dollar::GesturePPlus>();
DOLLAR_DEBUG("Load Gesture: " << _filename); DOLLAR_DEBUG("Load Gesture: " << _filename);
if (ref->load(_filename) == true) { if (ref->load(_filename) == true) {
@ -247,17 +247,17 @@ void dollar::EnginePPlus::addGesture(ememory::SharedPtr<dollar::Gesture> _gestur
ememory::SharedPtr<dollar::GesturePPlus> gest = ememory::dynamicPointerCast<dollar::GesturePPlus>(_gesture); ememory::SharedPtr<dollar::GesturePPlus> gest = ememory::dynamicPointerCast<dollar::GesturePPlus>(_gesture);
if (gest != nullptr) { if (gest != nullptr) {
gest->configure(m_PPlusDistance, m_scaleKeepRatio); gest->configure(m_PPlusDistance, m_scaleKeepRatio);
m_gestures.push_back(gest); m_gestures.pushBack(gest);
} }
} }
static void storeSVG(const std::string& _fileName, static void storeSVG(const etk::String& _fileName,
const ememory::SharedPtr<dollar::GesturePPlus>& _gesture, const ememory::SharedPtr<dollar::GesturePPlus>& _gesture,
const std::vector<std::vector<vec2>>& _strokes, const etk::Vector<etk::Vector<vec2>>& _strokes,
const std::vector<vec2>& _points, const etk::Vector<vec2>& _points,
std::vector<std::pair<int32_t, int32_t>> _links, etk::Vector<etk::Pair<int32_t, int32_t>> _links,
bool _keepAspectRatio) { bool _keepAspectRatio) {
std::string data("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); etk::String data("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
data += "<svg height=\"100\" width=\"100\">\n"; data += "<svg height=\"100\" width=\"100\">\n";
for (auto &itLines : dollar::scaleToOne(_gesture->getPath(), _keepAspectRatio)) { for (auto &itLines : dollar::scaleToOne(_gesture->getPath(), _keepAspectRatio)) {
data += " <polyline fill=\"none\" stroke=\"black\" stroke-opacity=\"0.8\" stroke-width=\"2\"\n"; data += " <polyline fill=\"none\" stroke=\"black\" stroke-opacity=\"0.8\" stroke-width=\"2\"\n";
@ -268,7 +268,7 @@ static void storeSVG(const std::string& _fileName,
data += " "; data += " ";
} }
first = false; first = false;
data += etk::to_string(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f); data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
} }
data += "\"\n"; data += "\"\n";
data += " />\n"; data += " />\n";
@ -282,25 +282,25 @@ static void storeSVG(const std::string& _fileName,
data += " "; data += " ";
} }
first = false; first = false;
data += etk::to_string(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f); data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
} }
data += "\"\n"; data += "\"\n";
data += " />\n"; data += " />\n";
} }
std::vector<vec2> refListPoint = _gesture->getEnginePoints(); etk::Vector<vec2> refListPoint = _gesture->getEnginePoints();
for (auto &it : refListPoint) { for (auto &it : refListPoint) {
data += " <circle fill=\"red\" cx=\"" + etk::to_string(it.x()*100.0f) + "\" cy=\"" + etk::to_string((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n"; data += " <circle fill=\"red\" cx=\"" + etk::toString(it.x()*100.0f) + "\" cy=\"" + etk::to_string((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n";
} }
std::vector<vec2> testListPoint = _points; etk::Vector<vec2> testListPoint = _points;
for (auto &it : testListPoint) { for (auto &it : testListPoint) {
data += " <circle fill=\"orange\" cx=\"" + etk::to_string(it.x()*100.0f) + "\" cy=\"" + etk::to_string((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n"; data += " <circle fill=\"orange\" cx=\"" + etk::toString(it.x()*100.0f) + "\" cy=\"" + etk::to_string((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n";
} }
for (auto &it : _links) { for (auto &it : _links) {
data += " <polyline fill=\"none\" stroke=\"blue\" stroke-opacity=\"0.8\" stroke-width=\"0.5\"\n"; data += " <polyline fill=\"none\" stroke=\"blue\" stroke-opacity=\"0.8\" stroke-width=\"0.5\"\n";
data += " points=\""; data += " points=\"";
data += etk::to_string(refListPoint[it.second].x()*100.0f) + "," + etk::to_string((1.0-refListPoint[it.second].y())*100.0f); data += etk::toString(refListPoint[it.second].x()*100.0f) + "," + etk::to_string((1.0-refListPoint[it.second].y())*100.0f);
data += " "; data += " ";
data += etk::to_string(testListPoint[it.first].x()*100.0f) + "," + etk::to_string((1.0-testListPoint[it.first].y())*100.0f); data += etk::toString(testListPoint[it.first].x()*100.0f) + "," + etk::to_string((1.0-testListPoint[it.first].y())*100.0f);
data += "\"\n"; data += "\"\n";
data += " />\n"; data += " />\n";
} }
@ -309,8 +309,8 @@ static void storeSVG(const std::string& _fileName,
} }
dollar::Results dollar::EnginePPlus::recognize2(const std::vector<std::vector<vec2>>& _strokes) { dollar::Results dollar::EnginePPlus::recognize2(const etk::Vector<etk::Vector<vec2>>& _strokes) {
std::vector<vec2> points = dollar::normalizePathToPoints(_strokes, m_PPlusDistance, m_scaleKeepRatio); etk::Vector<vec2> points = dollar::normalizePathToPoints(_strokes, m_PPlusDistance, m_scaleKeepRatio);
float inputAspectRatio = dollar::getAspectRatio(_strokes); float inputAspectRatio = dollar::getAspectRatio(_strokes);
// Keep maximum 5 results ... // Keep maximum 5 results ...
float bestDistance[m_nbResult]; float bestDistance[m_nbResult];
@ -335,13 +335,13 @@ dollar::Results dollar::EnginePPlus::recognize2(const std::vector<std::vector<ve
} }
*/ */
float distance = MAX_FLOAT; float distance = MAX_FLOAT;
std::vector<std::pair<int32_t, int32_t>> dataPair; etk::Vector<etk::Pair<int32_t, int32_t>> dataPair;
distance = calculatePPlusDistance(points, gesture->getEnginePoints(), dataPair, inputAspectRatio, gesture->getAspectRatio()); distance = calculatePPlusDistance(points, gesture->getEnginePoints(), dataPair, inputAspectRatio, gesture->getAspectRatio());
//distance = calculatePPlusDistanceSimple(points, gesture->getEnginePoints(), dataPair); //distance = calculatePPlusDistanceSimple(points, gesture->getEnginePoints(), dataPair);
if (nbStrokeRef != nbStrokeSample) { if (nbStrokeRef != nbStrokeSample) {
distance += 0.1f*float(std::abs(nbStrokeRef-nbStrokeSample)); distance += 0.1f*float(std::abs(nbStrokeRef-nbStrokeSample));
} }
//storeSVG("out_dollar/lib/recognizePPlus/" + gesture->getName() + "_" + etk::to_string(gesture->getId()) + ".svg", gesture, _strokes, points, dataPair, m_scaleKeepRatio); //storeSVG("out_dollar/lib/recognizePPlus/" + gesture->getName() + "_" + etk::toString(gesture->getId()) + ".svg", gesture, _strokes, points, dataPair, m_scaleKeepRatio);
for (size_t kkk=0; kkk<m_nbResult; ++kkk) { for (size_t kkk=0; kkk<m_nbResult; ++kkk) {
if (distance < bestDistance[kkk]) { if (distance < bestDistance[kkk]) {
if (kkk == 0) { if (kkk == 0) {
@ -371,7 +371,7 @@ dollar::Results dollar::EnginePPlus::recognize2(const std::vector<std::vector<ve
Results res; Results res;
for (size_t iii=0; iii<m_nbResult; ++iii) { for (size_t iii=0; iii<m_nbResult; ++iii) {
if (-1 != indexOfBestMatch[iii]) { if (-1 != indexOfBestMatch[iii]) {
//float score = std::max((2.0 - bestDistance[iii])/2.0, 0.0); //float score = etk::max((2.0 - bestDistance[iii])/2.0, 0.0);
float score = bestDistance[iii]; float score = bestDistance[iii];
res.addValue(m_gestures[indexOfBestMatch[iii]]->getName(), score); res.addValue(m_gestures[indexOfBestMatch[iii]]->getName(), score);
} }

View File

@ -12,7 +12,7 @@
#include <dollar/GesturePPlus.hpp> #include <dollar/GesturePPlus.hpp>
#include <limits> #include <limits>
#include <iostream> #include <iostream>
#include <string> #include <etk/String.hpp>
namespace dollar { namespace dollar {
class EnginePPlus : public dollar::Engine { class EnginePPlus : public dollar::Engine {
@ -47,21 +47,21 @@ namespace dollar {
void setPenalityAspectRatio(float _value); void setPenalityAspectRatio(float _value);
float getPenalityAspectRatio(); float getPenalityAspectRatio();
protected: protected:
std::vector<ememory::SharedPtr<dollar::GesturePPlus>> m_gestures; //!< List of all loaded gesture in the engine etk::Vector<ememory::SharedPtr<dollar::GesturePPlus>> m_gestures; //!< List of all loaded gesture in the engine
public: public:
EnginePPlus(); EnginePPlus();
dollar::Results recognize2(const std::vector<std::vector<vec2>>& _paths) override; dollar::Results recognize2(const etk::Vector<etk::Vector<vec2>>& _paths) override;
bool loadGesture(const std::string& _filename) override; bool loadGesture(const etk::String& _filename) override;
void addGesture(ememory::SharedPtr<dollar::Gesture> _gesture) override; void addGesture(ememory::SharedPtr<dollar::Gesture> _gesture) override;
protected: protected:
float calculatePPlusDistance(const std::vector<vec2>& _points, float calculatePPlusDistance(const etk::Vector<vec2>& _points,
const std::vector<vec2>& _reference, const etk::Vector<vec2>& _reference,
std::vector<std::pair<int32_t, int32_t>>& _dataDebug, etk::Vector<etk::Pair<int32_t, int32_t>>& _dataDebug,
float _inputAspectRatio, float _inputAspectRatio,
float _referenceAspectRatio); float _referenceAspectRatio);
float calculatePPlusDistanceSimple(const std::vector<vec2>& _points, float calculatePPlusDistanceSimple(const etk::Vector<vec2>& _points,
const std::vector<vec2>& _reference, const etk::Vector<vec2>& _reference,
std::vector<std::pair<int32_t, int32_t>>& _dataDebug); etk::Vector<etk::Pair<int32_t, int32_t>>& _dataDebug);
}; };
} }

View File

@ -13,9 +13,9 @@
#include <etk/stdTools.hpp> #include <etk/stdTools.hpp>
static std::vector<std::vector<vec2>> loadPointsJson(const ejson::Document& _doc) { static etk::Vector<etk::Vector<vec2>> loadPointsJson(const ejson::Document& _doc) {
// extract lines: // extract lines:
std::vector<std::vector<vec2>> out; etk::Vector<etk::Vector<vec2>> out;
const ejson::Array listOfLines = _doc["data"].toArray(); const ejson::Array listOfLines = _doc["data"].toArray();
if (listOfLines.exist() == false) { if (listOfLines.exist() == false) {
DOLLAR_WARNING("Reference element has no element named 'data' " << _doc["data"]); DOLLAR_WARNING("Reference element has no element named 'data' " << _doc["data"]);
@ -23,19 +23,19 @@ static std::vector<std::vector<vec2>> loadPointsJson(const ejson::Document& _doc
} }
for (auto itLines : listOfLines) { for (auto itLines : listOfLines) {
ejson::Array listOfpoint = itLines.toArray(); ejson::Array listOfpoint = itLines.toArray();
std::vector<vec2> line; etk::Vector<vec2> line;
for (auto itPoints : listOfpoint) { for (auto itPoints : listOfpoint) {
ejson::Array pointsArray = itPoints.toArray(); ejson::Array pointsArray = itPoints.toArray();
line.push_back(vec2(pointsArray[0].toNumber().get(), pointsArray[1].toNumber().get())); line.pushBack(vec2(pointsArray[0].toNumber().get(), pointsArray[1].toNumber().get()));
} }
if (line.size() > 1) { if (line.size() > 1) {
out.push_back(std::move(line)); out.pushBack(etk::move(line));
} }
} }
return out; return out;
} }
std::vector<std::vector<vec2>> dollar::loadPoints(const std::string& _fileName, std::string* _label, std::string* _type) { etk::Vector<etk::Vector<vec2>> dollar::loadPoints(const etk::String& _fileName, etk::String* _label, std::string* _type) {
ejson::Document doc; ejson::Document doc;
doc.load(_fileName); doc.load(_fileName);
if (_label != nullptr) { if (_label != nullptr) {
@ -45,17 +45,17 @@ std::vector<std::vector<vec2>> dollar::loadPoints(const std::string& _fileName,
*_type = doc["type"].toString().get(); *_type = doc["type"].toString().get();
} }
// extract lines: // extract lines:
std::vector<std::vector<vec2>> out; etk::Vector<etk::Vector<vec2>> out;
ejson::Array listOfLines = doc["data"].toArray(); ejson::Array listOfLines = doc["data"].toArray();
for (auto itLines : listOfLines) { for (auto itLines : listOfLines) {
ejson::Array listOfpoint = itLines.toObject()["list"].toArray(); ejson::Array listOfpoint = itLines.toObject()["list"].toArray();
std::vector<vec2> line; etk::Vector<vec2> line;
for (auto itPoints : listOfpoint) { for (auto itPoints : listOfpoint) {
ejson::Array pointsArray = itPoints.toArray(); ejson::Array pointsArray = itPoints.toArray();
line.push_back(vec2(pointsArray[0].toNumber().get(), pointsArray[1].toNumber().get())); line.pushBack(vec2(pointsArray[0].toNumber().get(), pointsArray[1].toNumber().get()));
} }
if (line.size() > 1) { if (line.size() > 1) {
out.push_back(std::move(line)); out.pushBack(etk::move(line));
} }
} }
return out; return out;
@ -70,8 +70,8 @@ dollar::Gesture::Gesture():
} }
bool dollar::Gesture::load(const std::string& _fileName) { bool dollar::Gesture::load(const etk::String& _fileName) {
std::string tmpName = etk::tolower(_fileName); etk::String tmpName = etk::tolower(_fileName);
if (etk::end_with(tmpName, ".json") == true) { if (etk::end_with(tmpName, ".json") == true) {
return loadJSON(_fileName); return loadJSON(_fileName);
} else if (etk::end_with(tmpName, ".svg") == true) { } else if (etk::end_with(tmpName, ".svg") == true) {
@ -82,7 +82,7 @@ bool dollar::Gesture::load(const std::string& _fileName) {
return false; return false;
} }
bool dollar::Gesture::loadJSON(const std::string& _fileName) { bool dollar::Gesture::loadJSON(const etk::String& _fileName) {
ejson::Document doc; ejson::Document doc;
doc.load(_fileName); doc.load(_fileName);
if (doc["type"].toString().get() != "REFERENCE") { if (doc["type"].toString().get() != "REFERENCE") {
@ -96,10 +96,10 @@ bool dollar::Gesture::loadJSON(const std::string& _fileName) {
return true; return true;
} }
bool dollar::Gesture::loadSVG(const std::string& _fileName) { bool dollar::Gesture::loadSVG(const etk::String& _fileName) {
esvg::Document doc; esvg::Document doc;
doc.load(_fileName); doc.load(_fileName);
std::vector<std::string> plop = etk::split(_fileName, '.'); etk::Vector<etk::String> plop = etk::split(_fileName, '.');
plop = etk::split(plop[plop.size() -2], '/'); plop = etk::split(plop[plop.size() -2], '/');
plop = etk::split(plop[plop.size() -1], '_'); plop = etk::split(plop[plop.size() -1], '_');
m_name = plop[0]; m_name = plop[0];
@ -116,8 +116,8 @@ bool dollar::Gesture::loadSVG(const std::string& _fileName) {
} }
bool dollar::Gesture::store(const std::string& _fileName) { bool dollar::Gesture::store(const etk::String& _fileName) {
std::string tmpName = etk::tolower(_fileName); etk::String tmpName = etk::tolower(_fileName);
if (etk::end_with(tmpName, ".json") == true) { if (etk::end_with(tmpName, ".json") == true) {
storeJSON(_fileName); storeJSON(_fileName);
return true; return true;
@ -130,7 +130,7 @@ bool dollar::Gesture::store(const std::string& _fileName) {
return false; return false;
} }
void dollar::Gesture::storeJSON(const std::string& _fileName) { void dollar::Gesture::storeJSON(const etk::String& _fileName) {
ejson::Document doc; ejson::Document doc;
doc.add("type", ejson::String("REFERENCE")); doc.add("type", ejson::String("REFERENCE"));
doc.add("value", ejson::String(m_name)); doc.add("value", ejson::String(m_name));
@ -151,9 +151,9 @@ void dollar::Gesture::storeJSON(const std::string& _fileName) {
doc.store(_fileName); doc.store(_fileName);
} }
void dollar::Gesture::storeSVG(const std::string& _fileName, bool _storeDot) { void dollar::Gesture::storeSVG(const etk::String& _fileName, bool _storeDot) {
std::vector<std::vector<vec2>> strokes = dollar::scaleToOne(m_path, true); etk::Vector<etk::Vector<vec2>> strokes = dollar::scaleToOne(m_path, true);
std::string data("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); etk::String data("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
data += "<svg height=\"100\" width=\"100\">\n"; data += "<svg height=\"100\" width=\"100\">\n";
for (auto &itLines : strokes) { for (auto &itLines : strokes) {
data += " <polyline fill=\"none\" stroke=\"black\" stroke-opacity=\"1\" stroke-width=\"2\"\n"; data += " <polyline fill=\"none\" stroke=\"black\" stroke-opacity=\"1\" stroke-width=\"2\"\n";
@ -164,7 +164,7 @@ void dollar::Gesture::storeSVG(const std::string& _fileName, bool _storeDot) {
data += " "; data += " ";
} }
first = false; first = false;
data += etk::to_string(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f); data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
} }
data += "\"\n"; data += "\"\n";
data += " />\n"; data += " />\n";
@ -172,7 +172,7 @@ void dollar::Gesture::storeSVG(const std::string& _fileName, bool _storeDot) {
if (_storeDot == true) { if (_storeDot == true) {
/* /*
for (auto &it : m_enginePoints) { for (auto &it : m_enginePoints) {
data += " <circle fill=\"red\" cx=\"" + etk::to_string(it.x()*100.0f) + "\" cy=\"" + etk::to_string((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n"; data += " <circle fill=\"red\" cx=\"" + etk::toString(it.x()*100.0f) + "\" cy=\"" + etk::to_string((1.0-it.y())*100.0f) + "\" r=\"0.6\"/>\n";
} }
*/ */
} }
@ -180,7 +180,7 @@ void dollar::Gesture::storeSVG(const std::string& _fileName, bool _storeDot) {
etk::FSNodeWriteAllData(_fileName, data); etk::FSNodeWriteAllData(_fileName, data);
} }
void dollar::Gesture::set(const std::string& _name, uint32_t _subId, std::vector<std::vector<vec2>> _path) { void dollar::Gesture::set(const etk::String& _name, uint32_t _subId, etk::Vector<etk::Vector<vec2>> _path) {
m_name = _name; m_name = _name;
m_subId = _subId; m_subId = _subId;
m_path = _path; m_path = _path;

View File

@ -8,15 +8,15 @@
#include <etk/math/Vector2D.hpp> #include <etk/math/Vector2D.hpp>
#include <ememory/memory.hpp> #include <ememory/memory.hpp>
#include <string> #include <etk/String.hpp>
namespace dollar { namespace dollar {
class Gesture { class Gesture {
protected: protected:
std::string m_name; etk::String m_name;
uint32_t m_subId; uint32_t m_subId;
float m_aspectRatio; float m_aspectRatio;
std::vector<std::vector<vec2>> m_path; etk::Vector<etk::Vector<vec2>> m_path;
public: public:
Gesture(); Gesture();
virtual ~Gesture() = default; virtual ~Gesture() = default;
@ -26,16 +26,16 @@ namespace dollar {
float getKeepAspectRatio() { float getKeepAspectRatio() {
return m_aspectRatio; return m_aspectRatio;
} }
bool load(const std::string& _filename); bool load(const etk::String& _filename);
bool store(const std::string& _filename); bool store(const etk::String& _filename);
void set(const std::string& _name, uint32_t _subId, std::vector<std::vector<vec2>> _path); void set(const etk::String& _name, uint32_t _subId, etk::Vector<etk::Vector<vec2>> _path);
protected: protected:
bool loadJSON(const std::string& _filename); bool loadJSON(const etk::String& _filename);
bool loadSVG(const std::string& _filename); bool loadSVG(const etk::String& _filename);
void storeJSON(const std::string& _filename); void storeJSON(const etk::String& _filename);
void storeSVG(const std::string& _filename, bool _storeDot=false); void storeSVG(const etk::String& _filename, bool _storeDot=false);
public: public:
const std::string& getName() { const etk::String& getName() {
return m_name; return m_name;
} }
const uint32_t& getId() { const uint32_t& getId() {
@ -46,5 +46,5 @@ namespace dollar {
* @brief Load all point from a specific file * @brief Load all point from a specific file
* *
*/ */
std::vector<std::vector<vec2>> loadPoints(const std::string& _fileName, std::string* _label=nullptr, std::string* _type=nullptr); etk::Vector<etk::Vector<vec2>> loadPoints(const etk::String& _fileName, etk::String* _label=nullptr, std::string* _type=nullptr);
} }

View File

@ -24,16 +24,16 @@ void dollar::GestureN::configure(float _startAngleIndex, size_t _nbSample, bool
m_engineStartV.clear(); m_engineStartV.clear();
m_path2 = dollar::scaleToOne(m_path, _keepAspectRatio); m_path2 = dollar::scaleToOne(m_path, _keepAspectRatio);
// for debug only // for debug only
//storeSVG("out_dollar/lib/gestures/" + m_name + "_" + etk::to_string(m_subId) + ".svg", true); //storeSVG("out_dollar/lib/gestures/" + m_name + "_" + etk::toString(m_subId) + ".svg", true);
// Simplyfy paths // Simplyfy paths
std::vector<std::vector<vec2>> uniPath = dollar::makeReferenceStrokes(m_path); etk::Vector<etk::Vector<vec2>> uniPath = dollar::makeReferenceStrokes(m_path);
// normalize paths // normalize paths
for (auto &it : uniPath) { for (auto &it : uniPath) {
std::vector<vec2> val = dollar::normalizePath(it, _nbSample, _ignoreRotation, _keepAspectRatio); etk::Vector<vec2> val = dollar::normalizePath(it, _nbSample, _ignoreRotation, _keepAspectRatio);
m_enginePath.push_back(val); m_enginePath.pushBack(val);
// calculate start vector: // calculate start vector:
vec2 startv = dollar::getStartVector(val, _startAngleIndex); vec2 startv = dollar::getStartVector(val, _startAngleIndex);
m_engineStartV.push_back(startv); m_engineStartV.pushBack(startv);
m_engineVector.push_back(dollar::normalyse(val)); m_engineVector.pushBack(dollar::normalyse(val));
} }
} }

View File

@ -8,35 +8,35 @@
#include <etk/math/Vector2D.hpp> #include <etk/math/Vector2D.hpp>
#include <dollar/Gesture.hpp> #include <dollar/Gesture.hpp>
#include <string> #include <etk/String.hpp>
namespace dollar { namespace dollar {
class GestureN : public dollar::Gesture { class GestureN : public dollar::Gesture {
protected: protected:
std::vector<std::vector<vec2>> m_path2; etk::Vector<etk::Vector<vec2>> m_path2;
public: public:
GestureN(); GestureN();
public: public:
const std::vector<std::vector<vec2>>& getPath() const { const etk::Vector<etk::Vector<vec2>>& getPath() const {
return m_path2; return m_path2;
} }
std::vector<std::vector<vec2>>& getPath() { etk::Vector<etk::Vector<vec2>>& getPath() {
return m_path2; return m_path2;
} }
protected: protected:
std::vector<std::vector<vec2>> m_enginePath; // Singulized path with every conbinaison etk::Vector<etk::Vector<vec2>> m_enginePath; // Singulized path with every conbinaison
std::vector<std::vector<vec2>> m_engineVector; etk::Vector<etk::Vector<vec2>> m_engineVector;
std::vector<vec2> m_engineStartV; etk::Vector<vec2> m_engineStartV;
public: public:
// Configure the reference gesture for recognition... // Configure the reference gesture for recognition...
void configure(float _startAngleIndex, size_t _nbSample, bool _ignoreRotation, bool _keepAspectRatio=false); void configure(float _startAngleIndex, size_t _nbSample, bool _ignoreRotation, bool _keepAspectRatio=false);
size_t getEngineSize() const { size_t getEngineSize() const {
return m_enginePath.size(); return m_enginePath.size();
} }
const std::vector<vec2>& getEnginePath(size_t _id) const { const etk::Vector<vec2>& getEnginePath(size_t _id) const {
return m_enginePath[_id]; return m_enginePath[_id];
} }
const std::vector<vec2>& getEngineVector(size_t _id) const { const etk::Vector<vec2>& getEngineVector(size_t _id) const {
return m_engineVector[_id]; return m_engineVector[_id];
} }
const vec2& getEngineStartVector(size_t _id) const { const vec2& getEngineStartVector(size_t _id) const {

View File

@ -20,6 +20,6 @@ dollar::GestureP::GestureP() {
void dollar::GestureP::configure(size_t _nbSample) { void dollar::GestureP::configure(size_t _nbSample) {
m_enginePoints.clear(); m_enginePoints.clear();
// Generates dots: // Generates dots:
std::vector<vec2> points = dollar::combineStrokes(m_path); etk::Vector<vec2> points = dollar::combineStrokes(m_path);
m_enginePoints = dollar::normalizePath(points, _nbSample, false, false); m_enginePoints = dollar::normalizePath(points, _nbSample, false, false);
} }

View File

@ -8,24 +8,24 @@
#include <etk/math/Vector2D.hpp> #include <etk/math/Vector2D.hpp>
#include <dollar/Gesture.hpp> #include <dollar/Gesture.hpp>
#include <string> #include <etk/String.hpp>
namespace dollar { namespace dollar {
class GestureP : public dollar::Gesture { class GestureP : public dollar::Gesture {
public: public:
GestureP(); GestureP();
protected: protected:
std::vector<vec2> m_enginePoints; etk::Vector<vec2> m_enginePoints;
public: public:
// Configure the reference gesture for recognition... // Configure the reference gesture for recognition...
void configure(size_t _nbSample); void configure(size_t _nbSample);
const std::vector<vec2>& getEnginePoints() const { const etk::Vector<vec2>& getEnginePoints() const {
return m_enginePoints; return m_enginePoints;
} }
const std::vector<vec2>& getPath() const { const etk::Vector<vec2>& getPath() const {
return m_enginePoints; return m_enginePoints;
} }
std::vector<vec2>& getPath() { etk::Vector<vec2>& getPath() {
return m_enginePoints; return m_enginePoints;
} }
}; };

View File

@ -8,25 +8,25 @@
#include <etk/math/Vector2D.hpp> #include <etk/math/Vector2D.hpp>
#include <dollar/Gesture.hpp> #include <dollar/Gesture.hpp>
#include <string> #include <etk/String.hpp>
namespace dollar { namespace dollar {
class GesturePPlus : public dollar::Gesture { class GesturePPlus : public dollar::Gesture {
public: public:
GesturePPlus(); GesturePPlus();
protected: protected:
std::vector<vec2> m_enginePoints; etk::Vector<vec2> m_enginePoints;
float m_aspectRatio; // original aspect ratio float m_aspectRatio; // original aspect ratio
public: public:
// Configure the reference gesture for recognition... // Configure the reference gesture for recognition...
void configure(float _distance, bool _keepAspectRatio); void configure(float _distance, bool _keepAspectRatio);
const std::vector<vec2>& getEnginePoints() const { const etk::Vector<vec2>& getEnginePoints() const {
return m_enginePoints; return m_enginePoints;
} }
const std::vector<std::vector<vec2>>& getPath() const { const etk::Vector<etk::Vector<vec2>>& getPath() const {
return m_path; return m_path;
} }
std::vector<std::vector<vec2>>& getPath() { etk::Vector<etk::Vector<vec2>>& getPath() {
return m_path; return m_path;
} }
const float& getAspectRatio() const { const float& getAspectRatio() const {

View File

@ -13,7 +13,7 @@ dollar::Rectangle::Rectangle(const vec2& _pos, const vec2& _size):
m_size(_size) { m_size(_size) {
} }
dollar::Rectangle::Rectangle(const std::vector<vec2>& _points) { dollar::Rectangle::Rectangle(const etk::Vector<vec2>& _points) {
vec2 minPos(MAX_FLOAT,MAX_FLOAT); vec2 minPos(MAX_FLOAT,MAX_FLOAT);
vec2 maxPos(-MAX_FLOAT,-MAX_FLOAT); vec2 maxPos(-MAX_FLOAT,-MAX_FLOAT);
for (auto &it : _points) { for (auto &it : _points) {
@ -23,7 +23,7 @@ dollar::Rectangle::Rectangle(const std::vector<vec2>& _points) {
m_pos = minPos; m_pos = minPos;
m_size = maxPos-minPos; m_size = maxPos-minPos;
} }
dollar::Rectangle::Rectangle(const std::vector<std::vector<vec2>>& _points) { dollar::Rectangle::Rectangle(const etk::Vector<etk::Vector<vec2>>& _points) {
vec2 minPos(MAX_FLOAT,MAX_FLOAT); vec2 minPos(MAX_FLOAT,MAX_FLOAT);
vec2 maxPos(-MAX_FLOAT,-MAX_FLOAT); vec2 maxPos(-MAX_FLOAT,-MAX_FLOAT);
for (auto &it : _points) { for (auto &it : _points) {

View File

@ -7,9 +7,9 @@
#include <etk/math/Vector2D.hpp> #include <etk/math/Vector2D.hpp>
#include <cmath> #include <cmath>
#include <string> #include <etk/String.hpp>
#include <list> #include <list>
#include <vector> #include <etk/Vector.hpp>
namespace dollar { namespace dollar {
/** /**
@ -24,12 +24,12 @@ namespace dollar {
* @brief Create a rectangle as a bounding box * @brief Create a rectangle as a bounding box
* @param[in] _points List of point that is contained in this area * @param[in] _points List of point that is contained in this area
*/ */
Rectangle(const std::vector<vec2>& _points); Rectangle(const etk::Vector<vec2>& _points);
/** /**
* @brief Create a rectangle as a bounding box * @brief Create a rectangle as a bounding box
* @param[in] _points List of point that is contained in this area * @param[in] _points List of point that is contained in this area
*/ */
Rectangle(const std::vector<std::vector<vec2>>& _points); Rectangle(const etk::Vector<etk::Vector<vec2>>& _points);
/** /**
* @brief Create a rectangle with values * @brief Create a rectangle with values
* @param[in] _pos Start position * @param[in] _pos Start position

View File

@ -20,7 +20,7 @@ size_t dollar::Results::getSize() const {
return m_values.size(); return m_values.size();
} }
std::string dollar::Results::getName(size_t _id) const { etk::String dollar::Results::getName(size_t _id) const {
if (_id >= m_values.size()) { if (_id >= m_values.size()) {
DOLLAR_ERROR("request acces error result out of range (name)"); DOLLAR_ERROR("request acces error result out of range (name)");
return ""; return "";
@ -36,8 +36,8 @@ float dollar::Results::getConfidence(size_t _id) const {
return m_values[_id].confidence; return m_values[_id].confidence;
} }
void dollar::Results::addValue(const std::string& _name, float _confidence) { void dollar::Results::addValue(const etk::String& _name, float _confidence) {
m_values.push_back(ResultData(_name, _confidence)); m_values.pushBack(ResultData(_name, _confidence));
} }

View File

@ -6,14 +6,14 @@
#pragma once #pragma once
#include <cmath> #include <cmath>
#include <string> #include <etk/String.hpp>
#include <list> #include <list>
#include <vector> #include <etk/Vector.hpp>
namespace dollar { namespace dollar {
class ResultData { class ResultData {
public: public:
std::string value; etk::String value;
float confidence; float confidence;
#ifdef DOLLAR_ANNALYSER_ENABLE #ifdef DOLLAR_ANNALYSER_ENABLE
float distance; float distance;
@ -22,7 +22,7 @@ namespace dollar {
int32_t deltaDots; //!< number of dots in delta if > 0 ==> more dots in the reference int32_t deltaDots; //!< number of dots in delta if > 0 ==> more dots in the reference
#endif #endif
public: public:
ResultData(const std::string& _value, float _confidence): ResultData(const etk::String& _value, float _confidence):
value(_value), value(_value),
confidence(_confidence) { confidence(_confidence) {
@ -30,14 +30,14 @@ namespace dollar {
}; };
class Results { class Results {
protected: protected:
std::vector<ResultData> m_values; etk::Vector<ResultData> m_values;
public: public:
Results(); Results();
bool haveMatch() const; bool haveMatch() const;
size_t getSize() const; size_t getSize() const;
std::string getName(size_t _id=0) const; etk::String getName(size_t _id=0) const;
float getConfidence(size_t _id=0) const; float getConfidence(size_t _id=0) const;
void addValue(const std::string& _name, float _confidence); void addValue(const etk::String& _name, float _confidence);
void clear(); void clear();
}; };
} }

View File

@ -11,7 +11,7 @@
#include <algorithm> #include <algorithm>
float dollar::pathLength(std::vector<vec2> _points) { float dollar::pathLength(etk::Vector<vec2> _points) {
float distance = 0; float distance = 0;
for (size_t iii = 1; iii < _points.size(); ++iii) { for (size_t iii = 1; iii < _points.size(); ++iii) {
distance += (_points[iii] - _points[iii-1]).length(); distance += (_points[iii] - _points[iii-1]).length();
@ -19,7 +19,7 @@ float dollar::pathLength(std::vector<vec2> _points) {
return distance; return distance;
} }
vec2 dollar::getBaryCenter(const std::vector<vec2>& _points) { vec2 dollar::getBaryCenter(const etk::Vector<vec2>& _points) {
vec2 center(0,0); vec2 center(0,0);
for (auto &it : _points) { for (auto &it : _points) {
center += it; center += it;
@ -29,20 +29,20 @@ vec2 dollar::getBaryCenter(const std::vector<vec2>& _points) {
} }
// TODO: Change this with the use of a generic matrix 2D... // TODO: Change this with the use of a generic matrix 2D...
std::vector<vec2> dollar::rotateBy(const std::vector<vec2>& _points, float _rotation) { etk::Vector<vec2> dollar::rotateBy(const etk::Vector<vec2>& _points, float _rotation) {
std::vector<vec2> out; etk::Vector<vec2> out;
vec2 center = getBaryCenter(_points); vec2 center = getBaryCenter(_points);
float cosine = std::cos(_rotation); float cosine = std::cos(_rotation);
float sine = std::sin(_rotation); float sine = std::sin(_rotation);
for (auto &it : _points) { for (auto &it : _points) {
float qx = (it.x() - center.x()) * cosine - (it.y() - center.y()) * sine + center.x(); float qx = (it.x() - center.x()) * cosine - (it.y() - center.y()) * sine + center.x();
float qy = (it.x() - center.x()) * sine + (it.y() - center.y()) * cosine + center.y(); float qy = (it.x() - center.x()) * sine + (it.y() - center.y()) * cosine + center.y();
out.push_back(vec2(qx, qy)); out.pushBack(vec2(qx, qy));
} }
return out; return out;
} }
std::vector<vec2> dollar::rotateToZero(const std::vector<vec2>& _points) { etk::Vector<vec2> dollar::rotateToZero(const etk::Vector<vec2>& _points) {
vec2 center = getBaryCenter(_points); vec2 center = getBaryCenter(_points);
float rotation = std::atan2(center.y() - _points[0].y(), center.x() - _points[0].x()); float rotation = std::atan2(center.y() - _points[0].y(), center.x() - _points[0].x());
return rotateBy(_points, -rotation); return rotateBy(_points, -rotation);
@ -51,9 +51,9 @@ std::vector<vec2> dollar::rotateToZero(const std::vector<vec2>& _points) {
float maxKeepAspectRatio = 5.5f; 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) { etk::Vector<vec2> dollar::scaleToOne(const etk::Vector<vec2>& _points, bool _keepAspectRation) {
dollar::Rectangle box(_points); dollar::Rectangle box(_points);
std::vector<vec2> out; etk::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);
if (_keepAspectRation == true) { if (_keepAspectRation == true) {
@ -75,14 +75,14 @@ std::vector<vec2> dollar::scaleToOne(const std::vector<vec2>& _points, bool _kee
vec2 tmp = it - box.getPos(); vec2 tmp = it - box.getPos();
tmp *= scale; tmp *= scale;
tmp += offset; tmp += offset;
out.push_back(tmp); out.pushBack(tmp);
} }
return out; return out;
} }
std::vector<std::vector<vec2>> dollar::scaleToOne(const std::vector<std::vector<vec2>>& _points, bool _keepAspectRation) { etk::Vector<etk::Vector<vec2>> dollar::scaleToOne(const std::vector<std::vector<vec2>>& _points, bool _keepAspectRation) {
dollar::Rectangle box(_points); dollar::Rectangle box(_points);
std::vector<std::vector<vec2>> out; etk::Vector<etk::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);
if (_keepAspectRation == true) { if (_keepAspectRation == true) {
@ -101,34 +101,34 @@ std::vector<std::vector<vec2>> dollar::scaleToOne(const std::vector<std::vector<
} }
} }
for (auto &it : _points) { for (auto &it : _points) {
std::vector<vec2> stroke; etk::Vector<vec2> stroke;
for (auto &itPoint : it) { for (auto &itPoint : it) {
vec2 tmp = itPoint - box.getPos(); vec2 tmp = itPoint - box.getPos();
tmp *= scale; tmp *= scale;
tmp += offset; tmp += offset;
stroke.push_back(tmp); stroke.pushBack(tmp);
} }
out.push_back(stroke); out.pushBack(stroke);
} }
return out; return out;
} }
std::vector<vec2> dollar::translateBariCenterToZero(std::vector<vec2> _points) { etk::Vector<vec2> dollar::translateBariCenterToZero(etk::Vector<vec2> _points) {
std::vector<vec2> out; etk::Vector<vec2> out;
vec2 center = getBaryCenter(_points); vec2 center = getBaryCenter(_points);
for (auto &it :_points) { for (auto &it :_points) {
out.push_back(it - center); out.pushBack(it - center);
} }
return out; return out;
} }
static std::vector<vec2> discretize(std::vector<vec2> _points, float _interval) { static etk::Vector<vec2> discretize(etk::Vector<vec2> _points, float _interval) {
std::vector<vec2> out; etk::Vector<vec2> out;
if (_points.size() == 0) { if (_points.size() == 0) {
return out; return out;
} }
// same first point ==> no change // same first point ==> no change
out.push_back(_points.front()); out.pushBack(_points.front());
float distance = 0.0f; float distance = 0.0f;
// For all other point we have to resample elements // For all other point we have to resample elements
for (size_t iii=1; iii<_points.size(); ++iii) { for (size_t iii=1; iii<_points.size(); ++iii) {
@ -137,7 +137,7 @@ static std::vector<vec2> discretize(std::vector<vec2> _points, float _interval)
float tmpDist = (currentPoint-previousPoint).length(); float tmpDist = (currentPoint-previousPoint).length();
if ((distance + tmpDist) >= _interval) { if ((distance + tmpDist) >= _interval) {
vec2 point = previousPoint + (currentPoint - previousPoint) * ((_interval - distance) / tmpDist); vec2 point = previousPoint + (currentPoint - previousPoint) * ((_interval - distance) / tmpDist);
out.push_back(point); out.pushBack(point);
_points.insert(_points.begin() + iii, point); _points.insert(_points.begin() + iii, point);
distance = 0.0; distance = 0.0;
} else { } else {
@ -147,8 +147,8 @@ static std::vector<vec2> discretize(std::vector<vec2> _points, float _interval)
return out; return out;
} }
std::vector<vec2> dollar::resample(std::vector<vec2> _points, int32_t _nbPoints) { etk::Vector<vec2> dollar::resample(etk::Vector<vec2> _points, int32_t _nbPoints) {
std::vector<vec2> out; etk::Vector<vec2> out;
if (_points.size() == 0) { if (_points.size() == 0) {
return out; return out;
} }
@ -157,17 +157,17 @@ std::vector<vec2> dollar::resample(std::vector<vec2> _points, int32_t _nbPoints)
out = discretize(_points, interval); out = discretize(_points, interval);
// somtimes we fall a rounding-error short of adding the last point, so add it if so // somtimes we fall a rounding-error short of adding the last point, so add it if so
if (int64_t(out.size()) == (_nbPoints - 1)) { if (int64_t(out.size()) == (_nbPoints - 1)) {
out.push_back(_points.back()); out.pushBack(_points.back());
} }
return out; return out;
} }
std::vector<std::vector<vec2>> dollar::makeReferenceStrokes(const std::vector<std::vector<vec2>>& _strokes) { etk::Vector<etk::Vector<vec2>> dollar::makeReferenceStrokes(const std::vector<std::vector<vec2>>& _strokes) {
std::vector<std::vector<vec2>> out; etk::Vector<etk::Vector<vec2>> out;
// create the ordr of all possibilities of writing the strokes ... (ABC, ACB, BAC, BCA ...) // create the ordr of all possibilities of writing the strokes ... (ABC, ACB, BAC, BCA ...)
std::vector<size_t> order; etk::Vector<size_t> order;
for(size_t iii=0; iii<_strokes.size(); ++iii) { for(size_t iii=0; iii<_strokes.size(); ++iii) {
order.push_back(iii); order.pushBack(iii);
} }
// For all orders (every permutation of the path): // For all orders (every permutation of the path):
do { do {
@ -175,36 +175,36 @@ std::vector<std::vector<vec2>> dollar::makeReferenceStrokes(const std::vector<st
size_t nbPermutation = std::pow(2, order.size()); size_t nbPermutation = std::pow(2, order.size());
// we use the bit like a flag to know the order of the draw // we use the bit like a flag to know the order of the draw
for (size_t permut=0; permut<nbPermutation; ++permut) { for (size_t permut=0; permut<nbPermutation; ++permut) {
std::vector<vec2> stroke; etk::Vector<vec2> stroke;
for (size_t iii=0; iii<order.size(); ++iii) { for (size_t iii=0; iii<order.size(); ++iii) {
std::vector<vec2> pts = _strokes[order[iii]]; etk::Vector<vec2> pts = _strokes[order[iii]];
// check to permut the value order // check to permut the value order
if (((permut>>iii) & 0x01) == 1) { if (((permut>>iii) & 0x01) == 1) {
reverse(pts.begin(),pts.end()); reverse(pts.begin(),pts.end());
} }
// Add point in next of the path... // Add point in next of the path...
for (auto &it : pts) { for (auto &it : pts) {
stroke.push_back(it); stroke.pushBack(it);
} }
} }
// Add new generated stroke // Add new generated stroke
out.push_back(stroke); out.pushBack(stroke);
} }
} while (next_permutation(order.begin(), order.end())); } while (next_permutation(order.begin(), order.end()));
return out; return out;
} }
std::vector<vec2> dollar::combineStrokes(const std::vector<std::vector<vec2>>& _strokes) { etk::Vector<vec2> dollar::combineStrokes(const etk::Vector<std::vector<vec2>>& _strokes) {
std::vector<vec2> out; etk::Vector<vec2> out;
for (auto &it : _strokes) { for (auto &it : _strokes) {
for (auto &pointIt : it) { for (auto &pointIt : it) {
out.push_back(pointIt); out.pushBack(pointIt);
} }
} }
return out; return out;
} }
vec2 dollar::getStartVector(const std::vector<vec2>& _points, float _index) { vec2 dollar::getStartVector(const etk::Vector<vec2>& _points, float _index) {
DOLLAR_ASSERT(_index > 0, "index must be != of 0"); DOLLAR_ASSERT(_index > 0, "index must be != of 0");
if (_points.size() <= _index) { if (_points.size() <= _index) {
return vec2(1.0, 0.0); return vec2(1.0, 0.0);
@ -214,9 +214,9 @@ vec2 dollar::getStartVector(const std::vector<vec2>& _points, float _index) {
return vect / len; return vect / len;
} }
std::vector<vec2> dollar::normalyse(const std::vector<vec2>& _points) { etk::Vector<vec2> dollar::normalyse(const etk::Vector<vec2>& _points) {
float sum = 0.0; float sum = 0.0;
std::vector<vec2> out = _points; etk::Vector<vec2> out = _points;
for (auto &it : _points) { for (auto &it : _points) {
sum += it.length2(); sum += it.length2();
} }
@ -232,7 +232,7 @@ std::vector<vec2> dollar::normalyse(const std::vector<vec2>& _points) {
} }
std::vector<vec2> dollar::normalizePath(std::vector<vec2> _points, size_t _nbSample, bool _ignoreRotation, bool _keepAspectRatio) { etk::Vector<vec2> dollar::normalizePath(etk::Vector<vec2> _points, size_t _nbSample, bool _ignoreRotation, bool _keepAspectRatio) {
_points = dollar::resample(_points, _nbSample); _points = dollar::resample(_points, _nbSample);
if (_ignoreRotation == true) { if (_ignoreRotation == true) {
_points = rotateToZero(_points); _points = rotateToZero(_points);
@ -241,7 +241,7 @@ std::vector<vec2> dollar::normalizePath(std::vector<vec2> _points, size_t _nbSam
return translateBariCenterToZero(_points); return translateBariCenterToZero(_points);
} }
float dollar::getAspectRatio(std::vector<std::vector<vec2>> _points) { float dollar::getAspectRatio(etk::Vector<etk::Vector<vec2>> _points) {
dollar::Rectangle box(_points); dollar::Rectangle box(_points);
if (box.getSize().x() < box.getSize().y()) { if (box.getSize().x() < box.getSize().y()) {
return 1.0f - box.getSize().x() / box.getSize().y(); return 1.0f - box.getSize().x() / box.getSize().y();
@ -250,24 +250,24 @@ float dollar::getAspectRatio(std::vector<std::vector<vec2>> _points) {
} }
} }
std::vector<vec2> dollar::normalizePathToPoints(std::vector<std::vector<vec2>> _points, float _distance, bool _keepAspectRatio) { etk::Vector<vec2> dollar::normalizePathToPoints(etk::Vector<std::vector<vec2>> _points, float _distance, bool _keepAspectRatio) {
// Scale point to (0.0,0.0) position and (1.0,1.0) size // Scale point to (0.0,0.0) position and (1.0,1.0) size
_points = dollar::scaleToOne(_points, _keepAspectRatio); _points = dollar::scaleToOne(_points, _keepAspectRatio);
std::vector<vec2> out; etk::Vector<vec2> out;
for (auto &it : _points) { for (auto &it : _points) {
if (it.size() == 0) { if (it.size() == 0) {
continue; continue;
} }
if (it.size() == 1) { if (it.size() == 1) {
out.push_back(it[0]); out.pushBack(it[0]);
continue; continue;
} }
std::vector<vec2> tmp = discretize(it, _distance); etk::Vector<vec2> tmp = discretize(it, _distance);
for (auto &pointIt : tmp) { for (auto &pointIt : tmp) {
out.push_back(pointIt); out.pushBack(pointIt);
} }
if (tmp[tmp.size()-1] != it[it.size()-1]) { if (tmp[tmp.size()-1] != it[it.size()-1]) {
out.push_back(it[it.size()-1]); out.pushBack(it[it.size()-1]);
} }
} }
return out; return out;

View File

@ -14,13 +14,13 @@ namespace dollar {
* @param[in] _points List of point of the path * @param[in] _points List of point of the path
* @return the size of the path * @return the size of the path
*/ */
float pathLength(std::vector<vec2> _points); float pathLength(etk::Vector<vec2> _points);
/** /**
* @brief Get the center position of the Path (baricenter)... * @brief Get the center position of the Path (baricenter)...
* @param[in] _points List of points. * @param[in] _points List of points.
* @return The center position of all the points. * @return The center position of all the points.
*/ */
vec2 getBaryCenter(const std::vector<vec2>& _points); vec2 getBaryCenter(const etk::Vector<vec2>& _points);
/** /**
* @brief Rotate a list of point from the center to the precise angle. * @brief Rotate a list of point from the center to the precise angle.
* @param[in] _points List of point in the path. * @param[in] _points List of point in the path.
@ -28,71 +28,71 @@ namespace dollar {
* @return new path with the rotated points. * @return new path with the rotated points.
*/ */
// TODO: Change this with the use of a generic matrix 2D... // TODO: Change this with the use of a generic matrix 2D...
std::vector<vec2> rotateBy(const std::vector<vec2>& _points, float _rotation); etk::Vector<vec2> rotateBy(const etk::Vector<vec2>& _points, float _rotation);
/** /**
* @brief Rotate a path to a specific angle (0rad) * @brief Rotate a path to a specific angle (0rad)
* @param[in] _points Path to rotate * @param[in] _points Path to rotate
* @return the Path aligned with 0; * @return the Path aligned with 0;
*/ */
std::vector<vec2> rotateToZero(const std::vector<vec2>& _points); etk::Vector<vec2> rotateToZero(const etk::Vector<vec2>& _points);
/** /**
* @brief Get the Bounding box associated at a path * @brief Get the Bounding box associated at a path
* @param[in] _points List of point at the path * @param[in] _points List of point at the path
* @return the rectangle with the bounding box associated * @return the rectangle with the bounding box associated
*/ */
dollar::Rectangle boundingBox(const std::vector<vec2>& _points); dollar::Rectangle boundingBox(const etk::Vector<vec2>& _points);
/** /**
* @brief Scale the list of point in a 1.0*1.0 box started at 0.0*0.0 * @brief Scale the list of point in a 1.0*1.0 box started at 0.0*0.0
* @param[in] _points input path * @param[in] _points input path
* @param[in] _keepAspectRation Keep the aspect ratio of the scaling * @param[in] _keepAspectRation Keep the aspect ratio of the scaling
* @return modify points * @return modify points
*/ */
std::vector<vec2> scaleToOne(const std::vector<vec2>& _points, bool _keepAspectRation=true); etk::Vector<vec2> scaleToOne(const etk::Vector<vec2>& _points, bool _keepAspectRation=true);
/** /**
* @brief Scale the list of point in a 1.0*1.0 box started at 0.0*0.0 * @brief Scale the list of point in a 1.0*1.0 box started at 0.0*0.0
* @param[in] _points input path * @param[in] _points input path
* @param[in] _keepAspectRation Keep the aspect ratio of the scaling * @param[in] _keepAspectRation Keep the aspect ratio of the scaling
* @return modify points * @return modify points
*/ */
std::vector<std::vector<vec2>> scaleToOne(const std::vector<std::vector<vec2>>& _points, bool _keepAspectRation=false); etk::Vector<etk::Vector<vec2>> scaleToOne(const std::vector<std::vector<vec2>>& _points, bool _keepAspectRation=false);
/** /**
* @brief Get center of the path and move the path to be center at (0,0) * @brief Get center of the path and move the path to be center at (0,0)
* @param[in] _points List of point in the path * @param[in] _points List of point in the path
* @return centered path. * @return centered path.
*/ */
std::vector<vec2> translateBariCenterToZero(std::vector<vec2> _points); etk::Vector<vec2> translateBariCenterToZero(etk::Vector<vec2> _points);
/** /**
* @brief Resample a path With a specific number of elements * @brief Resample a path With a specific number of elements
* @param[in] _points Path to change number of elements * @param[in] _points Path to change number of elements
* @param[in] _nbPoints Number of point desired in the output path * @param[in] _nbPoints Number of point desired in the output path
* @return Resample path. * @return Resample path.
*/ */
std::vector<vec2> resample(std::vector<vec2> _points, int32_t _nbPoints); etk::Vector<vec2> resample(etk::Vector<vec2> _points, int32_t _nbPoints);
/** /**
* @brief Make a list of all single stroke possible for a specific stroke (take in case the user can write the second stroke befor the first and he can do the stroke in the oposite way * @brief Make a list of all single stroke possible for a specific stroke (take in case the user can write the second stroke befor the first and he can do the stroke in the oposite way
* @param[in] _strokes List of all strokes * @param[in] _strokes List of all strokes
* @return List of a list of single stroke of multiple stroke * @return List of a list of single stroke of multiple stroke
*/ */
std::vector<std::vector<vec2>> makeReferenceStrokes(const std::vector<std::vector<vec2>>& _strokes); etk::Vector<etk::Vector<vec2>> makeReferenceStrokes(const std::vector<std::vector<vec2>>& _strokes);
/** /**
* @brief combine some stroke in a single one. * @brief combine some stroke in a single one.
* @param[in] _strokes value to merge * @param[in] _strokes value to merge
* @return Merged vector * @return Merged vector
*/ */
std::vector<vec2> combineStrokes(const std::vector<std::vector<vec2>>& _strokes); etk::Vector<vec2> combineStrokes(const etk::Vector<std::vector<vec2>>& _strokes);
/** /**
* @brief Normalise the Path with the full magnetude of the data * @brief Normalise the Path with the full magnetude of the data
* @param[in] _points Input path * @param[in] _points Input path
* @return Normalized path * @return Normalized path
*/ */
std::vector<vec2> normalyse(const std::vector<vec2>& _points); etk::Vector<vec2> normalyse(const etk::Vector<vec2>& _points);
/** /**
* @brief Calculate a starting vector of the path * @brief Calculate a starting vector of the path
* @param[in] _points List of point of the path * @param[in] _points List of point of the path
* @param[in] _index position index to get the vector (ratio to 0) * @param[in] _index position index to get the vector (ratio to 0)
* @return the start vector. * @return the start vector.
*/ */
vec2 getStartVector(const std::vector<vec2>& _points, float _index = 1); vec2 getStartVector(const etk::Vector<vec2>& _points, float _index = 1);
/** /**
* @brief Transform the path to be comparable, resample the path with a specific number of sample, and limit size at 1.0 square center around 0 * @brief Transform the path to be comparable, resample the path with a specific number of sample, and limit size at 1.0 square center around 0
* @param[in] _points List of points in the path * @param[in] _points List of points in the path
@ -101,7 +101,7 @@ namespace dollar {
* @param[in] _keepAspectRatio Keep Aspect ratio when scaling to the correct size (1.0,1.0) (it will be centered) * @param[in] _keepAspectRatio Keep Aspect ratio when scaling to the correct size (1.0,1.0) (it will be centered)
* @return new list of points * @return new list of points
*/ */
std::vector<vec2> normalizePath(std::vector<vec2> _points, size_t _nbSample, bool _ignoreRotation, bool _keepAspectRatio); etk::Vector<vec2> normalizePath(etk::Vector<vec2> _points, size_t _nbSample, bool _ignoreRotation, bool _keepAspectRatio);
/** /**
* @brief Transform the path to be comparable, resample the path with a specific number of sample, and limit size at 1.0 square center around 0 * @brief Transform the path to be comparable, resample the path with a specific number of sample, and limit size at 1.0 square center around 0
@ -111,13 +111,13 @@ namespace dollar {
* @param[in] _keepAspectRatio Keep Aspect ratio when scaling to the correct size (1.0,1.0) (it will be centered) * @param[in] _keepAspectRatio Keep Aspect ratio when scaling to the correct size (1.0,1.0) (it will be centered)
* @return new list of points * @return new list of points
*/ */
std::vector<vec2> normalizePathToPoints(std::vector<std::vector<vec2>> _points, float _distance, bool _keepAspectRatio); etk::Vector<vec2> normalizePathToPoints(etk::Vector<std::vector<vec2>> _points, float _distance, bool _keepAspectRatio);
/** /**
* @brief get the aspect ratio of a list of points * @brief get the aspect ratio of a list of points
* @param[in] _points List of points * @param[in] _points List of points
* @return the aspect ratio * @return the aspect ratio
*/ */
float getAspectRatio(std::vector<std::vector<vec2>> _points); float getAspectRatio(etk::Vector<etk::Vector<vec2>> _points);
} }

View File

@ -11,7 +11,7 @@
#include <etk/etk.hpp> #include <etk/etk.hpp>
#include <test-debug/debug.hpp> #include <test-debug/debug.hpp>
#include <etk/os/FSNode.hpp> #include <etk/os/FSNode.hpp>
#include <map> #include <etk/Map.hpp>
static bool keepAspectRatio = false; static bool keepAspectRatio = false;
static float distanceReference = 0.1f; // distance of the gesture reference [0.02, 0.3] static float distanceReference = 0.1f; // distance of the gesture reference [0.02, 0.3]
@ -20,32 +20,32 @@ static float penalityRef = 0.1;
static float penalitySample = 0.1; static float penalitySample = 0.1;
static float penalityAspectRatio = 0.2; //!< ==> result += delta aspect ratio * penality static float penalityAspectRatio = 0.2; //!< ==> result += delta aspect ratio * penality
void usage(const std::string& _progName) { void usage(const etk::String& _progName) {
TEST_PRINT("usage:"); TEST_PRINT("usage:");
TEST_PRINT(" " << _progName << " [option] reference_gesture corpus_path"); TEST_PRINT(" " << _progName << " [option] reference_gesture corpus_path");
TEST_PRINT(" [option]"); TEST_PRINT(" [option]");
TEST_PRINT(" -h --help Display this help"); TEST_PRINT(" -h --help Display this help");
TEST_PRINT(" --keep_ratio Keep aspect ratio for the form recognition (default:" + etk::to_string(keepAspectRatio) + ")"); TEST_PRINT(" --keep_ratio Keep aspect ratio for the form recognition (default:" + etk::toString(keepAspectRatio) + ")");
TEST_PRINT(" --dist-check=flaot Distance between points in the system recognition (default:" + etk::to_string(distanceReference) + ")"); TEST_PRINT(" --dist-check=flaot Distance between points in the system recognition (default:" + etk::toString(distanceReference) + ")");
TEST_PRINT(" --dist-excl=flaot Distance to exclude a point in a pathern matching ... (default:" + etk::to_string(distanceExclude) + ")"); TEST_PRINT(" --dist-excl=flaot Distance to exclude a point in a pathern matching ... (default:" + etk::toString(distanceExclude) + ")");
TEST_PRINT(" --penal-ref=float Penality for reference when not connected (default:" + etk::to_string(penalityRef) + ")"); TEST_PRINT(" --penal-ref=float Penality for reference when not connected (default:" + etk::toString(penalityRef) + ")");
TEST_PRINT(" --penal-sample=float Penality for sample when not connected (default:" + etk::to_string(penalitySample) + ")"); TEST_PRINT(" --penal-sample=float Penality for sample when not connected (default:" + etk::toString(penalitySample) + ")");
TEST_PRINT(" --penal-aspect-ratio=float Penality for the distance of aspect ratio (default:" + etk::to_string(penalityAspectRatio) + ")"); TEST_PRINT(" --penal-aspect-ratio=float Penality for the distance of aspect ratio (default:" + etk::toString(penalityAspectRatio) + ")");
TEST_PRINT(" parameters (must be here)"); TEST_PRINT(" parameters (must be here)");
TEST_PRINT(" reference_gesture Path of the reference gestures"); TEST_PRINT(" reference_gesture Path of the reference gestures");
TEST_PRINT(" corpus_path Path of the corpus files"); TEST_PRINT(" corpus_path Path of the corpus files");
} }
bool testCorpus(const std::string& _srcGesture, const std::string& _srcCorpus); bool testCorpus(const etk::String& _srcGesture, const etk::String& _srcCorpus);
int main(int _argc, const char *_argv[]) { int main(int _argc, const char *_argv[]) {
// init etk log system and file interface: // init etk log system and file interface:
etk::init(_argc, _argv); etk::init(_argc, _argv);
std::string srcGesture; etk::String srcGesture;
std::string srcCorpus; etk::String srcCorpus;
for (int32_t iii=1; iii<_argc; ++iii) { for (int32_t iii=1; iii<_argc; ++iii) {
std::string arg = _argv[iii]; etk::String arg = _argv[iii];
if ( arg == "-h" if ( arg == "-h"
|| arg == "--help") { || arg == "--help") {
usage(_argv[0]); usage(_argv[0]);
@ -56,31 +56,31 @@ int main(int _argc, const char *_argv[]) {
continue; continue;
} }
if (etk::start_with(arg,"--dist-ref=") == true) { if (etk::start_with(arg,"--dist-ref=") == true) {
std::string val(&arg[11]); etk::String val(&arg[11]);
distanceReference = etk::string_to_float(val); distanceReference = etk::string_to_float(val);
TEST_PRINT("configure distanceReference=" << distanceReference); TEST_PRINT("configure distanceReference=" << distanceReference);
continue; continue;
} }
if (etk::start_with(arg,"--dist-excl=") == true) { if (etk::start_with(arg,"--dist-excl=") == true) {
std::string val(&arg[12]); etk::String val(&arg[12]);
distanceExclude = etk::string_to_float(val); distanceExclude = etk::string_to_float(val);
TEST_PRINT("configure distanceExclude=" << distanceExclude); TEST_PRINT("configure distanceExclude=" << distanceExclude);
continue; continue;
} }
if (etk::start_with(arg,"--penal-ref=") == true) { if (etk::start_with(arg,"--penal-ref=") == true) {
std::string val(&arg[12]); etk::String val(&arg[12]);
penalityRef = etk::string_to_float(val); penalityRef = etk::string_to_float(val);
TEST_PRINT("configure penalityRef=" << penalityRef); TEST_PRINT("configure penalityRef=" << penalityRef);
continue; continue;
} }
if (etk::start_with(arg,"--penal-sample=") == true) { if (etk::start_with(arg,"--penal-sample=") == true) {
std::string val(&arg[15]); etk::String val(&arg[15]);
penalityRef = etk::string_to_float(val); penalityRef = etk::string_to_float(val);
TEST_PRINT("configure penalitySample=" << penalitySample); TEST_PRINT("configure penalitySample=" << penalitySample);
continue; continue;
} }
if (etk::start_with(arg,"--penal-aspect-ratio=") == true) { if (etk::start_with(arg,"--penal-aspect-ratio=") == true) {
std::string val(&arg[20]); etk::String val(&arg[20]);
penalityAspectRatio = etk::string_to_float(val); penalityAspectRatio = etk::string_to_float(val);
TEST_PRINT("configure penalityAspectRatio=" << penalityAspectRatio); TEST_PRINT("configure penalityAspectRatio=" << penalityAspectRatio);
continue; continue;
@ -110,11 +110,11 @@ int main(int _argc, const char *_argv[]) {
return testCorpus(srcGesture, srcCorpus); return testCorpus(srcGesture, srcCorpus);
} }
void generateFile(const std::string& _fileName, const std::vector<std::string>& _list) { void generateFile(const etk::String& _fileName, const etk::Vector<etk::String>& _list) {
std::string data("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); etk::String data("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
data += "<svg height=\"100\" width=\"100\">\n"; data += "<svg height=\"100\" width=\"100\">\n";
for (auto &itFile : _list) { for (auto &itFile : _list) {
std::vector<std::vector<vec2>> strokes = dollar::scaleToOne(dollar::loadPoints(itFile)); etk::Vector<etk::Vector<vec2>> strokes = dollar::scaleToOne(dollar::loadPoints(itFile));
for (auto &itLines : strokes) { for (auto &itLines : strokes) {
data += " <polyline fill=\"none\" stroke=\"black\" stroke-opacity=\"0.5\" stroke-width=\"1\"\n"; data += " <polyline fill=\"none\" stroke=\"black\" stroke-opacity=\"0.5\" stroke-width=\"1\"\n";
data += " points=\""; data += " points=\"";
@ -124,7 +124,7 @@ void generateFile(const std::string& _fileName, const std::vector<std::string>&
data += " "; data += " ";
} }
first = false; first = false;
data += etk::to_string(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f); data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
} }
data += "\"\n"; data += "\"\n";
data += " />\n"; data += " />\n";
@ -134,26 +134,26 @@ void generateFile(const std::string& _fileName, const std::vector<std::string>&
etk::FSNodeWriteAllData(_fileName, data); etk::FSNodeWriteAllData(_fileName, data);
} }
void annalyseResult(std::map<std::string, std::vector<std::pair<dollar::Results, std::string>>>& _result) { void annalyseResult(etk::Map<etk::String, etk::Vector<etk::Pair<dollar::Results, etk::String>>>& _result) {
TEST_PRINT("Full results:"); TEST_PRINT("Full results:");
for (auto &it : _result) { for (auto &it : _result) {
int32_t nbRecognise = 0; int32_t nbRecognise = 0;
int32_t nbtested = 0; int32_t nbtested = 0;
std::string label = etk::split(it.first, ' ')[0]; etk::String label = etk::split(it.first, ' ')[0];
std::string type; etk::String type;
if (etk::split(it.first, ' ').size() > 1) { if (etk::split(it.first, ' ').size() > 1) {
type = etk::split(it.first, ' ')[1]; type = etk::split(it.first, ' ')[1];
} }
std::vector<std::string> listFull; etk::Vector<etk::String> listFull;
std::vector<std::string> listWrong; etk::Vector<etk::String> listWrong;
std::map<std::string, int32_t> wrongValues; etk::Map<etk::String, int32_t> wrongValues;
for (auto itRes : it.second) { for (auto itRes : it.second) {
nbtested ++; nbtested ++;
listFull.push_back(itRes.second); listFull.pushBack(itRes.second);
if (label == itRes.first.getName()) { if (label == itRes.first.getName()) {
nbRecognise++; nbRecognise++;
} else { } else {
listWrong.push_back(itRes.second); listWrong.pushBack(itRes.second);
if (wrongValues.find(itRes.first.getName()) != wrongValues.end()) { if (wrongValues.find(itRes.first.getName()) != wrongValues.end()) {
wrongValues[itRes.first.getName()]++; wrongValues[itRes.first.getName()]++;
} else { } else {
@ -183,7 +183,7 @@ void annalyseResult(std::map<std::string, std::vector<std::pair<dollar::Results,
} }
} }
bool testCorpus(const std::string& _srcGesture, const std::string& _srcCorpus) { bool testCorpus(const etk::String& _srcGesture, const etk::String& _srcCorpus) {
// declare a Gesture (internal API) // declare a Gesture (internal API)
dollar::EnginePPlus reco; dollar::EnginePPlus reco;
reco.setScaleKeepRatio(keepAspectRatio); reco.setScaleKeepRatio(keepAspectRatio);
@ -202,31 +202,31 @@ bool testCorpus(const std::string& _srcGesture, const std::string& _srcCorpus) {
} }
TEST_DEBUG("List all file in the corpus path"); TEST_DEBUG("List all file in the corpus path");
etk::FSNode path(_srcCorpus); etk::FSNode path(_srcCorpus);
std::vector<std::string> files = path.folderGetSub(false, true, "*.json"); etk::Vector<etk::String> files = path.folderGetSub(false, true, "*.json");
TEST_PRINT("---------------------------------------------------------------------------"); TEST_PRINT("---------------------------------------------------------------------------");
TEST_PRINT("-- test gestures: "); TEST_PRINT("-- test gestures: ");
TEST_PRINT("---------------------------------------------------------------------------"); TEST_PRINT("---------------------------------------------------------------------------");
// "label_type" ==> list of (result, file test name) // "label_type" ==> list of (result, file test name)
std::map<std::string, std::vector<std::pair<dollar::Results, std::string>>> agregateResults; etk::Map<etk::String, etk::Vector<etk::Pair<dollar::Results, etk::String>>> agregateResults;
int32_t nbRecognise = 0; int32_t nbRecognise = 0;
int32_t nbRecognise2 = 0; int32_t nbRecognise2 = 0;
int32_t nbtested = 0; int32_t nbtested = 0;
for (auto &it : files) { for (auto &it : files) {
std::string label; etk::String label;
std::string type; etk::String type;
std::vector<std::vector<vec2>> listPoints = dollar::loadPoints(it, &label, &type); etk::Vector<etk::Vector<vec2>> listPoints = dollar::loadPoints(it, &label, &type);
if (type == "hand") { if (type == "hand") {
//continue; // rejest for now ... //continue; // rejest for now ...
} }
nbtested++; nbtested++;
std::vector<std::string> path = etk::split(it, '/'); etk::Vector<etk::String> path = etk::split(it, '/');
std::string filename = path[path.size()-1]; etk::String filename = path[path.size()-1];
TEST_PRINT("Test '" << label << "' type=" << type << " " << filename); TEST_PRINT("Test '" << label << "' type=" << type << " " << filename);
dollar::Results res = reco.recognize(listPoints); dollar::Results res = reco.recognize(listPoints);
//agregateResults[label+" "+type].push_back(std::make_pair(res,it)); //agregateResults[label+" "+type].pushBack(etk::makePair(res,it));
agregateResults[label].push_back(std::make_pair(res,it)); agregateResults[label].pushBack(etk::makePair(res,it));
if (res.haveMatch() == false) { if (res.haveMatch() == false) {
TEST_INFO(" Recognise noting ..."); TEST_INFO(" Recognise noting ...");

View File

@ -10,7 +10,7 @@
#include <etk/etk.hpp> #include <etk/etk.hpp>
#include <test-debug/debug.hpp> #include <test-debug/debug.hpp>
void usage(const std::string& _progName) { void usage(const etk::String& _progName) {
TEST_PRINT("usage:"); TEST_PRINT("usage:");
TEST_PRINT(" " << _progName << " [option] source destination"); TEST_PRINT(" " << _progName << " [option] source destination");
TEST_PRINT(" [option]"); TEST_PRINT(" [option]");
@ -23,10 +23,10 @@ void usage(const std::string& _progName) {
int main(int _argc, const char *_argv[]) { int main(int _argc, const char *_argv[]) {
// init etk log system and file interface: // init etk log system and file interface:
etk::init(_argc, _argv); etk::init(_argc, _argv);
std::string src; etk::String src;
std::string dst; etk::String dst;
for (int32_t iii=1; iii<_argc; ++iii) { for (int32_t iii=1; iii<_argc; ++iii) {
std::string arg = _argv[iii]; etk::String arg = _argv[iii];
if ( arg == "-h" if ( arg == "-h"
|| arg == "--help") { || arg == "--help") {
usage(_argv[0]); usage(_argv[0]);

View File

@ -11,7 +11,7 @@
#include <etk/os/FSNode.hpp> #include <etk/os/FSNode.hpp>
#include <iostream> #include <iostream>
#include <map> #include <etk/Map.hpp>
@ -23,19 +23,19 @@ static float penalityRef = 0.1;
static float penalitySample = 0.1; static float penalitySample = 0.1;
static float penalityAspectRatio = 0.2; //!< ==> result += delta aspect ratio * penality static float penalityAspectRatio = 0.2; //!< ==> result += delta aspect ratio * penality
void usage(const std::string& _progName) { void usage(const etk::String& _progName) {
TEST_PRINT("usage:"); TEST_PRINT("usage:");
TEST_PRINT(" " << _progName << " [option] corpus_path"); TEST_PRINT(" " << _progName << " [option] corpus_path");
TEST_PRINT(" "); TEST_PRINT(" ");
TEST_PRINT(" [option]"); TEST_PRINT(" [option]");
TEST_PRINT(" -h --help Display this help"); TEST_PRINT(" -h --help Display this help");
TEST_PRINT(" --keep_ratio Keep aspect ratio for the form recognition (default:" + etk::to_string(keepAspectRatio) + ")"); TEST_PRINT(" --keep_ratio Keep aspect ratio for the form recognition (default:" + etk::toString(keepAspectRatio) + ")");
TEST_PRINT(" --dist-check=flaot Distance between points in the system recognition (default:" + etk::to_string(distanceReference) + ")"); TEST_PRINT(" --dist-check=flaot Distance between points in the system recognition (default:" + etk::toString(distanceReference) + ")");
TEST_PRINT(" --dist-excl=flaot Distance to exclude a point in a pathern matching ... (default:" + etk::to_string(distanceExclude) + ")"); TEST_PRINT(" --dist-excl=flaot Distance to exclude a point in a pathern matching ... (default:" + etk::toString(distanceExclude) + ")");
TEST_PRINT(" --group-size=flaot Size of the distance between point to stop grouping in one form (default:" + etk::to_string(distanceGroupLimiting) + ")"); TEST_PRINT(" --group-size=flaot Size of the distance between point to stop grouping in one form (default:" + etk::toString(distanceGroupLimiting) + ")");
TEST_PRINT(" --penal-ref=float Penality for reference when not connected (default:" + etk::to_string(penalityRef) + ")"); TEST_PRINT(" --penal-ref=float Penality for reference when not connected (default:" + etk::toString(penalityRef) + ")");
TEST_PRINT(" --penal-sample=float Penality for sample when not connected (default:" + etk::to_string(penalitySample) + ")"); TEST_PRINT(" --penal-sample=float Penality for sample when not connected (default:" + etk::toString(penalitySample) + ")");
TEST_PRINT(" --penal-aspect-ratio=float Penality for the distance of aspect ratio (default:" + etk::to_string(penalityAspectRatio) + ")"); TEST_PRINT(" --penal-aspect-ratio=float Penality for the distance of aspect ratio (default:" + etk::toString(penalityAspectRatio) + ")");
TEST_PRINT(" "); TEST_PRINT(" ");
TEST_PRINT(" parameters (must be here)"); TEST_PRINT(" parameters (must be here)");
TEST_PRINT(" corpus_path Path of the corpus files"); TEST_PRINT(" corpus_path Path of the corpus files");
@ -44,16 +44,16 @@ void usage(const std::string& _progName) {
TEST_PRINT(" example:"); TEST_PRINT(" example:");
} }
bool testCorpus(const std::string& _srcCorpus); bool testCorpus(const etk::String& _srcCorpus);
int main(int _argc, const char *_argv[]) { int main(int _argc, const char *_argv[]) {
// init etk log system and file interface: // init etk log system and file interface:
etk::init(_argc, _argv); etk::init(_argc, _argv);
std::string srcCorpus; etk::String srcCorpus;
for (int32_t iii=1; iii<_argc; ++iii) { for (int32_t iii=1; iii<_argc; ++iii) {
std::string arg = _argv[iii]; etk::String arg = _argv[iii];
if ( arg == "-h" if ( arg == "-h"
|| arg == "--help") { || arg == "--help") {
usage(_argv[0]); usage(_argv[0]);
@ -64,37 +64,37 @@ int main(int _argc, const char *_argv[]) {
continue; continue;
} }
if (etk::start_with(arg,"--dist-ref=") == true) { if (etk::start_with(arg,"--dist-ref=") == true) {
std::string val(&arg[11]); etk::String val(&arg[11]);
distanceReference = etk::string_to_float(val); distanceReference = etk::string_to_float(val);
TEST_PRINT("configure distanceReference=" << distanceReference); TEST_PRINT("configure distanceReference=" << distanceReference);
continue; continue;
} }
if (etk::start_with(arg,"--dist-excl=") == true) { if (etk::start_with(arg,"--dist-excl=") == true) {
std::string val(&arg[12]); etk::String val(&arg[12]);
distanceExclude = etk::string_to_float(val); distanceExclude = etk::string_to_float(val);
TEST_PRINT("configure distanceExclude=" << distanceExclude); TEST_PRINT("configure distanceExclude=" << distanceExclude);
continue; continue;
} }
if (etk::start_with(arg,"--group-size=") == true) { if (etk::start_with(arg,"--group-size=") == true) {
std::string val(&arg[13]); etk::String val(&arg[13]);
distanceGroupLimiting = etk::string_to_float(val); distanceGroupLimiting = etk::string_to_float(val);
TEST_PRINT("configure distanceGroupLimiting=" << distanceGroupLimiting); TEST_PRINT("configure distanceGroupLimiting=" << distanceGroupLimiting);
continue; continue;
} }
if (etk::start_with(arg,"--penal-ref=") == true) { if (etk::start_with(arg,"--penal-ref=") == true) {
std::string val(&arg[12]); etk::String val(&arg[12]);
penalityRef = etk::string_to_float(val); penalityRef = etk::string_to_float(val);
TEST_PRINT("configure penalityRef=" << penalityRef); TEST_PRINT("configure penalityRef=" << penalityRef);
continue; continue;
} }
if (etk::start_with(arg,"--penal-sample=") == true) { if (etk::start_with(arg,"--penal-sample=") == true) {
std::string val(&arg[15]); etk::String val(&arg[15]);
penalityRef = etk::string_to_float(val); penalityRef = etk::string_to_float(val);
TEST_PRINT("configure penalitySample=" << penalitySample); TEST_PRINT("configure penalitySample=" << penalitySample);
continue; continue;
} }
if (etk::start_with(arg,"--penal-aspect-ratio=") == true) { if (etk::start_with(arg,"--penal-aspect-ratio=") == true) {
std::string val(&arg[20]); etk::String val(&arg[20]);
penalityAspectRatio = etk::string_to_float(val); penalityAspectRatio = etk::string_to_float(val);
TEST_PRINT("configure penalityAspectRatio=" << penalityAspectRatio); TEST_PRINT("configure penalityAspectRatio=" << penalityAspectRatio);
continue; continue;
@ -119,12 +119,12 @@ int main(int _argc, const char *_argv[]) {
return testCorpus(srcCorpus); return testCorpus(srcCorpus);
} }
void generateFile(const std::string& _fileName, const std::vector<std::string>& _list, const std::string& _refName) { void generateFile(const etk::String& _fileName, const etk::Vector<etk::String>& _list, const std::string& _refName) {
TEST_PRINT(" " << _fileName); TEST_PRINT(" " << _fileName);
std::string data("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); etk::String data("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
data += "<svg height=\"100\" width=\"100\">\n"; data += "<svg height=\"100\" width=\"100\">\n";
for (auto &itFile : _list) { for (auto &itFile : _list) {
std::vector<std::vector<vec2>> strokes = dollar::scaleToOne(dollar::loadPoints(itFile), keepAspectRatio); etk::Vector<etk::Vector<vec2>> strokes = dollar::scaleToOne(dollar::loadPoints(itFile), keepAspectRatio);
for (auto &itLines : strokes) { for (auto &itLines : strokes) {
if (itLines.size() == 1) { if (itLines.size() == 1) {
// TODO: This is a line .... // TODO: This is a line ....
@ -137,14 +137,14 @@ void generateFile(const std::string& _fileName, const std::vector<std::string>&
data += " "; data += " ";
} }
first = false; first = false;
data += etk::to_string(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f); data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
} }
data += "\"\n"; data += "\"\n";
data += " />\n"; data += " />\n";
} }
} }
if (_refName != "") { if (_refName != "") {
std::vector<std::vector<vec2>> strokes = dollar::scaleToOne(dollar::loadPoints(_refName), keepAspectRatio); etk::Vector<etk::Vector<vec2>> strokes = dollar::scaleToOne(dollar::loadPoints(_refName), keepAspectRatio);
for (auto &itLines : strokes) { for (auto &itLines : strokes) {
if (itLines.size() == 1) { if (itLines.size() == 1) {
// TODO: This is a line .... // TODO: This is a line ....
@ -157,7 +157,7 @@ void generateFile(const std::string& _fileName, const std::vector<std::string>&
data += " "; data += " ";
} }
first = false; first = false;
data += etk::to_string(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f); data += etk::toString(itPoints.x()*100.0f) + "," + etk::to_string((1.0-itPoints.y())*100.0f);
} }
data += "\"\n"; data += "\"\n";
data += " />\n"; data += " />\n";
@ -169,33 +169,33 @@ void generateFile(const std::string& _fileName, const std::vector<std::string>&
#define OUT_OF_RANGE (999999.0f) #define OUT_OF_RANGE (999999.0f)
bool testCorpus(const std::string& _srcCorpus) { bool testCorpus(const etk::String& _srcCorpus) {
TEST_PRINT("---------------------------------------------------------------------------"); TEST_PRINT("---------------------------------------------------------------------------");
TEST_PRINT("-- Create list of files: " << _srcCorpus); TEST_PRINT("-- Create list of files: " << _srcCorpus);
TEST_PRINT("---------------------------------------------------------------------------"); TEST_PRINT("---------------------------------------------------------------------------");
etk::FSNode path(_srcCorpus); etk::FSNode path(_srcCorpus);
std::vector<std::string> files = path.folderGetSub(false, true, "*.json"); etk::Vector<etk::String> files = path.folderGetSub(false, true, "*.json");
TEST_PRINT("corpus have " << files.size() << " files"); TEST_PRINT("corpus have " << files.size() << " files");
std::vector<std::string> listOfElementInCorpus; etk::Vector<etk::String> listOfElementInCorpus;
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, '/'); etk::Vector<etk::String> path = etk::split(it, '/');
std::string elemName = etk::split(path[path.size()-1],'_')[0]; etk::String elemName = etk::split(path[path.size()-1],'_')[0];
if (elemName == "slash") { if (elemName == "slash") {
elemName = "/"; elemName = "/";
}if (elemName == "back-slash") { }if (elemName == "back-slash") {
elemName = "\\"; 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.pushBack(elemName);
} }
} }
} }
// remove generation path ... // remove generation path ...
etk::FSNodeRemove("out_dollar/generate-form"); etk::FSNodeRemove("out_dollar/generate-form");
//listOfElementInCorpus.clear(); //listOfElementInCorpus.clear();
//listOfElementInCorpus.push_back("slash"); //listOfElementInCorpus.pushBack("slash");
TEST_PRINT(" will done for: " << listOfElementInCorpus); TEST_PRINT(" will done for: " << listOfElementInCorpus);
@ -204,8 +204,8 @@ bool testCorpus(const std::string& _srcCorpus) {
TEST_PRINT("---------------------------------------------------------------------------"); TEST_PRINT("---------------------------------------------------------------------------");
TEST_PRINT("-- Generate FOR: '" << itTypeOfCorpus << "'"); TEST_PRINT("-- Generate FOR: '" << itTypeOfCorpus << "'");
TEST_PRINT("---------------------------------------------------------------------------"); TEST_PRINT("---------------------------------------------------------------------------");
std::vector<std::string> fileFiltered; etk::Vector<etk::String> fileFiltered;
std::string fileNameIt = itTypeOfCorpus; etk::String fileNameIt = itTypeOfCorpus;
if (fileNameIt == "/") { if (fileNameIt == "/") {
fileNameIt = "slash"; fileNameIt = "slash";
} else if (fileNameIt == "\\") { } else if (fileNameIt == "\\") {
@ -213,21 +213,21 @@ bool testCorpus(const std::string& _srcCorpus) {
} }
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, '/'); etk::Vector<etk::String> path = etk::split(it, '/');
std::string filename = path[path.size()-1]; etk::String filename = path[path.size()-1];
if (etk::start_with(filename, fileNameIt + "_") == true) { if (etk::start_with(filename, fileNameIt + "_") == true) {
fileFiltered.push_back(it); fileFiltered.pushBack(it);
} }
} }
} }
TEST_PRINT("correlation of " << fileFiltered.size() << " files"); TEST_PRINT("correlation of " << fileFiltered.size() << " files");
std::vector<std::vector<float>> results; etk::Vector<etk::Vector<float>> results;
results.resize(fileFiltered.size()); results.resize(fileFiltered.size());
for (auto &it : results) { for (auto &it : results) {
it.resize(fileFiltered.size(), OUT_OF_RANGE); it.resize(fileFiltered.size(), OUT_OF_RANGE);
} }
// Generate Full Files: // Generate Full Files:
std::string itTypeOfCorpusFileName = itTypeOfCorpus; etk::String itTypeOfCorpusFileName = itTypeOfCorpus;
if (itTypeOfCorpusFileName == "/") { if (itTypeOfCorpusFileName == "/") {
itTypeOfCorpusFileName = "slash"; itTypeOfCorpusFileName = "slash";
} else if (itTypeOfCorpusFileName == "\\") { } else if (itTypeOfCorpusFileName == "\\") {
@ -236,15 +236,15 @@ bool testCorpus(const std::string& _srcCorpus) {
itTypeOfCorpusFileName = "question"; itTypeOfCorpusFileName = "question";
} }
{ {
std::vector<std::string> listPath; etk::Vector<etk::String> listPath;
for (size_t iii=0; iii<fileFiltered.size(); ++iii) { for (size_t iii=0; iii<fileFiltered.size(); ++iii) {
listPath.push_back(fileFiltered[iii]); listPath.pushBack(fileFiltered[iii]);
} }
generateFile("out_dollar/generate-form/pre_generate/" + itTypeOfCorpusFileName + "_FULL.svg", listPath, ""); generateFile("out_dollar/generate-form/pre_generate/" + itTypeOfCorpusFileName + "_FULL.svg", listPath, "");
} }
for (size_t iii=0; iii<fileFiltered.size(); ++iii) { for (size_t iii=0; iii<fileFiltered.size(); ++iii) {
ememory::SharedPtr<dollar::GesturePPlus> gest = ememory::makeShared<dollar::GesturePPlus>(); ememory::SharedPtr<dollar::GesturePPlus> gest = ememory::makeShared<dollar::GesturePPlus>();
std::vector<std::vector<vec2>> listPoints = dollar::loadPoints(fileFiltered[iii]); etk::Vector<etk::Vector<vec2>> listPoints = dollar::loadPoints(fileFiltered[iii]);
gest->set(itTypeOfCorpus, 0, listPoints); gest->set(itTypeOfCorpus, 0, listPoints);
dollar::EnginePPlus reco; dollar::EnginePPlus reco;
reco.setScaleKeepRatio(keepAspectRatio); reco.setScaleKeepRatio(keepAspectRatio);
@ -254,8 +254,8 @@ bool testCorpus(const std::string& _srcCorpus) {
reco.setPenalityNotLinkSample(penalitySample); reco.setPenalityNotLinkSample(penalitySample);
reco.setPenalityAspectRatio(penalityAspectRatio); reco.setPenalityAspectRatio(penalityAspectRatio);
reco.addGesture(gest); reco.addGesture(gest);
std::vector<std::string> path = etk::split(fileFiltered[iii], '/'); etk::Vector<etk::String> path = etk::split(fileFiltered[iii], '/');
std::string filename = path[path.size()-1]; etk::String filename = path[path.size()-1];
TEST_DEBUG("Test : " << fileFiltered[iii]); TEST_DEBUG("Test : " << fileFiltered[iii]);
for (size_t jjj=0; jjj<fileFiltered.size(); ++jjj) { for (size_t jjj=0; jjj<fileFiltered.size(); ++jjj) {
if (iii >= jjj) { if (iii >= jjj) {
@ -267,7 +267,7 @@ bool testCorpus(const std::string& _srcCorpus) {
results[iii][jjj] = res.getConfidence(); results[iii][jjj] = res.getConfidence();
results[jjj][iii] = res.getConfidence(); results[jjj][iii] = res.getConfidence();
path = etk::split(fileFiltered[jjj], '/'); path = etk::split(fileFiltered[jjj], '/');
std::string filename2 = path[path.size()-1]; etk::String filename2 = path[path.size()-1];
TEST_DEBUG(" " << res.getConfidence() << " " << filename2); TEST_DEBUG(" " << res.getConfidence() << " " << filename2);
} }
} }
@ -278,7 +278,7 @@ bool testCorpus(const std::string& _srcCorpus) {
int32_t subId = 1; int32_t subId = 1;
while (residualValues > 0) { while (residualValues > 0) {
std::vector<int32_t> countMinimum; etk::Vector<int32_t> countMinimum;
countMinimum.resize(fileFiltered.size(), 0); countMinimum.resize(fileFiltered.size(), 0);
for (size_t iii=0; iii<fileFiltered.size(); ++iii) { for (size_t iii=0; iii<fileFiltered.size(); ++iii) {
for (size_t jjj=0; jjj<fileFiltered.size(); ++jjj) { for (size_t jjj=0; jjj<fileFiltered.size(); ++jjj) {
@ -309,15 +309,15 @@ bool testCorpus(const std::string& _srcCorpus) {
TEST_INFO("find NB element : " << countMinimum[bestId] << " for ID=" << bestId); TEST_INFO("find NB element : " << countMinimum[bestId] << " for ID=" << bestId);
} }
// Order the result for the bestID ==> permit to show if it is possible to do a better case ... // Order the result for the bestID ==> permit to show if it is possible to do a better case ...
std::vector<int32_t> linkIds; etk::Vector<int32_t> linkIds;
for (size_t jjj=0; jjj<fileFiltered.size(); ++jjj) { for (size_t jjj=0; jjj<fileFiltered.size(); ++jjj) {
if (results[bestId][jjj] < distanceGroupLimiting) { if (results[bestId][jjj] < distanceGroupLimiting) {
linkIds.push_back(jjj); linkIds.pushBack(jjj);
} }
} }
TEST_INFO(" nbEle(tmp) " << linkIds.size() << " / " << residualValues << " / " << fileFiltered.size()); TEST_INFO(" nbEle(tmp) " << linkIds.size() << " / " << residualValues << " / " << fileFiltered.size());
{ {
std::vector<std::pair<float, size_t>> ordered; etk::Vector<etk::Pair<float, size_t>> ordered;
for (size_t jjj=0; jjj<fileFiltered.size(); ++jjj) { for (size_t jjj=0; jjj<fileFiltered.size(); ++jjj) {
float val = results[bestId][jjj]; float val = results[bestId][jjj];
if (val >= OUT_OF_RANGE) { if (val >= OUT_OF_RANGE) {
@ -327,14 +327,14 @@ bool testCorpus(const std::string& _srcCorpus) {
bool added = false; bool added = false;
while (it != ordered.end()) { while (it != ordered.end()) {
if (it->first > val) { if (it->first > val) {
ordered.insert(it, std::make_pair(val, jjj)); ordered.insert(it, etk::makePair(val, jjj));
added = true; added = true;
break; break;
} }
++it; ++it;
} }
if (added == false) { if (added == false) {
ordered.push_back(std::make_pair(val, jjj)); ordered.pushBack(etk::makePair(val, jjj));
} }
} }
// enable/disable grouping auto ... // enable/disable grouping auto ...
@ -344,11 +344,11 @@ bool testCorpus(const std::string& _srcCorpus) {
linkIds.clear(); linkIds.clear();
for (size_t jjj=0; jjj<ordered.size(); ++jjj) { for (size_t jjj=0; jjj<ordered.size(); ++jjj) {
if (ordered[jjj].first < distanceGroupLimiting) { if (ordered[jjj].first < distanceGroupLimiting) {
linkIds.push_back(ordered[jjj].second); linkIds.pushBack(ordered[jjj].second);
} else { } else {
// auto find a separation in the group ... // auto find a separation in the group ...
if (ordered[jjj].first <= (lastValue + 0.15)) { if (ordered[jjj].first <= (lastValue + 0.15)) {
linkIds.push_back(ordered[jjj].second); linkIds.pushBack(ordered[jjj].second);
} else { } else {
break; break;
} }
@ -359,9 +359,9 @@ bool testCorpus(const std::string& _srcCorpus) {
TEST_INFO(" nbElement : " << linkIds.size() << " / " << residualValues << " / " << fileFiltered.size()); TEST_INFO(" nbElement : " << linkIds.size() << " / " << residualValues << " / " << fileFiltered.size());
TEST_INFO(" values : " << linkIds); TEST_INFO(" values : " << linkIds);
for (size_t jjj=0; jjj<ordered.size(); ++jjj) { for (size_t jjj=0; jjj<ordered.size(); ++jjj) {
std::vector<std::string> path = etk::split(fileFiltered[ordered[jjj].second], '/'); etk::Vector<etk::String> path = etk::split(fileFiltered[ordered[jjj].second], '/');
std::string filename = path[path.size()-1]; etk::String filename = path[path.size()-1];
std::string tmppp = " "; etk::String tmppp = " ";
if (jjj<linkIds.size()) { if (jjj<linkIds.size()) {
tmppp = "*"; tmppp = "*";
} }
@ -391,18 +391,18 @@ bool testCorpus(const std::string& _srcCorpus) {
residualValues -= (linkIds.size() +1); residualValues -= (linkIds.size() +1);
TEST_DEBUG("Generate output files (SVG with all added path in one file)"); TEST_DEBUG("Generate output files (SVG with all added path in one file)");
// Generate Files: // Generate Files:
std::vector<std::string> listPath; etk::Vector<etk::String> listPath;
for (size_t iii=0; iii<linkIds.size(); ++iii) { for (size_t iii=0; iii<linkIds.size(); ++iii) {
listPath.push_back(fileFiltered[linkIds[iii]]); listPath.pushBack(fileFiltered[linkIds[iii]]);
} }
generateFile("out_dollar/generate-form/pre_generate/" + itTypeOfCorpusFileName + "_" + etk::to_string(subId) + ".svg", listPath, fileFiltered[bestId]); generateFile("out_dollar/generate-form/pre_generate/" + itTypeOfCorpusFileName + "_" + etk::toString(subId) + ".svg", listPath, fileFiltered[bestId]);
TEST_DEBUG("Generate output file (corpus ...)"); TEST_DEBUG("Generate output file (corpus ...)");
// declare a Gesture (internal API) // declare a Gesture (internal API)
dollar::Gesture ref; dollar::Gesture ref;
ref.set(itTypeOfCorpus, subId, dollar::loadPoints(fileFiltered[bestId])); ref.set(itTypeOfCorpus, subId, dollar::loadPoints(fileFiltered[bestId]));
// Store gesture with his extention type: // Store gesture with his extention type:
ref.store("out_dollar/generate-form/corpus/" + itTypeOfCorpusFileName + "_" + etk::to_string(subId) + ".json"); ref.store("out_dollar/generate-form/corpus/" + itTypeOfCorpusFileName + "_" + etk::toString(subId) + ".json");
ref.store("out_dollar/generate-form/corpus_svg/" + itTypeOfCorpusFileName + "_" + etk::to_string(subId) + ".svg"); ref.store("out_dollar/generate-form/corpus_svg/" + itTypeOfCorpusFileName + "_" + etk::toString(subId) + ".svg");
// Increment subId... // Increment subId...

View File

@ -22,7 +22,7 @@ class MainApplication : public ewol::context::Application {
void onCreate(ewol::Context& _context) override { void onCreate(ewol::Context& _context) override {
APPL_INFO(" == > CREATE ... " << PROJECT_NAME << " v" << APPL_VERSION << " (START) [" << gale::getBoardType() << "] (" << gale::getCompilationMode() << ") (BEGIN)"); APPL_INFO(" == > CREATE ... " << PROJECT_NAME << " v" << APPL_VERSION << " (START) [" << gale::getBoardType() << "] (" << gale::getCompilationMode() << ") (BEGIN)");
for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) { for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) {
std::string tmpppp = _context.getCmd().get(iii); etk::String tmpppp = _context.getCmd().get(iii);
if ( tmpppp == "-h" if ( tmpppp == "-h"
|| tmpppp == "--help") { || tmpppp == "--help") {
APPL_INFO(" -h/--help display this help" ); APPL_INFO(" -h/--help display this help" );

View File

@ -19,92 +19,92 @@ appl::Windows::Windows() :
m_currentTypeId(0), m_currentTypeId(0),
m_userName("Edouard DUPIN") { m_userName("Edouard DUPIN") {
addObjectType("appl::Windows"); addObjectType("appl::Windows");
propertyTitle.setDirectCheck(std::string("sample ") + PROJECT_NAME); propertyTitle.setDirectCheck(etk::String("sample ") + PROJECT_NAME);
} }
void appl::Windows::init() { void appl::Windows::init() {
ewol::widget::Windows::init(); ewol::widget::Windows::init();
m_listType.push_back("hand"); m_listType.pushBack("hand");
m_listType.push_back("print"); m_listType.pushBack("print");
m_currentTypeId = 0; m_currentTypeId = 0;
std::string tmp; etk::String tmp;
for (char iii='0'; iii<='9'; ++iii) { for (char iii='0'; iii<='9'; ++iii) {
tmp = iii; tmp = iii;
m_listValue.push_back(tmp); m_listValue.pushBack(tmp);
} }
for (char iii='a'; iii<='z'; ++iii) { for (char iii='a'; iii<='z'; ++iii) {
tmp = iii; tmp = iii;
m_listValue.push_back(tmp); m_listValue.pushBack(tmp);
} }
for (char iii='A'; iii<='Z'; ++iii) { for (char iii='A'; iii<='Z'; ++iii) {
tmp = iii; tmp = iii;
m_listValue.push_back(tmp); m_listValue.pushBack(tmp);
} }
m_listValue.push_back("+"); m_listValue.pushBack("+");
m_listValue.push_back("-"); m_listValue.pushBack("-");
m_listValue.push_back("*"); m_listValue.pushBack("*");
m_listValue.push_back("="); m_listValue.pushBack("=");
m_listValue.push_back("/"); m_listValue.pushBack("/");
m_listValue.push_back("?"); m_listValue.pushBack("?");
m_listValue.push_back("!"); m_listValue.pushBack("!");
m_listValue.push_back("@"); m_listValue.pushBack("@");
m_listValue.push_back("#"); m_listValue.pushBack("#");
m_listValue.push_back("~"); m_listValue.pushBack("~");
m_listValue.push_back("&"); m_listValue.pushBack("&");
m_listValue.push_back("("); m_listValue.pushBack("(");
m_listValue.push_back(")"); m_listValue.pushBack(")");
m_listValue.push_back("["); m_listValue.pushBack("[");
m_listValue.push_back("]"); m_listValue.pushBack("]");
m_listValue.push_back("{"); m_listValue.pushBack("{");
m_listValue.push_back("}"); m_listValue.pushBack("}");
m_listValue.push_back("^"); m_listValue.pushBack("^");
m_listValue.push_back("%"); m_listValue.pushBack("%");
m_listValue.push_back(";"); m_listValue.pushBack(";");
m_listValue.push_back("."); m_listValue.pushBack(".");
m_listValue.push_back(","); m_listValue.pushBack(",");
m_listValue.push_back("<"); m_listValue.pushBack("<");
m_listValue.push_back(">"); m_listValue.pushBack(">");
m_listValue.push_back("µ"); m_listValue.pushBack("µ");
m_listValue.push_back("$"); m_listValue.pushBack("$");
m_listValue.push_back("\""); m_listValue.pushBack("\"");
m_listValue.push_back("'"); m_listValue.pushBack("'");
m_listValue.push_back("|"); m_listValue.pushBack("|");
m_listValue.push_back("\\"); m_listValue.pushBack("\\");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back("ù"); m_listValue.pushBack("ù");
m_listValue.push_back("é"); m_listValue.pushBack("é");
m_listValue.push_back("è"); m_listValue.pushBack("è");
m_listValue.push_back("ç"); m_listValue.pushBack("ç");
m_listValue.push_back("à"); m_listValue.pushBack("à");
m_listValue.push_back("÷"); m_listValue.pushBack("÷");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_listValue.push_back(""); m_listValue.pushBack("");
m_currentId = 0; m_currentId = 0;
std::string composition = std::string(""); etk::String composition = etk::String("");
composition += "<sizer mode='vert'>\n"; composition += "<sizer mode='vert'>\n";
composition += " <spacer min-size='4%'/>\n"; composition += " <spacer min-size='4%'/>\n";
composition += " <sizer mode='hori' lock='false,true' min-size='9%'>\n"; composition += " <sizer mode='hori' lock='false,true' min-size='9%'>\n";
@ -183,7 +183,7 @@ void appl::Windows::init() {
} }
} }
void appl::Windows::onCallbackChangeNameUser(const std::string& _value) { void appl::Windows::onCallbackChangeNameUser(const etk::String& _value) {
m_userName = _value; m_userName = _value;
} }

View File

@ -15,18 +15,18 @@ namespace appl {
class Windows : public ewol::widget::Windows { class Windows : public ewol::widget::Windows {
private: private:
ewol::widget::ComposerShared m_composer; ewol::widget::ComposerShared m_composer;
std::vector<std::string> m_listValue; etk::Vector<etk::String> m_listValue;
size_t m_currentId; size_t m_currentId;
std::vector<std::string> m_listType; etk::Vector<etk::String> m_listType;
size_t m_currentTypeId; size_t m_currentTypeId;
std::string m_userName; etk::String m_userName;
protected: protected:
Windows(); Windows();
void init(); void init();
public: public:
DECLARE_FACTORY(Windows); DECLARE_FACTORY(Windows);
public: // callback functions public: // callback functions
void onCallbackChangeNameUser(const std::string& _value); void onCallbackChangeNameUser(const etk::String& _value);
void onCallbackClear(); void onCallbackClear();
void onCallbackUndo(); void onCallbackUndo();
void onCallbackStore(); void onCallbackStore();

View File

@ -51,11 +51,11 @@ void appl::widget::TextAreaRecognition::undo() {
markToRedraw(); markToRedraw();
} }
void appl::widget::TextAreaRecognition::setCompare(const std::string& _compare) { void appl::widget::TextAreaRecognition::setCompare(const etk::String& _compare) {
m_compare = _compare; m_compare = _compare;
} }
void appl::widget::TextAreaRecognition::store(const std::string& _userName, const std::string& _value, const std::string& _type) { void appl::widget::TextAreaRecognition::store(const etk::String& _userName, const etk::String& _value, const std::string& _type) {
if (m_dataList.size() == 0) { if (m_dataList.size() == 0) {
return; return;
} }
@ -69,7 +69,7 @@ void appl::widget::TextAreaRecognition::store(const std::string& _userName, cons
doc.add("data", list); doc.add("data", list);
for (auto &it : m_dataList) { for (auto &it : m_dataList) {
ejson::Object obj; ejson::Object obj;
obj.add("type", ejson::String(etk::to_string(it.m_type))); obj.add("type", ejson::String(etk::toString(it.m_type)));
ejson::Array listPoint; ejson::Array listPoint;
obj.add("list", listPoint); obj.add("list", listPoint);
for (size_t iii=0; iii<it.m_data.size(); ++iii) { for (size_t iii=0; iii<it.m_data.size(); ++iii) {
@ -80,8 +80,8 @@ void appl::widget::TextAreaRecognition::store(const std::string& _userName, cons
} }
list.add(obj); list.add(obj);
} }
std::string streamOut = doc.generateMachineString(); etk::String streamOut = doc.generateMachineString();
std::string fileName; etk::String fileName;
fileName = "HOME:DOLLAR/corpus/"; fileName = "HOME:DOLLAR/corpus/";
if (_value == "/") { if (_value == "/") {
fileName += "slash"; fileName += "slash";
@ -95,7 +95,7 @@ void appl::widget::TextAreaRecognition::store(const std::string& _userName, cons
fileName += "_"; fileName += "_";
fileName += _userName; fileName += _userName;
fileName += "_"; fileName += "_";
fileName += etk::to_string(m_time.time_since_epoch().count()); fileName += etk::toString(m_time.time_since_epoch().count());
fileName += ".json"; fileName += ".json";
etk::FSNodeWriteAllData(fileName, streamOut); etk::FSNodeWriteAllData(fileName, streamOut);
APPL_WARNING("store: " << fileName); APPL_WARNING("store: " << fileName);
@ -106,7 +106,7 @@ void appl::widget::TextAreaRecognition::onDraw() {
m_text.draw(); m_text.draw();
} }
std::vector<std::vector<vec2>> scalePoints(std::vector<std::vector<vec2>> _list, float _objectSize) { etk::Vector<etk::Vector<vec2>> scalePoints(std::vector<std::vector<vec2>> _list, float _objectSize) {
// get min/max point // get min/max point
vec2 minPos(99999999,99999999); vec2 minPos(99999999,99999999);
vec2 maxPos(0,0); vec2 maxPos(0,0);
@ -137,11 +137,11 @@ std::vector<std::vector<vec2>> scalePoints(std::vector<std::vector<vec2>> _list,
return _list; return _list;
} }
std::vector<etk::Color<float,4>> renderWithSVG(const std::vector<std::vector<vec2>>& _list, int32_t _objectSize, const std::string& _filename) { etk::Vector<etk::Color<float,4>> renderWithSVG(const etk::Vector<std::vector<vec2>>& _list, int32_t _objectSize, const etk::String& _filename) {
// generate SVG to render: // generate SVG to render:
esvg::Document docSvg; esvg::Document docSvg;
std::string data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"); etk::String data("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n");
data += "<svg height='" + etk::to_string(_objectSize) + "' width='" + etk::to_string(_objectSize) + "'>\n"; data += "<svg height='" + etk::toString(_objectSize) + "' width='" + etk::to_string(_objectSize) + "'>\n";
for (auto &itLines : _list) { for (auto &itLines : _list) {
data += " <polyline\n"; data += " <polyline\n";
data += " fill='none'\n"; data += " fill='none'\n";
@ -155,7 +155,7 @@ std::vector<etk::Color<float,4>> renderWithSVG(const std::vector<std::vector<vec
data += " "; data += " ";
} }
first = false; first = false;
data += etk::to_string(itPoints.x()) + "," + etk::to_string(itPoints.y()); data += etk::toString(itPoints.x()) + "," + etk::to_string(itPoints.y());
} }
data += "'\n"; data += "'\n";
data += " />\n"; data += " />\n";
@ -290,11 +290,11 @@ void appl::widget::TextAreaRecognition::onRegenerateDisplay() {
} else { } else {
m_text.setColor(etk::color::red); m_text.setColor(etk::color::red);
} }
m_text.print(m_dollarResults.getName(iii) + " " + etk::to_string(m_dollarResults.getConfidence(iii)) + "%"); m_text.print(m_dollarResults.getName(iii) + " " + etk::toString(m_dollarResults.getConfidence(iii)) + "%");
} }
m_text.setColor(etk::color::white); m_text.setColor(etk::color::white);
m_text.setPos(vec2(0, m_text.getHeight()*2)); m_text.setPos(vec2(0, m_text.getHeight()*2));
m_text.print("Dollar=" + etk::to_string(m_dollarTime.count()) + " ms"); m_text.print("Dollar=" + etk::toString(m_dollarTime.count()) + " ms");
} }
} }
@ -313,7 +313,7 @@ bool appl::widget::TextAreaRecognition::onEventInput(const ewol::event::Input& _
} }
if(_event.getStatus() == gale::key::status::up) { if(_event.getStatus() == gale::key::status::up) {
m_current.addPoint(relativePosition(_event.getPos())); m_current.addPoint(relativePosition(_event.getPos()));
m_dataList.push_back(m_current); m_dataList.pushBack(m_current);
m_current.clear(); m_current.clear();
} }
if(_event.getStatus() == gale::key::status::move) { if(_event.getStatus() == gale::key::status::move) {
@ -329,11 +329,11 @@ bool appl::widget::TextAreaRecognition::onEventInput(const ewol::event::Input& _
return false; return false;
} }
static std::vector<std::vector<vec2>> convertInLines(const std::vector<appl::DrawingLine>& _list) { static etk::Vector<etk::Vector<vec2>> convertInLines(const std::vector<appl::DrawingLine>& _list) {
std::vector<std::vector<vec2>> out; etk::Vector<etk::Vector<vec2>> out;
for (auto &it : _list) { for (auto &it : _list) {
if (it.m_data.size() > 1) { if (it.m_data.size() > 1) {
out.push_back(it.m_data); out.pushBack(it.m_data);
} else { } else {
// TODO // TODO
} }
@ -356,7 +356,7 @@ void appl::widget::TextAreaRecognition::callbackPeriodicUpdate(const ewol::event
return; return;
} }
// extract lines from json file: // extract lines from json file:
std::vector<std::vector<vec2>> fullListlines = convertInLines(m_dataList); etk::Vector<etk::Vector<vec2>> fullListlines = convertInLines(m_dataList);
if (fullListlines.size() == 0) { if (fullListlines.size() == 0) {
APPL_ERROR(" can not manage an objest with no line ..."); APPL_ERROR(" can not manage an objest with no line ...");
return; return;

View File

@ -20,7 +20,7 @@ namespace appl {
} }
enum gale::key::type m_type; enum gale::key::type m_type;
std::vector<vec2> m_data; etk::Vector<vec2> m_data;
void clear() { void clear() {
m_type = gale::key::type::unknow; m_type = gale::key::type::unknow;
m_data.clear(); m_data.clear();
@ -31,7 +31,7 @@ namespace appl {
return; return;
} }
} }
m_data.push_back(_point); m_data.pushBack(_point);
} }
}; };
namespace widget { namespace widget {
@ -39,18 +39,18 @@ namespace appl {
protected: protected:
ewol::compositing::Drawing m_draw; //!< drawing instance ewol::compositing::Drawing m_draw; //!< drawing instance
ewol::compositing::Text m_text; //!< drawing instance ewol::compositing::Text m_text; //!< drawing instance
std::vector<DrawingLine> m_dataList; etk::Vector<DrawingLine> m_dataList;
DrawingLine m_current; DrawingLine m_current;
std::chrono::system_clock::time_point m_time; std::chrono::system_clock::time_point m_time;
std::chrono::system_clock::time_point m_lastEvent; std::chrono::system_clock::time_point m_lastEvent;
esignal::Connection m_periodicConnection; esignal::Connection m_periodicConnection;
bool m_updateDone; bool m_updateDone;
std::string m_svgData; etk::String m_svgData;
int32_t m_detectId; int32_t m_detectId;
std::string m_compare; etk::String m_compare;
ememory::SharedPtr<dollar::Engine> m_dollarEngine; ememory::SharedPtr<dollar::Engine> m_dollarEngine;
dollar::Results m_dollarResults; dollar::Results m_dollarResults;
std::string m_findValue; etk::String m_findValue;
std::chrono::milliseconds m_dollarTime; std::chrono::milliseconds m_dollarTime;
protected: protected:
//! @brief constructor //! @brief constructor
@ -63,8 +63,8 @@ namespace appl {
public: public:
void clear(); void clear();
void undo(); void undo();
void store(const std::string& _userName, const std::string& _value, const std::string& _type); void store(const etk::String& _userName, const etk::String& _value, const std::string& _type);
void setCompare(const std::string& _compare); void setCompare(const etk::String& _compare);
public: public:
void onDraw() override; void onDraw() override;
void onRegenerateDisplay() override; void onRegenerateDisplay() override;

View File

@ -43,7 +43,7 @@ def configure(target, my_module):
]) ])
my_module.add_flag('c++', [ my_module.add_flag('c++', [
"-DPROJECT_NAME=\"\\\"" + my_module.get_name() + "\\\"\"", "-DPROJECT_NAME=\"\\\"" + my_module.get_name() + "\\\"\"",
"-DAPPL_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\"" "-DAPPL_VERSION=\"\\\"" + tools.version_toString(get_version()) + "\\\"\""
]) ])
my_module.add_path(".") my_module.add_path(".")
my_module.set_pkg("VERSION_CODE", 1) my_module.set_pkg("VERSION_CODE", 1)