diff --git a/README.md b/README.md index ae83536a..9dd45821 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,13 @@ In other cases you can contact the developer via email: getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) { zerlegt = ZerlegeZeile(aktparamgraph); + if ((toUpper(zerlegt[0]) == "FLIPIMAGESIZE") && (zerlegt.size() > 1)) + { + if (toUpper(zerlegt[1]) == "TRUE") + initialflip = true; + } if ((toUpper(zerlegt[0]) == "INITIALMIRROR") && (zerlegt.size() > 1)) { if (toUpper(zerlegt[1]) == "TRUE") @@ -153,7 +159,13 @@ bool ClassFlowAlignment::doFlow(string time) delete AlignAndCutImage; AlignAndCutImage = new CAlignAndCutImage(ImageBasis, ImageTMP); - CRotateImage rt(AlignAndCutImage, ImageTMP); + CRotateImage rt(AlignAndCutImage, ImageTMP, initialflip); + if (initialflip) + { + int _zw = ImageBasis->height; + ImageBasis->height = ImageBasis->width; + ImageBasis->width = _zw; + } if (initialmirror){ printf("do mirror\n"); @@ -161,7 +173,7 @@ bool ClassFlowAlignment::doFlow(string time) if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/mirror.jpg")); } - if (initalrotate != 0) + if ((initalrotate != 0) || initialflip) { rt.Rotate(initalrotate); if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/rot.jpg")); @@ -176,6 +188,12 @@ bool ClassFlowAlignment::doFlow(string time) if (SaveAllFiles) { + if (initialflip) + { + int _zw = ImageTMP->width; + ImageTMP->width = ImageTMP->height; + ImageTMP->height = _zw; + } DrawRef(ImageTMP); ImageTMP->SaveToFile(FormatFileName("/sdcard/img_tmp/alg_roi.jpg")); } diff --git a/code/components/jomjol_flowcontroll/ClassFlowAlignment.h b/code/components/jomjol_flowcontroll/ClassFlowAlignment.h index 8c0e07ce..180dc7f6 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowAlignment.h +++ b/code/components/jomjol_flowcontroll/ClassFlowAlignment.h @@ -15,6 +15,7 @@ class ClassFlowAlignment : protected: float initalrotate; bool initialmirror; + bool initialflip; RefInfo References[2]; int anz_ref; string namerawimage; diff --git a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp index 2b9a9f50..0d69a31a 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp @@ -19,6 +19,10 @@ esp_err_t ClassFlowMakeImage::camera_capture(){ void ClassFlowMakeImage::takePictureWithFlash(int flashdauer) { + // für den Fall, dass das Bild geflippt wird, muss es hier zurück gesetzt werden //// + rawImage->width = image_width; + rawImage->height = image_height; + ///////////////////////////////////////////////////////////////////////////////////// Camera.CaptureToBasisImage(rawImage, flashdauer); if (SaveAllFiles) rawImage->SaveToFile(namerawimage); } diff --git a/code/components/jomjol_image_proc/CRotateImage.cpp b/code/components/jomjol_image_proc/CRotateImage.cpp index e40efda5..b6b2321b 100644 --- a/code/components/jomjol_image_proc/CRotateImage.cpp +++ b/code/components/jomjol_image_proc/CRotateImage.cpp @@ -1,7 +1,7 @@ #include "CRotateImage.h" -CRotateImage::CRotateImage(CImageBasis *_org, CImageBasis *_temp) +CRotateImage::CRotateImage(CImageBasis *_org, CImageBasis *_temp, bool _flip) { rgb_image = _org->rgb_image; channels = _org->channels; @@ -9,8 +9,10 @@ CRotateImage::CRotateImage(CImageBasis *_org, CImageBasis *_temp) height = _org->height; bpp = _org->bpp; externalImage = true; - ImageTMP = _temp; + ImageTMP = _temp; + ImageOrg = _org; islocked = false; + doflip = _flip; } void CRotateImage::Mirror(){ @@ -58,12 +60,33 @@ void CRotateImage::Mirror(){ void CRotateImage::Rotate(float _angle, int _centerx, int _centery) { + int org_width, org_height; float m[2][3]; float x_center = _centerx; float y_center = _centery; _angle = _angle / 180 * M_PI; + if (doflip) + { + org_width = width; + org_height = height; + height = org_width; + width = org_height; + x_center = x_center - (org_width/2) + (org_height/2); + y_center = y_center + (org_width/2) - (org_height/2); + if (ImageOrg) + { + ImageOrg->height = height; + ImageOrg->width = width; + } + } + else + { + org_width = width; + org_height = height; + } + m[0][0] = cos(_angle); m[0][1] = sin(_angle); m[0][2] = (1 - m[0][0]) * x_center - m[0][1] * y_center; @@ -72,6 +95,12 @@ void CRotateImage::Rotate(float _angle, int _centerx, int _centery) m[1][1] = m[0][0]; m[1][2] = m[0][1] * x_center + (1 - m[0][0]) * y_center; + if (doflip) + { + m[0][2] = m[0][2] + (org_width/2) - (org_height/2); + m[1][2] = m[1][2] - (org_width/2) + (org_height/2); + } + int memsize = width * height * channels; uint8_t* odata; if (ImageTMP) @@ -101,9 +130,9 @@ void CRotateImage::Rotate(float _angle, int _centerx, int _centery) x_source += int(m[0][2]); y_source += int(m[1][2]); - if ((x_source >= 0) && (x_source < width) && (y_source >= 0) && (y_source < height)) + if ((x_source >= 0) && (x_source < org_width) && (y_source >= 0) && (y_source < org_height)) { - p_source = rgb_image + (channels * (y_source * width + x_source)); + p_source = rgb_image + (channels * (y_source * org_width + x_source)); for (int _channels = 0; _channels < channels; ++_channels) p_target[_channels] = p_source[_channels]; } diff --git a/code/components/jomjol_image_proc/CRotateImage.h b/code/components/jomjol_image_proc/CRotateImage.h index ccd362b4..90ad7d71 100644 --- a/code/components/jomjol_image_proc/CRotateImage.h +++ b/code/components/jomjol_image_proc/CRotateImage.h @@ -4,10 +4,11 @@ class CRotateImage: public CImageBasis { public: - CImageBasis *ImageTMP; - CRotateImage(std::string _image) : CImageBasis(_image) {ImageTMP = NULL;}; - CRotateImage(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {ImageTMP = NULL;}; - CRotateImage(CImageBasis *_org, CImageBasis *_temp); + CImageBasis *ImageTMP, *ImageOrg; + bool doflip; + CRotateImage(std::string _image, bool _flip = false) : CImageBasis(_image) {ImageTMP = NULL; ImageOrg = NULL; doflip = _flip;}; + CRotateImage(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp, bool _flip = false) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {ImageTMP = NULL; ImageOrg = NULL; doflip = _flip;}; + CRotateImage(CImageBasis *_org, CImageBasis *_temp, bool _flip = false); void Rotate(float _angle); void Rotate(float _angle, int _centerx, int _centery); diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 719e8d7a..fb5df4ee 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -387,7 +387,7 @@ httpd_handle_t start_webserver(void) httpd_config_t config = { }; config.task_priority = tskIDLE_PRIORITY+5; - config.stack_size = 16384; // bei 32k stürzt das Programm beim Bilderaufnehmen ab + config.stack_size = 32384; // bei 32k stürzt das Programm beim Bilderaufnehmen ab config.core_id = tskNO_AFFINITY; config.server_port = 80; config.ctrl_port = 32768; diff --git a/code/main/version.cpp b/code/main/version.cpp index 60c6a4b2..a9baceb0 100644 --- a/code/main/version.cpp +++ b/code/main/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="a45a529"; +const char* GIT_REV="bc6a014"; const char* GIT_TAG=""; -const char* GIT_BRANCH="master"; -const char* BUILD_TIME="2021-05-01 17:42"; \ No newline at end of file +const char* GIT_BRANCH="rolling"; +const char* BUILD_TIME="2021-05-06 20:21"; \ No newline at end of file diff --git a/code/main/version.h b/code/main/version.h index 130b1a62..965b1014 100644 --- a/code/main/version.h +++ b/code/main/version.h @@ -13,7 +13,7 @@ extern "C" #include "Helper.h" #include -const char* GIT_BASE_BRANCH = "master - v6.7.1 - 2020-01-05"; +const char* GIT_BASE_BRANCH = "master - v6.7.1 - 2020-05-01"; const char* git_base_branch(void) diff --git a/code/version.cpp b/code/version.cpp index 60c6a4b2..a9baceb0 100644 --- a/code/version.cpp +++ b/code/version.cpp @@ -1,4 +1,4 @@ -const char* GIT_REV="a45a529"; +const char* GIT_REV="bc6a014"; const char* GIT_TAG=""; -const char* GIT_BRANCH="master"; -const char* BUILD_TIME="2021-05-01 17:42"; \ No newline at end of file +const char* GIT_BRANCH="rolling"; +const char* BUILD_TIME="2021-05-06 20:21"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index 3358d19c..636e3b94 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index 9405f80c..87efda93 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/firmware/html.zip b/firmware/html.zip index 0fb191bd..88f0c56d 100644 Binary files a/firmware/html.zip and b/firmware/html.zip differ diff --git a/sd-card/config/config.ini b/sd-card/config/config.ini index 716e0aeb..1f6cb3dd 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -9,6 +9,7 @@ FixedExposure = false [Alignment] InitialRotate=180 +FlipImageSize = false /config/ref0.jpg 119 273 /config/ref1.jpg 456 138 SearchFieldX = 20 diff --git a/sd-card/html/edit_reference.html b/sd-card/html/edit_reference.html index beb334b9..e937db5b 100644 --- a/sd-card/html/edit_reference.html +++ b/sd-card/html/edit_reference.html @@ -44,6 +44,11 @@ table { + + + + + @@ -129,6 +134,13 @@ table { document.getElementById("labelmirror").style = "color:lightgrey;"; } + if (param["Alignment"]["FlipImageSize"].found) + document.getElementById("flip").disabled = false; + else + { + document.getElementById("labelflip").style = "color:lightgrey;"; + } + if (param["MakeImage"]["Brightness"].found && param["MakeImage"]["Brightness"].enabled) document.getElementById("MakeImage_Brightness_value1").disabled = false; else @@ -156,6 +168,9 @@ table { if (_param["Alignment"]["InitialMirror"].found && (_param["Alignment"]["InitialMirror"].value1 == "true")) document.getElementById("mirror").checked = true; + if (_param["Alignment"]["FlipImageSize"].found && (_param["Alignment"]["FlipImageSize"].value1 == "true")) + document.getElementById("flip").checked = true; + document.getElementById("finerotate").disabled = true; document.getElementById("prerotateangle").disabled = true; document.getElementById("updatereferenceimage").disabled = true; @@ -164,6 +179,7 @@ table { // document.getElementById("MakeImage_Saturation_value1").disabled = true; // document.getElementById("MakeImage_Contrast_value1").disabled = true; document.getElementById("mirror").disabled = false; + document.getElementById("flip").disabled = false; if (!(param["MakeImage"]["Brightness"].found)) { document.getElementById("MakeImage_Brightness_value1").type = "hidden"; @@ -172,6 +188,7 @@ table { document.getElementById("mirror").disabled = true; + document.getElementById("flip").disabled = true; isActReference = true; loadCanvas(url); @@ -190,11 +207,17 @@ table { function SaveReference(){ if (confirm("Are you sure you want to update the reference image?")) { param["Alignment"]["InitialRotate"].value1 = document.getElementById("prerotateangle").value; + if ((param["Alignment"]["InitialMirror"].found == true) && (document.getElementById("mirror").checked)) param["Alignment"]["InitialMirror"].value1 = "true"; else param["Alignment"]["InitialMirror"].value1 = "false"; + if ((param["Alignment"]["FlipImageSize"].found == true) && (document.getElementById("flip").checked)) + param["Alignment"]["FlipImageSize"].value1 = "true"; + else + param["Alignment"]["FlipImageSize"].value1 = "false"; + if (param["MakeImage"]["Brightness"].found && param["MakeImage"]["Brightness"].enabled) { ReadParameter(param, "MakeImage", "Brightness", false); @@ -319,6 +342,7 @@ table { finerot= parseFloat(document.getElementById("finerotate").value); prerot = parseFloat(document.getElementById("prerotateangle").value); mirror = document.getElementById("mirror").checked; + flip = document.getElementById("flip").checked; if (finerot == 1) { prerot+=1 @@ -332,10 +356,22 @@ table { document.getElementById("finerotate").value = finerot; document.getElementById("prerotateangle").value = prerot; + var canvas = document.getElementById('canvas'); + if (flip == 1) + { + canvas.width = imageObj.height; + canvas.height = imageObj.width; + } + else + { + canvas.width = imageObj.width; + canvas.height = imageObj.height; + } + var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); - context.clearRect(0,0,imageObj.width,imageObj.height); + context.clearRect(0,0,canvas.width,canvas.height); context.save(); if (isActReference) @@ -344,17 +380,12 @@ table { } else { + context.translate(canvas.width/2,canvas.height/2); + context.rotate(degrees*Math.PI/180); if (mirror) { context.scale(-1, 1); - context.translate(-imageObj.width/2,imageObj.height/2); - context.rotate(-degrees*Math.PI/180); - context.drawImage(imageObj, imageObj.width/2,-imageObj.height/2, -imageObj.width, imageObj.height); - } - else { - context.translate(imageObj.width/2,imageObj.height/2); - context.rotate(degrees*Math.PI/180); - context.drawImage(imageObj,-imageObj.width/2,-imageObj.height/2); } + context.drawImage(imageObj,-imageObj.width/2,-imageObj.height/2); } diff --git a/sd-card/html/gethost.js b/sd-card/html/gethost.js index 40a7c87a..056a06e9 100644 --- a/sd-card/html/gethost.js +++ b/sd-card/html/gethost.js @@ -9,7 +9,7 @@ function getbasepath(){ { // host = "http://192.168.2.118"; // jomjol interner test // host = "http://192.168.178.26"; // jomjol interner test - host = "http://192.168.178.22"; // jomjol interner Real + host = "http://192.168.178.75"; // jomjol interner Real // host = "."; // jomjol interner localhost } diff --git a/sd-card/html/html.zip b/sd-card/html/html.zip new file mode 100644 index 00000000..88f0c56d Binary files /dev/null and b/sd-card/html/html.zip differ diff --git a/sd-card/html/readconfigparam.js b/sd-card/html/readconfigparam.js index 960bcc0b..e5f9516b 100644 --- a/sd-card/html/readconfigparam.js +++ b/sd-card/html/readconfigparam.js @@ -39,7 +39,8 @@ function ParseConfig() { ParamAddValue(param, catname, "InitialMirror"); ParamAddValue(param, catname, "SearchFieldX"); ParamAddValue(param, catname, "SearchFieldY"); - ParamAddValue(param, catname, "AlignmentAlgo"); + ParamAddValue(param, catname, "AlignmentAlgo"); + ParamAddValue(param, catname, "FlipImageSize"); var catname = "Digits"; category[catname] = new Object(); diff --git a/sd-card/html/version.txt b/sd-card/html/version.txt index f22d756d..f0e13c50 100644 --- a/sd-card/html/version.txt +++ b/sd-card/html/version.txt @@ -1 +1 @@ -6.5.0 +6.7.0 diff --git a/sd-card/html/wasserzaehler_roi.html b/sd-card/html/wasserzaehler_roi.html index e4e47f9e..d12cbe64 100644 --- a/sd-card/html/wasserzaehler_roi.html +++ b/sd-card/html/wasserzaehler_roi.html @@ -31,7 +31,7 @@ var m = addZero(d.getMinutes()); var s = addZero(d.getSeconds()); - $('#img').html(''); + $('#img').html(''); $("#raw").load("/wasserzaehler.html?rawvalue=true"); $("#corrected").load("/wasserzaehler.html"); $("#checked").load("/setPreValue.html"); @@ -49,7 +49,7 @@ var m = addZero(d.getMinutes()); var s = addZero(d.getSeconds()); // reassign the url to be like alg_roi.jpg?timestamp=456784512 based on timestamp - $('#img').html(''); + $('#img').html(''); $("#raw").load("/wasserzaehler.html?rawvalue=true"); $("#corrected").load("/wasserzaehler.html"); $("#checked").load("/setPreValue.html");