Browse Source

Fix initialflip issue

Slider0007 3 years ago
parent
commit
4986b1936f

+ 4 - 7
code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp

@@ -208,6 +208,10 @@ bool ClassFlowAlignment::doFlow(string time)
         int _zw = ImageBasis->height;
         ImageBasis->height = ImageBasis->width;
         ImageBasis->width = _zw;
+
+        _zw = ImageTMP->width;
+        ImageTMP->width = ImageTMP->height;
+        ImageTMP->height = _zw;
     }
 
     if (initialmirror)
@@ -246,13 +250,6 @@ bool ClassFlowAlignment::doFlow(string time)
     
     if (SaveAllFiles)
     {
-        if (initialflip)
-        {
-            int _zw = ImageTMP->width;
-            ImageTMP->width = ImageTMP->height;
-            ImageTMP->height = _zw;
-        }
-
         AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/alg.jpg"));
         ImageTMP->SaveToFile(FormatFileName("/sdcard/img_tmp/alg_roi.jpg"));
     }

+ 2 - 1
code/components/jomjol_flowcontroll/ClassFlowControll.cpp

@@ -755,7 +755,8 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
                     fseek(file, 0, SEEK_SET); /* reset */
                     
                     if (flowalignment->AlgROI->size > MAX_JPG_SIZE) {
-                        LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "File /sdcard/html/Flowstate_take_image.jpg too large: " + std::to_string(flowalignment->AlgROI->size));
+                        LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "File /sdcard/html/Flowstate_take_image.jpg (" + std::to_string(flowalignment->AlgROI->size) +
+                                                                ") > allocated buffer (" + std::to_string(MAX_JPG_SIZE) + ")");
                         fclose(file);
                         return ESP_FAIL;
                     }

+ 3 - 3
code/components/jomjol_image_proc/CImageBasis.cpp

@@ -67,7 +67,7 @@ void writejpghelp(void *context, void *data, int size)
     uint8_t *voidstart = _zw->data;
     uint8_t *datastart = (uint8_t*) data;
     
-    if ((_zw->size < MAX_JPG_SIZE)) {   // Abort copy -> no buffer anymore
+    if ((_zw->size < MAX_JPG_SIZE)) {   // Abort copy to prevent buffer overflow
         voidstart += _zw->size;
 
         for (int i = 0; i < size; ++i)
@@ -91,7 +91,7 @@ ImageData* CImageBasis::writeToMemoryAsJPG(const int quality)
 
     if (jpgFileTooLarge) {
         jpgFileTooLarge = false;
-        LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "writeToMemoryAsJPG: JPG creation aborted! Preallocated buffer not sufficient: " + std::to_string(MAX_JPG_SIZE));
+        LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "writeToMemoryAsJPG: Creation aborted! JPG size > preallocated buffer: " + std::to_string(MAX_JPG_SIZE));
     }
     return ii;
 }
@@ -107,7 +107,7 @@ void CImageBasis::writeToMemoryAsJPG(ImageData* i, const int quality)
 
     if (jpgFileTooLarge) {
         jpgFileTooLarge = false;
-        LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "writeToMemoryAsJPG: JPG creation aborted! Preallocated buffer not sufficient: " + std::to_string(MAX_JPG_SIZE));
+        LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "writeToMemoryAsJPG: Creation aborted! JPG size > preallocated buffer: " + std::to_string(MAX_JPG_SIZE));
     }
     memCopy((uint8_t*) ii, (uint8_t*) i, sizeof(ImageData));
     delete ii;