mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-11 22:16:56 +03:00
Inital
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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);
|
||||
Reference in New Issue
Block a user