From 4986b1936f2113a4c29b3931ad7da92573469df5 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Thu, 2 Feb 2023 16:45:26 +0100 Subject: [PATCH] Fix initialflip issue --- .../jomjol_flowcontroll/ClassFlowAlignment.cpp | 11 ++++------- .../jomjol_flowcontroll/ClassFlowControll.cpp | 3 ++- code/components/jomjol_image_proc/CImageBasis.cpp | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp b/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp index 4d4038b8..1b686176 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp +++ b/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")); } diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 3da1e39f..667ab683 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/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; } diff --git a/code/components/jomjol_image_proc/CImageBasis.cpp b/code/components/jomjol_image_proc/CImageBasis.cpp index 781bdd8f..a8637e3f 100644 --- a/code/components/jomjol_image_proc/CImageBasis.cpp +++ b/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;