Update to v0.9.0
6
Changelog.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Versions
|
||||
|
||||
##### 0.1.0 (2020-08-07)
|
||||
|
||||
* Initial Version
|
||||
|
||||
34
README.md
@@ -2,45 +2,45 @@
|
||||
|
||||
This is an example of Artificial Intelligence (AI) calculations on a very cheap hardware.
|
||||
|
||||
Details on **function**, **installation** and **configuration** can be found on the **[Wiki Page](https://github.com/jomjol/AI-on-the-edge-device/wiki)**
|
||||
### Details on **function**, **installation** and **configuration** can be found on the **[Wiki Page](https://github.com/jomjol/AI-on-the-edge-device/wiki)**
|
||||
|
||||
A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571627
|
||||
|
||||
<img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/main.jpg" width="300"><img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/size.png" width="300">
|
||||
<img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/watermeter_all.jpg" width="200"><img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/main.jpg" width="200"><img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/size.png" width="200">
|
||||
|
||||
<img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/index.png" width="600">
|
||||
<img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/watermeter.jpg" width="600">
|
||||
<img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/edit_reference.jpg" width="600">
|
||||
|
||||
|
||||
## Change log - latest version
|
||||
## Change log
|
||||
|
||||
##### Rolling (2020-08-23)
|
||||
##### Rolling - based on 1.0.0 (2020-09-04)
|
||||
|
||||
* Preparation for web configuration
|
||||
|
||||
* Security Issue: Remove access to "wlan.ini"
|
||||
|
||||
* Only editor for config.ini
|
||||
|
||||
* Implementation of Digital Consistency Check: check if Digit shows next number earlier, than previous number has gone through zero - Turn on/off - see updated config.ini `CheckDigitIncreaseConsistency = True`)
|
||||
Not fully tested!
|
||||
* currently identical to 1.0.0
|
||||
* work in progress version for testing of new features
|
||||
|
||||
##### 1.0.0 (2020-09-04)
|
||||
|
||||
* **First usable version** - compatible to previous project (https://github.com/jomjol/water-meter-system-complete)
|
||||
* NEW:
|
||||
* no docker container for CNN calculation necessary
|
||||
* web based configuration editor on board
|
||||
|
||||
##### 0.1.0 (2020-08-07)
|
||||
|
||||
* Initial Version
|
||||
|
||||
|
||||
#### [Full Changelog](Changelog.md)
|
||||
|
||||
|
||||
|
||||
## Known Issues
|
||||
|
||||
* spontaneous reboot, especially in case of intensive web server access
|
||||
* stopping automated tflite flow - Error teared down to alignment procedure (results in restart) - Image load fails
|
||||
|
||||
|
||||
|
||||
## Solved topics
|
||||
|
||||
* stuck in reboot - Solved by modified startup sequence
|
||||
* Camera initialization stuck not often, but randomly 5s after reboot - Hard reboot (power on/off) necessary :-(
|
||||
--> Next try: adopted reboot sequence with additional and extended camera reset --> seems working!
|
||||
* n.a.
|
||||
7657
code/lib/jomjol_fileserver_ota/miniz.c
Normal file
1338
code/lib/jomjol_fileserver_ota/miniz.h
Normal file
@@ -31,6 +31,7 @@
|
||||
#include "server_help.h"
|
||||
|
||||
#include "Helper.h"
|
||||
#include "miniz.h"
|
||||
|
||||
/* Max length a file path can have on storage */
|
||||
// #define FILE_PATH_MAX (ESP_VFS_PATH_MAX + CONFIG_SPIFFS_OBJ_NAME_LEN)
|
||||
@@ -487,6 +488,103 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
|
||||
}
|
||||
|
||||
|
||||
void delete_all_in_directory(std::string _directory)
|
||||
{
|
||||
struct dirent *entry;
|
||||
DIR *dir = opendir(_directory.c_str());
|
||||
std::string filename;
|
||||
|
||||
if (!dir) {
|
||||
ESP_LOGE(TAG, "Failed to stat dir : %s", _directory.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
/* Iterate over all files / folders and fetch their names and sizes */
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if (!(entry->d_type == DT_DIR)){
|
||||
filename = _directory + std::string(entry->d_name);
|
||||
ESP_LOGI(TAG, "Deleting file : %s", filename.c_str());
|
||||
/* Delete file */
|
||||
unlink(filename.c_str());
|
||||
};
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
void unzip(std::string _in_zip_file, std::string _target_directory){
|
||||
int i, sort_iter;
|
||||
mz_bool status;
|
||||
size_t uncomp_size;
|
||||
mz_zip_archive zip_archive;
|
||||
void* p;
|
||||
const int N = 50;
|
||||
char data[2048];
|
||||
char archive_filename[64];
|
||||
std::string zw;
|
||||
// static const char* s_Test_archive_filename = "testhtml.zip";
|
||||
|
||||
printf("miniz.c version: %s\n", MZ_VERSION);
|
||||
|
||||
// Now try to open the archive.
|
||||
memset(&zip_archive, 0, sizeof(zip_archive));
|
||||
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), 0);
|
||||
if (!status)
|
||||
{
|
||||
printf("mz_zip_reader_init_file() failed!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get and print information about each file in the archive.
|
||||
int numberoffiles = (int)mz_zip_reader_get_num_files(&zip_archive);
|
||||
for (sort_iter = 0; sort_iter < 2; sort_iter++)
|
||||
{
|
||||
memset(&zip_archive, 0, sizeof(zip_archive));
|
||||
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
|
||||
if (!status)
|
||||
{
|
||||
printf("mz_zip_reader_init_file() failed!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < numberoffiles; i++)
|
||||
{
|
||||
mz_zip_archive_file_stat file_stat;
|
||||
mz_zip_reader_file_stat(&zip_archive, i, &file_stat);
|
||||
sprintf(archive_filename, file_stat.m_filename);
|
||||
|
||||
// Try to extract all the files to the heap.
|
||||
p = mz_zip_reader_extract_file_to_heap(&zip_archive, archive_filename, &uncomp_size, 0);
|
||||
if (!p)
|
||||
{
|
||||
printf("mz_zip_reader_extract_file_to_heap() failed!\n");
|
||||
mz_zip_reader_end(&zip_archive);
|
||||
return;
|
||||
}
|
||||
|
||||
// Save to File.
|
||||
zw = std::string(archive_filename);
|
||||
zw = _target_directory + zw;
|
||||
printf("Filename to extract: %s", zw.c_str());
|
||||
FILE* fpTargetFile = fopen(zw.c_str(), "wb");
|
||||
fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
|
||||
fclose(fpTargetFile);
|
||||
|
||||
printf("Successfully extracted file \"%s\", size %u\n", archive_filename, (uint)uncomp_size);
|
||||
// printf("File data: \"%s\"\n", (const char*)p);
|
||||
|
||||
// We're done.
|
||||
mz_free(p);
|
||||
}
|
||||
|
||||
// Close the archive, freeing any resources it was using
|
||||
mz_zip_reader_end(&zip_archive);
|
||||
}
|
||||
|
||||
printf("Success.\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void register_server_file_uri(httpd_handle_t server, const char *base_path)
|
||||
{
|
||||
static struct file_server_data *server_data = NULL;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
#include <esp_http_server.h>
|
||||
#include <string>
|
||||
|
||||
void register_server_file_uri(httpd_handle_t server, const char *base_path);
|
||||
|
||||
void unzip(std::string _in_zip_file, std::string _target_directory);
|
||||
|
||||
void delete_all_in_directory(std::string _directory);
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "server_tflite.h"
|
||||
#include "server_file.h"
|
||||
|
||||
#include "ClassLogFile.h"
|
||||
|
||||
@@ -301,14 +302,23 @@ void CheckOTAUpdate(void)
|
||||
esp_err_t handler_ota_update(httpd_req_t *req)
|
||||
{
|
||||
LogFile.WriteToFile("handler_ota_update");
|
||||
char _query[100];
|
||||
char _query[200];
|
||||
char _filename[30];
|
||||
char _valuechar[30];
|
||||
std::string fn = "/sdcard/firmware/";
|
||||
bool _file_del = false;
|
||||
std::string _task;
|
||||
|
||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||
if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK)
|
||||
{
|
||||
printf("Query: "); printf(_query); printf("\n");
|
||||
|
||||
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
||||
{
|
||||
printf("task is found"); printf(_valuechar); printf("\n");
|
||||
_task = std::string(_valuechar);
|
||||
}
|
||||
|
||||
if (httpd_query_key_value(_query, "file", _filename, 30) == ESP_OK)
|
||||
{
|
||||
fn.append(_filename);
|
||||
@@ -323,6 +333,20 @@ esp_err_t handler_ota_update(httpd_req_t *req)
|
||||
|
||||
};
|
||||
|
||||
if (_task.compare("unziphtml") == 0)
|
||||
{
|
||||
std::string in, out, zw;
|
||||
|
||||
in = "/sdcard/firmware/html.zip";
|
||||
out = "/sdcard/html/";
|
||||
|
||||
unzip(in, out);
|
||||
zw = "Unzip html Done";
|
||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (_file_del)
|
||||
{
|
||||
struct stat file_stat;
|
||||
|
||||
@@ -72,6 +72,10 @@ bool ClassFlow::doFlow(string time)
|
||||
return false;
|
||||
}
|
||||
|
||||
string ClassFlow::getHTMLSingleStep(string host){
|
||||
return "";
|
||||
}
|
||||
|
||||
string ClassFlow::getReadout()
|
||||
{
|
||||
return string();
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
ClassFlow(std::vector<ClassFlow*> * lfc);
|
||||
virtual bool ReadParameter(FILE* pfile, string &aktparamgraph);
|
||||
virtual bool doFlow(string time);
|
||||
virtual string getHTMLSingleStep(string host);
|
||||
virtual string getReadout();
|
||||
virtual string name(){return "ClassFlow";};
|
||||
|
||||
|
||||
@@ -60,6 +60,17 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
string input = namerawimage;
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
ClassFlowAlignment(std::vector<ClassFlow*>* lfc);
|
||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||
bool doFlow(string time);
|
||||
string getHTMLSingleStep(string host);
|
||||
string name(){return "ClassFlowAlignment";};
|
||||
};
|
||||
|
||||
|
||||
@@ -113,6 +113,31 @@ bool ClassFlowAnalog::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
}
|
||||
|
||||
|
||||
string ClassFlowAnalog::getHTMLSingleStep(string host)
|
||||
{
|
||||
string result, zw;
|
||||
std::vector<HTMLInfo*> htmlinfo;
|
||||
|
||||
result = "<p>Found ROIs: </p> <p><img src=\"" + host + "/img_tmp/alg_roi.jpg\"></p>\n";
|
||||
result = result + "Analog Pointers: <p> ";
|
||||
|
||||
htmlinfo = GetHTMLInfo();
|
||||
for (int i = 0; i < htmlinfo.size(); ++i)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << std::fixed << std::setprecision(1) << htmlinfo[i]->val;
|
||||
zw = stream.str();
|
||||
|
||||
result = result + "<img src=\"" + host + "/img_tmp/" + htmlinfo[i]->filename + "\"> " + zw;
|
||||
delete htmlinfo[i];
|
||||
}
|
||||
htmlinfo.clear();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ClassFlowAnalog::doFlow(string time)
|
||||
{
|
||||
doAlignAndCut(time);
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
ClassFlowAnalog(std::vector<ClassFlow*>* lfc);
|
||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||
bool doFlow(string time);
|
||||
string getHTMLSingleStep(string host);
|
||||
string getReadout();
|
||||
|
||||
bool doNeuralNetwork(string time);
|
||||
|
||||
@@ -1,8 +1,39 @@
|
||||
#include "ClassFlowControll.h"
|
||||
|
||||
#include "ClassLogFile.h"
|
||||
#include "time_sntp.h"
|
||||
#include "Helper.h"
|
||||
|
||||
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
||||
bool found = false;
|
||||
std::string _classname = "";
|
||||
std::string result = "";
|
||||
if (_stepname.compare("[MakeImage]") == 0){
|
||||
_classname = "ClassFlowMakeImage";
|
||||
}
|
||||
if (_stepname.compare("[Alignment]") == 0){
|
||||
_classname = "ClassFlowAlignment";
|
||||
}
|
||||
if (_stepname.compare("[Digits]") == 0){
|
||||
_classname = "ClassFlowDigit";
|
||||
}
|
||||
if (_stepname.compare("[Analog]") == 0){
|
||||
_classname = "ClassFlowAnalog";
|
||||
}
|
||||
// std::string zw = "Classname: " + _classname + "\n";
|
||||
// printf(zw.c_str());
|
||||
|
||||
for (int i = 0; i < FlowControll.size(); ++i)
|
||||
if (FlowControll[i]->name().compare(_classname) == 0){
|
||||
// printf(FlowControll[i]->name().c_str()); printf("\n");
|
||||
FlowControll[i]->doFlow("");
|
||||
result = FlowControll[i]->getHTMLSingleStep(_host);
|
||||
found = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<HTMLInfo*> ClassFlowControll::GetAllDigital()
|
||||
{
|
||||
for (int i = 0; i < FlowControll.size(); ++i)
|
||||
@@ -67,8 +98,6 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
||||
|
||||
void ClassFlowControll::InitFlow(std::string config)
|
||||
{
|
||||
int aktFlow;
|
||||
bool handeled;
|
||||
string line;
|
||||
|
||||
flowpostprocessing = NULL;
|
||||
@@ -79,8 +108,6 @@ void ClassFlowControll::InitFlow(std::string config)
|
||||
pFile = fopen(config.c_str(), "r");
|
||||
|
||||
line = "";
|
||||
handeled = true;
|
||||
|
||||
|
||||
char zw[1024];
|
||||
if (pFile != NULL)
|
||||
@@ -109,15 +136,24 @@ void ClassFlowControll::InitFlow(std::string config)
|
||||
|
||||
}
|
||||
|
||||
std::string ClassFlowControll::getActStatus(){
|
||||
return aktstatus;
|
||||
}
|
||||
|
||||
bool ClassFlowControll::doFlow(string time)
|
||||
{
|
||||
bool result = true;
|
||||
std::string zw_time;
|
||||
for (int i = 0; i < FlowControll.size(); ++i)
|
||||
{
|
||||
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
||||
aktstatus = zw_time + ": " + FlowControll[i]->name();
|
||||
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
|
||||
LogFile.WriteToFile(zw);
|
||||
result = result && FlowControll[i]->doFlow(time);
|
||||
}
|
||||
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
||||
aktstatus = zw_time + ": Flow is done";
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ protected:
|
||||
bool AutoStart;
|
||||
float AutoIntervall;
|
||||
void SetInitialParameter(void);
|
||||
std::string aktstatus;
|
||||
|
||||
|
||||
public:
|
||||
@@ -31,8 +32,12 @@ public:
|
||||
string GetPrevalue();
|
||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||
|
||||
std::string doSingleStep(std::string _stepname, std::string _host);
|
||||
|
||||
bool isAutoStart(long &_intervall);
|
||||
|
||||
std::string getActStatus();
|
||||
|
||||
std::vector<HTMLInfo*> GetAllDigital();
|
||||
std::vector<HTMLInfo*> GetAllAnalog();
|
||||
|
||||
|
||||
@@ -91,6 +91,32 @@ bool ClassFlowDigit::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
}
|
||||
|
||||
|
||||
string ClassFlowDigit::getHTMLSingleStep(string host)
|
||||
{
|
||||
string result, zw;
|
||||
std::vector<HTMLInfo*> htmlinfo;
|
||||
|
||||
result = "<p>Found ROIs: </p> <p><img src=\"" + host + "/img_tmp/alg_roi.jpg\"></p>\n";
|
||||
result = result + "Digital Counter: <p> ";
|
||||
|
||||
htmlinfo = GetHTMLInfo();
|
||||
for (int i = 0; i < htmlinfo.size(); ++i)
|
||||
{
|
||||
if (htmlinfo[i]->val == 10)
|
||||
zw = "NaN";
|
||||
else
|
||||
{
|
||||
zw = to_string((int) htmlinfo[i]->val);
|
||||
}
|
||||
result = result + "<img src=\"" + host + "/img_tmp/" + htmlinfo[i]->filename + "\"> " + zw;
|
||||
delete htmlinfo[i];
|
||||
}
|
||||
htmlinfo.clear();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool ClassFlowDigit::doFlow(string time)
|
||||
{
|
||||
doAlignAndCut(time);
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
ClassFlowDigit(std::vector<ClassFlow*>* lfc);
|
||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||
bool doFlow(string time);
|
||||
string getHTMLSingleStep(string host);
|
||||
string getReadout();
|
||||
std::vector<HTMLInfo*> GetHTMLInfo();
|
||||
|
||||
|
||||
@@ -120,6 +120,12 @@ void ClassFlowMakeImage::CopyFile(string input, string output)
|
||||
printf("Copy done\n");
|
||||
}
|
||||
|
||||
string ClassFlowMakeImage::getHTMLSingleStep(string host)
|
||||
{
|
||||
string result;
|
||||
result = "Raw Image: <br>\n<img src=\"" + host + "/img_tmp/raw.jpg\">\n";
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ClassFlowMakeImage::doFlow(string zwtime)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
ClassFlowMakeImage(std::vector<ClassFlow*>* lfc);
|
||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||
bool doFlow(string time);
|
||||
string getHTMLSingleStep(string host);
|
||||
time_t getTimeImageTaken();
|
||||
string name(){return "ClassFlowMakeImage";};
|
||||
};
|
||||
|
||||
@@ -18,10 +18,14 @@ float CTfLiteClass::GetOutputValue(int nr)
|
||||
|
||||
int CTfLiteClass::GetClassFromImage(std::string _fn)
|
||||
{
|
||||
// printf("Before Load image %s\n", _fn.c_str());
|
||||
if (!LoadInputImage(_fn))
|
||||
return -1000;
|
||||
// printf("After Load image %s\n", _fn.c_str());
|
||||
|
||||
Invoke();
|
||||
printf("After Invoke %s\n", _fn.c_str());
|
||||
|
||||
return GetOutClassification();
|
||||
// return 0;
|
||||
}
|
||||
@@ -102,46 +106,6 @@ void CTfLiteClass::Invoke()
|
||||
// printf("Invoke Done.\n");
|
||||
}
|
||||
|
||||
/* mit CImageBasis --> funktioniert nicht, keine Ahnung warum !!!
|
||||
|
||||
bool CTfLiteClass::LoadInputImage(std::string _fn)
|
||||
{
|
||||
|
||||
CImageBasis *cib = new CImageBasis(_fn);
|
||||
|
||||
GetInputDimension(true);
|
||||
|
||||
printf("TFlite load image size: %d x %d x %d\n", cib->getWidth(), cib->getHeight(), cib->getChannels());
|
||||
// printf("TFlite expected image size: %d x %d x %d\n", im_width, im_height, im_channel);
|
||||
|
||||
if ((cib->getWidth() != im_width) || (cib->getHeight() != im_height) || (cib->getChannels() != im_channel))
|
||||
{
|
||||
printf("Input Imagesize Wrong.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
input_i = 0;
|
||||
float* input_data_ptr = (interpreter->input(0))->data.f;
|
||||
uint8_t ui8;
|
||||
unsigned char zw;
|
||||
|
||||
for (int y = 0; y < cib->getHeight(); ++y)
|
||||
for (int x = 0; x < cib->getWidth(); ++x)
|
||||
{
|
||||
printf("CIB: ");
|
||||
for (int ch = 0; ch < cib->getChannels(); ++ch)
|
||||
{
|
||||
ui8 = cib->GetPixelColor(x, y, ch);
|
||||
printf("%f ", (float) ui8);
|
||||
*(input_data_ptr) = (float) ui8;
|
||||
input_data_ptr++;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
delete cib;
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
bool CTfLiteClass::LoadInputImage(std::string _fn)
|
||||
{
|
||||
|
||||
@@ -233,7 +233,7 @@ httpd_handle_t start_webserver(void)
|
||||
httpd_config_t config = { };
|
||||
|
||||
config.task_priority = tskIDLE_PRIORITY+5;
|
||||
config.stack_size = 16384;
|
||||
config.stack_size = 16384; // bei 32k stürzt das Programm beim Bilderaufnehmen ab
|
||||
config.core_id = tskNO_AFFINITY;
|
||||
config.server_port = 80;
|
||||
config.ctrl_port = 32768;
|
||||
|
||||
@@ -196,21 +196,6 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
||||
}
|
||||
htmlinfo.clear();
|
||||
|
||||
|
||||
/*
|
||||
for i in range(len(resultdigital)):
|
||||
if resultdigital[i] == 'NaN':
|
||||
zw = 'NaN'
|
||||
else:
|
||||
zw = str(int(resultdigital[i]))
|
||||
txt += '<img src=/image_tmp/'+ str(resultcut[1][i][0]) + '.jpg></img>' + zw
|
||||
txt = txt + '<p>'
|
||||
if self.AnalogReadOutEnabled:
|
||||
txt = txt + 'Analog Meter: <p>'
|
||||
for i in range(len(resultanalog)):
|
||||
txt += '<img src=/image_tmp/'+ str(resultcut[0][i][0]) + '.jpg></img>' + "{:.1f}".format(resultanalog[i])
|
||||
txt = txt + '<p>'
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +217,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
||||
string zw;
|
||||
bool _rawValue = false;
|
||||
|
||||
printf("handler_editflow uri:\n"); printf(req->uri); printf("\n");
|
||||
printf("handler_editflow uri: "); printf(req->uri); printf("\n");
|
||||
|
||||
char _query[200];
|
||||
char _valuechar[30];
|
||||
@@ -242,7 +227,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
||||
{
|
||||
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
||||
{
|
||||
printf("task is found"); printf(_valuechar); printf("\n");
|
||||
printf("task is found: %s\n", _valuechar);
|
||||
_task = string(_valuechar);
|
||||
}
|
||||
}
|
||||
@@ -333,6 +318,56 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||
}
|
||||
|
||||
if (_task.compare("test_take") == 0)
|
||||
{
|
||||
std::string _host = "";
|
||||
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
|
||||
_host = std::string(_valuechar);
|
||||
}
|
||||
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
|
||||
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
|
||||
std::string zw = tfliteflow.doSingleStep("[MakeImage]", _host);
|
||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||
}
|
||||
|
||||
|
||||
if (_task.compare("test_align") == 0)
|
||||
{
|
||||
std::string _host = "";
|
||||
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
|
||||
_host = std::string(_valuechar);
|
||||
}
|
||||
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
|
||||
|
||||
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
|
||||
std::string zw = tfliteflow.doSingleStep("[Alignment]", _host);
|
||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||
}
|
||||
if (_task.compare("test_analog") == 0)
|
||||
{
|
||||
std::string _host = "";
|
||||
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
|
||||
_host = std::string(_valuechar);
|
||||
}
|
||||
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
|
||||
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
|
||||
std::string zw = tfliteflow.doSingleStep("[Analog]", _host);
|
||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||
}
|
||||
if (_task.compare("test_digits") == 0)
|
||||
{
|
||||
std::string _host = "";
|
||||
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
|
||||
_host = std::string(_valuechar);
|
||||
}
|
||||
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
|
||||
|
||||
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
|
||||
std::string zw = tfliteflow.doSingleStep("[Digits]", _host);
|
||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||
}
|
||||
|
||||
|
||||
/* Respond with an empty chunk to signal HTTP response completion */
|
||||
httpd_resp_sendstr_chunk(req, NULL);
|
||||
|
||||
|
||||
0
code/src/zip._c
Normal file
BIN
images/edit_reference.jpg
Normal file
|
After Width: | Height: | Size: 135 KiB |
BIN
images/watermeter.jpg
Normal file
|
After Width: | Height: | Size: 152 KiB |
BIN
images/watermeter_all.jpg
Normal file
|
After Width: | Height: | Size: 111 KiB |
BIN
sd-card/config/ana0630s2.tflite
Normal file
@@ -12,17 +12,19 @@ SearchFieldX = 20
|
||||
SearchFieldY = 20
|
||||
|
||||
[Digits]
|
||||
Model=/config/dig0622.tfl
|
||||
ModelInputSize 20, 32
|
||||
;Model=/config/dig0622.tfl
|
||||
Model=/config/dig0630s3.tflite
|
||||
LogImageLocation = /log/digit
|
||||
ModelInputSize 20, 32
|
||||
digit1, 306, 120, 37, 67
|
||||
digit2, 355, 120, 37, 67
|
||||
digit3, 404, 120, 37, 67
|
||||
|
||||
[Analog]
|
||||
Model=/config/ana0622.tfl
|
||||
ModelInputSize 32, 32
|
||||
;Model=/config/ana0622.tfl
|
||||
Model=/config/ana0630s2.tflite
|
||||
LogImageLocation = /log/analog
|
||||
ModelInputSize 32, 32
|
||||
analog1, 444, 225, 92, 92
|
||||
analog2, 391, 329, 92, 92
|
||||
analog3, 294, 369, 92, 92
|
||||
|
||||
BIN
sd-card/config/dig0630s3.tflite
Normal file
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -92,6 +92,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="./gethost.js"></script>
|
||||
<script type="text/javascript" src="./readconfig.js"></script>
|
||||
|
||||
<script language="JavaScript">
|
||||
@@ -162,8 +163,8 @@ function UpdateReference(){
|
||||
}
|
||||
|
||||
function ParseIni(_basepath) {
|
||||
loadConfigJS(_basepath);
|
||||
ParseReference();
|
||||
loadConfig(_basepath);
|
||||
ParseConfig();
|
||||
UpdateReference();
|
||||
}
|
||||
|
||||
@@ -259,6 +260,7 @@ function dataURLtoBlob(dataurl) {
|
||||
|
||||
|
||||
function init() {
|
||||
basepath = getbasepath();
|
||||
canvas.addEventListener('mousedown', mouseDown, false);
|
||||
canvas.addEventListener('mouseup', mouseUp, false);
|
||||
canvas.addEventListener('mousemove', mouseMove, false);
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<div id="createrefernce">
|
||||
<div style="padding-left: 30px">
|
||||
<h3>Define Alignment Structure in Reference Image</h3>
|
||||
<h3>Edit Analog</h3>
|
||||
|
||||
<div style="padding-left: 30px">
|
||||
<table>
|
||||
@@ -21,14 +21,23 @@
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="submit" name="newROI" onclick="newROI()" value="New ROI (after current)">
|
||||
<input type="submit" name="deleteROI" onclick="deleteROI()" value="Delete ROI">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select id="index" name="reference" onchange="ChangeSelection()">
|
||||
<option value="0" selected>Reference 0</option>
|
||||
<option value="1" >Reference 1</option>
|
||||
<select id="index" name="index" onchange="ChangeSelection()">
|
||||
<option value="0" selected>ROI 0</option>
|
||||
<option value="1" >ROI 1</option>
|
||||
</select>
|
||||
Storage path/name: <input type="text" name="name" id="name">
|
||||
name: <input type="text" name="name" id="name" onchange="onNameChange()">
|
||||
<input type="submit" id="moveNext" onclick="moveNext()" value="move Next">
|
||||
<input type="submit" id="movePrevious" onclick="movePrevious()" value="move Previous">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -39,7 +48,11 @@
|
||||
x: <input type="number" name="refx" id="refx" step=1 onchange="valuemanualchanged()">
|
||||
</td>
|
||||
<td>
|
||||
dx: <input type="number" name="refdx" id="refdx" step=1 onchange="valuemanualchanged()">
|
||||
dx: <input type="number" name="refdx" id="refdx" step=1 onchange="valuemanualchangeddx()">
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" id="lockAR" name="lockAR" value="1" onclick="changelockAR()" checked>
|
||||
<label for="lockAR"> lock aspect ratio</label><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -50,39 +63,12 @@
|
||||
dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="button" value="Update Reference" onclick="CutOutReference()">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
Original Image
|
||||
</td>
|
||||
<td>
|
||||
Reference Image
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img id="img_ref_org" src = "/img_tmp/ref_zw_org.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<img id="img_ref" src = "/img_tmp/ref_zw.jpg">
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" value="Enhance Contrast" onclick="EnhanceContrast()">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<input type="submit" name="saveroi" onclick="SaveToConfig()" value="Save to Config.ini">
|
||||
<input type="submit" name="saveroi" onclick="SaveToConfig()" value="Save all to Config.ini">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -92,6 +78,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="./gethost.js"></script>
|
||||
<script type="text/javascript" src="./readconfig.js"></script>
|
||||
|
||||
<script language="JavaScript">
|
||||
@@ -101,132 +88,126 @@
|
||||
rect = {},
|
||||
drag = false,
|
||||
aktindex = 0,
|
||||
refInfo,
|
||||
ROIInfo,
|
||||
enhanceCon = false;
|
||||
lockAR = true;
|
||||
basepath = "http://192.168.178.26";
|
||||
|
||||
function onNameChange(){
|
||||
ROIInfo[aktindex]["name"] = document.getElementById("name").value;
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function deleteROI(){
|
||||
ROIInfo.splice(aktindex, 1);
|
||||
if (aktindex > ROIInfo.length - 1){
|
||||
aktindex = ROIInfo.length - 1;
|
||||
}
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function newROI(){
|
||||
var zw = ROIInfo[ROIInfo.length-1];
|
||||
ROIInfo.push(zw);
|
||||
for (var i = ROIInfo.length-2; i > aktindex + 1; --i){
|
||||
ROIInfo[i] = ROIInfo[i-1];
|
||||
}
|
||||
aktindex++;
|
||||
ROIInfo[aktindex] = new Object;
|
||||
ROIInfo[aktindex]["pos_ref"] = -1;
|
||||
ROIInfo[aktindex]["name"] = "ROI" + aktindex;
|
||||
ROIInfo[aktindex]["x"] = 1;
|
||||
ROIInfo[aktindex]["y"] = 1;
|
||||
ROIInfo[aktindex]["dx"] = ROIInfo[aktindex-1]["dx"];
|
||||
ROIInfo[aktindex]["dy"] = ROIInfo[aktindex-1]["dy"];
|
||||
ROIInfo[aktindex]["ar"] = ROIInfo[aktindex-1]["ar"];
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function movePrevious(){
|
||||
var zw = ROIInfo[aktindex];
|
||||
ROIInfo[aktindex] = ROIInfo[aktindex-1];
|
||||
ROIInfo[aktindex-1] = zw;
|
||||
aktindex--;
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function moveNext(){
|
||||
var zw = ROIInfo[aktindex];
|
||||
ROIInfo[aktindex] = ROIInfo[aktindex+1];
|
||||
ROIInfo[aktindex+1] = zw;
|
||||
aktindex++;
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function changelockAR(){
|
||||
lockAR = document.getElementById("lockAR").checked;
|
||||
}
|
||||
|
||||
function ChangeSelection(){
|
||||
aktindex = parseInt(document.getElementById("index").value);
|
||||
UpdateReference();
|
||||
// lockAR = true;
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function SaveToConfig(){
|
||||
refInfo["name"] = document.getElementById("name").value;
|
||||
refInfo["x"] = document.getElementById("refx").value;
|
||||
refInfo["y"] = document.getElementById("refy").value;
|
||||
refInfo["dx"] = document.getElementById("refdx").value;
|
||||
refInfo["dy"] = document.getElementById("refdy").value;
|
||||
UpdateConfig(refInfo, aktindex, enhanceCon, basepath);
|
||||
// location.reload();
|
||||
SaveROIToConfig(ROIInfo, "[Analog]", basepath);
|
||||
location.reload();
|
||||
}
|
||||
|
||||
function EnhanceContrast(){
|
||||
refInfo["name"] = document.getElementById("name").value;
|
||||
refInfo["x"] = document.getElementById("refx").value;
|
||||
refInfo["y"] = document.getElementById("refy").value;
|
||||
refInfo["dx"] = document.getElementById("refdx").value;
|
||||
refInfo["dy"] = document.getElementById("refdy").value;
|
||||
|
||||
enhanceCon = true;
|
||||
MakeContrastImageZW(refInfo, enhanceCon, basepath);
|
||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw.jpg?" + Date.now();
|
||||
document.getElementById("img_ref").src = url;
|
||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw_org.jpg?" + Date.now();
|
||||
document.getElementById("img_ref_org").src = url;
|
||||
}
|
||||
|
||||
function UpdateReference(){
|
||||
refInfo = GetCoordinates(aktindex, basepath);
|
||||
document.getElementById("img_ref").onload = function () {
|
||||
document.getElementById("refdx").value = this.width;
|
||||
document.getElementById("refdy").value = this.height;
|
||||
refInfo["dx"] = this.width;
|
||||
refInfo["dy"] = this.height;
|
||||
rect.w = document.getElementById("refdx").value;
|
||||
rect.h = document.getElementById("refdy").value;
|
||||
draw();
|
||||
function UpdateROIs(){
|
||||
if (ROIInfo.length == 0){
|
||||
alert("There are no ROIs defined.\nPlease first define minimum one ROI in the config.ini by hand.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw_org.jpg?" + Date.now();
|
||||
document.getElementById("img_ref_org").src = url;
|
||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw.jpg?" + Date.now();
|
||||
document.getElementById("img_ref").src = url;
|
||||
var _index = document.getElementById("index");
|
||||
while (_index.length){
|
||||
_index.remove(0);
|
||||
}
|
||||
|
||||
document.getElementById("name").value = refInfo["name"];
|
||||
document.getElementById("refx").value = refInfo["x"];
|
||||
document.getElementById("refy").value = refInfo["y"];
|
||||
rect.startX = document.getElementById("refx").value;
|
||||
rect.startY = document.getElementById("refy").value;
|
||||
for (var i = 0; i < ROIInfo.length; ++i){
|
||||
var option = document.createElement("option");
|
||||
option.text = "ROI " + (i + 1);
|
||||
option.value = i;
|
||||
_index.add(option);
|
||||
}
|
||||
_index.selectedIndex = aktindex;
|
||||
|
||||
|
||||
document.getElementById("movePrevious").disabled = false;
|
||||
if (aktindex == 0){
|
||||
document.getElementById("movePrevious").disabled = true;
|
||||
}
|
||||
|
||||
document.getElementById("moveNext").disabled = false;
|
||||
if (aktindex == (ROIInfo.length-1)){
|
||||
document.getElementById("moveNext").disabled = true;
|
||||
}
|
||||
|
||||
document.getElementById("lockAR").checked = lockAR;
|
||||
|
||||
document.getElementById("name").value = ROIInfo[aktindex]["name"];
|
||||
document.getElementById("refx").value = ROIInfo[aktindex]["x"];
|
||||
document.getElementById("refy").value = ROIInfo[aktindex]["y"];
|
||||
document.getElementById("refdx").value = ROIInfo[aktindex]["dx"];
|
||||
document.getElementById("refdy").value = ROIInfo[aktindex]["dy"];
|
||||
rect.startX = ROIInfo[aktindex]["x"];
|
||||
rect.startY = ROIInfo[aktindex]["y"];
|
||||
rect.w = ROIInfo[aktindex]["dx"];
|
||||
rect.h = ROIInfo[aktindex]["dy"];
|
||||
draw();
|
||||
}
|
||||
|
||||
function ParseIni(_basepath) {
|
||||
loadConfigJS(_basepath);
|
||||
ParseReference();
|
||||
UpdateReference();
|
||||
loadConfig(_basepath);
|
||||
ParseConfig();
|
||||
ROIInfo = getROIInfo("[Analog]");
|
||||
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function dataURLtoBlob(dataurl) {
|
||||
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
|
||||
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
||||
while(n--){
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
return new Blob([u8arr], {type:mime});
|
||||
}
|
||||
|
||||
function SaveReference()
|
||||
{
|
||||
|
||||
if (confirm("Are you sure you want to update \"reference.jpg\"?")) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
/* first delete the old firmware */
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4) {
|
||||
if (xhttp.status == 200) {
|
||||
/* keine Reaktion, damit sich das Dokument nicht ändert */
|
||||
} else if (xhttp.status == 0) {
|
||||
alert("Server closed the connection abruptly!");
|
||||
location.reload()
|
||||
} else {
|
||||
alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
||||
location.reload()
|
||||
}
|
||||
}
|
||||
};
|
||||
xhttp.open("POST", basepath + "/delete/config/reference.jpg", false);
|
||||
xhttp.send();
|
||||
/* ----------------------------- */
|
||||
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4) {
|
||||
if (xhttp.status == 200) {
|
||||
alert("Update \"reference.jpg\" successfull!\n\nTo make it active you need to reboot.")
|
||||
document.reload();
|
||||
} else if (xhttp.status == 0) {
|
||||
alert("Server closed the connection abruptly!");
|
||||
location.reload()
|
||||
} else {
|
||||
alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
||||
location.reload()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
upload_path = basepath + "/upload/config/reference.jpg";
|
||||
|
||||
var canvas = document.getElementById("canvas");
|
||||
|
||||
var JPEG_QUALITY=0.5;
|
||||
var dataUrl = canvas.toDataURL('image/jpeg', JPEG_QUALITY);
|
||||
var rtn = dataURLtoBlob(dataUrl);
|
||||
|
||||
xhttp.open("POST", upload_path, true);
|
||||
xhttp.send(rtn);
|
||||
}
|
||||
}
|
||||
|
||||
function loadCanvas(dataURL) {
|
||||
var canvas = document.getElementById('canvas');
|
||||
@@ -258,6 +239,7 @@ function dataURLtoBlob(dataurl) {
|
||||
|
||||
|
||||
function init() {
|
||||
basepath = getbasepath();
|
||||
canvas.addEventListener('mousedown', mouseDown, false);
|
||||
canvas.addEventListener('mouseup', mouseUp, false);
|
||||
canvas.addEventListener('mousemove', mouseMove, false);
|
||||
@@ -276,48 +258,6 @@ function dataURLtoBlob(dataurl) {
|
||||
}
|
||||
|
||||
|
||||
function CutOutReference(){
|
||||
refInfo["x"] = document.getElementById("refx").value;
|
||||
refInfo["y"] = document.getElementById("refy").value;
|
||||
refInfo["dx"] = document.getElementById("refdx").value;
|
||||
refInfo["dy"] = document.getElementById("refdy").value;
|
||||
MakeRefZW(refInfo, basepath);
|
||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw.jpg?" + Date.now();
|
||||
document.getElementById("img_ref_org").src = url;
|
||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw_org.jpg?" + Date.now();
|
||||
document.getElementById("img_ref").src = url;
|
||||
draw();
|
||||
}
|
||||
|
||||
function drawGrid(){
|
||||
var canvas = document.getElementById('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
w = canvas.width;
|
||||
h = canvas.height;
|
||||
ctx.save();
|
||||
ctx.strokeStyle = '#00FF00';
|
||||
|
||||
for (i = h/2; i < h; i += 100)
|
||||
{
|
||||
ctx.moveTo(0, i);
|
||||
ctx.lineTo(w, i);
|
||||
ctx.stroke();
|
||||
ctx.moveTo(0, h-i);
|
||||
ctx.lineTo(w, h-i);
|
||||
ctx.stroke();
|
||||
}
|
||||
for (i = w/2; i < w; i += 100)
|
||||
{
|
||||
ctx.moveTo(i, 0);
|
||||
ctx.lineTo(i, h);
|
||||
ctx.stroke();
|
||||
ctx.moveTo(w-i, 0);
|
||||
ctx.lineTo(w-i, h);
|
||||
ctx.stroke(); }
|
||||
// ctx.restore();
|
||||
}
|
||||
|
||||
|
||||
function draw() {
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
@@ -330,6 +270,10 @@ function dataURLtoBlob(dataurl) {
|
||||
var dx = parseInt(rect.w) + parseInt(lw);
|
||||
var dy = parseInt(rect.h) + parseInt(lw);
|
||||
context.strokeRect(x0, y0, dx, dy);
|
||||
ROIInfo[aktindex]["x"] = rect.startX;
|
||||
ROIInfo[aktindex]["y"] = rect.startY;
|
||||
ROIInfo[aktindex]["dx"] = rect.w;
|
||||
ROIInfo[aktindex]["dy"] = rect.h;
|
||||
}
|
||||
|
||||
function getCoords(elem) { // crossbrowser version
|
||||
@@ -373,8 +317,15 @@ function dataURLtoBlob(dataurl) {
|
||||
function mouseMove(e) {
|
||||
if (drag) {
|
||||
zw = getCoords(this)
|
||||
|
||||
|
||||
if (lockAR) {
|
||||
rect.h = (e.pageY - zw.top) - rect.startY;
|
||||
rect.w = Math.round(rect.h * ROIInfo[aktindex]["ar"]); }
|
||||
else {
|
||||
rect.w = (e.pageX - zw.left) - rect.startX;
|
||||
rect.h = (e.pageY - zw.top) - rect.startY ;
|
||||
rect.h = (e.pageY - zw.top) - rect.startY;
|
||||
}
|
||||
document.getElementById("refdx").value = rect.w;
|
||||
document.getElementById("refdy").value = rect.h;
|
||||
draw();
|
||||
@@ -403,6 +354,26 @@ function dataURLtoBlob(dataurl) {
|
||||
if (!drag) {
|
||||
rect.w = document.getElementById("refdx").value;
|
||||
rect.h = document.getElementById("refdy").value;
|
||||
if (lockAR) {
|
||||
rect.w = Math.round(rect.h * ROIInfo[aktindex]["ar"]);
|
||||
document.getElementById("refdx").value = rect.w;
|
||||
}
|
||||
|
||||
rect.startX = document.getElementById("refx").value;
|
||||
rect.startY = document.getElementById("refy").value;
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
function valuemanualchangeddx(){
|
||||
if (!drag) {
|
||||
rect.w = document.getElementById("refdx").value;
|
||||
rect.h = document.getElementById("refdy").value;
|
||||
if (lockAR) {
|
||||
rect.h = Math.round(rect.w / ROIInfo[aktindex]["ar"]);
|
||||
document.getElementById("refdy").value = rect.h;
|
||||
}
|
||||
|
||||
rect.startX = document.getElementById("refx").value;
|
||||
rect.startY = document.getElementById("refy").value;
|
||||
draw();
|
||||
112
sd-card/html/edit_check.html
Normal file
@@ -0,0 +1,112 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<table>
|
||||
<tr><td>Result:</td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<iframe name="maincontent" id ="maincontent" width="800px" height="800px"></iframe>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<input type="submit" id="take" onclick="doTake()" value="1. Take Picture">
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" id="align" onclick="doAlign()" value="2. Align Image"><br>
|
||||
Takes up to 2 Minutes!
|
||||
</p>
|
||||
Digits and Analog recognition not yet implemented.
|
||||
<p>
|
||||
<input type="submit" id="digits" onclick="doDigits()" value="3a. Analyse Digits">
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" id="analog" onclick="doAnalog()" value="3b Analyse Analog">
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript" src="./gethost.js"></script>
|
||||
<script type="text/javascript" src="./readconfig.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var basepath = "http://192.168.178.26";
|
||||
|
||||
function doAnalog(){
|
||||
var xhttp = new XMLHttpRequest();
|
||||
url = basepath + "/editflow.html?task=test_analog";
|
||||
if (basepath.length > 0){
|
||||
url = url + "&host=" + basepath;
|
||||
}
|
||||
xhttp.open("GET", url, false);
|
||||
xhttp.send();
|
||||
var html = xhttp.responseText;
|
||||
html = html.replace("src=\"/", "src=\"" + basepath + "/");
|
||||
|
||||
document.getElementById("maincontent").src = 'data:text/html,' + encodeURIComponent(html);
|
||||
}
|
||||
|
||||
|
||||
function doDigits(){
|
||||
var xhttp = new XMLHttpRequest();
|
||||
url = basepath + "/editflow.html?task=test_digits";
|
||||
if (basepath.length > 0){
|
||||
url = url + "&host=" + basepath;
|
||||
}
|
||||
xhttp.open("GET", url, false);
|
||||
xhttp.send();
|
||||
var html = xhttp.responseText;
|
||||
html = html.replace("src=\"/", "src=\"" + basepath + "/");
|
||||
|
||||
document.getElementById("maincontent").src = 'data:text/html,' + encodeURIComponent(html);
|
||||
}
|
||||
|
||||
|
||||
function doAlign(){
|
||||
var xhttp = new XMLHttpRequest();
|
||||
url = basepath + "/editflow.html?task=test_align";
|
||||
if (basepath.length > 0){
|
||||
url = url + "&host=" + basepath;
|
||||
}
|
||||
xhttp.open("GET", url, false);
|
||||
xhttp.send();
|
||||
var html = xhttp.responseText;
|
||||
html = html.replace("src=\"/", "src=\"" + basepath + "/");
|
||||
|
||||
document.getElementById("maincontent").src = 'data:text/html,' + encodeURIComponent(html);
|
||||
|
||||
document.getElementById("align").disabled = false;
|
||||
// document.getElementById("digits").disabled = false;
|
||||
// document.getElementById("analog").disabled = false;
|
||||
}
|
||||
|
||||
|
||||
function doTake(){
|
||||
var xhttp = new XMLHttpRequest();
|
||||
url = basepath + "/editflow.html?task=test_take";
|
||||
if (basepath.length > 0){
|
||||
url = url + "&host=" + basepath;
|
||||
}
|
||||
xhttp.open("GET", url, false);
|
||||
xhttp.send();
|
||||
var html = xhttp.responseText;
|
||||
document.getElementById("maincontent").src = 'data:text/html,' + encodeURIComponent(html);
|
||||
|
||||
document.getElementById("align").disabled = false;
|
||||
document.getElementById("digits").disabled = true;
|
||||
document.getElementById("analog").disabled = true;
|
||||
}
|
||||
|
||||
function Init(){
|
||||
basepath = getbasepath();
|
||||
document.getElementById("align").disabled = true;
|
||||
document.getElementById("digits").disabled = true;
|
||||
document.getElementById("analog").disabled = true;
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -13,68 +13,30 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript" src="./gethost.js"></script>
|
||||
<script type="text/javascript" src="./readconfig.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var canvas = document.getElementById('canvas'),
|
||||
basepath = "http://192.168.178.26";
|
||||
|
||||
function loadConfig() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onload = function () {
|
||||
// alert(this.responseText);
|
||||
document.getElementById("inputTextToSave").value = this.responseText;
|
||||
};
|
||||
url = '/fileserver/config/config.ini';
|
||||
xhr.open('GET', url);
|
||||
xhr.send();
|
||||
|
||||
function LoadConfigNeu() {
|
||||
basepath = getbasepath();
|
||||
loadConfig(basepath);
|
||||
document.getElementById("inputTextToSave").value = getConfig();
|
||||
}
|
||||
|
||||
|
||||
function saveTextAsFile()
|
||||
{
|
||||
if (confirm("Are you sure you want to update \"config.ini\"?")) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
/* first delete the old firmware */
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4) {
|
||||
if (xhttp.status == 200) {
|
||||
/* keine Reaktion, damit sich das Dokument nicht ändert */
|
||||
} else if (xhttp.status == 0) {
|
||||
alert("Server closed the connection abruptly!");
|
||||
location.reload()
|
||||
} else {
|
||||
alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
||||
location.reload()
|
||||
}
|
||||
}
|
||||
};
|
||||
xhttp.open("POST", "/delete/config/config.ini", false);
|
||||
xhttp.send();
|
||||
/* ----------------------------- */
|
||||
|
||||
FileDeleteOnServer("/config/config.ini", basepath);
|
||||
var textToSave = document.getElementById("inputTextToSave").value;
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4) {
|
||||
if (xhttp.status == 200) {
|
||||
alert("Update \"config.ini\" successfull!\n\nTo make it active you need to reboot.")
|
||||
document.reload();
|
||||
} else if (xhttp.status == 0) {
|
||||
alert("Server closed the connection abruptly!");
|
||||
location.reload()
|
||||
} else {
|
||||
alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
||||
location.reload()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
upload_path = "/upload/config/config.ini";
|
||||
|
||||
xhttp.open("POST", upload_path, true);
|
||||
xhttp.send(textToSave);
|
||||
FileSendContent(textToSave, "/config/config.ini", basepath);
|
||||
}
|
||||
}
|
||||
|
||||
loadConfig();
|
||||
LoadConfigNeu();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -13,16 +13,20 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript" src="./readconfig.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
function LoadConfigNeu() {
|
||||
loadConfigJS();
|
||||
document.getElementById("inputTextToSave").value = getConfig();
|
||||
function loadConfig() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onload = function () {
|
||||
// alert(this.responseText);
|
||||
document.getElementById("inputTextToSave").value = this.responseText;
|
||||
};
|
||||
url = '/fileserver/config/config.ini';
|
||||
xhr.open('GET', url);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
|
||||
function saveTextAsFile()
|
||||
{
|
||||
if (confirm("Are you sure you want to update \"config.ini\"?")) {
|
||||
@@ -70,7 +74,7 @@ function saveTextAsFile()
|
||||
}
|
||||
}
|
||||
|
||||
LoadConfigNeu();
|
||||
loadConfig();
|
||||
|
||||
</script>
|
||||
|
||||
389
sd-card/html/edit_digits.html
Normal file
@@ -0,0 +1,389 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Make Alignment</title>
|
||||
</head>
|
||||
|
||||
<div class="body-content">
|
||||
|
||||
<div id="createrefernce">
|
||||
<div style="padding-left: 30px">
|
||||
<h3>Edit Digits</h3>
|
||||
|
||||
<div style="padding-left: 30px">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<canvas id="canvas" crossorigin></canvas>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="submit" name="newROI" onclick="newROI()" value="New ROI (after current)">
|
||||
<input type="submit" name="deleteROI" onclick="deleteROI()" value="Delete ROI">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select id="index" name="index" onchange="ChangeSelection()">
|
||||
<option value="0" selected>ROI 0</option>
|
||||
<option value="1" >ROI 1</option>
|
||||
</select>
|
||||
name: <input type="text" name="name" id="name" onchange="onNameChange()">
|
||||
<input type="submit" id="moveNext" onclick="moveNext()" value="move Next">
|
||||
<input type="submit" id="movePrevious" onclick="movePrevious()" value="move Previous">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
x: <input type="number" name="refx" id="refx" step=1 onchange="valuemanualchanged()">
|
||||
</td>
|
||||
<td>
|
||||
dx: <input type="number" name="refdx" id="refdx" step=1 onchange="valuemanualchangeddx()">
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" id="lockAR" name="lockAR" value="1" onclick="changelockAR()" checked>
|
||||
<label for="lockAR"> lock aspect ratio</label><br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
y: <input type="number" name="refy" id="refy" step=1 onchange="valuemanualchanged()">
|
||||
</td>
|
||||
<td>
|
||||
dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="submit" name="saveroi" onclick="SaveToConfig()" value="Save all to Config.ini">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="./gethost.js"></script>
|
||||
<script type="text/javascript" src="./readconfig.js"></script>
|
||||
|
||||
<script language="JavaScript">
|
||||
var canvas = document.getElementById('canvas'),
|
||||
ctx = canvas.getContext('2d'),
|
||||
imageObj = new Image(),
|
||||
rect = {},
|
||||
drag = false,
|
||||
aktindex = 0,
|
||||
ROIInfo,
|
||||
enhanceCon = false;
|
||||
lockAR = true;
|
||||
basepath = "http://192.168.178.26";
|
||||
|
||||
function onNameChange(){
|
||||
ROIInfo[aktindex]["name"] = document.getElementById("name").value;
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function deleteROI(){
|
||||
ROIInfo.splice(aktindex, 1);
|
||||
if (aktindex > ROIInfo.length - 1){
|
||||
aktindex = ROIInfo.length - 1;
|
||||
}
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function newROI(){
|
||||
var zw = ROIInfo[ROIInfo.length-1];
|
||||
ROIInfo.push(zw);
|
||||
for (var i = ROIInfo.length-2; i > aktindex + 1; --i){
|
||||
ROIInfo[i] = ROIInfo[i-1];
|
||||
}
|
||||
aktindex++;
|
||||
ROIInfo[aktindex] = new Object;
|
||||
ROIInfo[aktindex]["pos_ref"] = -1;
|
||||
ROIInfo[aktindex]["name"] = "ROI" + aktindex;
|
||||
ROIInfo[aktindex]["x"] = 1;
|
||||
ROIInfo[aktindex]["y"] = 1;
|
||||
ROIInfo[aktindex]["dx"] = ROIInfo[aktindex-1]["dx"];
|
||||
ROIInfo[aktindex]["dy"] = ROIInfo[aktindex-1]["dy"];
|
||||
ROIInfo[aktindex]["ar"] = ROIInfo[aktindex-1]["ar"];
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function movePrevious(){
|
||||
var zw = ROIInfo[aktindex];
|
||||
ROIInfo[aktindex] = ROIInfo[aktindex-1];
|
||||
ROIInfo[aktindex-1] = zw;
|
||||
aktindex--;
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function moveNext(){
|
||||
var zw = ROIInfo[aktindex];
|
||||
ROIInfo[aktindex] = ROIInfo[aktindex+1];
|
||||
ROIInfo[aktindex+1] = zw;
|
||||
aktindex++;
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function changelockAR(){
|
||||
lockAR = document.getElementById("lockAR").checked;
|
||||
}
|
||||
|
||||
function ChangeSelection(){
|
||||
aktindex = parseInt(document.getElementById("index").value);
|
||||
// lockAR = true;
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
function SaveToConfig(){
|
||||
SaveROIToConfig(ROIInfo, "[Digits]", basepath);
|
||||
location.reload();
|
||||
}
|
||||
|
||||
|
||||
function UpdateROIs(){
|
||||
if (ROIInfo.length == 0){
|
||||
alert("There are no ROIs defined.\nPlease first define minimum one ROI in the config.ini by hand.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
var _index = document.getElementById("index");
|
||||
while (_index.length){
|
||||
_index.remove(0);
|
||||
}
|
||||
|
||||
for (var i = 0; i < ROIInfo.length; ++i){
|
||||
var option = document.createElement("option");
|
||||
option.text = "ROI " + (i + 1);
|
||||
option.value = i;
|
||||
_index.add(option);
|
||||
}
|
||||
_index.selectedIndex = aktindex;
|
||||
|
||||
|
||||
document.getElementById("movePrevious").disabled = false;
|
||||
if (aktindex == 0){
|
||||
document.getElementById("movePrevious").disabled = true;
|
||||
}
|
||||
|
||||
document.getElementById("moveNext").disabled = false;
|
||||
if (aktindex == (ROIInfo.length-1)){
|
||||
document.getElementById("moveNext").disabled = true;
|
||||
}
|
||||
|
||||
document.getElementById("lockAR").checked = lockAR;
|
||||
|
||||
document.getElementById("name").value = ROIInfo[aktindex]["name"];
|
||||
document.getElementById("refx").value = ROIInfo[aktindex]["x"];
|
||||
document.getElementById("refy").value = ROIInfo[aktindex]["y"];
|
||||
document.getElementById("refdx").value = ROIInfo[aktindex]["dx"];
|
||||
document.getElementById("refdy").value = ROIInfo[aktindex]["dy"];
|
||||
rect.startX = ROIInfo[aktindex]["x"];
|
||||
rect.startY = ROIInfo[aktindex]["y"];
|
||||
rect.w = ROIInfo[aktindex]["dx"];
|
||||
rect.h = ROIInfo[aktindex]["dy"];
|
||||
draw();
|
||||
}
|
||||
|
||||
function ParseIni(_basepath) {
|
||||
loadConfig(_basepath);
|
||||
ParseConfig();
|
||||
ROIInfo = getROIInfo("[Digits]");
|
||||
|
||||
UpdateROIs();
|
||||
}
|
||||
|
||||
|
||||
function loadCanvas(dataURL) {
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
imageObj.onload = function() {
|
||||
canvas.width = this.width;
|
||||
canvas.height = this.height;
|
||||
drawImage();
|
||||
};
|
||||
|
||||
imageObj.src = dataURL;
|
||||
}
|
||||
|
||||
|
||||
function getCoords(elem) { // crossbrowser version
|
||||
var box = elem.getBoundingClientRect();
|
||||
var body = document.body;
|
||||
var docEl = document.documentElement;
|
||||
var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
|
||||
var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
|
||||
var clientTop = docEl.clientTop || body.clientTop || 0;
|
||||
var clientLeft = docEl.clientLeft || body.clientLeft || 0;
|
||||
var top = box.top + scrollTop - clientTop;
|
||||
var left = box.left + scrollLeft - clientLeft;
|
||||
return { top: Math.round(top), left: Math.round(left) };
|
||||
}
|
||||
|
||||
|
||||
|
||||
function init() {
|
||||
basepath = getbasepath();
|
||||
canvas.addEventListener('mousedown', mouseDown, false);
|
||||
canvas.addEventListener('mouseup', mouseUp, false);
|
||||
canvas.addEventListener('mousemove', mouseMove, false);
|
||||
loadCanvas(basepath + "/fileserver/config/reference.jpg");
|
||||
ParseIni(basepath);
|
||||
drawImage();
|
||||
}
|
||||
function drawImage(){
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
context.clearRect(0,0,imageObj.width,imageObj.height);
|
||||
context.save();
|
||||
context.drawImage(imageObj, 0, 0);
|
||||
// context.restore();
|
||||
}
|
||||
|
||||
|
||||
function draw() {
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
context.drawImage(imageObj, 0, 0);
|
||||
lw = 4
|
||||
context.lineWidth = lw;
|
||||
context.strokeStyle = "#FF0000";
|
||||
var x0 = parseInt(rect.startX) - parseInt(lw/2);
|
||||
var y0 = parseInt(rect.startY) - parseInt(lw/2);
|
||||
var dx = parseInt(rect.w) + parseInt(lw);
|
||||
var dy = parseInt(rect.h) + parseInt(lw);
|
||||
context.strokeRect(x0, y0, dx, dy);
|
||||
ROIInfo[aktindex]["x"] = rect.startX;
|
||||
ROIInfo[aktindex]["y"] = rect.startY;
|
||||
ROIInfo[aktindex]["dx"] = rect.w;
|
||||
ROIInfo[aktindex]["dy"] = rect.h;
|
||||
}
|
||||
|
||||
function getCoords(elem) { // crossbrowser version
|
||||
var box = elem.getBoundingClientRect();
|
||||
var body = document.body;
|
||||
var docEl = document.documentElement;
|
||||
var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
|
||||
var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
|
||||
var clientTop = docEl.clientTop || body.clientTop || 0;
|
||||
var clientLeft = docEl.clientLeft || body.clientLeft || 0;
|
||||
var top = box.top + scrollTop - clientTop;
|
||||
var left = box.left + scrollLeft - clientLeft;
|
||||
return { top: Math.round(top), left: Math.round(left) };
|
||||
}
|
||||
|
||||
function mouseDown(e) {
|
||||
zw = getCoords(this)
|
||||
rect.startX = e.pageX - zw.left;
|
||||
rect.startY = e.pageY - zw.top;
|
||||
document.getElementById("refx").value = rect.startX;
|
||||
document.getElementById("refy").value = rect.startY;
|
||||
drag = true;
|
||||
}
|
||||
|
||||
function mouseUp() {
|
||||
drag = false;
|
||||
if (rect.w < 0) {
|
||||
rect.w = -rect.w
|
||||
rect.startX-=rect.w
|
||||
}
|
||||
if (rect.h < 0) {
|
||||
rect.h = -rect.h
|
||||
rect.startY-=rect.h
|
||||
}
|
||||
document.getElementById("refdx").value = rect.w;
|
||||
document.getElementById("refdy").value = rect.h;
|
||||
document.getElementById("refx").value = rect.startX;
|
||||
document.getElementById("refy").value = rect.startY;
|
||||
}
|
||||
|
||||
function mouseMove(e) {
|
||||
if (drag) {
|
||||
zw = getCoords(this)
|
||||
|
||||
|
||||
if (lockAR) {
|
||||
rect.h = (e.pageY - zw.top) - rect.startY;
|
||||
rect.w = Math.round(rect.h * ROIInfo[aktindex]["ar"]); }
|
||||
else {
|
||||
rect.w = (e.pageX - zw.left) - rect.startX;
|
||||
rect.h = (e.pageY - zw.top) - rect.startY;
|
||||
}
|
||||
document.getElementById("refdx").value = rect.w;
|
||||
document.getElementById("refdy").value = rect.h;
|
||||
draw();
|
||||
}
|
||||
else {
|
||||
draw();
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
zw = getCoords(this);
|
||||
x = e.pageX - zw.left;
|
||||
y = e.pageY - zw.top;
|
||||
|
||||
context.lineWidth = 2;
|
||||
context.strokeStyle = "#00FF00";
|
||||
context.beginPath();
|
||||
context.moveTo(0,y);
|
||||
context.lineTo(canvas.width, y);
|
||||
context.moveTo(x, 0);
|
||||
context.lineTo(x, canvas.height);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
function valuemanualchanged(){
|
||||
if (!drag) {
|
||||
rect.w = document.getElementById("refdx").value;
|
||||
rect.h = document.getElementById("refdy").value;
|
||||
if (lockAR) {
|
||||
rect.w = Math.round(rect.h * ROIInfo[aktindex]["ar"]);
|
||||
document.getElementById("refdx").value = rect.w;
|
||||
}
|
||||
|
||||
rect.startX = document.getElementById("refx").value;
|
||||
rect.startY = document.getElementById("refy").value;
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
function valuemanualchangeddx(){
|
||||
if (!drag) {
|
||||
rect.w = document.getElementById("refdx").value;
|
||||
rect.h = document.getElementById("refdy").value;
|
||||
if (lockAR) {
|
||||
rect.h = Math.round(rect.w / ROIInfo[aktindex]["ar"]);
|
||||
document.getElementById("refdy").value = rect.h;
|
||||
}
|
||||
|
||||
rect.startX = document.getElementById("refx").value;
|
||||
rect.startY = document.getElementById("refy").value;
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
226
sd-card/html/edit_reference.html
Normal file
@@ -0,0 +1,226 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Make refernce</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3>Create Reference out of Raw Image</h3>
|
||||
<div style="padding-left: 30px">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="button" value="Show acutual Reference" onclick="showReference()">
|
||||
</td>
|
||||
<td>
|
||||
<input type="button" value="Create new Reference" onclick="loadRawImage()">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
Pre-rotate Angle
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" id="prerotateangle" name="prerotateangle" value=0 min="-360" max="360" onchange="drawRotated()">°
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Fine Alignment
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" id="finerotate" name="finerotate" value=0.0 min="-1" max="1" step="0.2" onchange="drawRotated()">°
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<canvas id="canvas"></canvas>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="button" value="Update Reference Image" onclick="SaveReference()">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="./gethost.js"></script>
|
||||
<script type="text/javascript" src="./readconfig.js"></script>
|
||||
|
||||
<script language="JavaScript">
|
||||
var canvas = document.getElementById('canvas'),
|
||||
ctx = canvas.getContext('2d'),
|
||||
imageObj = new Image()
|
||||
basepath = "http://192.168.178.26";
|
||||
|
||||
function loadRawImage(){
|
||||
url = basepath + "/fileserver/img_tmp/raw.jpg";
|
||||
document.getElementById("finerotate").value = 0;
|
||||
document.getElementById("prerotateangle").value = getPreRotate();
|
||||
document.getElementById("finerotate").disabled = false;
|
||||
document.getElementById("prerotateangle").disabled = false;
|
||||
// document.getElementById("ButtonRotate").disabled = false;
|
||||
drawRotated();
|
||||
}
|
||||
|
||||
function showReference(){
|
||||
url = basepath + "/fileserver/config/reference.jpg";
|
||||
document.getElementById("finerotate").value = 0;
|
||||
document.getElementById("prerotateangle").value = 0;
|
||||
document.getElementById("finerotate").disabled = true;
|
||||
document.getElementById("prerotateangle").disabled = true;
|
||||
// document.getElementById("ButtonRotate").disabled = true;
|
||||
loadCanvas(url);
|
||||
ParseConfig();
|
||||
drawRotated();
|
||||
}
|
||||
|
||||
function dataURLtoBlob(dataurl) {
|
||||
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
|
||||
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
||||
while(n--){
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
return new Blob([u8arr], {type:mime});
|
||||
}
|
||||
|
||||
function SaveReference(){
|
||||
if (confirm("Are you sure you want to update the reference image?")) {
|
||||
setPreRotate(document.getElementById("prerotateangle").value);
|
||||
UpdateConfigFile(basepath);
|
||||
var canvas = document.getElementById("canvas");
|
||||
var okay = SaveCanvasToImage(canvas, "/config/reference.jpg", true, basepath);
|
||||
if (okay) {
|
||||
alert("Update \"reference.jpg\" successfull!")
|
||||
}
|
||||
else {
|
||||
alert("Error on update \"reference.jpg\"!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadCanvas(dataURL) {
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
imageObj.onload = function() {
|
||||
canvas.width = this.width;
|
||||
canvas.height = this.height;
|
||||
drawRotated();
|
||||
};
|
||||
|
||||
imageObj.src = dataURL;
|
||||
}
|
||||
|
||||
|
||||
function getCoords(elem) { // crossbrowser version
|
||||
var box = elem.getBoundingClientRect();
|
||||
var body = document.body;
|
||||
var docEl = document.documentElement;
|
||||
var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
|
||||
var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
|
||||
var clientTop = docEl.clientTop || body.clientTop || 0;
|
||||
var clientLeft = docEl.clientLeft || body.clientLeft || 0;
|
||||
var top = box.top + scrollTop - clientTop;
|
||||
var left = box.left + scrollLeft - clientLeft;
|
||||
return { top: Math.round(top), left: Math.round(left) };
|
||||
}
|
||||
|
||||
function init() {
|
||||
canvas.addEventListener('mousemove', mouseMove, false);
|
||||
basepath = getbasepath();
|
||||
loadConfig(basepath);
|
||||
showReference();
|
||||
}
|
||||
|
||||
function drawRotated(){
|
||||
finerot= parseFloat(document.getElementById("finerotate").value);
|
||||
prerot = parseFloat(document.getElementById("prerotateangle").value);
|
||||
if (finerot == 1) {
|
||||
prerot+=1
|
||||
finerot = 0
|
||||
}
|
||||
if (finerot == -1) {
|
||||
prerot-=1
|
||||
finerot = 0
|
||||
}
|
||||
degrees = finerot + prerot;
|
||||
document.getElementById("finerotate").value = finerot;
|
||||
document.getElementById("prerotateangle").value = prerot;
|
||||
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
context.clearRect(0,0,imageObj.width,imageObj.height);
|
||||
context.save();
|
||||
context.translate(imageObj.width/2,imageObj.height/2);
|
||||
context.rotate(degrees*Math.PI/180);
|
||||
context.drawImage(imageObj,-imageObj.width/2,-imageObj.height/2);
|
||||
context.restore();
|
||||
drawGrid();
|
||||
}
|
||||
|
||||
function drawGrid(){
|
||||
var canvas = document.getElementById('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
w = canvas.width;
|
||||
h = canvas.height;
|
||||
ctx.save();
|
||||
ctx.strokeStyle = '#00FF00';
|
||||
|
||||
for (i = h/2; i < h; i += 100)
|
||||
{
|
||||
ctx.moveTo(0, i);
|
||||
ctx.lineTo(w, i);
|
||||
ctx.stroke();
|
||||
ctx.moveTo(0, h-i);
|
||||
ctx.lineTo(w, h-i);
|
||||
ctx.stroke();
|
||||
}
|
||||
for (i = w/2; i < w; i += 100)
|
||||
{
|
||||
ctx.moveTo(i, 0);
|
||||
ctx.lineTo(i, h);
|
||||
ctx.stroke();
|
||||
ctx.moveTo(w-i, 0);
|
||||
ctx.lineTo(w-i, h);
|
||||
ctx.stroke(); }
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function mouseMove(e) {
|
||||
drawRotated();
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
zw = getCoords(this);
|
||||
x = e.pageX - zw.left;
|
||||
y = e.pageY - zw.top;
|
||||
|
||||
context.lineWidth = 2;
|
||||
context.strokeStyle = "#00FF00";
|
||||
context.beginPath();
|
||||
context.moveTo(0,y);
|
||||
context.lineTo(canvas.width, y);
|
||||
context.moveTo(x, 0);
|
||||
context.lineTo(x, canvas.height);
|
||||
context.stroke();
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
56
sd-card/html/fileserver/config/config.ini
Normal file
@@ -0,0 +1,56 @@
|
||||
[MakeImage]
|
||||
;LogImageLocation = /log/source
|
||||
WaitBeforeTakingPicture=5
|
||||
ImageQuality = 5
|
||||
ImageSize = VGA
|
||||
|
||||
[Alignment]
|
||||
InitalRotate=180
|
||||
/config/ref0.jpg 86, 253
|
||||
/config/ref1.jpg 446, 113
|
||||
SearchFieldX = 20
|
||||
SearchFieldY = 20
|
||||
|
||||
[Digits]
|
||||
Model=/config/dig0622.tfl
|
||||
LogImageLocation = /log/digit
|
||||
ModelInputSize 20, 32
|
||||
digit1, 306, 120, 37, 67
|
||||
digit2, 355, 120, 37, 67
|
||||
digit3, 404, 120, 37, 67
|
||||
|
||||
[Analog]
|
||||
Model=/config/ana0622.tfl
|
||||
LogImageLocation = /log/analog
|
||||
ModelInputSize 32, 32
|
||||
analog1, 444, 225, 92, 92
|
||||
analog2, 391, 329, 92, 92
|
||||
analog3, 294, 369, 92, 92
|
||||
analog4, 168, 326, 92, 92
|
||||
|
||||
[PostProcessing]
|
||||
PreValueUse = True
|
||||
PreValueAgeStartup = 30
|
||||
AllowNegativeRates = False
|
||||
MaxRateValue = 0.1
|
||||
ErrorMessage = True
|
||||
CheckDigitIncreaseConsistency = True
|
||||
|
||||
|
||||
[AutoTimer]
|
||||
AutoStart= True
|
||||
Intervall = 4.85
|
||||
|
||||
[Ende]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
sd-card/html/fileserver/config/reference.jpg
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
sd-card/html/fileserver/img_tmp/raw.jpg
Normal file
|
After Width: | Height: | Size: 108 KiB |
15
sd-card/html/gethost.js
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
function getbasepath(){
|
||||
var host = window.location.hostname;
|
||||
if (host == "127.0.0.1")
|
||||
{
|
||||
host = "http://192.168.178.26"; // jomjol interner test
|
||||
// host = "http://192.168.178.22"; // jomjol interner Real
|
||||
// host = "."; // jomjol interner localhost
|
||||
}
|
||||
else
|
||||
{
|
||||
host = "http://" + host;
|
||||
}
|
||||
return host;
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Make refernce</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/static/configurator/site.css"/>
|
||||
|
||||
</head>
|
||||
|
||||
<body onScroll="document.cookie='ypos=' + window.pageYOffset">
|
||||
|
||||
<div class="body-content">
|
||||
|
||||
<div id="createrefernce">
|
||||
|
||||
|
||||
<script language="JavaScript">
|
||||
function createscroll(){
|
||||
var zw = document.cookie
|
||||
var n1 = zw.indexOf('ypos=')
|
||||
var n2 = zw.indexOf(";", n1)
|
||||
var a = zw.substr(n1+5, n2-n1-5)
|
||||
//window.alert(zw + " -- "+ a + " -- " + + n1 + " -- " + n2)
|
||||
window.scrollTo(0, a)
|
||||
}
|
||||
</script>
|
||||
|
||||
<div style="padding-left: 30px">
|
||||
|
||||
<h3>Create Reference out of Raw Image</h3>
|
||||
|
||||
<div style="padding-left: 30px">
|
||||
|
||||
<form method="post">
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="lxUFaiYFqzjTUDz63phwtZsErDkz9WjIHPsw56IM1nOYkkvljkwbA2TuKvP97GJy">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<h4>Pre-rotate Angle</h4>
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" id="prerotateangle" name="prerotateangle" value=179.0 min="-360" max="360">°
|
||||
<input type="button" value="Rotate" onclick="drawRotated()">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<h4>Fine Alignment</h4>
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" id="finerotate" name="finerotate" value=0.0 min="-1" max="1" step="0.2" onchange="drawRotated()">°
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<canvas id="canvas"></canvas>
|
||||
</td>
|
||||
<td>
|
||||
<input type="hidden" name="degree" id="degree" value="0">
|
||||
<input type="button" value="Save Reference Image" onclick="SaveReference()">
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script language="JavaScript">
|
||||
var canvas = document.getElementById('canvas'),
|
||||
ctx = canvas.getContext('2d'),
|
||||
imageObj = new Image();
|
||||
|
||||
function dataURLtoBlob(dataurl) {
|
||||
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
|
||||
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
||||
while(n--){
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
}
|
||||
return new Blob([u8arr], {type:mime});
|
||||
}
|
||||
|
||||
function SaveReference()
|
||||
{
|
||||
|
||||
if (confirm("Are you sure you want to update \"reference2.jpg\"?")) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
/* first delete the old firmware */
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4) {
|
||||
if (xhttp.status == 200) {
|
||||
/* keine Reaktion, damit sich das Dokument nicht ändert */
|
||||
} else if (xhttp.status == 0) {
|
||||
alert("Server closed the connection abruptly!");
|
||||
location.reload()
|
||||
} else {
|
||||
alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
||||
location.reload()
|
||||
}
|
||||
}
|
||||
};
|
||||
xhttp.open("POST", "http://192.168.178.22/delete/config/reference2.jpg", false);
|
||||
xhttp.send();
|
||||
/* ----------------------------- */
|
||||
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4) {
|
||||
if (xhttp.status == 200) {
|
||||
alert("Update \"reference2.jpg\" successfull!\n\nTo make it active you need to reboot.")
|
||||
document.reload();
|
||||
} else if (xhttp.status == 0) {
|
||||
alert("Server closed the connection abruptly!");
|
||||
location.reload()
|
||||
} else {
|
||||
alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
||||
location.reload()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
upload_path = "http://192.168.178.22/upload/config/reference2.jpg";
|
||||
|
||||
var canvas = document.getElementById("canvas");
|
||||
|
||||
var JPEG_QUALITY=0.5;
|
||||
var dataUrl = canvas.toDataURL('image/jpeg', JPEG_QUALITY);
|
||||
var rtn = dataURLtoBlob(dataUrl);
|
||||
|
||||
xhttp.open("POST", upload_path, true);
|
||||
xhttp.send(rtn);
|
||||
}
|
||||
}
|
||||
|
||||
function loadCanvas(dataURL) {
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
imageObj.onload = function() {
|
||||
canvas.width = this.width;
|
||||
canvas.height = this.height;
|
||||
drawRotated();
|
||||
createscroll();
|
||||
};
|
||||
|
||||
imageObj.src = dataURL;
|
||||
}
|
||||
|
||||
|
||||
function getCoords(elem) { // crossbrowser version
|
||||
var box = elem.getBoundingClientRect();
|
||||
var body = document.body;
|
||||
var docEl = document.documentElement;
|
||||
var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
|
||||
var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
|
||||
var clientTop = docEl.clientTop || body.clientTop || 0;
|
||||
var clientLeft = docEl.clientLeft || body.clientLeft || 0;
|
||||
var top = box.top + scrollTop - clientTop;
|
||||
var left = box.left + scrollLeft - clientLeft;
|
||||
return { top: Math.round(top), left: Math.round(left) };
|
||||
}
|
||||
|
||||
|
||||
|
||||
function init() {
|
||||
// alert("load image");
|
||||
loadCanvas("http://192.168.178.22/fileserver/img_tmp/raw.jpg");
|
||||
drawRotated();
|
||||
}
|
||||
|
||||
function drawRotated(){
|
||||
finerot= parseFloat(document.getElementById("finerotate").value);
|
||||
prerot = parseFloat(document.getElementById("prerotateangle").value);
|
||||
if (finerot == 1) {
|
||||
prerot+=1
|
||||
finerot = 0
|
||||
}
|
||||
if (finerot == -1) {
|
||||
prerot-=1
|
||||
finerot = 0
|
||||
}
|
||||
degrees = finerot + prerot;
|
||||
document.getElementById("finerotate").value = finerot;
|
||||
document.getElementById("prerotateangle").value = prerot;
|
||||
document.getElementById("degree").value = degrees;
|
||||
|
||||
|
||||
var canvas = document.getElementById('canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
context.clearRect(0,0,imageObj.width,imageObj.height);
|
||||
context.save();
|
||||
context.translate(imageObj.width/2,imageObj.height/2);
|
||||
context.rotate(degrees*Math.PI/180);
|
||||
context.drawImage(imageObj,-imageObj.width/2,-imageObj.height/2);
|
||||
context.restore();
|
||||
drawGrid();
|
||||
}
|
||||
function drawGrid(){
|
||||
var canvas = document.getElementById('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
w = canvas.width;
|
||||
h = canvas.height;
|
||||
ctx.save();
|
||||
ctx.strokeStyle = '#00FF00';
|
||||
|
||||
for (i = h/2; i < h; i += 100)
|
||||
{
|
||||
ctx.moveTo(0, i);
|
||||
ctx.lineTo(w, i);
|
||||
ctx.stroke();
|
||||
ctx.moveTo(0, h-i);
|
||||
ctx.lineTo(w, h-i);
|
||||
ctx.stroke();
|
||||
}
|
||||
for (i = w/2; i < w; i += 100)
|
||||
{
|
||||
ctx.moveTo(i, 0);
|
||||
ctx.lineTo(i, h);
|
||||
ctx.stroke();
|
||||
ctx.moveTo(w-i, 0);
|
||||
ctx.lineTo(w-i, h);
|
||||
ctx.stroke(); }
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
init();
|
||||
</script>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
</body onScroll="document.cookie='ypos=' + window.pageYOffset">
|
||||
</html>
|
||||
@@ -78,32 +78,19 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>AI on the edge - an integrated water meter example</h1>
|
||||
<h1>Watermeter - AI on the edge - an ESP32 all in neural network recognition system</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li aria-current="page"><a href="#"onclick="document.getElementById('maincontent').src = '/wasserzaehler_roi.html';">wasserzaehler</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/prevalue_set.html';">PreValue</a> </li>
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/edit_config.html';">Edit Configuration</a> </li>
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/wasserzaehler.html?full';">wasserzaehler full</a> </li>
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/prevalue_set.html';">Set preValue</a> </li>
|
||||
<li><a href="index_configure.html">Edit Configuration</a> </li>
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/wasserzaehler.html?full';">/wasserzaehler.html?full</a> </li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li><a href="#" onclick="document.getElementById('maincontent').src = '/fileserver/';">File Server</a> </li>
|
||||
<li><a href="#">Manuel Mode</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/doinit';">Init</a> </li>
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/doflow';">Recognize</a> </li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li><a href="#">Image</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/img_tmp/raw.jpg';">Raw</a> </li>
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/img_tmp/rot.jpg';">Rotated</a> </li>
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/img_tmp/alg.jpg';">Aligned</a> </li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#">System</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = '/starttime';">Start time</a> </li>
|
||||
|
||||
116
sd-card/html/index_configure.html
Normal file
@@ -0,0 +1,116 @@
|
||||
<html><head>
|
||||
<title>jomjol - AI on the edge</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type="text/css" media="screen">
|
||||
nav > ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
nav li {
|
||||
margin: 0.5em;
|
||||
padding: 0;
|
||||
font-size: 1.5em;
|
||||
flex: 1 1 0%;
|
||||
}
|
||||
|
||||
@media (min-width: 45em) {
|
||||
nav > ul {
|
||||
flex-direction: row;
|
||||
}
|
||||
nav li {
|
||||
flex: 1;
|
||||
font-size: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
nav a {
|
||||
display: block;
|
||||
padding: 0.4em;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
border: 1px solid darkblue;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 5px 10px white inset;
|
||||
color: gold;
|
||||
background-color: darkblue;
|
||||
transition: all .25s ease-in;
|
||||
}
|
||||
|
||||
nav li[aria-current] a {
|
||||
background-color: firebrick;
|
||||
color: gold;
|
||||
}
|
||||
|
||||
nav a:focus,
|
||||
nav a:hover,
|
||||
nav li[aria-current] a:focus,
|
||||
nav li[aria-current] a:hover {
|
||||
color: darkblue;
|
||||
background-color: gold;
|
||||
}
|
||||
|
||||
|
||||
html, body {
|
||||
height:100%;
|
||||
width:100%;
|
||||
margin:0;
|
||||
}
|
||||
.h_iframe iframe {
|
||||
width:98%;
|
||||
height:150%;
|
||||
}
|
||||
.h_iframe {
|
||||
height: 150%;
|
||||
width:98%;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
//]]>
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Configure watermeter</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
|
||||
|
||||
<li><a href="#" onclick="document.getElementById('maincontent').src = 'edit_config.html';">CONFIG.INI direct</a> </li>
|
||||
<li><a href="#">Alignment</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = 'edit_reference.html';">Reference Image</a> </li>
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = 'edit_alignment.html';">Alignment Marks</a> </li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#">Regions of interest</a>
|
||||
<ul class="submenu">
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = 'edit_digits.html';">Digital ROIs</a> </li>
|
||||
<li><a href="#"onclick="document.getElementById('maincontent').src = 'edit_analog.html';">Analog ROIs</a> </li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li><a href="#" onclick="document.getElementById('maincontent').src = 'edit_check.html';">Check</a> </li>
|
||||
<li aria-current="page"><a href="index.html">Main</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<p>
|
||||
|
||||
<div class="h_iframe">
|
||||
<iframe name="maincontent" id="maincontent" src="edit_config.html" title="fileserver"></iframe>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body></html>
|
||||
@@ -1,6 +1,9 @@
|
||||
var config_gesamt;
|
||||
var config_split;
|
||||
var ref = new Array(2);
|
||||
var digit = new Array(0);
|
||||
var analog = new Array(0);
|
||||
var initalrotate = new Object();
|
||||
|
||||
function MakeRefZW(zw, _basepath){
|
||||
url = _basepath + "/editflow.html?task=cutref&in=/config/reference.jpg&out=/img_tmp/ref_zw_org.jpg&x=" + zw["x"] + "&y=" + zw["y"] + "&dx=" + zw["dx"] + "&dy=" + zw["dy"];
|
||||
@@ -25,41 +28,172 @@ function GetCoordinates(index, _basepath){
|
||||
return ref[index];
|
||||
}
|
||||
|
||||
function ParseReference() {
|
||||
config_split = config_gesamt.split("\n");
|
||||
var i = 0;
|
||||
|
||||
for (var i in config_split) {
|
||||
if (config_split[i].trim() == "[Alignment]")
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= config_split.length){
|
||||
return;
|
||||
}
|
||||
|
||||
function ParseConfigAlignment(_aktline){
|
||||
var akt_ref = 0;
|
||||
++i;
|
||||
++_aktline;
|
||||
|
||||
while ((akt_ref < 2) && (i < config_split.length) && (config_split[i][0] != "[")) {
|
||||
var linesplit = ZerlegeZeile(config_split[i]);
|
||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
||||
var linesplit = ZerlegeZeile(config_split[_aktline]);
|
||||
if ((linesplit[0] == "InitalRotate") && (linesplit.length > 1))
|
||||
{
|
||||
initalrotate["angle"] = parseInt(linesplit[1]);
|
||||
initalrotate["pos_config"] = _aktline;
|
||||
}
|
||||
if (linesplit.length == 3)
|
||||
{
|
||||
ref[akt_ref] = new Object();
|
||||
ref[akt_ref]["pos_ref"] = i;
|
||||
ref[akt_ref]["pos_ref"] = _aktline;
|
||||
ref[akt_ref]["name"] = linesplit[0];
|
||||
ref[akt_ref]["x"] = linesplit[1];
|
||||
ref[akt_ref]["y"] = linesplit[2];
|
||||
akt_ref++;
|
||||
}
|
||||
++i;
|
||||
++_aktline;
|
||||
}
|
||||
return _aktline;
|
||||
}
|
||||
|
||||
function ParseConfigDigit(_aktline){
|
||||
++_aktline;
|
||||
digit.length = 0;
|
||||
|
||||
while ((_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
||||
var linesplit = ZerlegeZeile(config_split[_aktline]);
|
||||
if (linesplit.length >= 5)
|
||||
{
|
||||
zw = new Object();
|
||||
zw["pos_ref"] = _aktline;
|
||||
zw["name"] = linesplit[0];
|
||||
zw["x"] = linesplit[1];
|
||||
zw["y"] = linesplit[2];
|
||||
zw["dx"] = linesplit[3];
|
||||
zw["dy"] = linesplit[4];
|
||||
zw["ar"] = parseFloat(linesplit[3]) / parseFloat(linesplit[4]);
|
||||
digit.push(zw);
|
||||
}
|
||||
++_aktline;
|
||||
}
|
||||
return _aktline;
|
||||
}
|
||||
|
||||
|
||||
function ParseConfigAnalog(_aktline){
|
||||
++_aktline;
|
||||
analog.length = 0;
|
||||
|
||||
while ((_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
||||
var linesplit = ZerlegeZeile(config_split[_aktline]);
|
||||
if (linesplit.length >= 5)
|
||||
{
|
||||
zw = new Object();
|
||||
zw["pos_ref"] = _aktline;
|
||||
zw["name"] = linesplit[0];
|
||||
zw["x"] = linesplit[1];
|
||||
zw["y"] = linesplit[2];
|
||||
zw["dx"] = linesplit[3];
|
||||
zw["dy"] = linesplit[4];
|
||||
zw["ar"] = parseFloat(linesplit[3]) / parseFloat(linesplit[4]);
|
||||
analog.push(zw);
|
||||
}
|
||||
++_aktline;
|
||||
}
|
||||
return _aktline;
|
||||
}
|
||||
|
||||
|
||||
function getROIInfo(_typeROI){
|
||||
if (_typeROI == "[Digits]"){
|
||||
targetROI = digit;
|
||||
}
|
||||
if (_typeROI == "[Analog]"){
|
||||
targetROI = analog;
|
||||
}
|
||||
return targetROI.slice(); // Kopie senden, nicht orginal!!!
|
||||
}
|
||||
|
||||
function SaveROIToConfig(_ROIInfo, _typeROI, _basepath){
|
||||
if (_typeROI == "[Digits]"){
|
||||
targetROI = digit;
|
||||
}
|
||||
if (_typeROI == "[Analog]"){
|
||||
targetROI = analog;
|
||||
}
|
||||
|
||||
// Abstimmen Anzahl ROIs:
|
||||
var _pos = targetROI[targetROI.length-1]["pos_ref"];
|
||||
|
||||
for (var i = targetROI.length; i < _ROIInfo.length; ++i){
|
||||
var zw = config_split[config_split.length-1];
|
||||
config_split.push(zw);
|
||||
for (var j = config_split.length-2; j > _pos + 1; --j){
|
||||
config_split[j] = config_split[j-1];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = targetROI.length-1; i > _ROIInfo.length-1; --i){
|
||||
var _zwpos = targetROI[i]["pos_ref"];
|
||||
config_split.splice(_zwpos, 1);
|
||||
}
|
||||
|
||||
var linewrite = 0;
|
||||
for (i = 0; i < _ROIInfo.length; ++i){
|
||||
if (i < digit.length){
|
||||
linewrite = digit[i]["pos_ref"];
|
||||
}
|
||||
else {
|
||||
linewrite++;
|
||||
}
|
||||
config_split[linewrite] = _ROIInfo[i]["name"] + ", " + _ROIInfo[i]["x"] + ", " + _ROIInfo[i]["y"] + ", " + _ROIInfo[i]["dx"] + ", " + _ROIInfo[i]["dy"];
|
||||
}
|
||||
|
||||
SaveConfigToServer(_basepath);
|
||||
}
|
||||
|
||||
|
||||
function ParseConfig() {
|
||||
config_split = config_gesamt.split("\n");
|
||||
var aktline = 0;
|
||||
|
||||
while (aktline < config_split.length){
|
||||
if (config_split[aktline].trim() == "[Alignment]") {
|
||||
aktline = ParseConfigAlignment(aktline);
|
||||
continue;
|
||||
}
|
||||
if (config_split[aktline].trim() == "[Digits]") {
|
||||
aktline = ParseConfigDigit(aktline);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (config_split[aktline].trim() == "[Analog]") {
|
||||
aktline = ParseConfigAnalog(aktline);
|
||||
continue;
|
||||
}
|
||||
|
||||
aktline++;
|
||||
}
|
||||
}
|
||||
|
||||
function UpdateConfig(zw, _index, _enhance, _basepath){
|
||||
var zeile = zw["name"] + " " + zw["x"] + ", " + zw["y"];
|
||||
var _pos = ref[_index]["pos_ref"];
|
||||
config_split[_pos] = zeile;
|
||||
function getPreRotate(){
|
||||
return initalrotate["angle"];
|
||||
}
|
||||
|
||||
function setPreRotate(_prerotate){
|
||||
initalrotate["angle"] = _prerotate;
|
||||
}
|
||||
|
||||
function SaveCanvasToImage(_canvas, _filename, _delete = true, _basepath = ""){
|
||||
var JPEG_QUALITY=0.8;
|
||||
var dataUrl = _canvas.toDataURL('image/jpeg', JPEG_QUALITY);
|
||||
var rtn = dataURLtoBlob(dataUrl);
|
||||
|
||||
if (_delete) {
|
||||
FileDeleteOnServer(_filename, _basepath);
|
||||
}
|
||||
|
||||
FileSendContent(rtn, _filename, _basepath);
|
||||
}
|
||||
|
||||
function SaveConfigToServer(_basepath){
|
||||
FileDeleteOnServer("/config/config.ini", _basepath);
|
||||
|
||||
var config_gesamt = "";
|
||||
@@ -68,9 +202,29 @@ function UpdateConfig(zw, _index, _enhance, _basepath){
|
||||
config_gesamt = config_gesamt + config_split[i] + "\n";
|
||||
}
|
||||
|
||||
var rtn = new Blob([config_gesamt], {type: 'mime'});
|
||||
|
||||
FileSendContent(config_gesamt, "/config/config.ini", _basepath);
|
||||
}
|
||||
|
||||
function UpdateConfigFile(_basepath){
|
||||
for (var _index = 0; _index < ref.length; ++_index){
|
||||
var zeile = ref[_index]["name"] + " " + ref[_index]["x"] + ", " + ref[_index]["y"];
|
||||
var _pos = ref[_index]["pos_ref"];
|
||||
config_split[_pos] = zeile;
|
||||
}
|
||||
|
||||
zeile = "InitalRotate=" + initalrotate["angle"];
|
||||
var _pos = initalrotate["pos_config"];
|
||||
config_split[_pos] = zeile;
|
||||
|
||||
SaveConfigToServer(_basepath);
|
||||
}
|
||||
|
||||
function UpdateConfig(zw, _index, _enhance, _basepath){
|
||||
var zeile = zw["name"] + " " + zw["x"] + ", " + zw["y"];
|
||||
var _pos = ref[_index]["pos_ref"];
|
||||
config_split[_pos] = zeile;
|
||||
|
||||
SaveConfigToServer(_basepath);
|
||||
|
||||
var namezw = zw["name"];
|
||||
FileCopyOnServer("/img_tmp/ref_zw.jpg", namezw, _basepath);
|
||||
@@ -191,7 +345,7 @@ function trim(istring, adddelimiter)
|
||||
|
||||
|
||||
|
||||
function loadConfigJS(_basepath) {
|
||||
function loadConfig(_basepath) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
try {
|
||||
url = _basepath + '/fileserver/config/config.ini';
|
||||
@@ -206,7 +360,7 @@ function loadConfigJS(_basepath) {
|
||||
}
|
||||
|
||||
function getConfig() {
|
||||
return config_txt;
|
||||
return config_gesamt;
|
||||
}
|
||||
|
||||
|
||||
@@ -242,10 +396,10 @@ function FileDeleteOnServer(_filename, _basepath = ""){
|
||||
okay = true;
|
||||
} else if (xhttp.status == 0) {
|
||||
// alert("Server closed the connection on delete abruptly!");
|
||||
location.reload()
|
||||
// location.reload()
|
||||
} else {
|
||||
// alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
||||
location.reload()
|
||||
// location.reload()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||