|
@@ -5,7 +5,8 @@
|
|
|
#include <ClassFlowMakeImage.h>
|
|
#include <ClassFlowMakeImage.h>
|
|
|
|
|
|
|
|
void setUpClassFlowPostprocessing(void);
|
|
void setUpClassFlowPostprocessing(void);
|
|
|
-string process_doFlow(std::vector<float> analog, std::vector<float> digits, t_CNNType digType = Digital100);
|
|
|
|
|
|
|
+string process_doFlow(std::vector<float> analog, std::vector<float> digits, t_CNNType digType = Digital100,
|
|
|
|
|
+ bool checkConsistency=false, bool extendedResolution=false, int decimal_shift=0);
|
|
|
|
|
|
|
|
ClassFlowCNNGeneral* _analog;
|
|
ClassFlowCNNGeneral* _analog;
|
|
|
ClassFlowCNNGeneral* _digit;
|
|
ClassFlowCNNGeneral* _digit;
|
|
@@ -43,6 +44,7 @@ void test_doFlow() {
|
|
|
std::vector<float> digits = { 1.2, 6.7};
|
|
std::vector<float> digits = { 1.2, 6.7};
|
|
|
std::vector<float> analogs = { 9.5, 8.4};
|
|
std::vector<float> analogs = { 9.5, 8.4};
|
|
|
const char* expected = "16.98";
|
|
const char* expected = "16.98";
|
|
|
|
|
+ const char* expected_extended = "16.984";
|
|
|
std::string result = process_doFlow(analogs, digits);
|
|
std::string result = process_doFlow(analogs, digits);
|
|
|
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
|
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
|
|
|
|
|
|
@@ -195,11 +197,71 @@ void test_doFlow() {
|
|
|
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1242730397
|
|
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1242730397
|
|
|
digits = { 3.0, 2.0, 2.0, 8.0, 9.0, 4.0, 1.7, 9.8}; // falscher Wert 32290.420
|
|
digits = { 3.0, 2.0, 2.0, 8.0, 9.0, 4.0, 1.7, 9.8}; // falscher Wert 32290.420
|
|
|
analogs = { };
|
|
analogs = { };
|
|
|
- expected = "32289420";
|
|
|
|
|
- result = process_doFlow(analogs, digits);
|
|
|
|
|
|
|
+ expected = "32289.420";
|
|
|
|
|
+ expected_extended= "32289.4199";
|
|
|
|
|
+ // FALSCH! wegen ungenügender Präzision von NUMBERS->Value
|
|
|
|
|
+ // expected_extended= "32289.4198";
|
|
|
|
|
+
|
|
|
|
|
+ // extendResolution=false, checkConsistency=false
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, false, false, -3);
|
|
|
|
|
+ TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ // extendResolution=true
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, false, true, -3);
|
|
|
|
|
+ TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ // checkConsistency=true und extendResolution=true
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, false, true, -3);
|
|
|
|
|
+ TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ // Fehler Rolling (2022-09-10)
|
|
|
|
|
+ // not documented as issue
|
|
|
|
|
+ digits = { 0.0, 0.0, 7.9, 3.8}; // 84.99401 als falsches Ergebnis
|
|
|
|
|
+ analogs = { 0.0, 9.4, 4.1, 0.1};
|
|
|
|
|
+ expected = "83.9940";
|
|
|
|
|
+ expected_extended= "83.99401";
|
|
|
|
|
+
|
|
|
|
|
+ // checkConsistency=false
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, false);
|
|
|
|
|
+ TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // checkConsistency=true
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, true);
|
|
|
|
|
+ TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ // extendResolution=true
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, false, true);
|
|
|
|
|
+ TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ // checkConsistency=true und extendResolution=true
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, false, true);
|
|
|
|
|
+ TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ // Fehler Rolling (2022-09-10)
|
|
|
|
|
+ // https://github.com/jomjol/AI-on-the-edge-device/issues/994#issue-1368570945
|
|
|
|
|
+ digits = { 0.0, 0.0, 1.0, 2.0, 2.8, 1.9, 2.8, 5.6}; // 123245.6 als falsches Ergebnis
|
|
|
|
|
+ analogs = { };
|
|
|
|
|
+ expected = "123236";
|
|
|
|
|
+ expected_extended= "123235.6";
|
|
|
|
|
+
|
|
|
|
|
+ // checkConsistency=true
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, false, false);
|
|
|
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
|
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ // checkConsistency=true
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, true, false);
|
|
|
|
|
+ TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ // extendResolution=true
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, false, true);
|
|
|
|
|
+ TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
|
|
|
|
|
+
|
|
|
|
|
+ // checkConsistency=true und extendResolution=true
|
|
|
|
|
+ result = process_doFlow(analogs, digits, Digital100, false, true);
|
|
|
|
|
+ TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -221,7 +283,8 @@ void setUpClassFlowPostprocessing(t_CNNType digType, t_CNNType anaType)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-std::string process_doFlow(std::vector<float> analog, std::vector<float> digits, t_CNNType digType) {
|
|
|
|
|
|
|
+std::string process_doFlow(std::vector<float> analog, std::vector<float> digits, t_CNNType digType,
|
|
|
|
|
+ bool checkConsistency, bool extendedResolution, int decimal_shift) {
|
|
|
// setup the classundertest
|
|
// setup the classundertest
|
|
|
setUpClassFlowPostprocessing(digType, Analogue100);
|
|
setUpClassFlowPostprocessing(digType, Analogue100);
|
|
|
|
|
|
|
@@ -231,7 +294,6 @@ std::string process_doFlow(std::vector<float> analog, std::vector<float> digits,
|
|
|
if (digits.size()>0) {
|
|
if (digits.size()>0) {
|
|
|
general* gen_digit = _digit->GetGENERAL("default", true);
|
|
general* gen_digit = _digit->GetGENERAL("default", true);
|
|
|
gen_digit->ROI.clear();
|
|
gen_digit->ROI.clear();
|
|
|
-
|
|
|
|
|
for (int i = 0; i<digits.size(); i++) {
|
|
for (int i = 0; i<digits.size(); i++) {
|
|
|
roi* digitROI = new roi();
|
|
roi* digitROI = new roi();
|
|
|
string name = "digit_" + std::to_string(i);
|
|
string name = "digit_" + std::to_string(i);
|
|
@@ -258,6 +320,30 @@ std::string process_doFlow(std::vector<float> analog, std::vector<float> digits,
|
|
|
printf("Setup ROIs completed.\n");
|
|
printf("Setup ROIs completed.\n");
|
|
|
|
|
|
|
|
undertestPost->InitNUMBERS();
|
|
undertestPost->InitNUMBERS();
|
|
|
|
|
+ if (checkConsistency) {
|
|
|
|
|
+ printf("checkConsistency=true\n");
|
|
|
|
|
+ std::vector<NumberPost*>* NUMBERS = undertestPost->GetNumbers();
|
|
|
|
|
+ for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
|
|
|
|
|
+ printf("Set checkConsistency on number: %d\n", _n);
|
|
|
|
|
+ (*NUMBERS)[_n]->checkDigitIncreaseConsistency = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (extendedResolution ) {
|
|
|
|
|
+ std::vector<NumberPost*>* NUMBERS = undertestPost->GetNumbers();
|
|
|
|
|
+ for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
|
|
|
|
|
+ printf("Set extendedResolution on number: %d\n", _n);
|
|
|
|
|
+ (*NUMBERS)[_n]->isExtendedResolution = true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ if (decimal_shift!=0) {
|
|
|
|
|
+ std::vector<NumberPost*>* NUMBERS = undertestPost->GetNumbers();
|
|
|
|
|
+ for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
|
|
|
|
|
+ printf("Set decimalshif on number: %d to %d\n", _n, decimal_shift);
|
|
|
|
|
+ (*NUMBERS)[_n]->DecimalShift = decimal_shift;
|
|
|
|
|
+ (*NUMBERS)[_n]->DecimalShiftInitial = decimal_shift;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
string time;
|
|
string time;
|
|
|
// run test
|
|
// run test
|