This commit is contained in:
jomjol
2020-12-22 08:08:07 +01:00
parent f5c28107d4
commit b418525b3b
39 changed files with 1173 additions and 501 deletions

View File

@@ -21,6 +21,18 @@ float CTfLiteClass::GetOutputValue(int nr)
return output2->data.f[nr];
}
int CTfLiteClass::GetClassFromImageBasis(CImageBasis *rs)
{
// printf("Before Load image %s\n", _fn.c_str());
if (!LoadInputImageBasis(rs))
return -1000;
Invoke();
printf("After Invoke \n");
return GetOutClassification();
}
int CTfLiteClass::GetClassFromImage(std::string _fn)
{
@@ -33,7 +45,6 @@ int CTfLiteClass::GetClassFromImage(std::string _fn)
printf("After Invoke %s\n", _fn.c_str());
return GetOutClassification();
// return 0;
}
int CTfLiteClass::GetOutClassification()
@@ -113,6 +124,46 @@ void CTfLiteClass::Invoke()
}
bool CTfLiteClass::LoadInputImageBasis(CImageBasis *rs)
{
std::string zw = "ClassFlowAnalog::doNeuralNetwork nach LoadInputResizeImage: ";
// LogFile.WriteToFile(zw);
unsigned int w = rs->width;
unsigned int h = rs->height;
unsigned char red, green, blue;
// printf("Image: %s size: %d x %d\n", _fn.c_str(), w, h);
input_i = 0;
float* input_data_ptr = (interpreter->input(0))->data.f;
for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x)
{
red = rs->GetPixelColor(x, y, 0);
green = rs->GetPixelColor(x, y, 1);
blue = rs->GetPixelColor(x, y, 2);
*(input_data_ptr) = (float) red;
input_data_ptr++;
*(input_data_ptr) = (float) green;
input_data_ptr++;
*(input_data_ptr) = (float) blue;
input_data_ptr++;
// printf("BMP: %f %f %f\n", (float) red, (float) green, (float) blue);
}
if (debugdetailtflite) LogFile.WriteToFile("Nach dem Laden in input");
return true;
}
bool CTfLiteClass::LoadInputImage(std::string _fn)
{
std::string zw = "ClassFlowAnalog::doNeuralNetwork nach Load Image: " + _fn;
@@ -239,7 +290,7 @@ CTfLiteClass::CTfLiteClass()
this->interpreter = nullptr;
this->input = nullptr;
this->output = nullptr;
this->kTensorArenaSize = 600 * 1024;
this->kTensorArenaSize = 150 * 1024; /// laut testfile: 108000 - bisher 600
this->tensor_arena = new uint8_t[kTensorArenaSize];
}

View File

@@ -14,6 +14,8 @@
#include "esp_err.h"
#include "esp_log.h"
#include "CFindTemplate.h"
#define SUPRESS_TFLITE_ERRORS // use, to avoid error messages from TFLITE
@@ -59,10 +61,12 @@ class CTfLiteClass
void MakeAllocate();
void GetInputTensorSize();
bool LoadInputImage(std::string _fn);
bool LoadInputImageBasis(CImageBasis *rs);
void Invoke();
void GetOutPut();
int GetOutClassification();
int GetClassFromImage(std::string _fn);
int GetClassFromImageBasis(CImageBasis *rs);
float GetOutputValue(int nr);
void GetInputDimension(bool silent);

View File

@@ -29,6 +29,16 @@ bool flowisrunning = false;
long auto_intervall = 0;
bool auto_isrunning = false;
ImageData* GetJPG(std::string _filename)
{
return tfliteflow.GetJPGStream(_filename);
}
esp_err_t GetRawJPG(httpd_req_t *req)
{
return tfliteflow.SendRawJPG(req);
}
bool isSetupModusActive() {
return tfliteflow.getStatusSetupModus();
return false;
@@ -171,7 +181,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
{
string txt, zw;
txt = "<p>Aligned Image: <p><img src=\"/img_tmp/alg.jpg\"> <p>\n";
txt = "<p>Aligned Image: <p><img src=\"/img_tmp/alg_roi.jpg\"> <p>\n";
txt = txt + "Digital Counter: <p> ";
httpd_resp_sendstr_chunk(req, txt.c_str());

View File

@@ -1,6 +1,7 @@
#include <esp_log.h>
#include <esp_http_server.h>
#include "CFindTemplate.h"
//#include "ClassControllCamera.h"
@@ -12,4 +13,8 @@ void KillTFliteTasks();
void TFliteDoAutoStart();
bool isSetupModusActive();
bool isSetupModusActive();
ImageData* GetJPG(std::string _filename);
esp_err_t GetRawJPG(httpd_req_t *req);