mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-16 16:36:59 +03:00
Restructure Image Processing
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Helper.h"
|
||||
#include "CFindTemplate.h"
|
||||
#include "CImageBasis.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
#include "ClassFlowMakeImage.h"
|
||||
#include "ClassFlow.h"
|
||||
|
||||
#include "CRotateImage.h"
|
||||
|
||||
#include "ClassLogFile.h"
|
||||
|
||||
|
||||
|
||||
bool AlignmentExtendedDebugging = true;
|
||||
|
||||
|
||||
@@ -118,7 +122,7 @@ bool ClassFlowAlignment::doFlow(string time)
|
||||
delete AlignAndCutImage;
|
||||
AlignAndCutImage = new CAlignAndCutImage(ImageBasis, ImageTMP);
|
||||
|
||||
CRotate rt(AlignAndCutImage, ImageTMP);
|
||||
CRotateImage rt(AlignAndCutImage, ImageTMP);
|
||||
|
||||
if (initialmirror){
|
||||
printf("do mirror\n");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "ClassFlow.h"
|
||||
#include "Helper.h"
|
||||
#include "CAlignAndCutImage.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ void ClassFlowAnalog::SetInitialParameter(void)
|
||||
modelysize = 1;
|
||||
ListFlowControll = NULL;
|
||||
previousElement = NULL;
|
||||
SaveAllFiles = false;
|
||||
SaveAllFiles = true;
|
||||
}
|
||||
|
||||
ClassFlowAnalog::ClassFlowAnalog(std::vector<ClassFlow*>* lfc) : ClassFlowImage(lfc, TAG)
|
||||
@@ -132,9 +132,14 @@ bool ClassFlowAnalog::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
if (toUpper(zerlegt[1]) == "TRUE")
|
||||
SaveAllFiles = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < ROI.size(); ++i)
|
||||
{
|
||||
ROI[i]->image = new CImageBasis(modelxsize, modelysize, 3);
|
||||
ROI[i]->image_org = new CImageBasis(ROI[i]->deltax, ROI[i]->deltay, 3);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -186,19 +191,12 @@ bool ClassFlowAnalog::doAlignAndCut(string time)
|
||||
for (int i = 0; i < ROI.size(); ++i)
|
||||
{
|
||||
printf("Analog %d - Align&Cut\n", i);
|
||||
|
||||
caic->CutAndSave(ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay, ROI[i]->image_org);
|
||||
if (SaveAllFiles) ROI[i]->image_org->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".jpg"));
|
||||
|
||||
CResizeImage *rs = caic->CutAndSave(ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay);
|
||||
if (ROI[i]->image_org)
|
||||
delete ROI[i]->image_org;
|
||||
ROI[i]->image_org = new CImageBasis((CImageBasis*) rs);
|
||||
|
||||
if (SaveAllFiles) rs->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".jpg"));
|
||||
|
||||
rs->Resize(modelxsize, modelysize);
|
||||
if (SaveAllFiles) rs->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".bmp"));
|
||||
if (ROI[i]->image)
|
||||
delete ROI[i]->image;
|
||||
ROI[i]->image = rs;
|
||||
ROI[i]->image_org->Resize(modelxsize, modelysize, ROI[i]->image);
|
||||
if (SaveAllFiles) ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".bmp"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "Helper.h"
|
||||
#include "server_ota.h"
|
||||
|
||||
#include "server_help.h"
|
||||
|
||||
static const char* TAG = "flow_controll";
|
||||
|
||||
bool flowcontrolldebugdetail = true;
|
||||
@@ -415,28 +417,31 @@ esp_err_t ClassFlowControll::SendRawJPG(httpd_req_t *req)
|
||||
}
|
||||
|
||||
|
||||
ImageData* ClassFlowControll::GetJPGStream(std::string _fn)
|
||||
esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
||||
{
|
||||
printf("ClassFlowControll::GetJPGStream %s\n", _fn.c_str());
|
||||
ImageData* ret = NULL;
|
||||
|
||||
CImageBasis *_send = NULL;
|
||||
esp_err_t result = ESP_FAIL;
|
||||
bool Dodelete = false;
|
||||
|
||||
if (_fn == "alg.jpg")
|
||||
{
|
||||
return flowalignment->ImageBasis->writeToMemoryAsJPG();
|
||||
_send = flowalignment->ImageBasis;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (_fn == "alg_roi.jpg")
|
||||
{
|
||||
CImageBasis* _imgzw = new CImageBasis(flowalignment->ImageBasis);
|
||||
flowalignment->DrawRef(_imgzw);
|
||||
if (flowdigit) flowdigit->DrawROI(_imgzw);
|
||||
if (flowanalog) flowanalog->DrawROI(_imgzw);
|
||||
ret = _imgzw->writeToMemoryAsJPG();
|
||||
delete _imgzw;
|
||||
return ret;
|
||||
_send = _imgzw;
|
||||
Dodelete = true;
|
||||
}
|
||||
|
||||
|
||||
std::vector<HTMLInfo*> htmlinfo;
|
||||
htmlinfo = GetAllDigital();
|
||||
for (int i = 0; i < htmlinfo.size(); ++i)
|
||||
@@ -444,12 +449,12 @@ ImageData* ClassFlowControll::GetJPGStream(std::string _fn)
|
||||
if (_fn == htmlinfo[i]->filename)
|
||||
{
|
||||
if (htmlinfo[i]->image)
|
||||
return htmlinfo[i]->image->writeToMemoryAsJPG();
|
||||
_send = htmlinfo[i]->image;
|
||||
}
|
||||
if (_fn == htmlinfo[i]->filename_org)
|
||||
{
|
||||
if (htmlinfo[i]->image_org)
|
||||
return htmlinfo[i]->image_org->writeToMemoryAsJPG();
|
||||
_send = htmlinfo[i]->image_org;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,15 +464,29 @@ ImageData* ClassFlowControll::GetJPGStream(std::string _fn)
|
||||
if (_fn == htmlinfo[i]->filename)
|
||||
{
|
||||
if (htmlinfo[i]->image)
|
||||
return htmlinfo[i]->image->writeToMemoryAsJPG();
|
||||
_send = htmlinfo[i]->image;
|
||||
}
|
||||
if (_fn == htmlinfo[i]->filename_org)
|
||||
{
|
||||
if (htmlinfo[i]->image_org)
|
||||
return htmlinfo[i]->image_org->writeToMemoryAsJPG();
|
||||
_send = htmlinfo[i]->image_org;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Kein internes Bild gefunden - suche auf SD-Karte\n");
|
||||
return NULL;
|
||||
if (_send)
|
||||
{
|
||||
ESP_LOGI(TAG, "Sending file : %s ...", _fn.c_str());
|
||||
set_content_type_from_file(req, _fn.c_str());
|
||||
result = _send->SendJPGtoHTTP(req);
|
||||
ESP_LOGI(TAG, "File sending complete");
|
||||
/* Respond with an empty chunk to signal HTTP response completion */
|
||||
httpd_resp_send_chunk(req, NULL, 0);
|
||||
}
|
||||
|
||||
if (Dodelete)
|
||||
{
|
||||
delete _send;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
string GetPrevalue();
|
||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||
|
||||
ImageData* GetJPGStream(std::string _fn);
|
||||
esp_err_t GetJPGStream(std::string _fn, httpd_req_t *req);
|
||||
esp_err_t SendRawJPG(httpd_req_t *req);
|
||||
|
||||
std::string doSingleStep(std::string _stepname, std::string _host);
|
||||
|
||||
@@ -24,7 +24,7 @@ void ClassFlowDigit::SetInitialParameter(void)
|
||||
modelysize = 1;
|
||||
ListFlowControll = NULL;
|
||||
previousElement = NULL;
|
||||
SaveAllFiles = false;
|
||||
SaveAllFiles = true;
|
||||
}
|
||||
|
||||
ClassFlowDigit::ClassFlowDigit() : ClassFlowImage(TAG)
|
||||
@@ -128,6 +128,13 @@ bool ClassFlowDigit::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < ROI.size(); ++i)
|
||||
{
|
||||
ROI[i]->image = new CImageBasis(modelxsize, modelysize, 3);
|
||||
ROI[i]->image_org = new CImageBasis(ROI[i]->deltax, ROI[i]->deltay, 3);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -178,19 +185,12 @@ bool ClassFlowDigit::doAlignAndCut(string time)
|
||||
for (int i = 0; i < ROI.size(); ++i)
|
||||
{
|
||||
printf("DigitalDigit %d - Align&Cut\n", i);
|
||||
CResizeImage *rs = caic->CutAndSave(ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay);
|
||||
|
||||
caic->CutAndSave(ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay, ROI[i]->image_org);
|
||||
if (SaveAllFiles) ROI[i]->image_org->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".jpg"));
|
||||
|
||||
if (ROI[i]->image_org)
|
||||
free(ROI[i]->image_org);
|
||||
ROI[i]->image_org = new CImageBasis((CImageBasis*) rs);
|
||||
if (SaveAllFiles) rs->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".jpg"));
|
||||
|
||||
rs->Resize(modelxsize, modelysize);
|
||||
if (SaveAllFiles) rs->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".bmp"));
|
||||
|
||||
if (ROI[i]->image)
|
||||
free(ROI[i]->image);
|
||||
ROI[i]->image = rs;
|
||||
ROI[i]->image_org->Resize(modelxsize, modelysize, ROI[i]->image);
|
||||
if (SaveAllFiles) ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".bmp"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <dirent.h>
|
||||
#include "time_sntp.h"
|
||||
#include "ClassLogFile.h"
|
||||
#include "CFindTemplate.h"
|
||||
#include "CImageBasis.h"
|
||||
|
||||
ClassFlowImage::ClassFlowImage(const char* logTag)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "ClassFlowMakeImage.h"
|
||||
#include "Helper.h"
|
||||
|
||||
#include "CFindTemplate.h"
|
||||
#include "CImageBasis.h"
|
||||
#include "ClassControllCamera.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
Reference in New Issue
Block a user