- implementation mirroring
- index.hthml
This commit is contained in:
jomjol
2020-09-12 09:21:13 +02:00
parent 3712c0ea7e
commit 9fea3b4b3a
12 changed files with 186 additions and 28 deletions

View File

@@ -8,6 +8,7 @@ ClassFlowAlignment::ClassFlowAlignment()
anz_ref = 0;
suchex = 40;
suchey = 40;
initialmirror = false;
namerawimage = "/sdcard/img_tmp/raw.jpg";
ListFlowControll = NULL;
}
@@ -18,6 +19,7 @@ ClassFlowAlignment::ClassFlowAlignment(std::vector<ClassFlow*>* lfc)
anz_ref = 0;
suchex = 40;
suchey = 40;
initialmirror = false;
namerawimage = "/sdcard/img_tmp/raw.jpg";
ListFlowControll = lfc;
}
@@ -38,7 +40,12 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
{
zerlegt = this->ZerlegeZeile(aktparamgraph);
if ((zerlegt[0] == "InitalRotate") && (zerlegt.size() > 1))
if ((zerlegt[0] == "InitialMirror") && (zerlegt.size() > 1))
{
if (toUpper(zerlegt[1]) == "TRUE")
initialmirror = true;
}
if (((zerlegt[0] == "InitalRotate") || (zerlegt[0] == "InitialRotate")) && (zerlegt.size() > 1))
{
this->initalrotate = std::stod(zerlegt[1]);
}
@@ -80,26 +87,38 @@ bool ClassFlowAlignment::doFlow(string time)
string output3 = "/sdcard/img_tmp/rot_roi.jpg";
string output2 = "/sdcard/img_tmp/alg.jpg";
string output4 = "/sdcard/img_tmp/alg_roi.jpg";
string output1 = "/sdcard/img_tmp/mirror.jpg";
input = FormatFileName(input);
output = FormatFileName(output);
output2 = FormatFileName(output2);
if (initialmirror){
CRotate *rt;
rt = new CRotate(input);
if (!rt->ImageOkay()){
LogFile.WriteToFile("ClassFlowAlignment::doFlow CRotate Inital Mirror raw.jpg not okay!");
delete rt;
return false;
}
printf("do mirror\n");
rt->Mirror();
rt->SaveToFile(output1);
input = output1;
delete rt;
}
if (initalrotate != 0)
{
CRotate *rt;
CRotate *rt = NULL;
printf("Load rotationfile: %s\n", input.c_str());
rt = new CRotate(input);
if (!rt->ImageOkay()){
LogFile.WriteToFile("ClassFlowAlignment::doFlow CRotate raw.jpg not okay!");
delete rt;
LogFile.WriteToFile("ClassFlowAlignment::doFlow 1x reload.");
rt = new CRotate(input);
if (!rt->ImageOkay()){
LogFile.WriteToFile("ClassFlowAlignment::doFlow Reload auch nicht erfolgreich!");
delete rt;
return false;
}
return false;
}
rt->Rotate(this->initalrotate);
rt->SaveToFile(output);

View File

@@ -12,6 +12,7 @@ class ClassFlowAlignment :
{
protected:
float initalrotate;
bool initialmirror;
string reffilename[2];
int ref_x[2], ref_y[2];
int anz_ref;

View File

@@ -12,7 +12,21 @@
string ClassFlowPostProcessing::GetPreValue()
{
return to_string(PreValue);
std::string result;
result = to_string(PreValue);
for (int i = 0; i < ListFlowControll->size(); ++i)
{
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
{
int AnzahlNachkomma = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
std::stringstream stream;
stream << std::fixed << std::setprecision(AnzahlNachkomma) << PreValue;
result = stream.str();
}
}
return result;
}
bool ClassFlowPostProcessing::LoadPreValue(void)

View File

@@ -44,6 +44,32 @@ void CResizeImage::Resize(int _new_dx, int _new_dy)
stbi_image_free(odata);
}
void CRotate::Mirror(){
int memsize = this->width * this->height * this->channels;
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
int x_source, y_source;
stbi_uc* p_target;
stbi_uc* p_source;
for (int x = 0; x < this->width; ++x)
for (int y = 0; y < this->height; ++y)
{
p_target = odata + (this->channels * (y * this->width + x));
x_source = this->width - x;
y_source = y;
p_source = this->rgb_image + (this->channels * (y_source * this->width + x_source));
for (int channels = 0; channels < this->channels; ++channels)
p_target[channels] = p_source[channels];
}
// memcpy(this->rgb_image, odata, memsize);
this->memCopy(odata, this->rgb_image, memsize);
stbi_image_free(odata);
}
void CRotate::Rotate(float _angle, int _centerx, int _centery)
{
float m[2][3];

View File

@@ -70,6 +70,7 @@ class CRotate: public CImageBasis
void Rotate(float _angle);
void Rotate(float _angle, int _centerx, int _centery);
void Translate(int _dx, int _dy);
void Mirror();
};

View File

@@ -397,7 +397,7 @@ esp_err_t handler_prevalue(httpd_req_t *req)
}
if (strlen(_size) == 0)
zw = "Actual PreValue: " + tfliteflow.GetPrevalue();
zw = tfliteflow.GetPrevalue();
else
zw = "SetPrevalue to " + tfliteflow.UpdatePrevalue(_size);