ClassFlowCNNGeneral.cpp 42 KB

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