[DEV] try to add tools to bench
This commit is contained in:
parent
aaceff37cb
commit
d984faf27f
@ -55,6 +55,7 @@ static float pathDistance(const std::vector<vec2>& _path1, const std::vector<vec
|
||||
|
||||
dollar::Engine::Engine():
|
||||
m_PPlusDistance(0.10f),
|
||||
m_PPlusExcludeDistance(0.2*0.2),
|
||||
m_scaleKeepRatio(false) {
|
||||
m_numPointsInGesture = 128;
|
||||
DOLLAR_ASSERT(m_numPointsInGesture>16, "NB element in a path must be > 16 ...");
|
||||
@ -78,19 +79,29 @@ size_t dollar::Engine::getNumberPointInGesture() {
|
||||
}
|
||||
|
||||
void dollar::Engine::setPPlusDistance(float _value) {
|
||||
if (_value == m_PPlusDistance) {
|
||||
if (_value*_value == m_PPlusDistance*) {
|
||||
return;
|
||||
}
|
||||
m_PPlusDistance = _value;
|
||||
m_PPlusDistance = _value*_value;
|
||||
for (auto &it: m_gestures) {
|
||||
it.configure(m_numPointsInGesture/RATIO_START_VECTOR, m_numPointsInGesture, m_paramterIgnoreRotation, m_PPlusDistance, m_scaleKeepRatio);
|
||||
}
|
||||
}
|
||||
|
||||
float dollar::Engine::getPPlusDistance() {
|
||||
return m_PPlusDistance;
|
||||
return std::sqrt(m_PPlusDistance);
|
||||
}
|
||||
|
||||
void dollar::Engine::setPPlusExcludeDistance(float _value) {
|
||||
if (_value == m_PPlusExcludeDistance) {
|
||||
return;
|
||||
}
|
||||
m_PPlusExcludeDistance = _value;
|
||||
}
|
||||
|
||||
float dollar::Engine::getPPlusExcludeDistance() {
|
||||
return m_PPlusExcludeDistance;
|
||||
}
|
||||
void dollar::Engine::setScaleKeepRatio(bool _value) {
|
||||
if (_value == m_scaleKeepRatio) {
|
||||
return;
|
||||
@ -207,7 +218,7 @@ static float calculatePPlusDistance(const std::vector<vec2>& _points,
|
||||
}
|
||||
if (kkkBest != -1) {
|
||||
// reject the distance ... if too big ...
|
||||
if (bestDistance <= 0.2*0.2) {
|
||||
if (bestDistance <= m_PPlusExcludeDistance) {
|
||||
int32_t previous = usedId[kkkBest];
|
||||
usedId[kkkBest] = iii;
|
||||
distance[iii] = bestDistance;
|
||||
@ -560,7 +571,7 @@ dollar::Results dollar::Engine::recognizePPlus(const std::vector<std::vector<vec
|
||||
continue;
|
||||
}
|
||||
if (gesture.getEnginePoints().size() == 0) {
|
||||
DOLLAR_ERROR("Reference path with no Value");
|
||||
//DOLLAR_ERROR("Reference path with no Value");
|
||||
continue;
|
||||
}
|
||||
float distance = MAX_FLOAT;
|
||||
|
@ -20,6 +20,11 @@ namespace dollar {
|
||||
public:
|
||||
void setPPlusDistance(float _value);
|
||||
float getPPlusDistance();
|
||||
protected:
|
||||
float m_PPlusExcludeDistance;
|
||||
public:
|
||||
void setPPlusExcludeDistance(float _value);
|
||||
float setPPlusExcludeDistance();
|
||||
protected:
|
||||
bool m_scaleKeepRatio; // when rescale the path, keep the aspect ration for processing
|
||||
public:
|
||||
|
@ -115,6 +115,9 @@ std::vector<vec2> dollar::translateBariCenterToZero(std::vector<vec2> _points) {
|
||||
|
||||
static std::vector<vec2> discretize(std::vector<vec2> _points, float _interval) {
|
||||
std::vector<vec2> out;
|
||||
if (_points.size() == 0) {
|
||||
return out;
|
||||
}
|
||||
// same first point ==> no change
|
||||
out.push_back(_points.front());
|
||||
float distance = 0.0f;
|
||||
@ -137,6 +140,9 @@ static std::vector<vec2> discretize(std::vector<vec2> _points, float _interval)
|
||||
|
||||
std::vector<vec2> dollar::resample(std::vector<vec2> _points, int32_t _nbPoints) {
|
||||
std::vector<vec2> out;
|
||||
if (_points.size() == 0) {
|
||||
return out;
|
||||
}
|
||||
// calculate the interval between every points ...
|
||||
float interval = pathLength(_points) / (_nbPoints - 1);
|
||||
out = discretize(_points, interval);
|
||||
@ -191,6 +197,9 @@ std::vector<vec2> dollar::combineStrokes(const std::vector<std::vector<vec2>>& _
|
||||
|
||||
vec2 dollar::getStartVector(const std::vector<vec2>& _points, float _index) {
|
||||
DOLLAR_ASSERT(_index > 0, "index must be != of 0");
|
||||
if (_points.size() <= _index) {
|
||||
return vec2(1.0, 0.0);
|
||||
}
|
||||
vec2 vect = _points[_index] - _points[0];
|
||||
float len = vect.length();
|
||||
return vect / len;
|
||||
|
@ -24,10 +24,20 @@ void usage(const std::string& _progName) {
|
||||
|
||||
bool testCorpus(const std::string& _srcCorpus);
|
||||
|
||||
static bool keepAspectRatio = false;
|
||||
static float distanceReference; // distance of the gesture reference [0.02, 0.3]
|
||||
static float distanceCheck; // distance of the test points [0.02, 0.3]
|
||||
static float distanceExclude; // distance of the exclusion point [0.1, 1.0]
|
||||
|
||||
setScaleKeepRatio(keepAspectRatio);
|
||||
setPPlusDistance(distanceReference); // to generate reference gesture
|
||||
setPPlusDistance(distanceCheck); // to generate test gesture
|
||||
setPPlusExcludeDistance(distanceExclude);
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
// init etk log system and file interface:
|
||||
etk::init(_argc, _argv);
|
||||
std::string srcCorpus;
|
||||
|
||||
for (int32_t iii=1; iii<_argc; ++iii) {
|
||||
std::string arg = _argv[iii];
|
||||
if ( arg == "-h"
|
||||
@ -35,8 +45,27 @@ int main(int _argc, const char *_argv[]) {
|
||||
usage(_argv[0]);
|
||||
return 0;
|
||||
}
|
||||
if( arg[0] == '-'
|
||||
&& arg[1] == '-') {
|
||||
if (arg == "--keep_ratio") {
|
||||
keepAspectRatio = true;
|
||||
continue;
|
||||
}
|
||||
if (etk::start_with(arg,"--dist-ref=") == true) {
|
||||
std::string val(&arg[11]);
|
||||
distanceReference = etk::string_to_float(val);
|
||||
continue;
|
||||
}
|
||||
if (etk::start_with(arg,"--dist-check=") == true) {
|
||||
std::string val(&arg[13]);
|
||||
distanceCheck = etk::string_to_float(val);
|
||||
continue;
|
||||
}
|
||||
if (etk::start_with(arg,"--dist-excl=") == true) {
|
||||
std::string val(&arg[12]);
|
||||
distanceExclude = etk::string_to_float(val);
|
||||
continue;
|
||||
}
|
||||
if ( arg[0] == '-'
|
||||
&& arg[1] == '-') {
|
||||
// subLibrary usage ...
|
||||
continue;
|
||||
}
|
||||
@ -118,13 +147,14 @@ bool testCorpus(const std::string& _srcCorpus) {
|
||||
}
|
||||
}
|
||||
//listOfElementInCorpus.clear();
|
||||
//listOfElementInCorpus.push_back("z");
|
||||
//listOfElementInCorpus.push_back("slash");
|
||||
// Value to stop grouping in the same element ...
|
||||
float groupSize = 1.0;
|
||||
groupSize = 1.0;
|
||||
bool keepAspectRatio = false;
|
||||
|
||||
TEST_PRINT(" will done for: " << listOfElementInCorpus);
|
||||
int32_t nbElementGenerated = 0;
|
||||
for (auto &itTypeOfCorpus : listOfElementInCorpus) {
|
||||
TEST_PRINT("---------------------------------------------------------------------------");
|
||||
TEST_PRINT("-- Generate FOR: '" << itTypeOfCorpus << "'");
|
||||
@ -134,7 +164,7 @@ bool keepAspectRatio = false;
|
||||
if (etk::end_with(it, ".json") == true) {
|
||||
std::vector<std::string> path = etk::split(it, '/');
|
||||
std::string filename = path[path.size()-1];
|
||||
if (etk::start_with(filename, itTypeOfCorpus) == true) {
|
||||
if (etk::start_with(filename, itTypeOfCorpus + "_") == true) {
|
||||
fileFiltered.push_back(it);
|
||||
}
|
||||
}
|
||||
@ -321,8 +351,12 @@ bool keepAspectRatio = false;
|
||||
|
||||
// Increment subId...
|
||||
subId++;
|
||||
nbElementGenerated++;
|
||||
}
|
||||
}
|
||||
TEST_PRINT("===========================================================================");
|
||||
TEST_PRINT("== Gererate Done: " << nbElementGenerated);
|
||||
TEST_PRINT("===========================================================================");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user