mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 20:46:52 +03:00
* Testcase for #2145 and debug-log (#2151) * new models ana-cont-11.0.5, ana-class100-1.5.7, dig-class100-1.6.0 * Testcase for #2145 Added debug log, if allowNegativeRates is handeled * Fix timezone config parser (#2169) * make sure to parse the whole config line * fix crash on empty timezone parameter --------- Co-authored-by: CaCO3 <caco@ruinelli.ch> * Enhance ROI pages (#2161) * Check if the ROIs are equidistant. Only if not, untick the checkbox * renaming * Check if the ROIs have same y, dy and dx. If so, tick the sync checkbox * only allow editing space when box is checked * fix sync check * show inner frame on all ROIs * cleanup * Check if the ROIs have same dy and dx. If so, tick the sync checkbox * checkbox position * renaming * renaming * show inner frame and cross hairs on all ROIs * update ROIs on ticking checkboxes * show timezone hint * fix deleting last ROI * cleanup --------- Co-authored-by: CaCO3 <caco@ruinelli.ch> * restart timeout on progress, catch error (#2170) * restart timeout on progress, catch error * . --------- Co-authored-by: CaCO3 <caco@ruinelli.ch> * BugFix #2167 * Release 15.1 preparations (#2171) * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update changelog * Fix links to PR * Formating * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md * Update Changelog.md --------- Co-authored-by: Slider0007 <jobbelle@gmx.net> Co-authored-by: Slider0007 <115730895+Slider0007@users.noreply.github.com> * fix typo * Replace relative documentation links with absolute ones pointing to the external documentation (#2180) Co-authored-by: CaCO3 <caco@ruinelli.ch> * Sort model files in configuration combobox (#2189) * new models ana-cont-11.0.5, ana-class100-1.5.7, dig-class100-1.6.0 * Testcase for #2145 Added debug log, if allowNegativeRates is handeled * Sort model files in combobox * reboot task - increase stack size (#2201) Avoid stack overflow * Update interface_influxdb.cpp * Update Changelog.md * Show PSRAM usage (#2206) * centralize PSRAM usage (application code only) * update logging * update logging * fix use after free * initialize buffer * free rgb_image before ussing it for new allocation * use wrapper function * switch log level to debug * . * undo adding free() calls * . * add names to all CImage instances * . * . * . * revert changes of stbi_image_free() with free_psram_heap() on the places where is is not in PSRAM * . * typos * typo * Added MQTT Outbox explanation/warning * added CONFIG_SPIRAM_USE_MEMMAP explanation --------- Co-authored-by: CaCO3 <caco@ruinelli.ch> * Disable custom MQTT Outbox. This also moves the MQTT Publishing memory usage back to the internal RAM! * log MQTT connection refused reasons (#2216) * Revert PSRAM usage as it lead to memory fragmentation. See https://github.com/jomjol/AI-on-the-edge-device/issues/2200 for details * fix missing value data * Revert PSRAM usage as it lead to memory fragmentation. (#2224) See https://github.com/jomjol/AI-on-the-edge-device/issues/2200 for details Co-authored-by: CaCO3 <caco@ruinelli.ch> * Fix missing value data in graph (#2230) * fix missing value data --------- Co-authored-by: CaCO3 <caco@ruinelli.ch> * Update Changelog.md (#2231) * Update interface_influxdb.cpp (#2233) * update copyright year * Cleanup * Set prevalue using MQTT + set prevalue to RAW value (REST+MQTT) (#2252) * Use double instead of float * Error handling + set to RAW if newvalue < 0 * REST SetPrevalue: Set to RAW if newvalue < 0 * set prevalue with MQTT * removed the stb_image files and re-add them as a submodule. (#2223) - stb_image.h: Version update 2.25 -> 2.28 - stb_resize.h: Version update 0.96 -> 0.97 - stb_write.h: Version update 1.14 -> 1.16 Co-authored-by: CaCO3 <caco@ruinelli.ch> * Remove obsolete ClassFlowWriteList (#2264) * Renaming & cleanup of some modules / functions in source code (#2265) * Rename module tag name * Rename server_tflite.cpp -> MainFlowControl.cpp * Remove redundandant MQTTMainTopic function * Update * Remove obsolete GetMQTTMainTopic * Fix last element missing in digit model drop down (#2282) * Debug influxdb (#2283) * Fix time offset issues in InfluxDB component. (#2278) Closes #2273 Closes #2150 * Update interface_influxdb.cpp * Update interface_influxdb.cpp * Improve Logging * Implement TimeSync at beginning * Update time_sntp.cpp * Update time_sntp.cpp * Set Time After WLAN Init --------- Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu> * Implement a camera livestream handler (#2286) * fix leading NaN (#2310) * analogROI: Activate save button after ROI creation (#2326) * Migration of PlatformIO 5.2.0 to 6.1.0 (resp. ESP IDF from 4.4.2 to 5.0.1) (#2305) * Migration to PlatformIO 6.1.0 * Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional! * moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore. * cleanup * fix leading NaN (#2310) * Migration to PlatformIO 6.1.0 * Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional! * moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore. * cleanup * Task watchdog has new config name * Fix return value check. It must be something else than ESP_FAIL, but it does not need to be ESP_OK! * add missing strucures to work around new RMTMEM restriction (untested) --------- Co-authored-by: CaCO3 <caco@ruinelli.ch> * Keep MainFlowTask alive to handle reboot (#2325) * Shared PSRAM memory (#2285) * enable PSRAM logging * add extra functions for psram shared memroy handling * CImageBasis objects still should used dynamic memory (eg. rawImage), haw ever tmpImage must be placed inside the shared memory * Place all STBI allocs inside the shared memory * The models are placed in the shared PSRAM reagion and must be allocated through the dedicated functions * . * renaming * fix cast warning * add flag to switch STBI PSRAM usage * improve PSRAM shared handling * reserve shared PSRAM as early as possible * init logging eralier so we can use it in PSRAM shared alloc * move Wifi_LWIP, BSS_SEG and MQTT Outbox into PSRAM to ffree internal memory * Check if model fits into reserved shared memory * Update code/components/jomjol_tfliteclass/CTfLiteClass.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_flowcontroll/ClassFlowControll.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_image_proc/CImageBasis.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * . * . * . * . * Korrektur Merge Conflict in main.cpp --------- Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> * fix PSRAM init return value check * Extend InfluxDBv1 with individual topic names (#2319) * Implement individual influx topic * Update interface_influxdb.cpp * Update interface_influxdb.cpp * Update FieldName * analogROI: Activate save button after ROI creation (#2326) * Migration of PlatformIO 5.2.0 to 6.1.0 (resp. ESP IDF from 4.4.2 to 5.0.1) (#2305) * Migration to PlatformIO 6.1.0 * Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional! * moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore. * cleanup * fix leading NaN (#2310) * Migration to PlatformIO 6.1.0 * Disable RMTMEM usage as it is no longer allowed -> Smart LEDs not functional! * moved miniz into subfolder of jomjol_fileserver_ota, else it does not build anymore. * cleanup * Task watchdog has new config name * Fix return value check. It must be something else than ESP_FAIL, but it does not need to be ESP_OK! * add missing strucures to work around new RMTMEM restriction (untested) --------- Co-authored-by: CaCO3 <caco@ruinelli.ch> * Keep MainFlowTask alive to handle reboot (#2325) * Shared PSRAM memory (#2285) * enable PSRAM logging * add extra functions for psram shared memroy handling * CImageBasis objects still should used dynamic memory (eg. rawImage), haw ever tmpImage must be placed inside the shared memory * Place all STBI allocs inside the shared memory * The models are placed in the shared PSRAM reagion and must be allocated through the dedicated functions * . * renaming * fix cast warning * add flag to switch STBI PSRAM usage * improve PSRAM shared handling * reserve shared PSRAM as early as possible * init logging eralier so we can use it in PSRAM shared alloc * move Wifi_LWIP, BSS_SEG and MQTT Outbox into PSRAM to ffree internal memory * Check if model fits into reserved shared memory * Update code/components/jomjol_tfliteclass/CTfLiteClass.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_flowcontroll/ClassFlowControll.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_image_proc/CImageBasis.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * Update code/components/jomjol_helper/psram.cpp * . * . * . * . * Korrektur Merge Conflict in main.cpp --------- Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> * fix PSRAM init return value check * Extend incl. indiv. Measurement * Implement UX * Update ClassFlowInfluxDBv2.cpp * Implement individual influx topic * Update interface_influxdb.cpp * Update interface_influxdb.cpp * Update FieldName * Extend incl. indiv. Measurement * Implement UX * Update ClassFlowInfluxDBv2.cpp * Update main.cpp --------- Co-authored-by: Slider0007 <115730895+Slider0007@users.noreply.github.com> Co-authored-by: CaCO3 <caco3@ruinelli.ch> Co-authored-by: CaCO3 <caco@ruinelli.ch> * Update Changelog.md (#2344) * Update Changelog.md * Update Changelog.md * merge conflicts * merge conflicts * update changelog --------- Co-authored-by: Frank Haverland <fspapaping@googlemail.com> Co-authored-by: CaCO3 <caco@ruinelli.ch> Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com> Co-authored-by: Slider0007 <jobbelle@gmx.net> Co-authored-by: Slider0007 <115730895+Slider0007@users.noreply.github.com> Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
394 lines
13 KiB
C++
394 lines
13 KiB
C++
#include "ClassFlowAlignment.h"
|
|
#include "ClassFlowTakeImage.h"
|
|
#include "ClassFlow.h"
|
|
#include "MainFlowControl.h"
|
|
|
|
#include "CRotateImage.h"
|
|
#include "esp_log.h"
|
|
|
|
|
|
#include "ClassLogFile.h"
|
|
#include "psram.h"
|
|
#include "../../include/defines.h"
|
|
|
|
|
|
static const char *TAG = "ALIGN";
|
|
|
|
// #define DEBUG_DETAIL_ON
|
|
|
|
|
|
void ClassFlowAlignment::SetInitialParameter(void)
|
|
{
|
|
initalrotate = 0;
|
|
anz_ref = 0;
|
|
initialmirror = false;
|
|
use_antialiasing = false;
|
|
initialflip = false;
|
|
SaveAllFiles = false;
|
|
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
|
FileStoreRefAlignment = "/sdcard/config/align.txt";
|
|
ListFlowControll = NULL;
|
|
AlignAndCutImage = NULL;
|
|
ImageBasis = NULL;
|
|
ImageTMP = NULL;
|
|
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG
|
|
AlgROI = (ImageData*)malloc_psram_heap(std::string(TAG) + "->AlgROI", sizeof(ImageData), MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
|
#endif
|
|
previousElement = NULL;
|
|
disabled = false;
|
|
SAD_criteria = 0.05;
|
|
}
|
|
|
|
|
|
ClassFlowAlignment::ClassFlowAlignment(std::vector<ClassFlow*>* lfc)
|
|
{
|
|
SetInitialParameter();
|
|
ListFlowControll = lfc;
|
|
|
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
|
{
|
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowTakeImage") == 0)
|
|
{
|
|
ImageBasis = ((ClassFlowTakeImage*) (*ListFlowControll)[i])->rawImage;
|
|
}
|
|
}
|
|
|
|
if (!ImageBasis) // the function take pictures does not exist --> must be created first ONLY FOR TEST PURPOSES
|
|
{
|
|
ESP_LOGD(TAG, "CImageBasis had to be created");
|
|
ImageBasis = new CImageBasis("ImageBasis", namerawimage);
|
|
}
|
|
}
|
|
|
|
|
|
bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|
{
|
|
std::vector<string> splitted;
|
|
int suchex = 40;
|
|
int suchey = 40;
|
|
int alg_algo = 0; //default=0; 1 =HIGHACCURACY; 2= FAST; 3= OFF //add disable aligment algo |01.2023
|
|
|
|
|
|
aktparamgraph = trim(aktparamgraph);
|
|
|
|
if (aktparamgraph.size() == 0)
|
|
if (!this->GetNextParagraph(pfile, aktparamgraph))
|
|
return false;
|
|
|
|
if (aktparamgraph.compare("[Alignment]") != 0) //Paragraph does not fit Alignment
|
|
return false;
|
|
|
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
|
{
|
|
splitted = ZerlegeZeile(aktparamgraph);
|
|
if ((toUpper(splitted[0]) == "FLIPIMAGESIZE") && (splitted.size() > 1))
|
|
{
|
|
if (toUpper(splitted[1]) == "TRUE")
|
|
initialflip = true;
|
|
}
|
|
if ((toUpper(splitted[0]) == "INITIALMIRROR") && (splitted.size() > 1))
|
|
{
|
|
if (toUpper(splitted[1]) == "TRUE")
|
|
initialmirror = true;
|
|
}
|
|
if (((toUpper(splitted[0]) == "INITALROTATE") || (toUpper(splitted[0]) == "INITIALROTATE")) && (splitted.size() > 1))
|
|
{
|
|
this->initalrotate = std::stod(splitted[1]);
|
|
}
|
|
if ((toUpper(splitted[0]) == "SEARCHFIELDX") && (splitted.size() > 1))
|
|
{
|
|
suchex = std::stod(splitted[1]);
|
|
}
|
|
if ((toUpper(splitted[0]) == "SEARCHFIELDY") && (splitted.size() > 1))
|
|
{
|
|
suchey = std::stod(splitted[1]);
|
|
}
|
|
if ((toUpper(splitted[0]) == "ANTIALIASING") && (splitted.size() > 1))
|
|
{
|
|
if (toUpper(splitted[1]) == "TRUE")
|
|
use_antialiasing = true;
|
|
}
|
|
if ((splitted.size() == 3) && (anz_ref < 2))
|
|
{
|
|
References[anz_ref].image_file = FormatFileName("/sdcard" + splitted[0]);
|
|
References[anz_ref].target_x = std::stod(splitted[1]);
|
|
References[anz_ref].target_y = std::stod(splitted[2]);
|
|
anz_ref++;
|
|
}
|
|
|
|
if ((toUpper(splitted[0]) == "SAVEALLFILES") && (splitted.size() > 1))
|
|
{
|
|
if (toUpper(splitted[1]) == "TRUE")
|
|
SaveAllFiles = true;
|
|
}
|
|
if ((toUpper(splitted[0]) == "ALIGNMENTALGO") && (splitted.size() > 1))
|
|
{
|
|
#ifdef DEBUG_DETAIL_ON
|
|
std::string zw2 = "Alignment mode selected: " + splitted[1];
|
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, zw2);
|
|
#endif
|
|
if (toUpper(splitted[1]) == "HIGHACCURACY")
|
|
alg_algo = 1;
|
|
if (toUpper(splitted[1]) == "FAST")
|
|
alg_algo = 2;
|
|
if (toUpper(splitted[1]) == "OFF") //no align algo if set to 3 = off => no draw ref //add disable aligment algo |01.2023
|
|
alg_algo = 3;
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < anz_ref; ++i)
|
|
{
|
|
References[i].search_x = suchex;
|
|
References[i].search_y = suchey;
|
|
References[i].fastalg_SAD_criteria = SAD_criteria;
|
|
References[i].alignment_algo = alg_algo;
|
|
#ifdef DEBUG_DETAIL_ON
|
|
std::string zw2 = "Alignment mode written: " + std::to_string(alg_algo);
|
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, zw2);
|
|
#endif
|
|
}
|
|
|
|
//no align algo if set to 3 = off => no draw ref //add disable aligment algo |01.2023
|
|
if(References[0].alignment_algo != 3){
|
|
LoadReferenceAlignmentValues();
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
string ClassFlowAlignment::getHTMLSingleStep(string host)
|
|
{
|
|
string result;
|
|
|
|
result = "<p>Rotated Image: </p> <p><img src=\"" + host + "/img_tmp/rot.jpg\"></p>\n";
|
|
result = result + "<p>Found Alignment: </p> <p><img src=\"" + host + "/img_tmp/rot_roi.jpg\"></p>\n";
|
|
result = result + "<p>Aligned Image: </p> <p><img src=\"" + host + "/img_tmp/alg.jpg\"></p>\n";
|
|
return result;
|
|
}
|
|
|
|
|
|
bool ClassFlowAlignment::doFlow(string time)
|
|
{
|
|
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG
|
|
if (!AlgROI) // AlgROI needs to be allocated before ImageTMP to avoid heap fragmentation
|
|
{
|
|
AlgROI = (ImageData*)heap_caps_realloc(AlgROI, sizeof(ImageData), MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
|
if (!AlgROI)
|
|
{
|
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't allocate AlgROI");
|
|
LogFile.WriteHeapInfo("ClassFlowAlignment-doFlow");
|
|
}
|
|
}
|
|
|
|
if (AlgROI)
|
|
{
|
|
ImageBasis->writeToMemoryAsJPG((ImageData*)AlgROI, 90);
|
|
}
|
|
#endif
|
|
|
|
if (!ImageTMP)
|
|
{
|
|
ImageTMP = new CImageBasis("tmpImage", ImageBasis); // Make sure the name does not get change, it is relevant for the PSRAM allocation!
|
|
if (!ImageTMP)
|
|
{
|
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't allocate tmpImage -> Exec this round aborted!");
|
|
LogFile.WriteHeapInfo("ClassFlowAlignment-doFlow");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
delete AlignAndCutImage;
|
|
AlignAndCutImage = new CAlignAndCutImage("AlignAndCutImage", ImageBasis, ImageTMP);
|
|
if (!AlignAndCutImage)
|
|
{
|
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't allocate AlignAndCutImage -> Exec this round aborted!");
|
|
LogFile.WriteHeapInfo("ClassFlowAlignment-doFlow");
|
|
return false;
|
|
}
|
|
|
|
CRotateImage rt("rawImage", AlignAndCutImage, ImageTMP, initialflip);
|
|
if (initialflip)
|
|
{
|
|
int _zw = ImageBasis->height;
|
|
ImageBasis->height = ImageBasis->width;
|
|
ImageBasis->width = _zw;
|
|
|
|
_zw = ImageTMP->width;
|
|
ImageTMP->width = ImageTMP->height;
|
|
ImageTMP->height = _zw;
|
|
}
|
|
|
|
if (initialmirror)
|
|
{
|
|
ESP_LOGD(TAG, "do mirror");
|
|
rt.Mirror();
|
|
|
|
if (SaveAllFiles)
|
|
AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/mirror.jpg"));
|
|
}
|
|
|
|
if ((initalrotate != 0) || initialflip)
|
|
{
|
|
if (use_antialiasing)
|
|
rt.RotateAntiAliasing(initalrotate);
|
|
else
|
|
rt.Rotate(initalrotate);
|
|
|
|
if (SaveAllFiles)
|
|
AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/rot.jpg"));
|
|
}
|
|
|
|
|
|
//no align algo if set to 3 = off //add disable aligment algo |01.2023
|
|
if(References[0].alignment_algo != 3){
|
|
if (!AlignAndCutImage->Align(&References[0], &References[1]))
|
|
{
|
|
SaveReferenceAlignmentValues();
|
|
}
|
|
}// no align
|
|
|
|
|
|
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG
|
|
if (AlgROI) {
|
|
//no align algo if set to 3 = off => no draw ref //add disable aligment algo |01.2023
|
|
if(References[0].alignment_algo != 3){
|
|
DrawRef(ImageTMP);
|
|
}
|
|
flowctrl.DigitalDrawROI(ImageTMP);
|
|
flowctrl.AnalogDrawROI(ImageTMP);
|
|
ImageTMP->writeToMemoryAsJPG((ImageData*)AlgROI, 90);
|
|
}
|
|
#endif
|
|
|
|
if (SaveAllFiles)
|
|
{
|
|
AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/alg.jpg"));
|
|
ImageTMP->SaveToFile(FormatFileName("/sdcard/img_tmp/alg_roi.jpg"));
|
|
}
|
|
|
|
// must be deleted to have memory space for loading tflite
|
|
delete ImageTMP;
|
|
ImageTMP = NULL;
|
|
|
|
//no align algo if set to 3 = off => no draw ref //add disable aligment algo |01.2023
|
|
if(References[0].alignment_algo != 3){
|
|
LoadReferenceAlignmentValues();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
void ClassFlowAlignment::SaveReferenceAlignmentValues()
|
|
{
|
|
FILE* pFile;
|
|
std::string zwtime, zwvalue;
|
|
|
|
pFile = fopen(FileStoreRefAlignment.c_str(), "w");
|
|
|
|
if (strlen(zwtime.c_str()) == 0)
|
|
{
|
|
time_t rawtime;
|
|
struct tm* timeinfo;
|
|
char buffer[80];
|
|
|
|
time(&rawtime);
|
|
timeinfo = localtime(&rawtime);
|
|
|
|
strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo);
|
|
zwtime = std::string(buffer);
|
|
}
|
|
|
|
fputs(zwtime.c_str(), pFile);
|
|
fputs("\n", pFile);
|
|
|
|
zwvalue = std::to_string(References[0].fastalg_x) + "\t" + std::to_string(References[0].fastalg_y);
|
|
zwvalue = zwvalue + "\t" +std::to_string(References[0].fastalg_SAD)+ "\t" +std::to_string(References[0].fastalg_min);
|
|
zwvalue = zwvalue + "\t" +std::to_string(References[0].fastalg_max)+ "\t" +std::to_string(References[0].fastalg_avg);
|
|
fputs(zwvalue.c_str(), pFile);
|
|
fputs("\n", pFile);
|
|
|
|
zwvalue = std::to_string(References[1].fastalg_x) + "\t" + std::to_string(References[1].fastalg_y);
|
|
zwvalue = zwvalue + "\t" +std::to_string(References[1].fastalg_SAD)+ "\t" +std::to_string(References[1].fastalg_min);
|
|
zwvalue = zwvalue + "\t" +std::to_string(References[1].fastalg_max)+ "\t" +std::to_string(References[1].fastalg_avg);
|
|
fputs(zwvalue.c_str(), pFile);
|
|
fputs("\n", pFile);
|
|
|
|
fclose(pFile);
|
|
}
|
|
|
|
|
|
bool ClassFlowAlignment::LoadReferenceAlignmentValues(void)
|
|
{
|
|
FILE* pFile;
|
|
char zw[1024];
|
|
string zwvalue;
|
|
std::vector<string> splitted;
|
|
|
|
|
|
pFile = fopen(FileStoreRefAlignment.c_str(), "r");
|
|
if (pFile == NULL)
|
|
return false;
|
|
|
|
fgets(zw, 1024, pFile);
|
|
ESP_LOGD(TAG, "%s", zw);
|
|
|
|
fgets(zw, 1024, pFile);
|
|
splitted = ZerlegeZeile(std::string(zw), " \t");
|
|
if (splitted.size() < 6)
|
|
{
|
|
fclose(pFile);
|
|
return false;
|
|
}
|
|
|
|
References[0].fastalg_x = stoi(splitted[0]);
|
|
References[0].fastalg_y = stoi(splitted[1]);
|
|
References[0].fastalg_SAD = stof(splitted[2]);
|
|
References[0].fastalg_min = stoi(splitted[3]);
|
|
References[0].fastalg_max = stoi(splitted[4]);
|
|
References[0].fastalg_avg = stof(splitted[5]);
|
|
|
|
fgets(zw, 1024, pFile);
|
|
splitted = ZerlegeZeile(std::string(zw));
|
|
if (splitted.size() < 6)
|
|
{
|
|
fclose(pFile);
|
|
return false;
|
|
}
|
|
|
|
References[1].fastalg_x = stoi(splitted[0]);
|
|
References[1].fastalg_y = stoi(splitted[1]);
|
|
References[1].fastalg_SAD = stof(splitted[2]);
|
|
References[1].fastalg_min = stoi(splitted[3]);
|
|
References[1].fastalg_max = stoi(splitted[4]);
|
|
References[1].fastalg_avg = stof(splitted[5]);
|
|
|
|
fclose(pFile);
|
|
|
|
|
|
/*#ifdef DEBUG_DETAIL_ON
|
|
std::string _zw = "\tLoadReferences[0]\tx,y:\t" + std::to_string(References[0].fastalg_x) + "\t" + std::to_string(References[0].fastalg_x);
|
|
_zw = _zw + "\tSAD, min, max, avg:\t" + std::to_string(References[0].fastalg_SAD) + "\t" + std::to_string(References[0].fastalg_min);
|
|
_zw = _zw + "\t" + std::to_string(References[0].fastalg_max) + "\t" + std::to_string(References[0].fastalg_avg);
|
|
LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", _zw);
|
|
_zw = "\tLoadReferences[1]\tx,y:\t" + std::to_string(References[1].fastalg_x) + "\t" + std::to_string(References[1].fastalg_x);
|
|
_zw = _zw + "\tSAD, min, max, avg:\t" + std::to_string(References[1].fastalg_SAD) + "\t" + std::to_string(References[1].fastalg_min);
|
|
_zw = _zw + "\t" + std::to_string(References[1].fastalg_max) + "\t" + std::to_string(References[1].fastalg_avg);
|
|
LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", _zw);
|
|
#endif*/
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
void ClassFlowAlignment::DrawRef(CImageBasis *_zw)
|
|
{
|
|
if (_zw->ImageOkay())
|
|
{
|
|
_zw->drawRect(References[0].target_x, References[0].target_y, References[0].width, References[0].height, 255, 0, 0, 2);
|
|
_zw->drawRect(References[1].target_x, References[1].target_y, References[1].width, References[1].height, 255, 0, 0, 2);
|
|
}
|
|
}
|