Merge branch 'pr/952' into rolling

This commit is contained in:
jomjol
2022-08-31 19:58:04 +02:00
9 changed files with 148 additions and 27 deletions

View File

@@ -439,6 +439,7 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph)
neuroi->posy = std::stoi(zerlegt[2]);
neuroi->deltax = std::stoi(zerlegt[3]);
neuroi->deltay = std::stoi(zerlegt[4]);
neuroi->CCW = toUpper(zerlegt[5]) == "TRUE";
neuroi->result_float = -1;
neuroi->image = NULL;
neuroi->image_org = NULL;
@@ -511,7 +512,7 @@ general* ClassFlowCNNGeneral::GetGENERAL(string _name, bool _create = true)
_ret->ROI.push_back(neuroi);
printf("GetGENERAL - GENERAL %s - roi %s\n", _analog.c_str(), _roi.c_str());
printf("GetGENERAL - GENERAL %s - roi %s - CCW: %d\n", _analog.c_str(), _roi.c_str(), neuroi->CCW);
return _ret;
}
@@ -724,8 +725,13 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
f1 = tflite->GetOutputValue(0);
f2 = tflite->GetOutputValue(1);
float result = fmod(atan2(f1, f2) / (M_PI * 2) + 2, 1);
GENERAL[_ana]->ROI[i]->result_float = result * 10;
printf("Result General(Analog)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
if(GENERAL[_ana]->ROI[i]->CCW)
GENERAL[_ana]->ROI[i]->result_float = 10 - (result * 10);
else
GENERAL[_ana]->ROI[i]->result_float = result * 10;
printf("Result General(Analog)%i - CCW: %d - %f\n", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float);
if (isLogImage)
LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
} break;
@@ -916,15 +922,17 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
_num = tflite->GetOutClassification();
GENERAL[_ana]->ROI[i]->result_float = (float)_num / 10.0;
if(GENERAL[_ana]->ROI[i]->CCW)
GENERAL[_ana]->ROI[i]->result_float = 10 - ((float)_num / 10.0);
else
GENERAL[_ana]->ROI[i]->result_float = (float)_num / 10.0;
_result_save_file = GENERAL[_ana]->ROI[i]->result_float;
GENERAL[_ana]->ROI[i]->isReject = false;
printf("Result General(Analog)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
printf("Result General(Analog)%i - CCW: %d - %f\n", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float);
if (isLogImage)
{

View File

@@ -7,7 +7,7 @@ struct roi {
int posx, posy, deltax, deltay;
float result_float;
int result_klasse;
bool isReject;
bool isReject, CCW;
string name;
CImageBasis *image, *image_org;
};

View File

@@ -170,6 +170,9 @@ bool ClassFlowMQTT::doFlow(string zwtime)
sprintf(rssi, "%d", get_WIFI_RSSI());
MQTTPublish(zw, rssi, SetRetainFlag);
zw = maintopic + "/" + "CPUtemp";
std::string cputemp = std::to_string(temperatureRead());
MQTTPublish(zw, cputemp, SetRetainFlag);
if (flowpostprocessing)
{

View File

@@ -21,6 +21,7 @@
#include "server_GPIO.h"
#include "server_file.h"
#include "connect_wlan.h"
#define DEBUG_DETAIL_ON
@@ -590,6 +591,55 @@ esp_err_t handler_statusflow(httpd_req_t *req)
return ESP_OK;
};
esp_err_t handler_cputemp(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_cputemp - Start");
#endif
const char* resp_str;
char cputemp[20];
sprintf(cputemp, "CPU Temp: %4.1f°C", temperatureRead());
resp_str = cputemp;
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_send(req, resp_str, strlen(resp_str));
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_cputemp - End");
#endif
return ESP_OK;
};
esp_err_t handler_rssi(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_rssi - Start");
#endif
const char* resp_str;
char rssi[20];
sprintf(rssi, "RSSI: %idBm", get_WIFI_RSSI());
resp_str = rssi;
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_send(req, resp_str, strlen(resp_str));
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_rssi - End");
#endif
return ESP_OK;
};
esp_err_t handler_prevalue(httpd_req_t *req)
{
@@ -643,7 +693,7 @@ esp_err_t handler_prevalue(httpd_req_t *req)
httpd_resp_send_chunk(req, NULL, 0);
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_prevalue - Start");
LogFile.WriteHeapInfo("handler_prevalue - End");
#endif
return ESP_OK;
@@ -766,6 +816,16 @@ void register_server_tflite_uri(httpd_handle_t server)
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/cputemp.html";
camuri.handler = handler_cputemp;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/rssi.html";
camuri.handler = handler_rssi;
camuri.user_ctx = (void*) "Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/editflow.html";
camuri.handler = handler_editflow;
camuri.user_ctx = (void*) "EditFlow";