ClassFlowCNNGeneral.cpp 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  1. #include "ClassFlowCNNGeneral.h"
  2. #include <math.h>
  3. #include <iomanip>
  4. #include <sys/types.h>
  5. #include <sstream> // std::stringstream
  6. #include "CTfLiteClass.h"
  7. #include "ClassLogFile.h"
  8. #include "esp_log.h"
  9. #include "../../include/defines.h"
  10. static const char* TAG = "CNN";
  11. //#ifdef CONFIG_HEAP_TRACING_STANDALONE
  12. #ifdef HEAP_TRACING_CLASS_FLOW_CNN_GENERAL_DO_ALING_AND_CUT
  13. #include <esp_heap_trace.h>
  14. #define NUM_RECORDS 300
  15. static heap_trace_record_t trace_record[NUM_RECORDS]; // This buffer must be in internal RAM
  16. #endif
  17. ClassFlowCNNGeneral::ClassFlowCNNGeneral(ClassFlowAlignment *_flowalign, t_CNNType _cnntype) : ClassFlowImage(NULL, TAG) {
  18. string cnnmodelfile = "";
  19. modelxsize = 1;
  20. modelysize = 1;
  21. CNNGoodThreshold = 0.0;
  22. ListFlowControll = NULL;
  23. previousElement = NULL;
  24. SaveAllFiles = false;
  25. disabled = false;
  26. isLogImageSelect = false;
  27. CNNType = AutoDetect;
  28. CNNType = _cnntype;
  29. flowpostalignment = _flowalign;
  30. imagesRetention = 5;
  31. }
  32. string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution, int prev, float _before_narrow_Analog, float analogDigitalTransitionStart) {
  33. string result = "";
  34. if (GENERAL[_analog]->ROI.size() == 0) {
  35. return result;
  36. }
  37. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout _analog=" + std::to_string(_analog) + ", _extendedResolution=" + std::to_string(_extendedResolution) + ", prev=" + std::to_string(prev));
  38. if (CNNType == Analogue || CNNType == Analogue100) {
  39. float number = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float;
  40. int result_after_decimal_point = ((int) floor(number * 10) + 10) % 10;
  41. prev = PointerEvalAnalogNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev);
  42. // LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout(analog) number=" + std::to_string(number) + ", result_after_decimal_point=" + std::to_string(result_after_decimal_point) + ", prev=" + std::to_string(prev));
  43. result = std::to_string(prev);
  44. if (_extendedResolution) {
  45. result = result + std::to_string(result_after_decimal_point);
  46. }
  47. for (int i = GENERAL[_analog]->ROI.size() - 2; i >= 0; --i) {
  48. prev = PointerEvalAnalogNew(GENERAL[_analog]->ROI[i]->result_float, prev);
  49. result = std::to_string(prev) + result;
  50. }
  51. return result;
  52. }
  53. if (CNNType == Digital) {
  54. for (int i = 0; i < GENERAL[_analog]->ROI.size(); ++i) {
  55. if (GENERAL[_analog]->ROI[i]->result_klasse >= 10) {
  56. result = result + "N";
  57. }
  58. else {
  59. result = result + std::to_string(GENERAL[_analog]->ROI[i]->result_klasse);
  60. }
  61. }
  62. return result;
  63. }
  64. if ((CNNType == DoubleHyprid10) || (CNNType == Digital100)) {
  65. float number = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float;
  66. // NaN?
  67. if (number >= 0) {
  68. // is only set if it is the first digit (no analogue before!)
  69. if (_extendedResolution) {
  70. int result_after_decimal_point = ((int) floor(number * 10)) % 10;
  71. int result_before_decimal_point = ((int) floor(number)) % 10;
  72. result = std::to_string(result_before_decimal_point) + std::to_string(result_after_decimal_point);
  73. prev = result_before_decimal_point;
  74. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout(dig100-ext) result_before_decimal_point=" + std::to_string(result_before_decimal_point) + ", result_after_decimal_point=" + std::to_string(result_after_decimal_point) + ", prev=" + std::to_string(prev));
  75. }
  76. else {
  77. if (_before_narrow_Analog >= 0) {
  78. prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, _before_narrow_Analog, prev, true, analogDigitalTransitionStart);
  79. }
  80. else {
  81. prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev, prev);
  82. }
  83. result = std::to_string(prev);
  84. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout(dig100) prev=" + std::to_string(prev));
  85. }
  86. }
  87. else {
  88. result = "N";
  89. if (_extendedResolution && (CNNType != Digital)) {
  90. result = "NN";
  91. }
  92. }
  93. for (int i = GENERAL[_analog]->ROI.size() - 2; i >= 0; --i) {
  94. if (GENERAL[_analog]->ROI[i]->result_float >= 0) {
  95. prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev);
  96. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout#PointerEvalHybridNew()= " + std::to_string(prev));
  97. result = std::to_string(prev) + result;
  98. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout#result= " + result);
  99. }
  100. else {
  101. prev = -1;
  102. result = "N" + result;
  103. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout(result_float<0 /'N') result_float=" + std::to_string(GENERAL[_analog]->ROI[i]->result_float));
  104. }
  105. }
  106. return result;
  107. }
  108. return result;
  109. }
  110. /**
  111. * @brief Determines the number of an ROI in connection with previous ROI results
  112. *
  113. * @param number: is the current ROI as float value from recognition
  114. * @param number_of_predecessors: is the last (lower) ROI as float from recognition
  115. * @param eval_predecessors: is the evaluated number. Sometimes a much lower value can change higer values
  116. * example: 9.8, 9.9, 0.1
  117. * 0.1 => 0 (eval_predecessors)
  118. * The 0 makes a 9.9 to 0 (eval_predecessors)
  119. * The 0 makes a 9.8 to 0
  120. * @param Analog_Predecessors false/true if the last ROI is an analog or digital ROI (default=false)
  121. * runs in special handling because analog is much less precise
  122. * @param digitalAnalogTransitionStart start of the transitionlogic begins on number_of_predecessor (default=9.2)
  123. *
  124. * @return int the determined number of the current ROI
  125. */
  126. int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors, float digitalAnalogTransitionStart) {
  127. int result;
  128. int result_after_decimal_point = ((int) floor(number * 10)) % 10;
  129. int result_before_decimal_point = ((int) floor(number) + 10) % 10;
  130. if (eval_predecessors < 0) {
  131. // on first digit is no spezial logic for transition needed
  132. // we use the recognition as given. The result is the int value of the recognition
  133. // add precisition of 2 digits and round before trunc
  134. result = (int) ((int) trunc(round((number+10 % 10)*100)) ) / 100;
  135. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - No predecessor - Result = " + std::to_string(result) +
  136. " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty));
  137. return result;
  138. }
  139. if (Analog_Predecessors) {
  140. result = PointerEvalAnalogToDigitNew(number, number_of_predecessors, eval_predecessors, digitalAnalogTransitionStart);
  141. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - Analog predecessor, evaluation over PointerEvalAnalogNew = " + std::to_string(result) +
  142. " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty));
  143. return result;
  144. }
  145. if ((number_of_predecessors > Digital_Transition_Area_Predecessor ) && (number_of_predecessors < (10.0 - Digital_Transition_Area_Predecessor)))
  146. {
  147. // no digit change, because predecessor is far enough away (0+/-DigitalTransitionRangePredecessor) --> number is rounded
  148. // Band around the digit --> Round off, as digit reaches inaccuracy in the frame
  149. if ((result_after_decimal_point <= DigitalBand) || (result_after_decimal_point >= (10-DigitalBand))) {
  150. result = ((int) round(number) + 10) % 10;
  151. }
  152. else {
  153. result = ((int) trunc(number) + 10) % 10;
  154. }
  155. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - NO analogue predecessor, no change of digits, as pre-decimal point far enough away = " + std::to_string(result) +
  156. " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty));
  157. return result;
  158. }
  159. // Zero crossing at the predecessor has taken place (! evaluation via Prev_value and not number!) --> round up here (2.8 --> 3, but also 3.1 --> 3)
  160. if (eval_predecessors <= 1) {
  161. // We simply assume that the current digit after the zero crossing of the predecessor
  162. // has passed through at least half (x.5)
  163. if (result_after_decimal_point > 5) {
  164. // The current digit does not yet have a zero crossing, but the predecessor does..
  165. result = (result_before_decimal_point + 1) % 10;
  166. }
  167. else {
  168. // Act. digit and predecessor have zero crossing
  169. result = result_before_decimal_point % 10;
  170. }
  171. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - NO analogue predecessor, zero crossing has taken placen = " + std::to_string(result) +
  172. " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty));
  173. return result;
  174. }
  175. // remains only >= 9.x --> no zero crossing yet --> 2.8 --> 2,
  176. // and from 9.7(DigitalTransitionRangeLead) 3.1 --> 2
  177. // everything >=x.4 can be considered as current number in transition. With 9.x predecessor the current
  178. // number can still be x.6 - x.7.
  179. // Preceding (else - branch) does not already happen from 9.
  180. if (((Digital_Transition_Area_Forward>=number_of_predecessors) && (eval_predecessors == (int)number_of_predecessors))
  181. || result_after_decimal_point >= 4)
  182. // The current digit, like the previous digit, does not yet have a zero crossing.
  183. result = result_before_decimal_point % 10;
  184. }
  185. else {
  186. // current digit precedes the smaller digit (9.x). So already >=x.0 while the previous digit has not yet
  187. // has no zero crossing. Therefore, it is reduced by 1.
  188. result = (result_before_decimal_point - 1 + 10) % 10;
  189. }
  190. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - O analogue predecessor, >= 9.5 --> no zero crossing yet = " + std::to_string(result) +
  191. " number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty) + " result_after_decimal_point = " + std::to_string(result_after_decimal_point));
  192. return result;
  193. }
  194. int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral_preceder, int eval_predecessors, float analogDigitalTransitionStart) {
  195. int result;
  196. int result_after_decimal_point = ((int) floor(number * 10)) % 10;
  197. int result_before_decimal_point = ((int) floor(number) + 10) % 10;
  198. bool roundedUp = false;
  199. // Within the digital inequalities
  200. if ((result_after_decimal_point >= (10-Digital_Uncertainty * 10) && ((int)numeral_preceder == eval_predecessors)) // Band around the digit --> Round off, as digit reaches inaccuracy in the frame
  201. || (eval_predecessors <= 4 && result_after_decimal_point>=6)) { // or digit runs after (analogue =0..4, digit >=6)
  202. result = (int) (round(number) + 10) % 10;
  203. roundedUp = true;
  204. // before/ after decimal point, because we adjust the number based on the uncertainty.
  205. result_after_decimal_point = ((int) floor(result * 10)) % 10;
  206. result_before_decimal_point = ((int) floor(result) + 10) % 10;
  207. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - Digital Uncertainty - Result = " + std::to_string(result) +
  208. " number: " + std::to_string(number) + " numeral_preceder: " + std::to_string(numeral_preceder) +
  209. " erg before comma: " + std::to_string(result_before_decimal_point) +
  210. " erg after comma: " + std::to_string(result_after_decimal_point));
  211. }
  212. else if (result_after_decimal_point < Digital_Uncertainty && numeral_preceder > analogDigitalTransitionStart) {
  213. result = ((result_before_decimal_point+10) - 1) % 10;
  214. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - Digital Uncertainty - Too early zero crossing - Result = " + std::to_string(result) +
  215. " number: " + std::to_string(number) + " numeral_preceder: " + std::to_string(numeral_preceder) +
  216. " erg before comma: " + std::to_string(result_before_decimal_point) +
  217. " erg after comma: " + std::to_string(result_after_decimal_point));
  218. }
  219. else {
  220. result = (int) ((int) trunc(number) + 10) % 10;
  221. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - NO digital Uncertainty - Result = " + std::to_string(result) +
  222. " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder));
  223. }
  224. // No zero crossing has taken place.
  225. // Only eval_predecessors used because numeral_preceder could be wrong here.
  226. // numeral_preceder<=0.1 & eval_predecessors=9 corresponds to analogue was reset because of previous analogue that are not yet at 0.
  227. if ((eval_predecessors >= 3 && (numeral_preceder > analogDigitalTransitionStart) && roundedUp))
  228. {
  229. result = ((result_before_decimal_point+10) - 1) % 10;
  230. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - No correction = " + std::to_string(result) +
  231. " number: " + std::to_string(number) +
  232. " numeral_preceder = " + std::to_string(numeral_preceder) +
  233. " eerg after comma = " + std::to_string(result_after_decimal_point));
  234. }
  235. return result;
  236. }
  237. int ClassFlowCNNGeneral::PointerEvalAnalogNew(float number, int numeral_preceder) {
  238. float number_min, number_max;
  239. int result;
  240. if (numeral_preceder == -1) {
  241. result = (int) floor(number);
  242. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogNew - No predecessor - Result = " + std::to_string(result) +
  243. " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder) + " Analog_error = " + std::to_string(Analog_error));
  244. return result;
  245. }
  246. number_min = number - Analog_error / 10.0;
  247. number_max = number + Analog_error / 10.0;
  248. if ((int) floor(number_max) - (int) floor(number_min) != 0) {
  249. if (numeral_preceder <= Analog_error) {
  250. result = ((int) floor(number_max) + 10) % 10;
  251. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogNew - number ambiguous, correction upwards - result = " + std::to_string(result) +
  252. " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder) + " Analog_error = " + std::to_string(Analog_error));
  253. return result;
  254. }
  255. if (numeral_preceder >= 10 - Analog_error) {
  256. result = ((int) floor(number_min) + 10) % 10;
  257. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogNew - number ambiguous, downward correction - result = " + std::to_string(result) +
  258. " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder) + " Analog_error = " + std::to_string(Analog_error));
  259. return result;
  260. }
  261. }
  262. result = ((int) floor(number) + 10) % 10;
  263. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogNew - number unambiguous, no correction necessary - result = " + std::to_string(result) +
  264. " number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder) + " Analog_error = " + std::to_string(Analog_error));
  265. return result;
  266. }
  267. bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph) {
  268. std::vector<string> splitted;
  269. aktparamgraph = trim(aktparamgraph);
  270. if (aktparamgraph.size() == 0) {
  271. if (!this->GetNextParagraph(pfile, aktparamgraph)) {
  272. return false;
  273. }
  274. }
  275. if ((toUpper(aktparamgraph) != "[ANALOG]") && (toUpper(aktparamgraph) != ";[ANALOG]")
  276. && (toUpper(aktparamgraph) != "[DIGIT]") && (toUpper(aktparamgraph) != ";[DIGIT]")
  277. && (toUpper(aktparamgraph) != "[DIGITS]") && (toUpper(aktparamgraph) != ";[DIGITS]")) {
  278. // Paragraph passt nicht
  279. return false;
  280. }
  281. if (aktparamgraph[0] == ';') {
  282. disabled = true;
  283. while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
  284. ESP_LOGD(TAG, "[Analog/Digit] is disabled!");
  285. return true;
  286. }
  287. while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) {
  288. splitted = ZerlegeZeile(aktparamgraph);
  289. if ((toUpper(splitted[0]) == "ROIIMAGESLOCATION") && (splitted.size() > 1)) {
  290. this->imagesLocation = "/sdcard" + splitted[1];
  291. this->isLogImage = true;
  292. }
  293. if ((toUpper(splitted[0]) == "LOGIMAGESELECT") && (splitted.size() > 1)) {
  294. LogImageSelect = splitted[1];
  295. isLogImageSelect = true;
  296. }
  297. if ((toUpper(splitted[0]) == "ROIIMAGESRETENTION") && (splitted.size() > 1)) {
  298. this->imagesRetention = std::stoi(splitted[1]);
  299. }
  300. if ((toUpper(splitted[0]) == "MODEL") && (splitted.size() > 1)) {
  301. this->cnnmodelfile = splitted[1];
  302. }
  303. if ((toUpper(splitted[0]) == "CNNGOODTHRESHOLD") && (splitted.size() > 1)) {
  304. CNNGoodThreshold = std::stof(splitted[1]);
  305. }
  306. if (splitted.size() >= 5) {
  307. general* _analog = GetGENERAL(splitted[0], true);
  308. roi* neuroi = _analog->ROI[_analog->ROI.size()-1];
  309. neuroi->posx = std::stoi(splitted[1]);
  310. neuroi->posy = std::stoi(splitted[2]);
  311. neuroi->deltax = std::stoi(splitted[3]);
  312. neuroi->deltay = std::stoi(splitted[4]);
  313. neuroi->CCW = false;
  314. if (splitted.size() >= 6) {
  315. neuroi->CCW = toUpper(splitted[5]) == "TRUE";
  316. }
  317. neuroi->result_float = -1;
  318. neuroi->image = NULL;
  319. neuroi->image_org = NULL;
  320. }
  321. if ((toUpper(splitted[0]) == "SAVEALLFILES") && (splitted.size() > 1)) {
  322. if (toUpper(splitted[1]) == "TRUE") {
  323. SaveAllFiles = true;
  324. }
  325. }
  326. }
  327. if (!getNetworkParameter()) {
  328. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "An error occured on setting up the Network -> Disabling it!");
  329. disabled = true; // An error occured, disable this CNN!
  330. return false;
  331. }
  332. for (int _ana = 0; _ana < GENERAL.size(); ++_ana) {
  333. for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i) {
  334. GENERAL[_ana]->ROI[i]->image = new CImageBasis("ROI " + GENERAL[_ana]->ROI[i]->name,
  335. modelxsize, modelysize, modelchannel);
  336. GENERAL[_ana]->ROI[i]->image_org = new CImageBasis("ROI " + GENERAL[_ana]->ROI[i]->name + " original",
  337. GENERAL[_ana]->ROI[i]->deltax, GENERAL[_ana]->ROI[i]->deltay, 3);
  338. }
  339. }
  340. return true;
  341. }
  342. general* ClassFlowCNNGeneral::FindGENERAL(string _name_number) {
  343. for (int i = 0; i < GENERAL.size(); ++i) {
  344. if (GENERAL[i]->name == _name_number) {
  345. return GENERAL[i];
  346. }
  347. }
  348. return NULL;
  349. }
  350. general* ClassFlowCNNGeneral::GetGENERAL(string _name, bool _create = true) {
  351. string _analog, _roi;
  352. int _pospunkt = _name.find_first_of(".");
  353. if (_pospunkt > -1) {
  354. _analog = _name.substr(0, _pospunkt);
  355. _roi = _name.substr(_pospunkt+1, _name.length() - _pospunkt - 1);
  356. }
  357. else {
  358. _analog = "default";
  359. _roi = _name;
  360. }
  361. general *_ret = NULL;
  362. for (int i = 0; i < GENERAL.size(); ++i) {
  363. if (GENERAL[i]->name == _analog) {
  364. _ret = GENERAL[i];
  365. }
  366. }
  367. // not found and should not be created
  368. if (!_create) {
  369. return _ret;
  370. }
  371. if (_ret == NULL) {
  372. _ret = new general;
  373. _ret->name = _analog;
  374. GENERAL.push_back(_ret);
  375. }
  376. roi* neuroi = new roi;
  377. neuroi->name = _roi;
  378. _ret->ROI.push_back(neuroi);
  379. ESP_LOGD(TAG, "GetGENERAL - GENERAL %s - roi %s - CCW: %d", _analog.c_str(), _roi.c_str(), neuroi->CCW);
  380. return _ret;
  381. }
  382. string ClassFlowCNNGeneral::getHTMLSingleStep(string host) {
  383. string result, zw;
  384. std::vector<HTMLInfo*> htmlinfo;
  385. result = "<p>Found ROIs: </p> <p><img src=\"" + host + "/img_tmp/alg_roi.jpg\"></p>\n";
  386. result = result + "Analog Pointers: <p> ";
  387. htmlinfo = GetHTMLInfo();
  388. for (int i = 0; i < htmlinfo.size(); ++i) {
  389. std::stringstream stream;
  390. stream << std::fixed << std::setprecision(1) << htmlinfo[i]->val;
  391. zw = stream.str();
  392. result = result + "<img src=\"" + host + "/img_tmp/" + htmlinfo[i]->filename + "\"> " + zw;
  393. delete htmlinfo[i];
  394. }
  395. htmlinfo.clear();
  396. return result;
  397. }
  398. bool ClassFlowCNNGeneral::doFlow(string time) {
  399. #ifdef HEAP_TRACING_CLASS_FLOW_CNN_GENERAL_DO_ALING_AND_CUT
  400. //register a buffer to record the memory trace
  401. ESP_ERROR_CHECK( heap_trace_init_standalone(trace_record, NUM_RECORDS) );
  402. // start tracing
  403. ESP_ERROR_CHECK( heap_trace_start(HEAP_TRACE_LEAKS) );
  404. #endif
  405. if (disabled) {
  406. return true;
  407. }
  408. if (!doAlignAndCut(time)){
  409. return false;
  410. }
  411. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "doFlow after alignment");
  412. doNeuralNetwork(time);
  413. RemoveOldLogs();
  414. #ifdef HEAP_TRACING_CLASS_FLOW_CNN_GENERAL_DO_ALING_AND_CUT
  415. ESP_ERROR_CHECK( heap_trace_stop() );
  416. heap_trace_dump();
  417. #endif
  418. return true;
  419. }
  420. bool ClassFlowCNNGeneral::doAlignAndCut(string time) {
  421. if (disabled) {
  422. return true;
  423. }
  424. CAlignAndCutImage *caic = flowpostalignment->GetAlignAndCutImage();
  425. for (int _ana = 0; _ana < GENERAL.size(); ++_ana) {
  426. for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i) {
  427. ESP_LOGD(TAG, "General %d - Align&Cut", i);
  428. caic->CutAndSave(GENERAL[_ana]->ROI[i]->posx, GENERAL[_ana]->ROI[i]->posy, GENERAL[_ana]->ROI[i]->deltax, GENERAL[_ana]->ROI[i]->deltay, GENERAL[_ana]->ROI[i]->image_org);
  429. if (SaveAllFiles) {
  430. if (GENERAL[_ana]->name == "default") {
  431. GENERAL[_ana]->ROI[i]->image_org->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->ROI[i]->name + ".jpg"));
  432. }
  433. else {
  434. GENERAL[_ana]->ROI[i]->image_org->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".jpg"));
  435. }
  436. }
  437. GENERAL[_ana]->ROI[i]->image_org->Resize(modelxsize, modelysize, GENERAL[_ana]->ROI[i]->image);
  438. if (SaveAllFiles) {
  439. if (GENERAL[_ana]->name == "default") {
  440. GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->ROI[i]->name + ".jpg"));
  441. }
  442. else {
  443. GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".jpg"));
  444. }
  445. }
  446. }
  447. }
  448. return true;
  449. }
  450. void ClassFlowCNNGeneral::DrawROI(CImageBasis *_zw) {
  451. if (_zw->ImageOkay()) {
  452. if (CNNType == Analogue || CNNType == Analogue100) {
  453. int r = 0;
  454. int g = 255;
  455. int b = 0;
  456. for (int _ana = 0; _ana < GENERAL.size(); ++_ana) {
  457. for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i) {
  458. _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);
  459. _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);
  460. _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);
  461. _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);
  462. }
  463. }
  464. }
  465. else {
  466. for (int _dig = 0; _dig < GENERAL.size(); ++_dig) {
  467. for (int i = 0; i < GENERAL[_dig]->ROI.size(); ++i) {
  468. _zw->drawRect(GENERAL[_dig]->ROI[i]->posx, GENERAL[_dig]->ROI[i]->posy, GENERAL[_dig]->ROI[i]->deltax, GENERAL[_dig]->ROI[i]->deltay, 0, 0, (255 - _dig*100), 2);
  469. }
  470. }
  471. }
  472. }
  473. }
  474. bool ClassFlowCNNGeneral::getNetworkParameter() {
  475. if (disabled) {
  476. return true;
  477. }
  478. CTfLiteClass *tflite = new CTfLiteClass;
  479. string zwcnn = "/sdcard" + cnnmodelfile;
  480. zwcnn = FormatFileName(zwcnn);
  481. ESP_LOGD(TAG, "%s", zwcnn.c_str());
  482. if (!tflite->LoadModel(zwcnn)) {
  483. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't load tflite model " + cnnmodelfile + " -> Init aborted!");
  484. LogFile.WriteHeapInfo("getNetworkParameter-LoadModel");
  485. delete tflite;
  486. return false;
  487. }
  488. if (!tflite->MakeAllocate()) {
  489. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't allocate tflite model -> Init aborted!");
  490. LogFile.WriteHeapInfo("getNetworkParameter-MakeAllocate");
  491. delete tflite;
  492. return false;
  493. }
  494. if (CNNType == AutoDetect) {
  495. tflite->GetInputDimension(false);
  496. modelxsize = tflite->ReadInputDimenstion(0);
  497. modelysize = tflite->ReadInputDimenstion(1);
  498. modelchannel = tflite->ReadInputDimenstion(2);
  499. int _anzoutputdimensions = tflite->GetAnzOutPut();
  500. switch (_anzoutputdimensions) {
  501. case 2:
  502. CNNType = Analogue;
  503. ESP_LOGD(TAG, "TFlite-Type set to Analogue");
  504. break;
  505. case 10:
  506. CNNType = DoubleHyprid10;
  507. ESP_LOGD(TAG, "TFlite-Type set to DoubleHyprid10");
  508. break;
  509. case 11:
  510. CNNType = Digital;
  511. ESP_LOGD(TAG, "TFlite-Type set to Digital");
  512. break;
  513. /* case 20:
  514. CNNType = DigitalHyprid10;
  515. ESP_LOGD(TAG, "TFlite-Type set to DigitalHyprid10");
  516. break;
  517. */
  518. // case 22:
  519. // CNNType = DigitalHyprid;
  520. // ESP_LOGD(TAG, "TFlite-Type set to DigitalHyprid");
  521. // break;
  522. case 100:
  523. if (modelxsize==32 && modelysize == 32) {
  524. CNNType = Analogue100;
  525. ESP_LOGD(TAG, "TFlite-Type set to Analogue100");
  526. }
  527. else {
  528. CNNType = Digital100;
  529. ESP_LOGD(TAG, "TFlite-Type set to Digital");
  530. }
  531. break;
  532. default:
  533. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "tflite does not fit the firmware (outout_dimension=" + std::to_string(_anzoutputdimensions) + ")");
  534. }
  535. }
  536. delete tflite;
  537. return true;
  538. }
  539. bool ClassFlowCNNGeneral::doNeuralNetwork(string time) {
  540. if (disabled) {
  541. return true;
  542. }
  543. string logPath = CreateLogFolder(time);
  544. CTfLiteClass *tflite = new CTfLiteClass;
  545. string zwcnn = "/sdcard" + cnnmodelfile;
  546. zwcnn = FormatFileName(zwcnn);
  547. ESP_LOGD(TAG, "%s", zwcnn.c_str());
  548. if (!tflite->LoadModel(zwcnn)) {
  549. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't load tflite model " + cnnmodelfile + " -> Exec aborted this round!");
  550. LogFile.WriteHeapInfo("doNeuralNetwork-LoadModel");
  551. delete tflite;
  552. return false;
  553. }
  554. if (!tflite->MakeAllocate()) {
  555. LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't allocate tfilte model -> Exec aborted this round!");
  556. LogFile.WriteHeapInfo("doNeuralNetwork-MakeAllocate");
  557. delete tflite;
  558. return false;
  559. }
  560. // For each NUMBER
  561. for (int n = 0; n < GENERAL.size(); ++n) {
  562. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Processing Number '" + GENERAL[n]->name + "'");
  563. // For each ROI
  564. for (int roi = 0; roi < GENERAL[n]->ROI.size(); ++roi) {
  565. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "ROI #" + std::to_string(roi) + " - TfLite");
  566. //ESP_LOGD(TAG, "General %d - TfLite", i);
  567. switch (CNNType) {
  568. case Analogue:
  569. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Analogue");
  570. {
  571. float f1, f2;
  572. f1 = 0; f2 = 0;
  573. tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image);
  574. tflite->Invoke();
  575. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "After Invoke");
  576. f1 = tflite->GetOutputValue(0);
  577. f2 = tflite->GetOutputValue(1);
  578. float result = fmod(atan2(f1, f2) / (M_PI * 2) + 2, 1);
  579. if(GENERAL[n]->ROI[roi]->CCW) {
  580. GENERAL[n]->ROI[roi]->result_float = 10 - (result * 10);
  581. }
  582. else {
  583. GENERAL[n]->ROI[roi]->result_float = result * 10;
  584. }
  585. ESP_LOGD(TAG, "General result (Analog)%i - CCW: %d - %f", roi, GENERAL[n]->ROI[roi]->CCW, GENERAL[n]->ROI[roi]->result_float);
  586. if (isLogImage) {
  587. LogImage(logPath, GENERAL[n]->ROI[roi]->name, &GENERAL[n]->ROI[roi]->result_float, NULL, time, GENERAL[n]->ROI[roi]->image_org);
  588. }
  589. } break;
  590. case Digital:
  591. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Digital");
  592. {
  593. GENERAL[n]->ROI[roi]->result_klasse = 0;
  594. GENERAL[n]->ROI[roi]->result_klasse = tflite->GetClassFromImageBasis(GENERAL[n]->ROI[roi]->image);
  595. ESP_LOGD(TAG, "General result (Digit)%i: %d", roi, GENERAL[n]->ROI[roi]->result_klasse);
  596. if (isLogImage) {
  597. string _imagename = GENERAL[n]->name + "_" + GENERAL[n]->ROI[roi]->name;
  598. if (isLogImageSelect) {
  599. if (LogImageSelect.find(GENERAL[n]->ROI[roi]->name) != std::string::npos) {
  600. LogImage(logPath, _imagename, NULL, &GENERAL[n]->ROI[roi]->result_klasse, time, GENERAL[n]->ROI[roi]->image_org);
  601. }
  602. }
  603. else {
  604. LogImage(logPath, _imagename, NULL, &GENERAL[n]->ROI[roi]->result_klasse, time, GENERAL[n]->ROI[roi]->image_org);
  605. }
  606. }
  607. } break;
  608. case DoubleHyprid10:
  609. {
  610. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: DoubleHyprid10");
  611. int _num, _numplus, _numminus;
  612. float _val, _valplus, _valminus;
  613. float _fit;
  614. float _result_save_file;
  615. tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image);
  616. tflite->Invoke();
  617. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "After Invoke");
  618. _num = tflite->GetOutClassification(0, 9);
  619. _numplus = (_num + 1) % 10;
  620. _numminus = (_num - 1 + 10) % 10;
  621. _val = tflite->GetOutputValue(_num);
  622. _valplus = tflite->GetOutputValue(_numplus);
  623. _valminus = tflite->GetOutputValue(_numminus);
  624. float result = _num;
  625. if (_valplus > _valminus) {
  626. result = result + _valplus / (_valplus + _val);
  627. _fit = _val + _valplus;
  628. }
  629. else {
  630. result = result - _valminus / (_val + _valminus);
  631. _fit = _val + _valminus;
  632. }
  633. if (result >= 10) {
  634. result = result - 10;
  635. }
  636. if (result < 0) {
  637. result = result + 10;
  638. }
  639. string zw = "_num (p, m): " + to_string(_num) + " " + to_string(_numplus) + " " + to_string(_numminus);
  640. zw = zw + " _val (p, m): " + to_string(_val) + " " + to_string(_valplus) + " " + to_string(_valminus);
  641. zw = zw + " result: " + to_string(result) + " _fit: " + to_string(_fit);
  642. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, zw);
  643. _result_save_file = result;
  644. if (_fit < CNNGoodThreshold) {
  645. GENERAL[n]->ROI[roi]->isReject = true;
  646. result = -1;
  647. _result_save_file+= 100; // In case fit is not sufficient, the result should still be saved with "-10x.y".
  648. string zw = "Value Rejected due to Threshold (Fit: " + to_string(_fit) + ", Threshold: " + to_string(CNNGoodThreshold) + ")";
  649. LogFile.WriteToFile(ESP_LOG_WARN, TAG, zw);
  650. }
  651. else {
  652. GENERAL[n]->ROI[roi]->isReject = false;
  653. }
  654. GENERAL[n]->ROI[roi]->result_float = result;
  655. ESP_LOGD(TAG, "Result General(Analog)%i: %f", roi, GENERAL[n]->ROI[roi]->result_float);
  656. if (isLogImage) {
  657. string _imagename = GENERAL[n]->name + "_" + GENERAL[n]->ROI[roi]->name;
  658. if (isLogImageSelect) {
  659. if (LogImageSelect.find(GENERAL[n]->ROI[roi]->name) != std::string::npos) {
  660. LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
  661. }
  662. }
  663. else {
  664. LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
  665. }
  666. }
  667. } break;
  668. case Digital100:
  669. case Analogue100:
  670. {
  671. LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Digital100 or Analogue100");
  672. int _num;
  673. float _result_save_file;
  674. tflite->LoadInputImageBasis(GENERAL[n]->ROI[roi]->image);
  675. tflite->Invoke();
  676. _num = tflite->GetOutClassification();
  677. if(GENERAL[n]->ROI[roi]->CCW) {
  678. GENERAL[n]->ROI[roi]->result_float = 10 - ((float)_num / 10.0);
  679. }
  680. else {
  681. GENERAL[n]->ROI[roi]->result_float = (float)_num / 10.0;
  682. }
  683. _result_save_file = GENERAL[n]->ROI[roi]->result_float;
  684. GENERAL[n]->ROI[roi]->isReject = false;
  685. ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", roi, GENERAL[n]->ROI[roi]->CCW, GENERAL[n]->ROI[roi]->result_float);
  686. if (isLogImage) {
  687. string _imagename = GENERAL[n]->name + "_" + GENERAL[n]->ROI[roi]->name;
  688. if (isLogImageSelect) {
  689. if (LogImageSelect.find(GENERAL[n]->ROI[roi]->name) != std::string::npos) {
  690. LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
  691. }
  692. }
  693. else {
  694. LogImage(logPath, _imagename, &_result_save_file, NULL, time, GENERAL[n]->ROI[roi]->image_org);
  695. }
  696. }
  697. } break;
  698. default:
  699. break;
  700. }
  701. }
  702. }
  703. delete tflite;
  704. return true;
  705. }
  706. bool ClassFlowCNNGeneral::isExtendedResolution(int _number) {
  707. if (CNNType == Digital) {
  708. return false;
  709. }
  710. return true;
  711. }
  712. std::vector<HTMLInfo*> ClassFlowCNNGeneral::GetHTMLInfo() {
  713. std::vector<HTMLInfo*> result;
  714. for (int _ana = 0; _ana < GENERAL.size(); ++_ana) {
  715. for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i) {
  716. ESP_LOGD(TAG, "Image: %d", (int) GENERAL[_ana]->ROI[i]->image);
  717. if (GENERAL[_ana]->ROI[i]->image) {
  718. if (GENERAL[_ana]->name == "default") {
  719. GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->ROI[i]->name + ".jpg"));
  720. }
  721. else {
  722. GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".jpg"));
  723. }
  724. }
  725. HTMLInfo *zw = new HTMLInfo;
  726. if (GENERAL[_ana]->name == "default") {
  727. zw->filename = GENERAL[_ana]->ROI[i]->name + ".jpg";
  728. zw->filename_org = GENERAL[_ana]->ROI[i]->name + ".jpg";
  729. }
  730. else {
  731. zw->filename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".jpg";
  732. zw->filename_org = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".jpg";
  733. }
  734. if (CNNType == Digital) {
  735. zw->val = GENERAL[_ana]->ROI[i]->result_klasse;
  736. }
  737. else {
  738. zw->val = GENERAL[_ana]->ROI[i]->result_float;
  739. }
  740. zw->image = GENERAL[_ana]->ROI[i]->image;
  741. zw->image_org = GENERAL[_ana]->ROI[i]->image_org;
  742. result.push_back(zw);
  743. }
  744. }
  745. return result;
  746. }
  747. int ClassFlowCNNGeneral::getNumberGENERAL() {
  748. return GENERAL.size();
  749. }
  750. string ClassFlowCNNGeneral::getNameGENERAL(int _analog) {
  751. if (_analog < GENERAL.size()) {
  752. return GENERAL[_analog]->name;
  753. }
  754. return "GENERAL DOES NOT EXIST";
  755. }
  756. general* ClassFlowCNNGeneral::GetGENERAL(int _analog) {
  757. if (_analog < GENERAL.size()) {
  758. return GENERAL[_analog];
  759. }
  760. return NULL;
  761. }
  762. void ClassFlowCNNGeneral::UpdateNameNumbers(std::vector<std::string> *_name_numbers) {
  763. for (int _dig = 0; _dig < GENERAL.size(); _dig++) {
  764. std::string _name = GENERAL[_dig]->name;
  765. bool found = false;
  766. for (int i = 0; i < (*_name_numbers).size(); ++i) {
  767. if ((*_name_numbers)[i] == _name) {
  768. found = true;
  769. }
  770. }
  771. if (!found) {
  772. (*_name_numbers).push_back(_name);
  773. }
  774. }
  775. }
  776. string ClassFlowCNNGeneral::getReadoutRawString(int _analog)
  777. {
  778. string rt = "";
  779. if (_analog >= GENERAL.size() || GENERAL[_analog]==NULL || GENERAL[_analog]->ROI.size() == 0) {
  780. return rt;
  781. }
  782. for (int i = 0; i < GENERAL[_analog]->ROI.size(); ++i) {
  783. if (CNNType == Analogue || CNNType == Analogue100) {
  784. rt = rt + "," + RundeOutput(GENERAL[_analog]->ROI[i]->result_float, 1);
  785. }
  786. if (CNNType == Digital) {
  787. if (GENERAL[_analog]->ROI[i]->result_klasse >= 10) {
  788. rt = rt + ",N";
  789. }
  790. else {
  791. rt = rt + "," + RundeOutput(GENERAL[_analog]->ROI[i]->result_klasse, 0);
  792. }
  793. }
  794. if ((CNNType == DoubleHyprid10) || (CNNType == Digital100)) {
  795. rt = rt + "," + RundeOutput(GENERAL[_analog]->ROI[i]->result_float, 1);
  796. }
  797. }
  798. return rt;
  799. }