Просмотр исходного кода

Merge pull request #4177 from SybexX/main

revert code optimization - #4175
SybexXx 1 месяц назад
Родитель
Сommit
41ccf2252a

+ 0 - 2
Changelog.md

@@ -3,8 +3,6 @@
 ### Core Changes and Bug fixes
 - Fix crash when webhook enabled without configured URL [#4136](https://github.com/jomjol/AI-on-the-edge-device/pull/4136)
 - Fix checkDigitConsistency corrupting sub-digits of large readings [#4145](https://github.com/jomjol/AI-on-the-edge-device/pull/4145)
-- code optimization [#4175](https://github.com/jomjol/AI-on-the-edge-device/pull/4175)
-- Added useful functions [#4174](https://github.com/jomjol/AI-on-the-edge-device/pull/4174)
 - perf(camera): memcpy/memset instead of per-pixel loops in capture path [#4168](https://github.com/jomjol/AI-on-the-edge-device/pull/4168)
 - fix(http): don't terminate HTTP responses twice [#4167](https://github.com/jomjol/AI-on-the-edge-device/pull/4167)
 - Update submodules, Refactor OTA update process and clean up code [#4135](https://github.com/jomjol/AI-on-the-edge-device/pull/4135)

+ 1 - 1
code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp

@@ -681,7 +681,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) {
 
                         f1 = tflite->GetOutputValue(0);
                         f2 = tflite->GetOutputValue(1);
-                        float result = fmod(fast_atan2(f1, f2) / (M_PI * 2) + 2, 1);
+						float result = fmod(atan2(f1, f2) / (M_PI * 2) + 2, 1);
                               
                         if(GENERAL[n]->ROI[roi]->CCW) {
                             GENERAL[n]->ROI[roi]->result_float = 10 - (result * 10);

+ 10 - 10
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp

@@ -895,8 +895,8 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) {
 
         if (PreValueUse && NUMBERS[j]->PreValueOkay) {
             if ((NUMBERS[j]->Nachkomma > 0) && (NUMBERS[j]->ChangeRateThreshold > 0)) {
-                double _difference1 = (NUMBERS[j]->PreValue - (NUMBERS[j]->ChangeRateThreshold / pow10_double(NUMBERS[j]->Nachkomma)));
-                double _difference2 = (NUMBERS[j]->PreValue + (NUMBERS[j]->ChangeRateThreshold / pow10_double(NUMBERS[j]->Nachkomma)));
+                double _difference1 = (NUMBERS[j]->PreValue - (NUMBERS[j]->ChangeRateThreshold / pow(10, NUMBERS[j]->Nachkomma)));
+                double _difference2 = (NUMBERS[j]->PreValue + (NUMBERS[j]->ChangeRateThreshold / pow(10, NUMBERS[j]->Nachkomma)));
 
                 if ((NUMBERS[j]->Value >= _difference1) && (NUMBERS[j]->Value <= _difference2)) {
                     NUMBERS[j]->Value = NUMBERS[j]->PreValue;
@@ -912,7 +912,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) {
                     if (NUMBERS[j]->isExtendedResolution) {
                         LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Neg: value=" + std::to_string(NUMBERS[j]->Value) 
                                                     + ", preValue=" + std::to_string(NUMBERS[j]->PreValue) 
-                                                    + ", preToll=" + std::to_string(NUMBERS[j]->PreValue - (2 / pow10_double(NUMBERS[j]->Nachkomma))));
+                                                    + ", preToll=" + std::to_string(NUMBERS[j]->PreValue - (2 / pow(10, NUMBERS[j]->Nachkomma))));
                     } 
 
                     NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Neg. Rate - Read: " + zwvalue + " - Raw: " + NUMBERS[j]->ReturnRawValue + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + " "; 
@@ -1097,7 +1097,7 @@ string ClassFlowPostProcessing::ErsetzteN(string input, double _prevalue) {
             pot = posPunkt - posN;
         }
 
-        zw =_prevalue / pow10_double(pot);
+        zw =_prevalue / pow(10, pot);
         ziffer = ((int) zw) % 10;
         input[posN] = ziffer + 48;
 
@@ -1129,27 +1129,27 @@ double ClassFlowPostProcessing::checkDigitConsistency(double input, int _decilam
     pot_max = ((int) log10(input)) + 1;
 	
     while (pot <= pot_max) {
-        zw = input / pow10_double(pot-1);
+        zw = input / pow(10, pot-1);
         aktdigit_before = ((int) zw) % 10;
-        zw = _preValue / pow10_double(pot-1);
+        zw = _preValue / pow(10, pot-1);
         olddigit_before = ((int) zw) % 10;
 
-        zw = input / pow10_double(pot);
+        zw = input / pow(10, pot);
         aktdigit = ((int) zw) % 10;
-        zw = _preValue / pow10_double(pot);
+        zw = _preValue / pow(10, pot);
         olddigit = ((int) zw) % 10;
 
         no_nulldurchgang = (olddigit_before <= aktdigit_before);
 
         if (no_nulldurchgang) {
             if (aktdigit != olddigit) {
-                input = input + ((double)(olddigit - aktdigit)) * pow10_double(pot);     // New Digit is replaced by old Digit;
+                input = input + ((double)(olddigit - aktdigit)) * pow(10, pot);     // New Digit is replaced by old Digit;
             }
         }
         else {
             // despite zero crossing, digit was not incremented --> add 1
             if (aktdigit == olddigit) {
-                input = input + ((double)(1)) * pow10_double(pot);   // add 1 at the point
+                input = input + ((double)(1)) * pow(10, pot);   // add 1 at the point
             }
         }
 			

+ 2 - 10
code/components/jomjol_image_proc/CAlignAndCutImage.cpp

@@ -59,7 +59,6 @@ bool CAlignAndCutImage::Align(RefInfo *_temp1, RefInfo *_temp2)
 
     delete ft;
 
-
     dx = _temp1->target_x - _temp1->found_x;
     dy = _temp1->target_y - _temp1->found_y;
 
@@ -71,8 +70,8 @@ bool CAlignAndCutImage::Align(RefInfo *_temp1, RefInfo *_temp2)
 
     float w_org, w_ist, d_winkel;
 
-    w_org = fast_atan2((float)(_temp2->found_y - _temp1->found_y), (float)(_temp2->found_x - _temp1->found_x));
-    w_ist = fast_atan2((float)(r1_y - r0_y), (float)(r1_x - r0_x));
+	w_org = atan2((float)(_temp2->found_y - _temp1->found_y), (float)(_temp2->found_x - _temp1->found_x));
+    w_ist = atan2((float)(r1_y - r0_y), (float)(r1_x - r0_x));
 
     d_winkel = (w_ist - w_org) * 180 / M_PI;
 
@@ -93,13 +92,8 @@ bool CAlignAndCutImage::Align(RefInfo *_temp1, RefInfo *_temp2)
     return (isSimilar1 && isSimilar2);
 }
 
-
-
-
-
 void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int dx, int dy)
 {
-
     int x2, y2;
 
     x2 = x1 + dx;
@@ -133,7 +127,6 @@ void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int d
     stbi_write_bmp(_template1.c_str(), dx, dy, channels, odata);
 #endif
     
-
     RGBImageRelease();
 
     stbi_image_free(odata);
@@ -176,7 +169,6 @@ void CAlignAndCutImage::CutAndSave(int x1, int y1, int dx, int dy, CImageBasis *
     _target->RGBImageRelease();
 }
 
-
 CImageBasis* CAlignAndCutImage::CutAndSave(int x1, int y1, int dx, int dy)
 {
     int x2, y2;