diff --git a/README.md b/README.md index 83b92d7e..fc27496a 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,11 @@ In other cases you can contact the developer via email: ROI.size() == 0) @@ -38,8 +39,6 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution float zahl = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float; int ergebnis_nachkomma = ((int) floor(zahl * 10) + 10) % 10; - int prev = -1; - prev = ZeigerEval(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev); result = std::to_string(prev); @@ -66,7 +65,51 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution return result; } - if (CNNType == DigitalHyprid) + if ((CNNType == DoubleHyprid10)) + { + float zahl = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float; + if (zahl >= 0) // NaN? + { + if (_extendedResolution) + { + int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10; + int ergebnis_vorkomma = ((int) floor(zahl)) % 10; + + result = std::to_string(ergebnis_vorkomma) + std::to_string(ergebnis_nachkomma); + prev = ergebnis_vorkomma; + } + else + { + prev = ZeigerEval(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev); +// prev = ZeigerEvalHybrid(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev, prev); + result = std::to_string(prev); + } + } + else + { + result = "N"; + if (_extendedResolution && (CNNType != Digital)) + result = "NN"; + } + + for (int i = GENERAL[_analog]->ROI.size() - 2; i >= 0; --i) + { + if (GENERAL[_analog]->ROI[i]->result_float >= 0) + { + prev = ZeigerEvalHybrid(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev); + result = std::to_string(prev) + result; + + } + else + { + prev = -1; + result = "N" + result; + } + } + return result; + } + + if ((CNNType == DigitalHyprid)) { int zif_akt = -1; @@ -110,6 +153,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution return result; } + return result; } @@ -153,6 +197,35 @@ int ClassFlowCNNGeneral::ZeigerEvalHybrid(float zahl, float zahl_vorgaenger, int return ((int) trunc(zahl) + 10) % 10; } +/* +int ClassFlowCNNGeneral::ZeigerEvalHybrid_NEU(float zahl, float zahl_vorgaenger) +{ + int ergebnis_nachkomma = ((int) floor(zahl * 10) + 10) % 10; + int ergebnis_vorkomma = ((int) floor(zahl) + 10) % 10; + int ergebnis, ergebnis_rating; + + + if (zahl_vorgaenger < 0) + return ergebnis_vorkomma % 10; + + ergebnis_rating = ergebnis_nachkomma - zahl_vorgaenger; + if (ergebnis_nachkomma >= 5) + ergebnis_rating-=5; + else + ergebnis_rating+=5; + ergebnis = (int) round(zahl); + if (ergebnis_rating < 0) + ergebnis-=1; + if (ergebnis == -1) + ergebnis+=10; + + ergebnis = (ergebnis + 10) % 10; + return ergebnis; + +} +*/ + + int ClassFlowCNNGeneral::ZeigerEval(float zahl, int ziffer_vorgaenger) { int ergebnis_nachkomma = ((int) floor(zahl * 10) + 10) % 10; @@ -206,12 +279,12 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph) while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { zerlegt = this->ZerlegeZeile(aktparamgraph); - if ((zerlegt[0] == "LogImageLocation") && (zerlegt.size() > 1)) + if ((toUpper(zerlegt[0]) == "LOGIMAGELOCATION") && (zerlegt.size() > 1)) { this->LogImageLocation = "/sdcard" + zerlegt[1]; this->isLogImage = true; } - if ((zerlegt[0] == "LogImageSelect") && (zerlegt.size() > 1)) + if ((toUpper(zerlegt[0]) == "LOGIMAGESELECT") && (zerlegt.size() > 1)) { LogImageSelect = zerlegt[1]; isLogImageSelect = true; @@ -227,11 +300,16 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph) CNNType = DigitalHyprid; } - if ((zerlegt[0] == "Model") && (zerlegt.size() > 1)) + if ((toUpper(zerlegt[0]) == "MODEL") && (zerlegt.size() > 1)) { this->cnnmodelfile = zerlegt[1]; } - if ((zerlegt[0] == "ModelInputSize") && (zerlegt.size() > 2)) + + if ((toUpper(zerlegt[0]) == "CNNGOODTHRESHOLD") && (zerlegt.size() > 1)) + { + CNNGoodThreshold = std::stof(zerlegt[1]); + } + if ((toUpper(zerlegt[0]) == "MODELINPUTSIZE") && (zerlegt.size() > 2)) { this->modelxsize = std::stoi(zerlegt[1]); this->modelysize = std::stoi(zerlegt[2]); @@ -408,7 +486,6 @@ void ClassFlowCNNGeneral::DrawROI(CImageBasis *_zw) for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i) { _zw->drawRect(GENERAL[_ana]->ROI[i]->posx, GENERAL[_ana]->ROI[i]->posy, GENERAL[_ana]->ROI[i]->deltax, GENERAL[_ana]->ROI[i]->deltay, r, g, b, 1); -// _zw->drawCircle((int) (GENERAL[_ana]->ROI[i]->posx + GENERAL[_ana]->ROI[i]->deltax/2), (int) (GENERAL[_ana]->ROI[i]->posy + GENERAL[_ana]->ROI[i]->deltay/2), (int) (GENERAL[_ana]->ROI[i]->deltax/2), r, g, b, 2); _zw->drawEllipse( (int) (GENERAL[_ana]->ROI[i]->posx + GENERAL[_ana]->ROI[i]->deltax/2), (int) (GENERAL[_ana]->ROI[i]->posy + GENERAL[_ana]->ROI[i]->deltay/2), (int) (GENERAL[_ana]->ROI[i]->deltax/2), (int) (GENERAL[_ana]->ROI[i]->deltay/2), r, g, b, 2); _zw->drawLine((int) (GENERAL[_ana]->ROI[i]->posx + GENERAL[_ana]->ROI[i]->deltax/2), (int) GENERAL[_ana]->ROI[i]->posy, (int) (GENERAL[_ana]->ROI[i]->posx + GENERAL[_ana]->ROI[i]->deltax/2), (int) (GENERAL[_ana]->ROI[i]->posy + GENERAL[_ana]->ROI[i]->deltay), r, g, b, 2); _zw->drawLine((int) GENERAL[_ana]->ROI[i]->posx, (int) (GENERAL[_ana]->ROI[i]->posy + GENERAL[_ana]->ROI[i]->deltay/2), (int) GENERAL[_ana]->ROI[i]->posx + GENERAL[_ana]->ROI[i]->deltax, (int) (GENERAL[_ana]->ROI[i]->posy + GENERAL[_ana]->ROI[i]->deltay/2), r, g, b, 2); @@ -451,6 +528,10 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) CNNType = Analogue; printf("TFlite-Type set to Analogue\n"); break; + case 10: + CNNType = DoubleHyprid10; + printf("TFlite-Type set to DoubleHyprid10\n"); + break; case 11: CNNType = Digital; printf("TFlite-Type set to Digital\n"); @@ -562,6 +643,62 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) if (isLogImage) LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org); } break; + + case DoubleHyprid10: + { + int _num, _numplus, _numminus; + float _val, _valplus, _valminus; + float _fit; + + tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image); + tflite->Invoke(); + if (debugdetailgeneral) LogFile.WriteToFile("Nach Invoke"); + + _num = tflite->GetOutClassification(0, 9); + _numplus = (_num + 1) % 10; + _numminus = (_num - 1) % 10; + + _val = tflite->GetOutputValue(_num); + _valplus = tflite->GetOutputValue(_numplus); + _valminus = tflite->GetOutputValue(_numminus); + + float result = _num; + + if (_valplus > _numminus) + { + result = result + _valplus / (_valplus + _val); + _fit = _val + _valplus; + } + else + { + result = result - _valminus / (_val + _valminus); + _fit = _val + _valminus; + + } + if (result > 10) + result = result - 10; + if (result < 0) + result = result + 10; + + if (_fit < CNNGoodThreshold) + { + GENERAL[_ana]->ROI[i]->isReject = true; + result = -1; + string zw = "Value Rejected due to Threshold (Fit: " + to_string(_fit) + "Threshold: " + to_string(CNNGoodThreshold); + printf("Value Rejected due to Threshold (Fit: %f, Threshold: %f\n", _fit, CNNGoodThreshold); + LogFile.WriteToFile(zw); + } + else + { + GENERAL[_ana]->ROI[i]->isReject = false; + } + + GENERAL[_ana]->ROI[i]->result_float = result; + printf("Result General(Analog)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float); + + } + break; + default: break; } diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h index ef0a6cd1..e9c5c3ce 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h @@ -11,6 +11,7 @@ enum t_CNNType { Digital, DigitalHyprid, DigitalHyprid10, + DoubleHyprid10, None }; @@ -20,6 +21,7 @@ class ClassFlowCNNGeneral : protected: t_CNNType CNNType; std::vector GENERAL; + float CNNGoodThreshold; string cnnmodelfile; int modelxsize, modelysize; @@ -44,7 +46,7 @@ public: bool doFlow(string time); string getHTMLSingleStep(string host); - string getReadout(int _analog, bool _extendedResolution); + string getReadout(int _analog, bool _extendedResolution = false, int prev = -1); void DrawROI(CImageBasis *_zw); diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index e6316e15..751d25af 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -70,8 +70,6 @@ std::string ClassFlowControll::TranslateAktstatus(std::string _input) return ("Take Image"); if (_input.compare("ClassFlowAlignment") == 0) return ("Aligning"); - //if (_input.compare("ClassFlowAnalog") == 0) - // return ("Analog ROIs"); if (_input.compare("ClassFlowCNNGeneral") == 0) return ("Digitalization of ROIs"); if (_input.compare("ClassFlowMQTT") == 0) @@ -80,6 +78,8 @@ std::string ClassFlowControll::TranslateAktstatus(std::string _input) return ("Sending InfluxDB"); if (_input.compare("ClassFlowPostProcessing") == 0) return ("Processing"); + if (_input.compare("ClassFlowWriteList") == 0) + return ("Processing"); return "Unkown Status"; } @@ -185,9 +185,13 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type) } if (toUpper(_type).compare("[MQTT]") == 0) cfc = new ClassFlowMQTT(&FlowControll); + if (toUpper(_type).compare("[INFLUXDB]") == 0) cfc = new ClassFlowInfluxDB(&FlowControll); + if (toUpper(_type).compare("[WRITELIST]") == 0) + cfc = new ClassFlowWriteList(&FlowControll); + if (toUpper(_type).compare("[POSTPROCESSING]") == 0) { cfc = new ClassFlowPostProcessing(&FlowControll, flowanalog, flowdigit); @@ -639,35 +643,7 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req) return result; } - -string ClassFlowControll::getJSON() +string ClassFlowControll::getJSON(std::string _id, std::string _mac) { - std::vector* NUMBERS = flowpostprocessing->GetNumbers(); - - std::string json="{\n"; - - for (int i = 0; i < (*NUMBERS).size(); ++i) - { - json += "\"" + (*NUMBERS)[i]->name + "\":\n"; - json += " {\n"; - if ((*NUMBERS)[i]->ReturnValue.length() > 0) - json += " \"value\": " + (*NUMBERS)[i]->ReturnValue + ",\n"; - else - json += " \"value\": \"\",\n"; - json += " \"raw\": \"" + (*NUMBERS)[i]->ReturnRawValue + "\",\n"; - json += " \"error\": \"" + (*NUMBERS)[i]->ErrorMessageText + "\",\n"; - if ((*NUMBERS)[i]->ReturnRateValue.length() > 0) - json += " \"rate\": " + (*NUMBERS)[i]->ReturnRateValue + ",\n"; - else - json += " \"rate\": \"\",\n"; - - json += " \"timestamp\": \"" + (*NUMBERS)[i]->timeStamp + "\"\n"; - if ((i+1) < (*NUMBERS).size()) - json += " },\n"; - else - json += " }\n"; - } - json += "}"; - - return json; + return flowpostprocessing->GetJSON(_id, _mac); } diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.h b/code/components/jomjol_flowcontroll/ClassFlowControll.h index cc4e30dc..a8f92dc3 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.h +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.h @@ -11,6 +11,7 @@ #include "ClassFlowMQTT.h" #include "ClassFlowInfluxDB.h" #include "ClassFlowCNNGeneral.h" +#include "ClassFlowWriteList.h" #define READOUT_TYPE_VALUE 0 @@ -49,7 +50,7 @@ public: string UpdatePrevalue(std::string _newvalue, std::string _numbers, bool _extern); string GetPrevalue(std::string _number = ""); bool ReadParameter(FILE* pfile, string& aktparamgraph); - string getJSON(); + string getJSON(std::string _id = "", std::string _mac = ""); string TranslateAktstatus(std::string _input); diff --git a/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h b/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h index 7d9b2bec..181332d0 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h +++ b/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h @@ -7,6 +7,7 @@ struct roi { int posx, posy, deltax, deltay; float result_float; int result_klasse; + bool isReject; string name; CImageBasis *image, *image_org; }; @@ -38,7 +39,7 @@ struct NumberPost { string ReturnRateValue; // RückgabewertRate string ReturnRawValue; // Rohwert (mit N & führenden 0) string ReturnValue; // korrigierter Rückgabewert, ggf. mit Fehlermeldung - string ReturnPreValue; // korrigierter Rückgabewert ohne Fehlermeldung + string ReturnPreValue; // korrigierter Rückgabewert ohne Fehlermeldung string ErrorMessageText; // Fehlermeldung bei Consistency Check int AnzahlAnalog; int AnzahlDigital; diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index f37d44a5..f61e0140 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -15,6 +15,42 @@ #define PREVALUE_TIME_FORMAT_INPUT "%d-%d-%dT%d:%d:%d" +std::string ClassFlowPostProcessing::GetJSON(std::string _id, std::string _mac, std::string _lineend) +{ + std::string json="{" + _lineend; + + for (int i = 0; i < NUMBERS.size(); ++i) + { + json += "\"" + NUMBERS[i]->name + "\":" + _lineend; + json += " {" + _lineend; + + if (_id.length() > 0) + json += " \"ID\": \"" + _id + "\"," + _lineend; + if (_mac.length() > 0) + json += " \"MAC\": \"" + _mac + "\"," + _lineend; + + if (NUMBERS[i]->ReturnValue.length() > 0) + json += " \"value\": \"" + NUMBERS[i]->ReturnValue + "\"," + _lineend; + else + json += " \"value\": \"\"," + _lineend; + json += " \"raw\": \"" + NUMBERS[i]->ReturnRawValue + "\"," + _lineend; + json += " \"error\": \"" + NUMBERS[i]->ErrorMessageText + "\"," + _lineend; + if (NUMBERS[i]->ReturnRateValue.length() > 0) + json += " \"rate\": " + NUMBERS[i]->ReturnRateValue + "," + _lineend; + else + json += " \"rate\": \"\"," + _lineend; + + json += " \"timestamp\": \"" + NUMBERS[i]->timeStamp + "\"" + _lineend; + if ((i+1) < NUMBERS.size()) + json += " }," + _lineend; + else + json += " }" + _lineend; + } + json += "}"; + + return json; +} + string ClassFlowPostProcessing::GetPreValue(std::string _number) { std::string result; @@ -612,18 +648,29 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) UpdateNachkommaDecimalShift(); + int previous_value = -1; + + if (NUMBERS[j]->analog_roi) + { + NUMBERS[j]->ReturnRawValue = flowAnalog->getReadout(j, NUMBERS[j]->isExtendedResolution); + if (NUMBERS[j]->ReturnRawValue.length() > 0) + { + char zw = NUMBERS[j]->ReturnRawValue[0]; + if (zw >= 48 && zw <=57) + previous_value = zw - 48; + } + } + + if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) + NUMBERS[j]->ReturnRawValue = "." + NUMBERS[j]->ReturnRawValue; + if (NUMBERS[j]->digit_roi) { if (NUMBERS[j]->analog_roi) - NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false); + NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value) + NUMBERS[j]->ReturnRawValue; else - NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution); // Extended Resolution nur falls es keine analogen Ziffern gibt + NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value); // Extended Resolution nur falls es keine analogen Ziffern gibt } - if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) - NUMBERS[j]->ReturnRawValue = NUMBERS[j]->ReturnRawValue + "."; - - if (NUMBERS[j]->analog_roi) - NUMBERS[j]->ReturnRawValue = NUMBERS[j]->ReturnRawValue + flowAnalog->getReadout(j, NUMBERS[j]->isExtendedResolution); NUMBERS[j]->ReturnRawValue = ShiftDecimal(NUMBERS[j]->ReturnRawValue, NUMBERS[j]->DecimalShift); diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index aa50a85c..34b2309c 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h @@ -60,6 +60,8 @@ public: string GetPreValue(std::string _number = ""); void SetPreValue(float zw, string _numbers, bool _extern = false); + std::string GetJSON(std::string _id = "", std::string _mac = "", std::string _lineend = "\n"); + void UpdateNachkommaDecimalShift(); std::vector* GetNumbers(){return &NUMBERS;}; diff --git a/code/components/jomjol_flowcontroll/ClassFlowWriteList.cpp b/code/components/jomjol_flowcontroll/ClassFlowWriteList.cpp new file mode 100644 index 00000000..4d406728 --- /dev/null +++ b/code/components/jomjol_flowcontroll/ClassFlowWriteList.cpp @@ -0,0 +1,97 @@ +#include +#include "ClassFlowWriteList.h" +#include "Helper.h" + +#include "time_sntp.h" + + +#include + +void ClassFlowWriteList::SetInitialParameter(void) +{ + flowpostprocessing = NULL; + previousElement = NULL; + ListFlowControll = NULL; + disabled = false; +} + +ClassFlowWriteList::ClassFlowWriteList() +{ + SetInitialParameter(); +} + +ClassFlowWriteList::ClassFlowWriteList(std::vector* lfc) +{ + SetInitialParameter(); + + ListFlowControll = lfc; + for (int i = 0; i < ListFlowControll->size(); ++i) + { + if (((*ListFlowControll)[i])->name().compare("ClassFlowPostProcessing") == 0) + { + flowpostprocessing = (ClassFlowPostProcessing*) (*ListFlowControll)[i]; + } + } +} + + +bool ClassFlowWriteList::ReadParameter(FILE* pfile, string& aktparamgraph) +{ + std::vector zerlegt; + + aktparamgraph = trim(aktparamgraph); + + if (aktparamgraph.size() == 0) + if (!this->GetNextParagraph(pfile, aktparamgraph)) + return false; + + if (toUpper(aktparamgraph).compare("[MQTT]") != 0) // Paragraph passt nich zu MakeImage + return false; + + while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) + { + zerlegt = this->ZerlegeZeile(aktparamgraph); +/* + if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1)) + { + this->user = zerlegt[1]; + } +*/ + } + + return true; +} + + + +bool ClassFlowWriteList::doFlow(string zwtime) +{ + std::string line = ""; + + std::string result; + std::string resulterror = ""; + std::string resultraw = ""; + std::string resultrate = ""; + std::string resulttimestamp = ""; + string zw = ""; + string namenumber = ""; + + if (flowpostprocessing) + { + std::vector* NUMBERS = flowpostprocessing->GetNumbers(); + + for (int i = 0; i < (*NUMBERS).size(); ++i) + { + result = (*NUMBERS)[i]->ReturnValue; + resultraw = (*NUMBERS)[i]->ReturnRawValue; + resulterror = (*NUMBERS)[i]->ErrorMessageText; + resultrate = (*NUMBERS)[i]->ReturnRateValue; + resulttimestamp = (*NUMBERS)[i]->timeStamp; + + line = line + resulttimestamp + "\t" + resultraw + "\t" + result + "\t" + resultraw + "\t" + resultrate + "\t" + resulttimestamp + "\t"; + + } + } + + return true; +} diff --git a/code/components/jomjol_flowcontroll/ClassFlowWriteList.h b/code/components/jomjol_flowcontroll/ClassFlowWriteList.h new file mode 100644 index 00000000..49078f19 --- /dev/null +++ b/code/components/jomjol_flowcontroll/ClassFlowWriteList.h @@ -0,0 +1,22 @@ +#pragma once +#include "ClassFlow.h" +#include "ClassFlowPostProcessing.h" + +#include + +class ClassFlowWriteList : + public ClassFlow +{ +protected: + ClassFlowPostProcessing* flowpostprocessing; + void SetInitialParameter(void); + +public: + ClassFlowWriteList(); + ClassFlowWriteList(std::vector* lfc); + + bool ReadParameter(FILE* pfile, string& aktparamgraph); + bool doFlow(string time); + string name(){return "ClassFlowWriteList";}; +}; + diff --git a/code/components/jomjol_tfliteclass/CTfLiteClass.h b/code/components/jomjol_tfliteclass/CTfLiteClass.h index d6e7aed4..cab5a0e3 100644 --- a/code/components/jomjol_tfliteclass/CTfLiteClass.h +++ b/code/components/jomjol_tfliteclass/CTfLiteClass.h @@ -9,7 +9,6 @@ #include "tensorflow/lite/micro/micro_error_reporter.h" #include "tensorflow/lite/micro/micro_interpreter.h" #include "tensorflow/lite/schema/schema_generated.h" -//#include "tensorflow/lite/version.h" #include "tensorflow/lite/micro/kernels/micro_ops.h" #include "esp_err.h" #include "esp_log.h" @@ -65,8 +64,6 @@ class CTfLiteClass bool LoadInputImageBasis(CImageBasis *rs); void Invoke(); int GetAnzOutPut(bool silent = true); -// void GetOutPut(); -// int GetOutClassification(); int GetOutClassification(int _von = -1, int _bis = -1); int GetClassFromImageBasis(CImageBasis *rs); diff --git a/code/main/main.cpp b/code/main/main.cpp index 25f3795d..05f0a889 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -103,18 +103,8 @@ bool Init_NVS_SDCard() } return false; } - - // Card has been initialized, print its properties sdmmc_card_print_info(stdout, card); - - // Init the GPIO - // Flash ausschalten - - // gpio_pad_select_gpio(FLASH_GPIO); - // gpio_set_direction(FLASH_GPIO, GPIO_MODE_OUTPUT); - // gpio_set_level(FLASH_GPIO, 0); - return true; } @@ -149,9 +139,7 @@ extern "C" void app_main(void) Camera.LightOnOff(false); xDelay = 2000 / portTICK_PERIOD_MS; printf("nach init camera: sleep for : %ldms\n", (long) xDelay); -// LogFile.WriteToFile("Startsequence 06"); vTaskDelay( xDelay ); -// LogFile.WriteToFile("Startsequence 07"); if (!Init_NVS_SDCard()) @@ -186,9 +174,7 @@ extern "C" void app_main(void) xDelay = 2000 / portTICK_PERIOD_MS; printf("main: sleep for : %ldms\n", (long) xDelay); -// LogFile.WriteToFile("Startsequence 06"); vTaskDelay( xDelay ); -// LogFile.WriteToFile("Startsequence 07"); setup_time(); setBootTime(); LogFile.WriteToFile("============================================================================================="); @@ -196,23 +182,18 @@ extern "C" void app_main(void) LogFile.WriteToFile("============================================================================================="); LogFile.SwitchOnOff(false); - - - std::string zw = gettimestring("%Y%m%d-%H%M%S"); printf("time %s\n", zw.c_str()); - - size_t _hsize = getESPHeapSize(); if (_hsize < 4000000) { - std::string _zws = "Not enought PSRAM available. Expected 4.194.304 MByte - available: " + std::to_string(_hsize); - _zws = _zws + "\nEither not initialzed or too small (2MByte only) or not present at all. Firmware cannot start!!"; - printf(_zws.c_str()); - LogFile.SwitchOnOff(true); - LogFile.WriteToFile(_zws); - LogFile.SwitchOnOff(false); + std::string _zws = "Not enought PSRAM available. Expected 4.194.304 MByte - available: " + std::to_string(_hsize); + _zws = _zws + "\nEither not initialzed or too small (2MByte only) or not present at all. Firmware cannot start!!"; + printf(_zws.c_str()); + LogFile.SwitchOnOff(true); + LogFile.WriteToFile(_zws); + LogFile.SwitchOnOff(false); } else { if (cam != ESP_OK) { ESP_LOGE(TAGMAIN, "Failed to initialize camera module. " diff --git a/code/main/server_main.h b/code/main/server_main.h index 00033b66..ccf4c7cb 100644 --- a/code/main/server_main.h +++ b/code/main/server_main.h @@ -20,5 +20,4 @@ httpd_handle_t start_webserver(void); void register_server_main_uri(httpd_handle_t server, const char *base_path); - #endif diff --git a/code/main/version.cpp b/code/main/version.cpp index f17394c2..10eaaa2b 100644 --- a/code/main/version.cpp +++ b/code/main/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="dc7eedc"; +const char* GIT_REV="ccb4bd5"; const char* GIT_TAG=""; const char* GIT_BRANCH="rolling"; -const char* BUILD_TIME="2022-04-15 14:46"; \ No newline at end of file +const char* BUILD_TIME="2022-04-17 19:48"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index f17394c2..10eaaa2b 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="dc7eedc"; +const char* GIT_REV="ccb4bd5"; const char* GIT_TAG=""; const char* GIT_BRANCH="rolling"; -const char* BUILD_TIME="2022-04-15 14:46"; \ No newline at end of file +const char* BUILD_TIME="2022-04-17 19:48"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index e9569d04..1b3dd33b 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/dhy0010s3q.tflite b/firmware/dhy0010s3q.tflite new file mode 100644 index 00000000..9f3d9acf Binary files /dev/null and b/firmware/dhy0010s3q.tflite differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index e7a38b5c..ebfcb971 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/firmware/html.zip b/firmware/html.zip index d378d900..c136949e 100644 Binary files a/firmware/html.zip and b/firmware/html.zip differ diff --git a/sd-card/config/config.ini b/sd-card/config/config.ini index 9c3c1005..34c0346a 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -46,6 +46,9 @@ PreValueUse = true PreValueAgeStartup = 720 AllowNegativeRates = false main.MaxRateValue = 0.05 +;main.MaxRateType = AbsoluteChange +;main.ExtendedResolution = false +;main.IgnoreLeadingNaN = true ErrorMessage = true CheckDigitIncreaseConsistency = false diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index bfadb0da..7dea248d 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -298,6 +298,22 @@ textarea { Path to CNN model file for image recognition + + + + + + + CNNGoodThreshold + + + + + + EXPERIMENTAL - NOT WORKING FOR ALL CNNs! - Threshold above which the classification should be to accept the value (only for digits meaningfull) + + + @@ -728,6 +744,7 @@ textarea { + AutoTimer @@ -1860,21 +1877,18 @@ function UpdateInput() { WriteParameter(param, category, "Alignment", "SearchFieldY", false); WriteParameter(param, category, "Alignment", "AlignmentAlgo", true); -// WriteParameter(param, category, "Digits", "Model", false); + WriteParameter(param, category, "Digits", "CNNGoodThreshold", true); WriteParameter(param, category, "Digits", "LogImageLocation", true); WriteParameter(param, category, "Digits", "LogfileRetentionInDays", true); WriteParameter(param, category, "Digits", "ModelInputSize", false); -// WriteParameter(param, category, "Analog", "Model", false); WriteParameter(param, category, "Analog", "LogImageLocation", true); WriteParameter(param, category, "Analog", "LogfileRetentionInDays", true); -// WriteParameter(param, category, "Analog", "ExtendedResolution", true); WriteParameter(param, category, "Analog", "ModelInputSize", false); WriteParameter(param, category, "PostProcessing", "PreValueUse", true); WriteParameter(param, category, "PostProcessing", "PreValueAgeStartup", true); WriteParameter(param, category, "PostProcessing", "AllowNegativeRates", true); -// WriteParameter(param, category, "PostProcessing", "MaxRateValue", true); WriteParameter(param, category, "PostProcessing", "ErrorMessage", true); WriteParameter(param, category, "PostProcessing", "CheckDigitIncreaseConsistency", true); @@ -1963,7 +1977,8 @@ function ReadParameterAll() ReadParameter(param, "Alignment", "SearchFieldY", false); ReadParameter(param, "Alignment", "AlignmentAlgo", true); - ReadParameter(param, "Digits", "Model", false); + ReadParameter(param, "Digits", "Model", false); + ReadParameter(param, "Digits", "CNNGoodThreshold", true); ReadParameter(param, "Digits", "LogImageLocation", true); ReadParameter(param, "Digits", "LogfileRetentionInDays", true); ReadParameter(param, "Digits", "ModelInputSize", false); diff --git a/sd-card/html/readconfigparam.js b/sd-card/html/readconfigparam.js index d3b17741..5deb5141 100644 --- a/sd-card/html/readconfigparam.js +++ b/sd-card/html/readconfigparam.js @@ -83,9 +83,11 @@ function ParseConfig() { category[catname]["found"] = false; param[catname] = new Object(); ParamAddValue(param, catname, "Model"); + ParamAddValue(param, catname, "CNNGoodThreshold", 1); ParamAddValue(param, catname, "LogImageLocation"); ParamAddValue(param, catname, "LogfileRetentionInDays"); - ParamAddValue(param, catname, "ModelInputSize", 2); + ParamAddValue(param, catname, "ModelInputSize", 2); + var catname = "Analog"; category[catname] = new Object(); diff --git a/sd-card/html/version.txt b/sd-card/html/version.txt index f13c819c..2f0f3c13 100644 --- a/sd-card/html/version.txt +++ b/sd-card/html/version.txt @@ -1 +1 @@ -14.0.0 \ No newline at end of file +14.1.0 \ No newline at end of file