mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-07 20:16:55 +03:00
Compare commits
91 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20b054472e | ||
|
|
21a70c5655 | ||
|
|
08270f5d6d | ||
|
|
9923be2f1d | ||
|
|
5df57c95d4 | ||
|
|
d8c91466d0 | ||
|
|
37b2e370fe | ||
|
|
98dfba0640 | ||
|
|
574c9084c2 | ||
|
|
9862ae8e7a | ||
|
|
7bc4e63209 | ||
|
|
ad40150cfa | ||
|
|
970530d99f | ||
|
|
c6ae989b82 | ||
|
|
a0ebf354b1 | ||
|
|
97ecbc792e | ||
|
|
5934a59489 | ||
|
|
ee18046581 | ||
|
|
1e4e38c02f | ||
|
|
7a3038eceb | ||
|
|
7d2f86b72e | ||
|
|
3aaa319505 | ||
|
|
f4075f0a51 | ||
|
|
59643a8d52 | ||
|
|
baf2a880e4 | ||
|
|
d71e8320c7 | ||
|
|
3b3d924f40 | ||
|
|
60701bc007 | ||
|
|
5ca3e184e0 | ||
|
|
2903d1a0a6 | ||
|
|
5f0f1802a4 | ||
|
|
5be56d9b00 | ||
|
|
d3fd1b5045 | ||
|
|
4615e87483 | ||
|
|
fb9b72deea | ||
|
|
5cc873a6bb | ||
|
|
26745496a5 | ||
|
|
4537725852 | ||
|
|
676bda22ae | ||
|
|
87028e5f35 | ||
|
|
912083d20f | ||
|
|
4b6044dade | ||
|
|
871d3b537d | ||
|
|
01f8a514a1 | ||
|
|
7dbd77d2a4 | ||
|
|
94dde53c21 | ||
|
|
e47eaa3ac3 | ||
|
|
4060299204 | ||
|
|
70a99927cd | ||
|
|
688cee9463 | ||
|
|
fa3e300c37 | ||
|
|
9dbad050fd | ||
|
|
87202115d0 | ||
|
|
abc4cb444a | ||
|
|
78744840eb | ||
|
|
46cfe45cf6 | ||
|
|
91ff41a9d9 | ||
|
|
3869da9d06 | ||
|
|
2530691347 | ||
|
|
c65de27e9d | ||
|
|
9bb715fcb2 | ||
|
|
8c4f39ab49 | ||
|
|
e5206091dd | ||
|
|
e53c6fe64c | ||
|
|
b893b24d88 | ||
|
|
c7caa55223 | ||
|
|
c675019ef3 | ||
|
|
f2fea0a402 | ||
|
|
aeafd631d5 | ||
|
|
aa442632ea | ||
|
|
2a4b5f88a7 | ||
|
|
0e36010937 | ||
|
|
8a06825871 | ||
|
|
ce2f1bcde6 | ||
|
|
c59826471c | ||
|
|
9c8f64f602 | ||
|
|
ae116981ef | ||
|
|
becb886ab7 | ||
|
|
3502ac9263 | ||
|
|
c64cb94b7d | ||
|
|
dffb28816d | ||
|
|
6e521f07c4 | ||
|
|
c05313aefc | ||
|
|
db0ca1cb9b | ||
|
|
584a73255a | ||
|
|
7e4f83c2f5 | ||
|
|
9971c82e99 | ||
|
|
b418525b3b | ||
|
|
f5c28107d4 | ||
|
|
793f928e6e | ||
|
|
a8fb2e37d5 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,7 +2,6 @@
|
|||||||
.pio/
|
.pio/
|
||||||
.vscode/
|
.vscode/
|
||||||
.code-workspace
|
.code-workspace
|
||||||
.helper/
|
|
||||||
/sd-card/htm./.vscode/
|
/sd-card/htm./.vscode/
|
||||||
/code/build
|
/code/build
|
||||||
|
|
||||||
|
|||||||
126
Changelog.md
126
Changelog.md
@@ -1,6 +1,130 @@
|
|||||||
# Versions
|
# Versions
|
||||||
|
|
||||||
|
##### 5.0.0 Setup Modus - (2020-12-06)
|
||||||
|
|
||||||
|
* Implementation of initial setup modus for fresh installation
|
||||||
|
|
||||||
|
* Code restructuring (full compatibility between pure ESP-IDF and Platformio w/ espressif)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 4.1.1 Configuration editor - (2020-12-02)
|
||||||
|
|
||||||
|
* Bug fixing: internal improvement of file handling (reduce not responding)
|
||||||
|
|
||||||
|
|
||||||
|
##### 4.1.0 Configuration editor - (2020-11-30)
|
||||||
|
|
||||||
|
* Implementation of configuration editor (including basic and expert mode)
|
||||||
|
|
||||||
|
* Adjustable time zone to adjust to local time setting (incl. daylight saving time)
|
||||||
|
|
||||||
|
* MQTT: additional topic for error reporting
|
||||||
|
|
||||||
|
* standardized access to current logfile via `http://IP-ADRESS/logfileact`
|
||||||
|
|
||||||
|
* Update digital CNN to v7.2.0, analog CNN to 6.3.0
|
||||||
|
|
||||||
|
* Bug fixing: truncation error, CheckDigitConsistency & PreValue implementation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 4.0.0 Tflite Core - (2020-11-15)
|
||||||
|
|
||||||
|
* Implementation of rolling log-files
|
||||||
|
|
||||||
|
* Update Tflite-Core to master@20201108 (v2.4)
|
||||||
|
|
||||||
|
* Bug-fixing for reducing reboots
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 3.1.0 MQTT-Client - (2020-10-26)
|
||||||
|
|
||||||
|
* Update digital CNN to v6.5.0 and HTML (Info to hostname, IP, ssid)
|
||||||
|
|
||||||
|
* New implementation of "checkDigitConsistency" also for digits
|
||||||
|
* MQTT-Adapter: user and password for sign in MQTT-Broker
|
||||||
|
|
||||||
|
##### 3.0.0 MQTT-Client (2020-10-14)
|
||||||
|
|
||||||
|
* Implementation of MQTT Client
|
||||||
|
* Improved Version Control
|
||||||
|
* bug-fixing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 2.2.1 Version Control (2020-09-27)
|
||||||
|
|
||||||
|
* Bug-Fixing (hostname in wlan.ini and error handling inside flow)
|
||||||
|
|
||||||
|
|
||||||
|
##### 2.2.0 Version Control (2020-09-27)
|
||||||
|
|
||||||
|
* Integrated automated versioning system (menu: SYSTEM --> INFO)
|
||||||
|
* Update Build-System to PlatformIO - Espressif 32 v2.0.0 (ESP-IDF 4.1)
|
||||||
|
|
||||||
|
|
||||||
|
##### 2.1.0 Decimal Shift, Chrome & Edge (2020-09-25)
|
||||||
|
|
||||||
|
* Implementation of Decimal Shift
|
||||||
|
|
||||||
|
* Update default CNN for digits to v6.4.0
|
||||||
|
|
||||||
|
* Improvement HTML
|
||||||
|
|
||||||
|
* Support for Chrome and Edge
|
||||||
|
|
||||||
|
* Reduce logging to minimum - extended logging on demand
|
||||||
|
|
||||||
|
* Implementation of hostname in wlan.ini (`hostname = "HOSTNAME")`
|
||||||
|
|
||||||
|
* Bug fixing, code corrections
|
||||||
|
|
||||||
|
|
||||||
|
##### 2.0.0 Layout update (2020-09-12)
|
||||||
|
|
||||||
|
* Update to **new and modern layout**
|
||||||
|
* Support for Chrome improved
|
||||||
|
* Improved robustness: improved error handling in auto flow reduces spontaneous reboots
|
||||||
|
* File server: Option for "DELETE ALL"
|
||||||
|
* WLan: support of spaces in SSID and password
|
||||||
|
* Reference Image: Option for mirror image, option for image update on the fly
|
||||||
|
* additional parameter in `wasserzaehler.html?noerror=true` to suppress an potential error message
|
||||||
|
* bug fixing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 1.1.3 (2020-09-09)
|
||||||
|
|
||||||
|
* **Bug in configuration of analog ROIs corrected** - correction in v.1.0.2 did not work properly
|
||||||
|
* Improved update page for the web server (`/html` can be updated via a zip-file, which is provided in `/firmware/html.zip`)
|
||||||
|
* Improved Chrome support
|
||||||
|
|
||||||
|
##### 1.1.0 (2020-09-06)
|
||||||
|
|
||||||
|
* Implementation of "delete complete directory"
|
||||||
|
**Attention: beside the `firmware.bin`, also the content of `/html` needs to be updated!**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 1.0.2 (2020-09-06)
|
||||||
|
|
||||||
|
* Bug in configuration of analog ROIs corrected
|
||||||
|
* minor bug correction
|
||||||
|
|
||||||
|
##### 1.0.1 (2020-09-05)
|
||||||
|
|
||||||
|
* preValue.ini Bug corrected
|
||||||
|
* minor bug correction
|
||||||
|
|
||||||
|
##### 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)
|
##### 0.1.0 (2020-08-07)
|
||||||
|
|
||||||
* Initial Version
|
* Initial Version
|
||||||
|
|
||||||
|
|||||||
72
FeatureRequest.md
Normal file
72
FeatureRequest.md
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
## Feature Requests
|
||||||
|
|
||||||
|
**There are a lot of ideas for further improvements, but only limited capacity on side of the developer.** Therefore I have created this page as a collection of ideas.
|
||||||
|
|
||||||
|
1. Who ever has a new idea can put it here, so it that it is not forgotten.
|
||||||
|
|
||||||
|
2. Who ever has time, capacity and passion to support, can take any of the ideas and implement them.
|
||||||
|
I will support and help where ever I can!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
____
|
||||||
|
|
||||||
|
#### #4 Initial Shifting and Rotation
|
||||||
|
|
||||||
|
* https://github.com/jomjol/AI-on-the-edge-device/issues/123
|
||||||
|
|
||||||
|
Implementation of a shifting additional to the initial rotation of the raw camera input
|
||||||
|
|
||||||
|
To do:
|
||||||
|
|
||||||
|
* Implementation of shifting
|
||||||
|
* Extension of configuration
|
||||||
|
* Adaption of the html configuration to implement shifting
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### #3 Allow grouping of digits to multiple reading values
|
||||||
|
|
||||||
|
* https://github.com/jomjol/AI-on-the-edge-device/issues/123
|
||||||
|
|
||||||
|
Implementation of two different independent readouts in one setup
|
||||||
|
|
||||||
|
To do:
|
||||||
|
|
||||||
|
* Extend the configuration, setting and processing flow for two independend readouts
|
||||||
|
|
||||||
|
https://github.com/jomjol/AI-on-the-edge-device/issues/123
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
____
|
||||||
|
|
||||||
|
#### #2 MQTT-controll with callback
|
||||||
|
* https://github.com/jomjol/AI-on-the-edge-device/issues/105
|
||||||
|
|
||||||
|
Extend the MQTT client to also enable callbacks for configuration setting
|
||||||
|
|
||||||
|
To do:
|
||||||
|
|
||||||
|
* implement callback for receiving information and override `config.ini` settings
|
||||||
|
|
||||||
|
* change configuration management to handle online updates (currently changes need a restart)
|
||||||
|
|
||||||
|
* think about the startup, as there the default config is loaded
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
____
|
||||||
|
|
||||||
|
#### #1 Optional GPIO for external flash/lighting
|
||||||
|
|
||||||
|
* https://github.com/jomjol/AI-on-the-edge-device/issues/133
|
||||||
|
|
||||||
|
Implementation of an an extrnal flash / lightning through GPIOs.
|
||||||
|
* available GPIOs: 12 & 13 (currently in use for html switching)
|
||||||
|
|
||||||
|
To do:
|
||||||
|
|
||||||
|
* Implementation of a software module for external light source (e.g. WS8132 LED controller, ...)
|
||||||
|
* Update of the camera module to use the external light instead of the internal flash light
|
||||||
|
* Adopt the configuration algorithm with a configurable light source
|
||||||
199
README.md
199
README.md
@@ -12,9 +12,12 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Donate
|
## Donate
|
||||||
|
|
||||||
If you would like to support the developer with a cup of coffee you can do that via [[Paypal]](https://www.paypal.com/donate?hosted_button_id=8TRSVYNYKDSWL).
|
------
|
||||||
|
|
||||||
|
If you would like to support the developer with a cup of coffee you can do that via [Paypal](https://www.paypal.com/donate?hosted_button_id=8TRSVYNYKDSWL).
|
||||||
|
|
||||||
<form action="https://www.paypal.com/donate" method="post" target="_top">
|
<form action="https://www.paypal.com/donate" method="post" target="_top">
|
||||||
<input type="hidden" name="hosted_button_id" value="8TRSVYNYKDSWL" />
|
<input type="hidden" name="hosted_button_id" value="8TRSVYNYKDSWL" />
|
||||||
@@ -29,141 +32,103 @@ If you would like to support the developer with a cup of coffee you can do that
|
|||||||
|
|
||||||
### Known Issues
|
### Known Issues
|
||||||
|
|
||||||
* Reboot on extensive web access due to the limits of the internal web server
|
* slow response of web server during picture analysis
|
||||||
|
* spontaneous reboots (mostly due to html access during image processing) - self recovery implemented
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
**General remark:** Beside the `firmware.bin`, typically also the content of `/html` needs to be updated!
|
**General remark:** Beside the `firmware.bin`, typically also the content of `/html` needs to be updated!
|
||||||
|
|
||||||
##### 5.0.0 Setup Modus - (2020-12-06)
|
|
||||||
|
|
||||||
* Implementation of intial setup modus for fresh installation
|
|
||||||
|
|
||||||
* Code restructuring (full compatibility between pure ESP-IDF and Platformio w/ espressif)
|
##### 6.6.1 Image Processing in Memory - (2021-04-05)
|
||||||
|
|
||||||
|
* NEW 6.6.1: failed SD card initialization indicated by fast blinking LED at startup
|
||||||
|
* Improved SD-card handling (increase compatibility with more type of cards)
|
||||||
|
|
||||||
|
##### 6.5.0 Image Processing in Memory - (2021-03-25)
|
||||||
|
|
||||||
|
* Upgrade digital CNN to v8.2.0 (added new type of digits)
|
||||||
|
* Supporting alignment structures in ROI definition
|
||||||
|
* Bug fixing: definition of hostname in `config.ini`
|
||||||
|
|
||||||
|
##### 6.4.0 Image Processing in Memory - (2021-03-20)
|
||||||
|
|
||||||
|
* Additional alignment marks for settings the ROIs (analog and digit)
|
||||||
|
* Upgrade analog CNN to v7.0.0 (added new type of pointer)
|
||||||
|
|
||||||
|
##### 6.3.1 Image Processing in Memory - (2021-03-16)
|
||||||
|
|
||||||
|
* NEW: 6.3.1: bug fixing in initial edit reference image and `config.ini` (Spelling error in `InitialRotate`)
|
||||||
|
* Initial setup mode: bug fixing, error correction
|
||||||
|
* Bug-fixing
|
||||||
|
|
||||||
|
##### 6.2.2 Image Processing in Memory - (2021-03-10)
|
||||||
|
|
||||||
|
* NEW 6.2.2: bug fixing
|
||||||
|
* NEW 6.2.1: Changed brightness and contrast to default if not enabled (resolves to bright images)
|
||||||
|
* Determination of fixed illumination settings during startup - speed up of 5s in each run
|
||||||
|
* Update digital CNN to v8.1.1 (additional digital images trained)
|
||||||
|
* Extended error message in MQTT error message
|
||||||
|
|
||||||
|
|
||||||
|
* Image brightness is now adjustable
|
||||||
|
|
||||||
|
|
||||||
|
* Bug fixing: minor topics
|
||||||
|
|
||||||
|
|
||||||
|
##### 6.1.0 Image Processing in Memory - (2021-01-20)
|
||||||
|
|
||||||
|
* Disabling of analog / digital counters in configuration
|
||||||
|
* Improved Alignment Algorithm (`AlignmentAlgo` = `Default`, `Accurate` , `Fast`)
|
||||||
|
* Analog counters: `ExtendedResolution` (last digit is extended by sub comma value of CNN)
|
||||||
|
* `config.ini`: additional parameter `hostname` (additional to wlan.ini)
|
||||||
|
* Switching of GPIO12/13 via http-interface: `/GPIO?GPIO=12&Status=high/low`
|
||||||
|
* Bug fixing: html configuration page, wlan password ("=" now possible)
|
||||||
|
|
||||||
|
##### 6.0.0 Image Processing in Memory - (2021-01-02)
|
||||||
|
|
||||||
|
* **Major change**: image processing fully in memory - no need of SD card buffer anymore
|
||||||
|
|
||||||
|
* Need to limit camera resolution to VGA (due to memory limits)
|
||||||
|
* MQTT: Last Will Testament (LWT) implemented: "connection lost" in case of connection lost to `TopicError`
|
||||||
|
* Disabled `CheckDigitIncreaseConsistency` in default configuration - must now be explicit enabled if needed
|
||||||
|
* Update digital CNN to v7.2.1 (additional digital images trained)
|
||||||
|
* Setting of arbitrary time server in `config.ini`
|
||||||
|
* Option for fixed IP-, DNS-Settings in `wlan.ini`
|
||||||
|
* Increased stability (internal image and camera handling)
|
||||||
|
* Bug fixing: edit digits, handling PreValue, html-bugs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Additional ideas
|
||||||
|
|
||||||
|
There are some ideas and feature request, which are not followed currently - mainly due to capacity reasons on side of the developer. They are collected here: [FeatureRequest.md](FeatureRequest.md)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
## History
|
||||||
|
|
||||||
|
##### 5.0.0 Setup Modus - (2020-12-06)
|
||||||
|
|
||||||
##### 4.1.1 Configuration editor - (2020-12-02)
|
##### 4.1.1 Configuration editor - (2020-12-02)
|
||||||
|
|
||||||
* Bug fixing: internal improvement of file handling (reduce not responding)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### 4.1.0 Configuration editor - (2020-11-30)
|
|
||||||
|
|
||||||
* Implementation of configuration editor (including basic and expert mode)
|
|
||||||
|
|
||||||
* Adjustable time zone to adjust to local time setting (incl. daylight saving time)
|
|
||||||
|
|
||||||
* MQTT: additional topic for error reporting
|
|
||||||
|
|
||||||
* standardized access to current logfile via `http://IP-ADRESS/logfileact`
|
|
||||||
|
|
||||||
* Update digital CNN to v7.2.0, analog CNN to 6.3.0
|
|
||||||
|
|
||||||
* Bug fixing: truncation error, CheckDigitConsistency & PreValue implementation
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### 4.0.0 Tflite Core - (2020-11-15)
|
##### 4.0.0 Tflite Core - (2020-11-15)
|
||||||
* Implementation of rolling log-files
|
|
||||||
|
|
||||||
* Update Tflite-Core to master@20201108 (v2.4)
|
|
||||||
|
|
||||||
* Bug-fixing for reducing reboots
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### 3.1.0 MQTT-Client - (2020-10-26)
|
##### 3.1.0 MQTT-Client - (2020-10-26)
|
||||||
|
|
||||||
* Update digital CNN to v6.5.0 and HTML (Info to hostname, IP, ssid)
|
##### 2.2.1 Version Control - (2020-09-27)
|
||||||
|
|
||||||
* New implementation of "checkDigitConsistency" also for digits
|
|
||||||
* MQTT-Adapter: user and password for sign in MQTT-Broker
|
|
||||||
|
|
||||||
##### 3.0.0 MQTT-Client (2020-10-14)
|
|
||||||
|
|
||||||
* Implementation of MQTT Client
|
|
||||||
* Improved Version Control
|
|
||||||
* bug-fixing
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 2.1.0 Decimal Shift, Chrome & Edge - (2020-09-25)
|
||||||
##### 2.2.1 Version Control (2020-09-27)
|
|
||||||
|
|
||||||
* Bug-Fixing (hostname in wlan.ini and error handling inside flow)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### 2.2.0 Version Control (2020-09-27)
|
##### 2.0.0 Layout update - (2020-09-12)
|
||||||
|
|
||||||
* Integrated automated versioning system (menu: SYSTEM --> INFO)
|
##### 1.1.3 Initial Version - (2020-09-09)
|
||||||
* Update Build-System to PlatformIO - Espressif 32 v2.0.0 (ESP-IDF 4.1)
|
|
||||||
|
|
||||||
|
|
||||||
##### 2.1.0 Decimal Shift, Chrome & Edge (2020-09-25)
|
|
||||||
|
|
||||||
* Implementation of Decimal Shift
|
|
||||||
|
|
||||||
* Update default CNN for digits to v6.4.0
|
|
||||||
|
|
||||||
* Improvement HTML
|
|
||||||
|
|
||||||
* Support for Chrome and Edge
|
|
||||||
|
|
||||||
* Reduce logging to minimum - extended logging on demand
|
|
||||||
|
|
||||||
* Implementation of hostname in wlan.ini (`hostname = "HOSTNAME")`
|
|
||||||
|
|
||||||
* Bug fixing, code corrections
|
|
||||||
|
|
||||||
|
|
||||||
##### 2.0.0 Layout update (2020-09-12)
|
|
||||||
|
|
||||||
* Update to **new and modern layout**
|
|
||||||
* Support for Chrome improved
|
|
||||||
* Improved robustness: improved error handling in auto flow reduces spontaneous reboots
|
|
||||||
* File server: Option for "DELETE ALL"
|
|
||||||
* WLan: support of spaces in SSID and password
|
|
||||||
* Reference Image: Option for mirror image, option for image update on the fly
|
|
||||||
* additional parameter in `wasserzaehler.html?noerror=true` to suppress an potential error message
|
|
||||||
* bug fixing
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### 1.1.3 (2020-09-09)
|
|
||||||
|
|
||||||
* **Bug in configuration of analog ROIs corrected** - correction in v.1.0.2 did not work properly
|
|
||||||
* Improved update page for the web server (`/html` can be updated via a zip-file, which is provided in `/firmware/html.zip`)
|
|
||||||
* Improved Chrome support
|
|
||||||
|
|
||||||
##### 1.1.0 (2020-09-06)
|
|
||||||
|
|
||||||
* Implementation of "delete complete directory"
|
|
||||||
**Attention: beside the `firmware.bin`, also the content of `/html` needs to be updated!**
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### 1.0.2 (2020-09-06)
|
|
||||||
|
|
||||||
* Bug in configuration of analog ROIs corrected
|
|
||||||
* minor bug correction
|
|
||||||
|
|
||||||
##### 1.0.1 (2020-09-05)
|
|
||||||
|
|
||||||
* preValue.ini Bug corrected
|
|
||||||
* minor bug correction
|
|
||||||
|
|
||||||
##### 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)
|
#### [Full Changelog](Changelog.md)
|
||||||
|
|||||||
1
code/.helper/makezip.bat
Normal file
1
code/.helper/makezip.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
powershell Compress-Archive "C:\Users\Muell\Documents\Programmieren\GitHub\AI-on-the-edge-device\sd-card\html\*.*" "C:\Users\Muell\Documents\Programmieren\GitHub\AI-on-the-edge-device\firmware\html.zip"
|
||||||
539
code/components/connect_wlan/connect_wlan._cpp_
Normal file
539
code/components/connect_wlan/connect_wlan._cpp_
Normal file
@@ -0,0 +1,539 @@
|
|||||||
|
#include "connect_wlan.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/event_groups.h"
|
||||||
|
#include "esp_wifi.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "Helper.h"
|
||||||
|
|
||||||
|
static const char *TAG = "connect_wlan";
|
||||||
|
|
||||||
|
std::string ssid = "";
|
||||||
|
std::string passphrase = "";
|
||||||
|
std::string hostname = "";
|
||||||
|
std::string ipaddress = "";
|
||||||
|
std::string gw = "";
|
||||||
|
std::string netmask = "";
|
||||||
|
std::string dns = "";
|
||||||
|
|
||||||
|
std::string std_hostname = "watermeter";
|
||||||
|
|
||||||
|
#define BLINK_GPIO GPIO_NUM_33
|
||||||
|
|
||||||
|
static EventGroupHandle_t s_wifi_event_group;
|
||||||
|
|
||||||
|
#define WIFI_CONNECTED_BIT BIT0
|
||||||
|
#define WIFI_FAIL_BIT BIT1
|
||||||
|
static int s_retry_num = 0;
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<string> ZerlegeZeile(std::string input, std::string _delimiter = "")
|
||||||
|
{
|
||||||
|
std::vector<string> Output;
|
||||||
|
std::string delimiter = " =,";
|
||||||
|
if (_delimiter.length() > 0){
|
||||||
|
delimiter = _delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
input = trim(input, delimiter);
|
||||||
|
size_t pos = findDelimiterPos(input, delimiter);
|
||||||
|
std::string token;
|
||||||
|
while (pos != std::string::npos) {
|
||||||
|
token = input.substr(0, pos);
|
||||||
|
token = trim(token, delimiter);
|
||||||
|
Output.push_back(token);
|
||||||
|
input.erase(0, pos + 1);
|
||||||
|
input = trim(input, delimiter);
|
||||||
|
pos = findDelimiterPos(input, delimiter);
|
||||||
|
}
|
||||||
|
Output.push_back(input);
|
||||||
|
|
||||||
|
return Output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void blinkstatus(int dauer, int _anzahl)
|
||||||
|
{
|
||||||
|
gpio_reset_pin(BLINK_GPIO);
|
||||||
|
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
||||||
|
for (int i = 0; i < _anzahl; ++i)
|
||||||
|
{
|
||||||
|
gpio_set_level(BLINK_GPIO, 0);
|
||||||
|
vTaskDelay(dauer / portTICK_PERIOD_MS);
|
||||||
|
gpio_set_level(BLINK_GPIO, 1);
|
||||||
|
vTaskDelay(dauer / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void strinttoip4(std::string ip, int &a, int &b, int &c, int &d) {
|
||||||
|
std::stringstream s(ip);
|
||||||
|
char ch; //to temporarily store the '.'
|
||||||
|
s >> a >> ch >> b >> ch >> c >> ch >> d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void event_handler_neu(void* arg, esp_event_base_t event_base,
|
||||||
|
int32_t event_id, void* event_data)
|
||||||
|
{
|
||||||
|
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
|
||||||
|
blinkstatus(200, 1);
|
||||||
|
esp_wifi_connect();
|
||||||
|
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
|
||||||
|
blinkstatus(200, 5);
|
||||||
|
esp_wifi_connect();
|
||||||
|
s_retry_num++;
|
||||||
|
ESP_LOGI(TAG, "retry to connect to the AP");
|
||||||
|
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
|
||||||
|
blinkstatus(1000, 3);
|
||||||
|
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
|
||||||
|
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
|
||||||
|
s_retry_num = 0;
|
||||||
|
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void initialise_wifi()
|
||||||
|
{
|
||||||
|
s_wifi_event_group = xEventGroupCreate();
|
||||||
|
ESP_ERROR_CHECK(esp_netif_init());
|
||||||
|
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||||
|
esp_netif_create_default_wifi_sta();
|
||||||
|
|
||||||
|
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||||
|
|
||||||
|
esp_event_handler_instance_t instance_any_id;
|
||||||
|
esp_event_handler_instance_t instance_got_ip;
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
|
||||||
|
ESP_EVENT_ANY_ID,
|
||||||
|
&event_handler_neu,
|
||||||
|
NULL,
|
||||||
|
&instance_any_id));
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
|
||||||
|
IP_EVENT_STA_GOT_IP,
|
||||||
|
&event_handler_neu,
|
||||||
|
NULL,
|
||||||
|
&instance_got_ip));
|
||||||
|
|
||||||
|
|
||||||
|
wifi_config_t wifi_config = { };
|
||||||
|
strcpy((char*)wifi_config.sta.ssid, (const char*)ssid.c_str());
|
||||||
|
strcpy((char*)wifi_config.sta.password, (const char*)passphrase.c_str());
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_start() );
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
||||||
|
|
||||||
|
// Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
|
||||||
|
// number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above)
|
||||||
|
EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
|
||||||
|
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
|
||||||
|
pdFALSE,
|
||||||
|
pdFALSE,
|
||||||
|
portMAX_DELAY);
|
||||||
|
|
||||||
|
// xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
|
||||||
|
// happened.
|
||||||
|
if (bits & WIFI_CONNECTED_BIT) {
|
||||||
|
ESP_LOGI(TAG, "connected to ap SSID:%s password:%s",
|
||||||
|
ssid.c_str(), passphrase.c_str());
|
||||||
|
} else if (bits & WIFI_FAIL_BIT) {
|
||||||
|
ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
|
||||||
|
ssid.c_str(), passphrase.c_str());
|
||||||
|
} else {
|
||||||
|
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
||||||
|
}
|
||||||
|
|
||||||
|
// The event will not be processed after unregister
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, instance_got_ip));
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, instance_any_id));
|
||||||
|
vEventGroupDelete(s_wifi_event_group);
|
||||||
|
|
||||||
|
tcpip_adapter_ip_info_t ip_info;
|
||||||
|
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
|
||||||
|
ipaddress = std::string(ip4addr_ntoa(&ip_info.ip));
|
||||||
|
netmask = std::string(ip4addr_ntoa(&ip_info.netmask));
|
||||||
|
gw = std::string(ip4addr_ntoa(&ip_info.gw));
|
||||||
|
printf("IPv4 : %s\n", ip4addr_ntoa(&ip_info.ip));
|
||||||
|
printf("HostName : %s\n", hostname.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void initialise_wifi_fixed_ip2()
|
||||||
|
{
|
||||||
|
s_wifi_event_group = xEventGroupCreate();
|
||||||
|
ESP_ERROR_CHECK(esp_netif_init());
|
||||||
|
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||||
|
esp_netif_t *my_sta = esp_netif_create_default_wifi_sta();
|
||||||
|
|
||||||
|
esp_netif_dhcpc_stop(my_sta);
|
||||||
|
|
||||||
|
esp_netif_ip_info_t ip_info;
|
||||||
|
|
||||||
|
int a, b, c, d;
|
||||||
|
|
||||||
|
strinttoip4(ipaddress, a, b, c, d);
|
||||||
|
IP4_ADDR(&ip_info.ip, a, b, c, d);
|
||||||
|
|
||||||
|
strinttoip4(gw, a, b, c, d);
|
||||||
|
IP4_ADDR(&ip_info.gw, a, b, c, d);
|
||||||
|
|
||||||
|
strinttoip4(netmask, a, b, c, d);
|
||||||
|
IP4_ADDR(&ip_info.netmask, a, b, c, d);
|
||||||
|
|
||||||
|
esp_netif_set_ip_info(my_sta, &ip_info);
|
||||||
|
|
||||||
|
|
||||||
|
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||||
|
|
||||||
|
if (dns.length() > 0) {
|
||||||
|
esp_netif_dns_info_t dns_info;
|
||||||
|
ip4_addr_t ip;
|
||||||
|
ip.addr = esp_ip4addr_aton(dns.c_str());
|
||||||
|
ip_addr_set_ip4_u32(&dns_info.ip, ip.addr);
|
||||||
|
ESP_ERROR_CHECK(esp_netif_set_dns_info(my_sta, ESP_NETIF_DNS_MAIN, &dns_info));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
esp_event_handler_instance_t instance_any_id;
|
||||||
|
esp_event_handler_instance_t instance_got_ip;
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
|
||||||
|
ESP_EVENT_ANY_ID,
|
||||||
|
&event_handler_neu,
|
||||||
|
NULL,
|
||||||
|
&instance_any_id));
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
|
||||||
|
IP_EVENT_STA_GOT_IP,
|
||||||
|
&event_handler_neu,
|
||||||
|
NULL,
|
||||||
|
&instance_got_ip));
|
||||||
|
|
||||||
|
|
||||||
|
wifi_config_t wifi_config = { };
|
||||||
|
strcpy((char*)wifi_config.sta.ssid, (const char*)ssid.c_str());
|
||||||
|
strcpy((char*)wifi_config.sta.password, (const char*)passphrase.c_str());
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_start() );
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
||||||
|
|
||||||
|
// Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
|
||||||
|
// number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above)
|
||||||
|
EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
|
||||||
|
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
|
||||||
|
pdFALSE,
|
||||||
|
pdFALSE,
|
||||||
|
portMAX_DELAY);
|
||||||
|
|
||||||
|
// xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
|
||||||
|
// happened.
|
||||||
|
if (bits & WIFI_CONNECTED_BIT) {
|
||||||
|
ESP_LOGI(TAG, "connected to ap SSID:%s password:%s",
|
||||||
|
ssid.c_str(), passphrase.c_str());
|
||||||
|
} else if (bits & WIFI_FAIL_BIT) {
|
||||||
|
ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
|
||||||
|
ssid.c_str(), passphrase.c_str());
|
||||||
|
} else {
|
||||||
|
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
||||||
|
}
|
||||||
|
|
||||||
|
// The event will not be processed after unregister
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, instance_got_ip));
|
||||||
|
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, instance_any_id));
|
||||||
|
vEventGroupDelete(s_wifi_event_group);
|
||||||
|
|
||||||
|
tcpip_adapter_ip_info_t ip_info2;
|
||||||
|
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info2));
|
||||||
|
ipaddress = std::string(ip4addr_ntoa(&ip_info2.ip));
|
||||||
|
netmask = std::string(ip4addr_ntoa(&ip_info2.netmask));
|
||||||
|
gw = std::string(ip4addr_ntoa(&ip_info2.gw));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectToWLAN()
|
||||||
|
{
|
||||||
|
if (ipaddress.length() == 0 || gw.length() == 0 || netmask.length() == 0)
|
||||||
|
{
|
||||||
|
printf("Connect to WLAN with dyn. IP\n");
|
||||||
|
initialise_wifi();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Connect to WLAN with fixed IP\n");
|
||||||
|
initialise_wifi_fixed_ip2();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ChangeHostName(std::string fn, std::string _newhostname)
|
||||||
|
{
|
||||||
|
if (_newhostname == hostname)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
string line = "";
|
||||||
|
std::vector<string> zerlegt;
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
std::vector<string> neuesfile;
|
||||||
|
|
||||||
|
FILE* pFile;
|
||||||
|
fn = FormatFileName(fn);
|
||||||
|
pFile = OpenFileAndWait(fn.c_str(), "r");
|
||||||
|
|
||||||
|
printf("file loaded\n");
|
||||||
|
|
||||||
|
if (pFile == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char zw[1024];
|
||||||
|
fgets(zw, 1024, pFile);
|
||||||
|
line = std::string(zw);
|
||||||
|
|
||||||
|
while ((line.size() > 0) || !(feof(pFile)))
|
||||||
|
{
|
||||||
|
printf("%s", line.c_str());
|
||||||
|
zerlegt = ZerlegeZeile(line, "=");
|
||||||
|
zerlegt[0] = trim(zerlegt[0], " ");
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
|
||||||
|
line = "hostname = \"" + _newhostname + "\"\n";
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
neuesfile.push_back(line);
|
||||||
|
|
||||||
|
if (fgets(zw, 1024, pFile) == NULL)
|
||||||
|
{
|
||||||
|
line = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
line = std::string(zw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
line = "hostname = \"" + _newhostname + "\"\n";
|
||||||
|
neuesfile.push_back(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(pFile);
|
||||||
|
|
||||||
|
pFile = OpenFileAndWait(fn.c_str(), "w+");
|
||||||
|
|
||||||
|
for (int i = 0; i < neuesfile.size(); ++i)
|
||||||
|
{
|
||||||
|
fputs(neuesfile[i].c_str(), pFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(pFile);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LoadWlanFromFile(std::string fn)
|
||||||
|
{
|
||||||
|
string line = "";
|
||||||
|
std::vector<string> zerlegt;
|
||||||
|
hostname = std_hostname;
|
||||||
|
|
||||||
|
FILE* pFile;
|
||||||
|
fn = FormatFileName(fn);
|
||||||
|
|
||||||
|
pFile = OpenFileAndWait(fn.c_str(), "r");
|
||||||
|
printf("file loaded\n");
|
||||||
|
|
||||||
|
if (pFile == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char zw[1024];
|
||||||
|
fgets(zw, 1024, pFile);
|
||||||
|
line = std::string(zw);
|
||||||
|
|
||||||
|
while ((line.size() > 0) || !(feof(pFile)))
|
||||||
|
{
|
||||||
|
printf("%s", line.c_str());
|
||||||
|
zerlegt = ZerlegeZeile(line, "=");
|
||||||
|
zerlegt[0] = trim(zerlegt[0], " ");
|
||||||
|
for (int i = 2; i < zerlegt.size(); ++i)
|
||||||
|
zerlegt[i] = zerlegt[i-1] + zerlegt[i];
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
|
||||||
|
hostname = trim(zerlegt[1]);
|
||||||
|
if ((hostname[0] == '"') && (hostname[hostname.length()-1] == '"')){
|
||||||
|
hostname = hostname.substr(1, hostname.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){
|
||||||
|
ssid = trim(zerlegt[1]);
|
||||||
|
if ((ssid[0] == '"') && (ssid[ssid.length()-1] == '"')){
|
||||||
|
ssid = ssid.substr(1, ssid.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "PASSWORD")){
|
||||||
|
passphrase = zerlegt[1];
|
||||||
|
if ((passphrase[0] == '"') && (passphrase[passphrase.length()-1] == '"')){
|
||||||
|
passphrase = passphrase.substr(1, passphrase.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){
|
||||||
|
ipaddress = zerlegt[1];
|
||||||
|
if ((ipaddress[0] == '"') && (ipaddress[ipaddress.length()-1] == '"')){
|
||||||
|
ipaddress = ipaddress.substr(1, ipaddress.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){
|
||||||
|
gw = zerlegt[1];
|
||||||
|
if ((gw[0] == '"') && (gw[gw.length()-1] == '"')){
|
||||||
|
gw = gw.substr(1, gw.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){
|
||||||
|
netmask = zerlegt[1];
|
||||||
|
if ((netmask[0] == '"') && (netmask[netmask.length()-1] == '"')){
|
||||||
|
netmask = netmask.substr(1, netmask.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){
|
||||||
|
dns = zerlegt[1];
|
||||||
|
if ((dns[0] == '"') && (dns[dns.length()-1] == '"')){
|
||||||
|
dns = dns.substr(1, dns.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (fgets(zw, 1024, pFile) == NULL)
|
||||||
|
{
|
||||||
|
line = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
line = std::string(zw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(pFile);
|
||||||
|
|
||||||
|
// Check if Hostname was empty in .ini if yes set to std_hostname
|
||||||
|
if(hostname.length() <= 0){
|
||||||
|
hostname = std_hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nWLan: %s, %s\n", ssid.c_str(), passphrase.c_str());
|
||||||
|
printf("Hostename: %s\n", hostname.c_str());
|
||||||
|
printf("Fixed IP: %s, Gateway %s, Netmask %s, DNS %s\n", ipaddress.c_str(), gw.c_str(), netmask.c_str(), dns.c_str());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadNetConfigFromFile(std::string _fn, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns)
|
||||||
|
{
|
||||||
|
string line = "";
|
||||||
|
std::vector<string> zerlegt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FILE* pFile;
|
||||||
|
_fn = FormatFileName(_fn);
|
||||||
|
pFile = OpenFileAndWait(_fn.c_str(), "r");
|
||||||
|
|
||||||
|
if (pFile == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char zw[1024];
|
||||||
|
fgets(zw, 1024, pFile);
|
||||||
|
line = std::string(zw);
|
||||||
|
|
||||||
|
while ((line.size() > 0) || !(feof(pFile)))
|
||||||
|
{
|
||||||
|
printf("%s", line.c_str());
|
||||||
|
zerlegt = ZerlegeZeile(line, "=");
|
||||||
|
zerlegt[0] = trim(zerlegt[0], " ");
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){
|
||||||
|
_ip = zerlegt[1];
|
||||||
|
if ((_ip[0] == '"') && (_ip[_ip.length()-1] == '"')){
|
||||||
|
_ip = _ip.substr(1, _ip.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){
|
||||||
|
_gw = zerlegt[1];
|
||||||
|
if ((_gw[0] == '"') && (_gw[_gw.length()-1] == '"')){
|
||||||
|
_gw = _gw.substr(1, _gw.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){
|
||||||
|
_netmask = zerlegt[1];
|
||||||
|
if ((_netmask[0] == '"') && (_netmask[_netmask.length()-1] == '"')){
|
||||||
|
_netmask = _netmask.substr(1, _netmask.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){
|
||||||
|
_dns = zerlegt[1];
|
||||||
|
if ((_dns[0] == '"') && (_dns[_dns.length()-1] == '"')){
|
||||||
|
_dns = _dns.substr(1, _dns.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fgets(zw, 1024, pFile) == NULL)
|
||||||
|
{
|
||||||
|
line = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
line = std::string(zw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(pFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string getHostname(){
|
||||||
|
return hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getIPAddress(){
|
||||||
|
return ipaddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getSSID(){
|
||||||
|
return ssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getNetMask(){
|
||||||
|
return netmask;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getGW(){
|
||||||
|
return gw;
|
||||||
|
}
|
||||||
|
|
||||||
21
code/components/connect_wlan/connect_wlan._h_
Normal file
21
code/components/connect_wlan/connect_wlan._h_
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
//#ifndef CONNECT_WLAN_H
|
||||||
|
//#define CONNECT_WLAN_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
|
const int CONNECTED_BIT = BIT0;
|
||||||
|
|
||||||
|
void ConnectToWLAN();
|
||||||
|
|
||||||
|
void LoadWlanFromFile(std::string fn);
|
||||||
|
|
||||||
|
bool ChangeHostName(std::string fn, std::string _newhostname);
|
||||||
|
|
||||||
|
std::string getHostname();
|
||||||
|
std::string getIPAddress();
|
||||||
|
std::string getSSID();
|
||||||
|
std::string getNetMask();
|
||||||
|
std::string getGW();
|
||||||
|
|
||||||
|
//#endif
|
||||||
@@ -23,14 +23,13 @@
|
|||||||
|
|
||||||
static const char *MAIN_TAG = "connect_wlan";
|
static const char *MAIN_TAG = "connect_wlan";
|
||||||
|
|
||||||
std::string ssid;
|
std::string ssid = "";
|
||||||
std::string passphrase;
|
std::string passphrase = "";
|
||||||
std::string hostname;
|
std::string hostname = "";
|
||||||
std::string ipaddress;
|
std::string ipaddress = "";
|
||||||
std::string gw;
|
std::string gw = "";
|
||||||
std::string netmask;
|
std::string netmask = "";
|
||||||
std::string dns;
|
std::string dns = "";
|
||||||
|
|
||||||
std::string std_hostname = "watermeter";
|
std::string std_hostname = "watermeter";
|
||||||
|
|
||||||
static EventGroupHandle_t wifi_event_group;
|
static EventGroupHandle_t wifi_event_group;
|
||||||
@@ -76,6 +75,8 @@ void wifi_connect(){
|
|||||||
ESP_ERROR_CHECK( esp_wifi_connect() );
|
ESP_ERROR_CHECK( esp_wifi_connect() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void blinkstatus(int dauer, int _anzahl)
|
void blinkstatus(int dauer, int _anzahl)
|
||||||
{
|
{
|
||||||
gpio_reset_pin(BLINK_GPIO);
|
gpio_reset_pin(BLINK_GPIO);
|
||||||
@@ -111,13 +112,11 @@ static esp_err_t event_handler(void *ctx, system_event_t *event)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _hostname)
|
void initialise_wifi()
|
||||||
{
|
{
|
||||||
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL) );
|
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL) );
|
||||||
wifi_event_group = xEventGroupCreate();
|
wifi_event_group = xEventGroupCreate();
|
||||||
ssid = _ssid;
|
|
||||||
passphrase = _passphrase;
|
|
||||||
hostname = _hostname;
|
|
||||||
esp_log_level_set("wifi", ESP_LOG_NONE); // disable wifi driver logging
|
esp_log_level_set("wifi", ESP_LOG_NONE); // disable wifi driver logging
|
||||||
tcpip_adapter_init();
|
tcpip_adapter_init();
|
||||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||||
@@ -147,14 +146,9 @@ void strinttoip4(std::string ip, int &a, int &b, int &c, int &d) {
|
|||||||
s >> a >> ch >> b >> ch >> c >> ch >> d;
|
s >> a >> ch >> b >> ch >> c >> ch >> d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _netmask, std::string _ssid, std::string _passphrase, std::string _hostname, std::string _dns)
|
void initialise_wifi_fixed_ip()
|
||||||
{
|
{
|
||||||
|
|
||||||
ssid = _ssid;
|
|
||||||
passphrase = _passphrase;
|
|
||||||
hostname = _hostname;
|
|
||||||
dns = _dns;
|
|
||||||
|
|
||||||
wifi_event_group = xEventGroupCreate();
|
wifi_event_group = xEventGroupCreate();
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_netif_init());
|
ESP_ERROR_CHECK(esp_netif_init());
|
||||||
@@ -168,13 +162,13 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net
|
|||||||
|
|
||||||
int a, b, c, d;
|
int a, b, c, d;
|
||||||
|
|
||||||
strinttoip4(_ip, a, b, c, d);
|
strinttoip4(ipaddress, a, b, c, d);
|
||||||
IP4_ADDR(&ip_info.ip, a, b, c, d);
|
IP4_ADDR(&ip_info.ip, a, b, c, d);
|
||||||
|
|
||||||
strinttoip4(_gw, a, b, c, d);
|
strinttoip4(gw, a, b, c, d);
|
||||||
IP4_ADDR(&ip_info.gw, a, b, c, d);
|
IP4_ADDR(&ip_info.gw, a, b, c, d);
|
||||||
|
|
||||||
strinttoip4(_netmask, a, b, c, d);
|
strinttoip4(netmask, a, b, c, d);
|
||||||
IP4_ADDR(&ip_info.netmask, a, b, c, d);
|
IP4_ADDR(&ip_info.netmask, a, b, c, d);
|
||||||
|
|
||||||
esp_netif_set_ip_info(my_sta, &ip_info);
|
esp_netif_set_ip_info(my_sta, &ip_info);
|
||||||
@@ -217,22 +211,207 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net
|
|||||||
netmask = std::string(ip4addr_ntoa(&ip_info2.netmask));
|
netmask = std::string(ip4addr_ntoa(&ip_info2.netmask));
|
||||||
gw = std::string(ip4addr_ntoa(&ip_info2.gw));
|
gw = std::string(ip4addr_ntoa(&ip_info2.gw));
|
||||||
|
|
||||||
vEventGroupDelete(wifi_event_group);
|
// vEventGroupDelete(wifi_event_group);
|
||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns)
|
|
||||||
|
|
||||||
void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname)
|
|
||||||
|
void ConnectToWLAN()
|
||||||
{
|
{
|
||||||
|
if (ipaddress.length() == 0 || gw.length() == 0 || netmask.length() == 0)
|
||||||
|
{
|
||||||
|
printf("Connect to WLAN with dyn. IP\n");
|
||||||
|
initialise_wifi();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Connect to WLAN with fixed IP\n");
|
||||||
|
initialise_wifi_fixed_ip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool ChangeHostName(std::string fn, std::string _newhostname)
|
||||||
|
{
|
||||||
|
if (_newhostname == hostname)
|
||||||
|
return false;
|
||||||
|
|
||||||
string line = "";
|
string line = "";
|
||||||
std::vector<string> zerlegt;
|
std::vector<string> zerlegt;
|
||||||
_hostname = std_hostname;
|
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
std::vector<string> neuesfile;
|
||||||
|
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
fn = FormatFileName(fn);
|
fn = FormatFileName(fn);
|
||||||
pFile = fopen(fn.c_str(), "r");
|
pFile = OpenFileAndWait(fn.c_str(), "r");
|
||||||
|
|
||||||
|
printf("file loaded\n");
|
||||||
|
|
||||||
|
if (pFile == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char zw[1024];
|
||||||
|
fgets(zw, 1024, pFile);
|
||||||
|
line = std::string(zw);
|
||||||
|
|
||||||
|
while ((line.size() > 0) || !(feof(pFile)))
|
||||||
|
{
|
||||||
|
printf("%s", line.c_str());
|
||||||
|
zerlegt = ZerlegeZeile(line, "=");
|
||||||
|
zerlegt[0] = trim(zerlegt[0], " ");
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
|
||||||
|
line = "hostname = \"" + _newhostname + "\"\n";
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
neuesfile.push_back(line);
|
||||||
|
|
||||||
|
if (fgets(zw, 1024, pFile) == NULL)
|
||||||
|
{
|
||||||
|
line = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
line = std::string(zw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
line = "hostname = \"" + _newhostname + "\"\n";
|
||||||
|
neuesfile.push_back(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(pFile);
|
||||||
|
|
||||||
|
pFile = OpenFileAndWait(fn.c_str(), "w+");
|
||||||
|
|
||||||
|
for (int i = 0; i < neuesfile.size(); ++i)
|
||||||
|
{
|
||||||
|
printf(neuesfile[i].c_str());
|
||||||
|
fputs(neuesfile[i].c_str(), pFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(pFile);
|
||||||
|
|
||||||
|
printf("*** Update hostname done ***\n");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LoadWlanFromFile(std::string fn)
|
||||||
|
{
|
||||||
|
string line = "";
|
||||||
|
std::vector<string> zerlegt;
|
||||||
|
hostname = std_hostname;
|
||||||
|
|
||||||
|
FILE* pFile;
|
||||||
|
fn = FormatFileName(fn);
|
||||||
|
|
||||||
|
pFile = OpenFileAndWait(fn.c_str(), "r");
|
||||||
|
printf("file loaded\n");
|
||||||
|
|
||||||
|
if (pFile == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char zw[1024];
|
||||||
|
fgets(zw, 1024, pFile);
|
||||||
|
line = std::string(zw);
|
||||||
|
|
||||||
|
while ((line.size() > 0) || !(feof(pFile)))
|
||||||
|
{
|
||||||
|
printf("%s", line.c_str());
|
||||||
|
zerlegt = ZerlegeZeile(line, "=");
|
||||||
|
zerlegt[0] = trim(zerlegt[0], " ");
|
||||||
|
for (int i = 2; i < zerlegt.size(); ++i)
|
||||||
|
zerlegt[i] = zerlegt[i-1] + zerlegt[i];
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
|
||||||
|
hostname = trim(zerlegt[1]);
|
||||||
|
if ((hostname[0] == '"') && (hostname[hostname.length()-1] == '"')){
|
||||||
|
hostname = hostname.substr(1, hostname.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){
|
||||||
|
ssid = trim(zerlegt[1]);
|
||||||
|
if ((ssid[0] == '"') && (ssid[ssid.length()-1] == '"')){
|
||||||
|
ssid = ssid.substr(1, ssid.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "PASSWORD")){
|
||||||
|
passphrase = zerlegt[1];
|
||||||
|
if ((passphrase[0] == '"') && (passphrase[passphrase.length()-1] == '"')){
|
||||||
|
passphrase = passphrase.substr(1, passphrase.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){
|
||||||
|
ipaddress = zerlegt[1];
|
||||||
|
if ((ipaddress[0] == '"') && (ipaddress[ipaddress.length()-1] == '"')){
|
||||||
|
ipaddress = ipaddress.substr(1, ipaddress.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "GATEWAY")){
|
||||||
|
gw = zerlegt[1];
|
||||||
|
if ((gw[0] == '"') && (gw[gw.length()-1] == '"')){
|
||||||
|
gw = gw.substr(1, gw.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "NETMASK")){
|
||||||
|
netmask = zerlegt[1];
|
||||||
|
if ((netmask[0] == '"') && (netmask[netmask.length()-1] == '"')){
|
||||||
|
netmask = netmask.substr(1, netmask.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "DNS")){
|
||||||
|
dns = zerlegt[1];
|
||||||
|
if ((dns[0] == '"') && (dns[dns.length()-1] == '"')){
|
||||||
|
dns = dns.substr(1, dns.length()-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (fgets(zw, 1024, pFile) == NULL)
|
||||||
|
{
|
||||||
|
line = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
line = std::string(zw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(pFile);
|
||||||
|
|
||||||
|
// Check if Hostname was empty in .ini if yes set to std_hostname
|
||||||
|
if(hostname.length() <= 0){
|
||||||
|
hostname = std_hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nWLan: %s, %s\n", ssid.c_str(), passphrase.c_str());
|
||||||
|
printf("Hostename: %s\n", hostname.c_str());
|
||||||
|
printf("Fixed IP: %s, Gateway %s, Netmask %s, DNS %s\n", ipaddress.c_str(), gw.c_str(), netmask.c_str(), dns.c_str());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadNetConfigFromFile(std::string fn, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns)
|
||||||
|
{
|
||||||
|
string line = "";
|
||||||
|
std::vector<string> zerlegt;
|
||||||
|
|
||||||
|
FILE* pFile;
|
||||||
|
fn = FormatFileName(fn);
|
||||||
|
pFile = OpenFileAndWait(fn.c_str(), "r");
|
||||||
|
|
||||||
printf("file loaded\n");
|
printf("file loaded\n");
|
||||||
|
|
||||||
@@ -249,28 +428,6 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
|
|||||||
zerlegt = ZerlegeZeile(line, "=");
|
zerlegt = ZerlegeZeile(line, "=");
|
||||||
zerlegt[0] = trim(zerlegt[0], " ");
|
zerlegt[0] = trim(zerlegt[0], " ");
|
||||||
|
|
||||||
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
|
|
||||||
_hostname = trim(zerlegt[1]);
|
|
||||||
if ((_hostname[0] == '"') && (_hostname[_hostname.length()-1] == '"')){
|
|
||||||
_hostname = _hostname.substr(1, _hostname.length()-2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "SSID")){
|
|
||||||
_ssid = trim(zerlegt[1]);
|
|
||||||
if ((_ssid[0] == '"') && (_ssid[_ssid.length()-1] == '"')){
|
|
||||||
_ssid = _ssid.substr(1, _ssid.length()-2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "PASSWORD")){
|
|
||||||
_passphrase = zerlegt[1];
|
|
||||||
if ((_passphrase[0] == '"') && (_passphrase[_passphrase.length()-1] == '"')){
|
|
||||||
_passphrase = _passphrase.substr(1, _passphrase.length()-2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){
|
if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "IP")){
|
||||||
_ip = zerlegt[1];
|
_ip = zerlegt[1];
|
||||||
if ((_ip[0] == '"') && (_ip[_ip.length()-1] == '"')){
|
if ((_ip[0] == '"') && (_ip[_ip.length()-1] == '"')){
|
||||||
@@ -298,8 +455,6 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
|
|||||||
_dns = _dns.substr(1, _dns.length()-2);
|
_dns = _dns.substr(1, _dns.length()-2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
if (fgets(zw, 1024, pFile) == NULL)
|
if (fgets(zw, 1024, pFile) == NULL)
|
||||||
{
|
{
|
||||||
@@ -312,11 +467,6 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
|
|||||||
}
|
}
|
||||||
|
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
// Check if Hostname was empty in .ini if yes set to std_hostname
|
|
||||||
if(_hostname.length() <= 0){
|
|
||||||
_hostname = std_hostname;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,11 @@
|
|||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
const int CONNECTED_BIT = BIT0;
|
const int CONNECTED_BIT = BIT0;
|
||||||
|
void ConnectToWLAN();
|
||||||
|
|
||||||
void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _hostname);
|
void LoadWlanFromFile(std::string fn);
|
||||||
void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _netmask, std::string _ssid, std::string _passphrase, std::string _hostname, std::string _dns = "");
|
|
||||||
|
|
||||||
|
bool ChangeHostName(std::string fn, std::string _newhostname);
|
||||||
void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname);
|
|
||||||
void LoadNetConfigFromFile(std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns);
|
|
||||||
|
|
||||||
std::string getHostname();
|
std::string getHostname();
|
||||||
std::string getIPAddress();
|
std::string getIPAddress();
|
||||||
|
|||||||
@@ -750,7 +750,7 @@ static void IRAM_ATTR dma_filter_buffer(size_t buf_idx)
|
|||||||
if(s_state->sensor.pixformat == PIXFORMAT_JPEG) {
|
if(s_state->sensor.pixformat == PIXFORMAT_JPEG) {
|
||||||
uint32_t sig = *((uint32_t *)s_state->fb->buf) & 0xFFFFFF;
|
uint32_t sig = *((uint32_t *)s_state->fb->buf) & 0xFFFFFF;
|
||||||
if(sig != 0xffd8ff) {
|
if(sig != 0xffd8ff) {
|
||||||
ets_printf("bh 0x%08x\n", sig);
|
ESP_LOGD(TAG,"unexpected JPEG signature 0x%08x\n", sig);
|
||||||
s_state->fb->bad = 1;
|
s_state->fb->bad = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <string.h>
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
#include "sccb.h"
|
#include "sccb.h"
|
||||||
@@ -42,6 +43,7 @@ int SCCB_Init(int pin_sda, int pin_scl)
|
|||||||
ESP_LOGI(TAG, "pin_sda %d pin_scl %d\n", pin_sda, pin_scl);
|
ESP_LOGI(TAG, "pin_sda %d pin_scl %d\n", pin_sda, pin_scl);
|
||||||
//log_i("SCCB_Init start");
|
//log_i("SCCB_Init start");
|
||||||
i2c_config_t conf;
|
i2c_config_t conf;
|
||||||
|
memset(&conf, 0, sizeof(i2c_config_t));
|
||||||
conf.mode = I2C_MODE_MASTER;
|
conf.mode = I2C_MODE_MASTER;
|
||||||
conf.sda_io_num = pin_sda;
|
conf.sda_io_num = pin_sda;
|
||||||
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
|
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
// 1. Board setup (Uncomment):
|
// 1. Board setup (Uncomment):
|
||||||
// #define BOARD_WROVER_KIT
|
// #define BOARD_WROVER_KIT
|
||||||
#define BOARD_ESP32CAM_AITHINKER
|
// #define BOARD_ESP32CAM_AITHINKER
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2. Kconfig setup
|
* 2. Kconfig setup
|
||||||
|
|||||||
9
code/components/jomjol_controlGPIO/CMakeLists.txt
Normal file
9
code/components/jomjol_controlGPIO/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
|
||||||
|
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
|
||||||
|
|
||||||
|
idf_component_register(SRCS ${app_sources}
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
REQUIRES esp_http_server jomjol_logfile)
|
||||||
|
|
||||||
|
|
||||||
124
code/components/jomjol_controlGPIO/server_GPIO.cpp
Normal file
124
code/components/jomjol_controlGPIO/server_GPIO.cpp
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
#include <string>
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "esp_system.h"
|
||||||
|
#include "esp_event.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
//#include "errno.h"
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "server_GPIO.h"
|
||||||
|
|
||||||
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
|
#include "Helper.h"
|
||||||
|
|
||||||
|
// #define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
esp_err_t handler_switch_GPIO(httpd_req_t *req)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_switch_GPIO - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LogFile.WriteToFile("handler_switch_GPIO");
|
||||||
|
char _query[200];
|
||||||
|
char _valueGPIO[30];
|
||||||
|
char _valueStatus[30];
|
||||||
|
std::string gpio, status, zw;
|
||||||
|
int gpionum = 0;
|
||||||
|
gpio_num_t gpio_num;
|
||||||
|
|
||||||
|
if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK)
|
||||||
|
{
|
||||||
|
printf("Query: "); printf(_query); printf("\n");
|
||||||
|
|
||||||
|
if (httpd_query_key_value(_query, "GPIO", _valueGPIO, 30) == ESP_OK)
|
||||||
|
{
|
||||||
|
printf("GPIO is found"); printf(_valueGPIO); printf("\n");
|
||||||
|
gpio = std::string(_valueGPIO);
|
||||||
|
}
|
||||||
|
if (httpd_query_key_value(_query, "Status", _valueStatus, 30) == ESP_OK)
|
||||||
|
{
|
||||||
|
printf("Status is found"); printf(_valueStatus); printf("\n");
|
||||||
|
status = std::string(_valueStatus);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
status = toUpper(status);
|
||||||
|
if (!(status == "HIGH") && !(status == "LOW"))
|
||||||
|
{
|
||||||
|
zw = "Status not valid: " + status;;
|
||||||
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpionum = stoi(gpio);
|
||||||
|
|
||||||
|
// frei: 16; 12-15; 2; 4 // nur 12 und 13 funktionieren 2: reboot, 4: BlitzLED, 14/15: DMA für SDKarte ???
|
||||||
|
|
||||||
|
switch (gpionum) {
|
||||||
|
case 12:
|
||||||
|
gpio_num = GPIO_NUM_12;
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
gpio_num = GPIO_NUM_13;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
zw = "GPIO" + std::to_string(gpionum) + " not support - only 12 & 13 free";
|
||||||
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == "HIGH")
|
||||||
|
gpio_set_level(gpio_num, 1);
|
||||||
|
else
|
||||||
|
gpio_set_level(gpio_num, 0);
|
||||||
|
|
||||||
|
|
||||||
|
zw = "GPIO" + std::to_string(gpionum) + " switched to " + status;
|
||||||
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
return ESP_OK;
|
||||||
|
};
|
||||||
|
|
||||||
|
void initGPIO()
|
||||||
|
{
|
||||||
|
gpio_config_t io_conf;
|
||||||
|
//disable interrupt
|
||||||
|
io_conf.intr_type = GPIO_INTR_DISABLE;
|
||||||
|
//set as output mode
|
||||||
|
io_conf.mode = GPIO_MODE_OUTPUT;
|
||||||
|
//bit mask of the pins that you want to set,e.g.GPIO18/19
|
||||||
|
// io_conf.pin_bit_mask = ((1ULL<<GPIO_OUTPUT_IO_0) | (1ULL<<GPIO_OUTPUT_IO_1));
|
||||||
|
// io_conf.pin_bit_mask = ((1ULL << GPIO_NUM_12) | (1ULL << GPIO_NUM_2) | (1ULL << GPIO_NUM_4) | (1ULL << GPIO_NUM_12) | (1ULL << GPIO_NUM_13) | (1ULL << GPIO_NUM_14) | (1ULL << GPIO_NUM_15));
|
||||||
|
io_conf.pin_bit_mask = ((1ULL << GPIO_NUM_12) | (1ULL << GPIO_NUM_13));
|
||||||
|
//disable pull-down mode
|
||||||
|
io_conf.pull_down_en = (gpio_pulldown_t) 0;
|
||||||
|
//disable pull-up mode
|
||||||
|
io_conf.pull_up_en = (gpio_pullup_t) 0;
|
||||||
|
//configure GPIO with the given settings
|
||||||
|
gpio_config(&io_conf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void register_server_GPIO_uri(httpd_handle_t server)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAGPARTGPIO, "server_GPIO - Registering URI handlers");
|
||||||
|
|
||||||
|
httpd_uri_t camuri = { };
|
||||||
|
camuri.method = HTTP_GET;
|
||||||
|
camuri.uri = "/GPIO";
|
||||||
|
camuri.handler = handler_switch_GPIO;
|
||||||
|
camuri.user_ctx = (void*) "switch GPIO";
|
||||||
|
httpd_register_uri_handler(server, &camuri);
|
||||||
|
|
||||||
|
initGPIO();
|
||||||
|
}
|
||||||
10
code/components/jomjol_controlGPIO/server_GPIO.h
Normal file
10
code/components/jomjol_controlGPIO/server_GPIO.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include <esp_log.h>
|
||||||
|
|
||||||
|
#include <esp_http_server.h>
|
||||||
|
|
||||||
|
//#include "ClassControllCamera.h"
|
||||||
|
|
||||||
|
static const char *TAGPARTGPIO = "server_GPIO";
|
||||||
|
|
||||||
|
void register_server_GPIO_uri(httpd_handle_t server);
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "ClassControllCamera.h"
|
#include "ClassControllCamera.h"
|
||||||
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
@@ -6,34 +7,11 @@
|
|||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include "CFindTemplate.h"
|
#include "CImageBasis.h"
|
||||||
|
|
||||||
// #include "camera_define.h"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
#define BOARD_ESP32CAM_AITHINKER
|
#define BOARD_ESP32CAM_AITHINKER
|
||||||
|
|
||||||
/**
|
|
||||||
* 2. Kconfig setup
|
|
||||||
*
|
|
||||||
* If you have a Kconfig file, copy the content from
|
|
||||||
* https://github.com/espressif/esp32-camera/blob/master/Kconfig into it.
|
|
||||||
* In case you haven't, copy and paste this Kconfig file inside the src directory.
|
|
||||||
* This Kconfig file has definitions that allows more control over the camera and
|
|
||||||
* how it will be initialized.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 3. Enable PSRAM on sdkconfig:
|
|
||||||
*
|
|
||||||
* CONFIG_ESP32_SPIRAM_SUPPORT=y
|
|
||||||
*
|
|
||||||
* More info on
|
|
||||||
* https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/kconfig.html#config-esp32-spiram-support
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ================================ CODE ======================================
|
|
||||||
|
|
||||||
#include <esp_event_loop.h>
|
#include <esp_event_loop.h>
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
@@ -47,31 +25,10 @@
|
|||||||
|
|
||||||
#include "esp_camera.h"
|
#include "esp_camera.h"
|
||||||
|
|
||||||
// WROVER-KIT PIN Map
|
// #define DEBUG_DETAIL_ON
|
||||||
#ifdef BOARD_WROVER_KIT
|
|
||||||
|
|
||||||
#define CAM_PIN_PWDN -1 //power down is not used
|
|
||||||
#define CAM_PIN_RESET -1 //software reset will be performed
|
|
||||||
#define CAM_PIN_XCLK 21
|
|
||||||
#define CAM_PIN_SIOD 26
|
|
||||||
#define CAM_PIN_SIOC 27
|
|
||||||
|
|
||||||
#define CAM_PIN_D7 35
|
|
||||||
#define CAM_PIN_D6 34
|
|
||||||
#define CAM_PIN_D5 39
|
|
||||||
#define CAM_PIN_D4 36
|
|
||||||
#define CAM_PIN_D3 19
|
|
||||||
#define CAM_PIN_D2 18
|
|
||||||
#define CAM_PIN_D1 5
|
|
||||||
#define CAM_PIN_D0 4
|
|
||||||
#define CAM_PIN_VSYNC 25
|
|
||||||
#define CAM_PIN_HREF 23
|
|
||||||
#define CAM_PIN_PCLK 22
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ESP32Cam (AiThinker) PIN Map
|
// ESP32Cam (AiThinker) PIN Map
|
||||||
#ifdef BOARD_ESP32CAM_AITHINKER
|
|
||||||
|
|
||||||
#define CAM_PIN_PWDN (gpio_num_t) 32
|
#define CAM_PIN_PWDN (gpio_num_t) 32
|
||||||
#define CAM_PIN_RESET -1 //software reset will be performed
|
#define CAM_PIN_RESET -1 //software reset will be performed
|
||||||
@@ -91,8 +48,6 @@
|
|||||||
#define CAM_PIN_HREF 23
|
#define CAM_PIN_HREF 23
|
||||||
#define CAM_PIN_PCLK 22
|
#define CAM_PIN_PCLK 22
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char *TAG = "example:take_picture";
|
static const char *TAG = "example:take_picture";
|
||||||
|
|
||||||
static camera_config_t camera_config = {
|
static camera_config_t camera_config = {
|
||||||
@@ -115,12 +70,14 @@ static camera_config_t camera_config = {
|
|||||||
.pin_pclk = CAM_PIN_PCLK,
|
.pin_pclk = CAM_PIN_PCLK,
|
||||||
|
|
||||||
//XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
|
//XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
|
||||||
.xclk_freq_hz = 20000000,
|
// .xclk_freq_hz = 20000000, // Orginalwert
|
||||||
|
.xclk_freq_hz = 5000000, // Test, um die Bildfehler los zu werden !!!!
|
||||||
.ledc_timer = LEDC_TIMER_0,
|
.ledc_timer = LEDC_TIMER_0,
|
||||||
.ledc_channel = LEDC_CHANNEL_0,
|
.ledc_channel = LEDC_CHANNEL_0,
|
||||||
|
|
||||||
.pixel_format = PIXFORMAT_JPEG, //YUV422,GRAYSCALE,RGB565,JPEG
|
.pixel_format = PIXFORMAT_JPEG, //YUV422,GRAYSCALE,RGB565,JPEG
|
||||||
.frame_size = FRAMESIZE_UXGA, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG
|
.frame_size = FRAMESIZE_VGA, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG
|
||||||
|
// .frame_size = FRAMESIZE_UXGA, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -128,14 +85,11 @@ static camera_config_t camera_config = {
|
|||||||
.fb_count = 1 //if more than one, i2s runs in continuous mode. Use only with JPEG
|
.fb_count = 1 //if more than one, i2s runs in continuous mode. Use only with JPEG
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "driver/ledc.h"
|
#include "driver/ledc.h"
|
||||||
|
|
||||||
CCamera Camera;
|
CCamera Camera;
|
||||||
|
|
||||||
|
|
||||||
#define FLASH_GPIO GPIO_NUM_4
|
#define FLASH_GPIO GPIO_NUM_4
|
||||||
#define BLINK_GPIO GPIO_NUM_33
|
#define BLINK_GPIO GPIO_NUM_33
|
||||||
|
|
||||||
@@ -145,8 +99,6 @@ typedef struct {
|
|||||||
} jpg_chunking_t;
|
} jpg_chunking_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
#define LEDC_LS_CH2_GPIO (4)
|
#define LEDC_LS_CH2_GPIO (4)
|
||||||
#define LEDC_LS_CH2_CHANNEL LEDC_CHANNEL_2
|
#define LEDC_LS_CH2_CHANNEL LEDC_CHANNEL_2
|
||||||
#define LEDC_LS_TIMER LEDC_TIMER_1
|
#define LEDC_LS_TIMER LEDC_TIMER_1
|
||||||
@@ -172,14 +124,6 @@ void test(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size_t len){
|
static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size_t len){
|
||||||
jpg_chunking_t *j = (jpg_chunking_t *)arg;
|
jpg_chunking_t *j = (jpg_chunking_t *)arg;
|
||||||
if(!index){
|
if(!index){
|
||||||
@@ -192,6 +136,42 @@ static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CCamera::SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
|
if (_brightness > -100)
|
||||||
|
_brightness = min(2, max(-2, _brightness));
|
||||||
|
if (_contrast > -100)
|
||||||
|
_contrast = min(2, max(-2, _contrast));
|
||||||
|
// _saturation = min(2, max(-2, _saturation));
|
||||||
|
|
||||||
|
// s->set_saturation(s, _saturation);
|
||||||
|
if (_contrast > -100)
|
||||||
|
s->set_contrast(s, _contrast);
|
||||||
|
if (_brightness > -100)
|
||||||
|
s->set_brightness(s, _brightness);
|
||||||
|
|
||||||
|
if ((_brightness != brightness) && (_brightness > -100))
|
||||||
|
result = true;
|
||||||
|
if ((_contrast != contrast) && (_contrast > -100))
|
||||||
|
result = true;
|
||||||
|
if ((_saturation != saturation) && (_saturation > -100))
|
||||||
|
result = true;
|
||||||
|
|
||||||
|
if (_brightness > -100)
|
||||||
|
brightness = _brightness;
|
||||||
|
if (_contrast > -100)
|
||||||
|
contrast = _contrast;
|
||||||
|
if (_saturation > -100)
|
||||||
|
saturation = _saturation;
|
||||||
|
|
||||||
|
if (result && isFixedExposure)
|
||||||
|
EnableAutoExposure(waitbeforepicture_org);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCamera::SetQualitySize(int qual, framesize_t resol)
|
void CCamera::SetQualitySize(int qual, framesize_t resol)
|
||||||
{
|
{
|
||||||
@@ -200,15 +180,169 @@ void CCamera::SetQualitySize(int qual, framesize_t resol)
|
|||||||
s->set_framesize(s, resol);
|
s->set_framesize(s, resol);
|
||||||
ActualResolution = resol;
|
ActualResolution = resol;
|
||||||
ActualQuality = qual;
|
ActualQuality = qual;
|
||||||
|
|
||||||
|
if (resol == FRAMESIZE_QVGA)
|
||||||
|
{
|
||||||
|
image_height = 240;
|
||||||
|
image_width = 320;
|
||||||
|
}
|
||||||
|
if (resol == FRAMESIZE_VGA)
|
||||||
|
{
|
||||||
|
image_height = 480;
|
||||||
|
image_width = 640;
|
||||||
|
}
|
||||||
|
// No higher Mode than VGA, damit der Kameraspeicher ausreicht.
|
||||||
|
/*
|
||||||
|
if (resol == FRAMESIZE_SVGA)
|
||||||
|
{
|
||||||
|
image_height = 600;
|
||||||
|
image_width = 800;
|
||||||
|
}
|
||||||
|
if (resol == FRAMESIZE_XGA)
|
||||||
|
{
|
||||||
|
image_height = 768;
|
||||||
|
image_width = 1024;
|
||||||
|
}
|
||||||
|
if (resol == FRAMESIZE_SXGA)
|
||||||
|
{
|
||||||
|
image_height = 1024;
|
||||||
|
image_width = 1280;
|
||||||
|
}
|
||||||
|
if (resol == FRAMESIZE_UXGA)
|
||||||
|
{
|
||||||
|
image_height = 1200;
|
||||||
|
image_width = 1600;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CCamera::EnableAutoExposure(int flashdauer)
|
||||||
|
{
|
||||||
|
LEDOnOff(true);
|
||||||
|
LightOnOff(true);
|
||||||
|
const TickType_t xDelay = flashdauer / portTICK_PERIOD_MS;
|
||||||
|
vTaskDelay( xDelay );
|
||||||
|
|
||||||
|
camera_fb_t * fb = esp_camera_fb_get();
|
||||||
|
if (!fb) {
|
||||||
|
ESP_LOGE(TAGCAMERACLASS, "Camera Capture Failed");
|
||||||
|
}
|
||||||
|
esp_camera_fb_return(fb);
|
||||||
|
|
||||||
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
|
s->set_gain_ctrl(s, 0);
|
||||||
|
s->set_exposure_ctrl(s, 0);
|
||||||
|
|
||||||
|
|
||||||
|
LEDOnOff(false);
|
||||||
|
LightOnOff(false);
|
||||||
|
isFixedExposure = true;
|
||||||
|
waitbeforepicture_org = flashdauer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
||||||
|
{
|
||||||
|
string ftype;
|
||||||
|
|
||||||
|
uint8_t *zwischenspeicher = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
LEDOnOff(true);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (delay > 0)
|
||||||
|
{
|
||||||
|
LightOnOff(true);
|
||||||
|
const TickType_t xDelay = delay / portTICK_PERIOD_MS;
|
||||||
|
vTaskDelay( xDelay );
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After LightOn");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
camera_fb_t * fb = esp_camera_fb_get();
|
||||||
|
if (!fb) {
|
||||||
|
ESP_LOGE(TAGCAMERACLASS, "Camera Capture Failed");
|
||||||
|
LEDOnOff(false);
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _size = fb->len;
|
||||||
|
zwischenspeicher = (uint8_t*) malloc(_size);
|
||||||
|
for (int i = 0; i < _size; ++i)
|
||||||
|
*(zwischenspeicher + i) = *(fb->buf + i);
|
||||||
|
esp_camera_fb_return(fb);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After fb_get");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LEDOnOff(false);
|
||||||
|
|
||||||
|
if (delay > 0)
|
||||||
|
LightOnOff(false);
|
||||||
|
|
||||||
|
// TickType_t xDelay = 1000 / portTICK_PERIOD_MS;
|
||||||
|
// vTaskDelay( xDelay ); // wait for power to recover
|
||||||
|
|
||||||
|
uint8_t * buf = NULL;
|
||||||
|
|
||||||
|
CImageBasis _zwImage;
|
||||||
|
_zwImage.LoadFromMemory(zwischenspeicher, _size);
|
||||||
|
free(zwischenspeicher);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After LoadFromMemory");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
stbi_uc* p_target;
|
||||||
|
stbi_uc* p_source;
|
||||||
|
int channels = 3;
|
||||||
|
int width = image_width;
|
||||||
|
int height = image_height;
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
std::string _zw = "Targetimage: " + std::to_string((int) _Image->rgb_image) + " Size: " + std::to_string(_Image->width) + ", " + std::to_string(_Image->height);
|
||||||
|
_zw = _zw + " _zwImage: " + std::to_string((int) _zwImage.rgb_image) + " Size: " + std::to_string(_zwImage.width) + ", " + std::to_string(_zwImage.height);
|
||||||
|
LogFile.WriteToFile(_zw);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int x = 0; x < width; ++x)
|
||||||
|
for (int y = 0; y < height; ++y)
|
||||||
|
{
|
||||||
|
p_target = _Image->rgb_image + (channels * (y * width + x));
|
||||||
|
p_source = _zwImage.rgb_image + (channels * (y * width + x));
|
||||||
|
p_target[0] = p_source[0];
|
||||||
|
p_target[1] = p_source[1];
|
||||||
|
p_target[2] = p_source[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After Copy To Target");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
free(buf);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t CCamera::CaptureToFile(std::string nm, int delay)
|
esp_err_t CCamera::CaptureToFile(std::string nm, int delay)
|
||||||
{
|
{
|
||||||
// nm = "/sdcard/josef_zw.bmp";
|
|
||||||
string ftype;
|
string ftype;
|
||||||
|
|
||||||
LEDOnOff(true);
|
LEDOnOff(true); // Abgeschaltet, um Strom zu sparen !!!!!!
|
||||||
|
|
||||||
if (delay > 0)
|
if (delay > 0)
|
||||||
{
|
{
|
||||||
@@ -224,13 +358,22 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay)
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
LEDOnOff(false);
|
LEDOnOff(false);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("w %d, h %d, size %d\n", fb->width, fb->height, fb->len);
|
printf("w %d, h %d, size %d\n", fb->width, fb->height, fb->len);
|
||||||
|
#endif
|
||||||
|
|
||||||
nm = FormatFileName(nm);
|
nm = FormatFileName(nm);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Save Camera to : %s\n", nm.c_str());
|
printf("Save Camera to : %s\n", nm.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
ftype = toUpper(getFileType(nm));
|
ftype = toUpper(getFileType(nm));
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Filetype: %s\n", ftype.c_str());
|
printf("Filetype: %s\n", ftype.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t * buf = NULL;
|
uint8_t * buf = NULL;
|
||||||
size_t buf_len = 0;
|
size_t buf_len = 0;
|
||||||
@@ -255,7 +398,7 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE * fp = fopen(nm.c_str(), "wb");
|
FILE * fp = OpenFileAndWait(nm.c_str(), "wb");
|
||||||
if (fp == NULL) /* If an error occurs during the file creation */
|
if (fp == NULL) /* If an error occurs during the file creation */
|
||||||
{
|
{
|
||||||
fprintf(stderr, "fopen() failed for '%s'\n", nm.c_str());
|
fprintf(stderr, "fopen() failed for '%s'\n", nm.c_str());
|
||||||
@@ -286,15 +429,29 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
|
|||||||
size_t fb_len = 0;
|
size_t fb_len = 0;
|
||||||
int64_t fr_start = esp_timer_get_time();
|
int64_t fr_start = esp_timer_get_time();
|
||||||
|
|
||||||
|
|
||||||
|
LEDOnOff(true);
|
||||||
|
|
||||||
|
if (delay > 0)
|
||||||
|
{
|
||||||
|
LightOnOff(true);
|
||||||
|
const TickType_t xDelay = delay / portTICK_PERIOD_MS;
|
||||||
|
vTaskDelay( xDelay );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fb = esp_camera_fb_get();
|
fb = esp_camera_fb_get();
|
||||||
if (!fb) {
|
if (!fb) {
|
||||||
ESP_LOGE(TAGCAMERACLASS, "Camera capture failed");
|
ESP_LOGE(TAGCAMERACLASS, "Camera capture failed");
|
||||||
httpd_resp_send_500(req);
|
httpd_resp_send_500(req);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LEDOnOff(false);
|
||||||
|
|
||||||
res = httpd_resp_set_type(req, "image/jpeg");
|
res = httpd_resp_set_type(req, "image/jpeg");
|
||||||
if(res == ESP_OK){
|
if(res == ESP_OK){
|
||||||
res = httpd_resp_set_hdr(req, "Content-Disposition", "inline; filename=capture.jpg");
|
res = httpd_resp_set_hdr(req, "Content-Disposition", "inline; filename=raw.jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(res == ESP_OK){
|
if(res == ESP_OK){
|
||||||
@@ -312,6 +469,12 @@ esp_err_t CCamera::CaptureToHTTP(httpd_req_t *req, int delay)
|
|||||||
int64_t fr_end = esp_timer_get_time();
|
int64_t fr_end = esp_timer_get_time();
|
||||||
|
|
||||||
ESP_LOGI(TAGCAMERACLASS, "JPG: %uKB %ums", (uint32_t)(fb_len/1024), (uint32_t)((fr_end - fr_start)/1000));
|
ESP_LOGI(TAGCAMERACLASS, "JPG: %uKB %ums", (uint32_t)(fb_len/1024), (uint32_t)((fr_end - fr_start)/1000));
|
||||||
|
|
||||||
|
if (delay > 0)
|
||||||
|
{
|
||||||
|
LightOnOff(false);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,7 +520,9 @@ void CCamera::GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol
|
|||||||
printf("Query: "); printf(_query); printf("\n");
|
printf("Query: "); printf(_query); printf("\n");
|
||||||
if (httpd_query_key_value(_query, "size", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "size", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Size: "); printf(_size); printf("\n");
|
printf("Size: "); printf(_size); printf("\n");
|
||||||
|
#endif
|
||||||
if (strcmp(_size, "QVGA") == 0)
|
if (strcmp(_size, "QVGA") == 0)
|
||||||
resol = FRAMESIZE_QVGA; // 320x240
|
resol = FRAMESIZE_QVGA; // 320x240
|
||||||
if (strcmp(_size, "VGA") == 0)
|
if (strcmp(_size, "VGA") == 0)
|
||||||
@@ -369,11 +534,13 @@ void CCamera::GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol
|
|||||||
if (strcmp(_size, "SXGA") == 0)
|
if (strcmp(_size, "SXGA") == 0)
|
||||||
resol = FRAMESIZE_SXGA; // 1280x1024
|
resol = FRAMESIZE_SXGA; // 1280x1024
|
||||||
if (strcmp(_size, "UXGA") == 0)
|
if (strcmp(_size, "UXGA") == 0)
|
||||||
resol = FRAMESIZE_UXGA; // 1600x1200
|
resol = FRAMESIZE_UXGA; // 1600x1200
|
||||||
}
|
}
|
||||||
if (httpd_query_key_value(_query, "quality", _qual, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "quality", _qual, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Quality: "); printf(_qual); printf("\n");
|
printf("Quality: "); printf(_qual); printf("\n");
|
||||||
|
#endif
|
||||||
qual = atoi(_qual);
|
qual = atoi(_qual);
|
||||||
|
|
||||||
if (qual > 63)
|
if (qual > 63)
|
||||||
@@ -404,13 +571,17 @@ framesize_t CCamera::TextToFramesize(const char * _size)
|
|||||||
|
|
||||||
CCamera::CCamera()
|
CCamera::CCamera()
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("CreateClassCamera\n");
|
printf("CreateClassCamera\n");
|
||||||
|
#endif
|
||||||
|
brightness = -5;
|
||||||
|
contrast = -5;
|
||||||
|
saturation = -5;
|
||||||
|
isFixedExposure = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t CCamera::InitCam()
|
esp_err_t CCamera::InitCam()
|
||||||
{
|
{
|
||||||
printf("Init Flash\n");
|
|
||||||
//power up the camera if PWDN pin is defined
|
|
||||||
if(CAM_PIN_PWDN != -1){
|
if(CAM_PIN_PWDN != -1){
|
||||||
// Init the GPIO
|
// Init the GPIO
|
||||||
gpio_pad_select_gpio(CAM_PIN_PWDN);
|
gpio_pad_select_gpio(CAM_PIN_PWDN);
|
||||||
|
|||||||
@@ -10,20 +10,26 @@
|
|||||||
#include "esp_camera.h"
|
#include "esp_camera.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <esp_http_server.h>
|
#include <esp_http_server.h>
|
||||||
|
#include "CImageBasis.h"
|
||||||
|
|
||||||
|
|
||||||
#define CAMERA_MODEL_AI_THINKER
|
#define CAMERA_MODEL_AI_THINKER
|
||||||
|
|
||||||
|
|
||||||
static const char *TAGCAMERACLASS = "server_part_camera";
|
static const char *TAGCAMERACLASS = "server_part_camera";
|
||||||
|
|
||||||
|
|
||||||
class CCamera {
|
class CCamera {
|
||||||
protected:
|
protected:
|
||||||
int ActualQuality;
|
int ActualQuality;
|
||||||
framesize_t ActualResolution;
|
framesize_t ActualResolution;
|
||||||
|
int brightness, contrast, saturation;
|
||||||
|
bool isFixedExposure;
|
||||||
|
int waitbeforepicture_org;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
int image_height, image_width;
|
||||||
|
|
||||||
CCamera();
|
CCamera();
|
||||||
esp_err_t InitCam();
|
esp_err_t InitCam();
|
||||||
|
|
||||||
@@ -31,17 +37,19 @@ class CCamera {
|
|||||||
void LEDOnOff(bool status);
|
void LEDOnOff(bool status);
|
||||||
esp_err_t CaptureToHTTP(httpd_req_t *req, int delay = 0);
|
esp_err_t CaptureToHTTP(httpd_req_t *req, int delay = 0);
|
||||||
void SetQualitySize(int qual, framesize_t resol);
|
void SetQualitySize(int qual, framesize_t resol);
|
||||||
|
bool SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation);
|
||||||
void GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol);
|
void GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol);
|
||||||
|
|
||||||
|
void EnableAutoExposure(int flashdauer);
|
||||||
|
|
||||||
|
|
||||||
framesize_t TextToFramesize(const char * text);
|
framesize_t TextToFramesize(const char * text);
|
||||||
|
|
||||||
|
|
||||||
esp_err_t CaptureToFile(std::string nm, int delay = 0);
|
esp_err_t CaptureToFile(std::string nm, int delay = 0);
|
||||||
|
esp_err_t CaptureToBasisImage(CImageBasis *_Image, int delay = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern CCamera Camera;
|
extern CCamera Camera;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -11,6 +11,9 @@
|
|||||||
#define SCRATCH_BUFSIZE2 8192
|
#define SCRATCH_BUFSIZE2 8192
|
||||||
char scratch2[SCRATCH_BUFSIZE2];
|
char scratch2[SCRATCH_BUFSIZE2];
|
||||||
|
|
||||||
|
//#define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PowerResetCamera(){
|
void PowerResetCamera(){
|
||||||
ESP_LOGD(TAGPARTCAMERA, "Resetting camera by power down line");
|
ESP_LOGD(TAGPARTCAMERA, "Resetting camera by power down line");
|
||||||
@@ -29,43 +32,72 @@ void PowerResetCamera(){
|
|||||||
|
|
||||||
esp_err_t handler_lightOn(httpd_req_t *req)
|
esp_err_t handler_lightOn(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_lightOn");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_lightOn - Start");
|
||||||
printf("handler_lightOn uri:\n"); printf(req->uri); printf("\n");
|
printf("handler_lightOn uri:\n"); printf(req->uri); printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
Camera.LightOnOff(true);
|
Camera.LightOnOff(true);
|
||||||
const char* resp_str = (const char*) req->user_ctx;
|
const char* resp_str = (const char*) req->user_ctx;
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_lightOn - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
esp_err_t handler_lightOff(httpd_req_t *req)
|
esp_err_t handler_lightOff(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_lightOff");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_lightOff - Start");
|
||||||
printf("handler_lightOff uri:\n"); printf(req->uri); printf("\n");
|
printf("handler_lightOff uri:\n"); printf(req->uri); printf("\n");
|
||||||
|
#endif
|
||||||
Camera.LightOnOff(false);
|
Camera.LightOnOff(false);
|
||||||
const char* resp_str = (const char*) req->user_ctx;
|
const char* resp_str = (const char*) req->user_ctx;
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_lightOff - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
esp_err_t handler_capture(httpd_req_t *req)
|
esp_err_t handler_capture(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_capture");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_capture - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
int quality;
|
int quality;
|
||||||
framesize_t res;
|
framesize_t res;
|
||||||
|
|
||||||
Camera.GetCameraParameter(req, quality, res);
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Size: %d", res); printf(" Quality: %d\n", quality);
|
printf("Size: %d", res); printf(" Quality: %d\n", quality);
|
||||||
|
#endif
|
||||||
|
|
||||||
Camera.SetQualitySize(quality, res);
|
Camera.SetQualitySize(quality, res);
|
||||||
|
|
||||||
esp_err_t ressult;
|
esp_err_t ressult;
|
||||||
ressult = Camera.CaptureToHTTP(req);
|
ressult = Camera.CaptureToHTTP(req);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_capture - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ressult;
|
return ressult;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_capture_with_ligth(httpd_req_t *req)
|
esp_err_t handler_capture_with_ligth(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_capture_with_ligth");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
|
||||||
|
#endif
|
||||||
char _query[100];
|
char _query[100];
|
||||||
char _delay[10];
|
char _delay[10];
|
||||||
|
|
||||||
@@ -78,7 +110,9 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
|
|||||||
printf("Query: "); printf(_query); printf("\n");
|
printf("Query: "); printf(_query); printf("\n");
|
||||||
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
printf("Delay: "); printf(_delay); printf("\n");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
printf("Delay: "); printf(_delay); printf("\n");
|
||||||
|
#endif
|
||||||
delay = atoi(_delay);
|
delay = atoi(_delay);
|
||||||
|
|
||||||
if (delay < 0)
|
if (delay < 0)
|
||||||
@@ -87,9 +121,12 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
|
|||||||
};
|
};
|
||||||
|
|
||||||
Camera.GetCameraParameter(req, quality, res);
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
printf("Size: %d", res); printf(" Quality: %d\n", quality);
|
|
||||||
Camera.SetQualitySize(quality, res);
|
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
printf("Size: %d", res); printf(" Quality: %d\n", quality);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Camera.SetQualitySize(quality, res);
|
||||||
Camera.LightOnOff(true);
|
Camera.LightOnOff(true);
|
||||||
const TickType_t xDelay = delay / portTICK_PERIOD_MS;
|
const TickType_t xDelay = delay / portTICK_PERIOD_MS;
|
||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
@@ -98,7 +135,11 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
|
|||||||
ressult = Camera.CaptureToHTTP(req);
|
ressult = Camera.CaptureToHTTP(req);
|
||||||
|
|
||||||
Camera.LightOnOff(false);
|
Camera.LightOnOff(false);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_capture_with_ligth - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ressult;
|
return ressult;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,7 +147,10 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
|
|||||||
|
|
||||||
esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_capture_save_to_file");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_capture_save_to_file - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
char _query[100];
|
char _query[100];
|
||||||
char _delay[10];
|
char _delay[10];
|
||||||
int delay = 0;
|
int delay = 0;
|
||||||
@@ -123,14 +167,18 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
|||||||
if (httpd_query_key_value(_query, "filename", filename, 100) == ESP_OK)
|
if (httpd_query_key_value(_query, "filename", filename, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
fn.append(filename);
|
fn.append(filename);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Filename: "); printf(fn.c_str()); printf("\n");
|
printf("Filename: "); printf(fn.c_str()); printf("\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fn.append("noname.jpg");
|
fn.append("noname.jpg");
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Delay: "); printf(_delay); printf("\n");
|
printf("Delay: "); printf(_delay); printf("\n");
|
||||||
|
#endif
|
||||||
delay = atoi(_delay);
|
delay = atoi(_delay);
|
||||||
|
|
||||||
if (delay < 0)
|
if (delay < 0)
|
||||||
@@ -142,7 +190,9 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
|||||||
fn.append("noname.jpg");
|
fn.append("noname.jpg");
|
||||||
|
|
||||||
Camera.GetCameraParameter(req, quality, res);
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Size: %d", res); printf(" Quality: %d\n", quality);
|
printf("Size: %d", res); printf(" Quality: %d\n", quality);
|
||||||
|
#endif
|
||||||
Camera.SetQualitySize(quality, res);
|
Camera.SetQualitySize(quality, res);
|
||||||
|
|
||||||
esp_err_t ressult;
|
esp_err_t ressult;
|
||||||
@@ -151,6 +201,10 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
|||||||
const char* resp_str = (const char*) fn.c_str();
|
const char* resp_str = (const char*) fn.c_str();
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_capture_save_to_file - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ressult;
|
return ressult;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -158,8 +212,10 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
|||||||
|
|
||||||
void register_server_camera_uri(httpd_handle_t server)
|
void register_server_camera_uri(httpd_handle_t server)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
ESP_LOGI(TAGPARTCAMERA, "server_part_camera - Registering URI handlers");
|
ESP_LOGI(TAGPARTCAMERA, "server_part_camera - Registering URI handlers");
|
||||||
|
#endif
|
||||||
|
|
||||||
httpd_uri_t camuri = { };
|
httpd_uri_t camuri = { };
|
||||||
camuri.method = HTTP_GET;
|
camuri.method = HTTP_GET;
|
||||||
|
|
||||||
|
|||||||
@@ -65,21 +65,6 @@ static esp_err_t index_html_get_handler(httpd_req_t *req)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handler to respond with an icon file embedded in flash.
|
|
||||||
* Browsers expect to GET website icon at URI /favicon.ico.
|
|
||||||
* This can be overridden by uploading file with same name */
|
|
||||||
static esp_err_t favicon_get_handler(httpd_req_t *req)
|
|
||||||
{
|
|
||||||
extern const unsigned char favicon_ico_start[] asm("_binary_favicon_ico_start");
|
|
||||||
extern const unsigned char favicon_ico_end[] asm("_binary_favicon_ico_end");
|
|
||||||
const size_t favicon_ico_size = (favicon_ico_end - favicon_ico_start);
|
|
||||||
httpd_resp_set_type(req, "image/x-icon");
|
|
||||||
httpd_resp_send(req, (const char *)favicon_ico_start, favicon_ico_size);
|
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Send HTTP response with a run-time generated html consisting of
|
/* Send HTTP response with a run-time generated html consisting of
|
||||||
* a list of all files and folders under the requested path.
|
* a list of all files and folders under the requested path.
|
||||||
* In case of SPIFFS this returns empty list when path is any
|
* In case of SPIFFS this returns empty list when path is any
|
||||||
@@ -121,7 +106,7 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
|
|||||||
|
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
if (!readonly) {
|
if (!readonly) {
|
||||||
FILE *fd = fopen("/sdcard/html/upload_script.html", "r");
|
FILE *fd = OpenFileAndWait("/sdcard/html/upload_script.html", "r");
|
||||||
char *chunk = ((struct file_server_data *)req->user_ctx)->scratch;
|
char *chunk = ((struct file_server_data *)req->user_ctx)->scratch;
|
||||||
size_t chunksize;
|
size_t chunksize;
|
||||||
do {
|
do {
|
||||||
@@ -231,7 +216,7 @@ static esp_err_t logfileact_get_handler(httpd_req_t *req)
|
|||||||
std::string currentfilename = LogFile.GetCurrentFileName();
|
std::string currentfilename = LogFile.GetCurrentFileName();
|
||||||
|
|
||||||
|
|
||||||
fd = fopen(currentfilename.c_str(), "r");
|
fd = OpenFileAndWait(currentfilename.c_str(), "r");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
ESP_LOGE(TAG, "Failed to read existing file : %s", filepath);
|
ESP_LOGE(TAG, "Failed to read existing file : %s", filepath);
|
||||||
/* Respond with 500 Internal Server Error */
|
/* Respond with 500 Internal Server Error */
|
||||||
@@ -337,7 +322,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = fopen(filepath, "r");
|
fd = OpenFileAndWait(filepath, "r");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
ESP_LOGE(TAG, "Failed to read existing file : %s", filepath);
|
ESP_LOGE(TAG, "Failed to read existing file : %s", filepath);
|
||||||
/* Respond with 500 Internal Server Error */
|
/* Respond with 500 Internal Server Error */
|
||||||
@@ -424,7 +409,7 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = fopen(filepath, "w");
|
fd = OpenFileAndWait(filepath, "w");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
ESP_LOGE(TAG, "Failed to create file : %s", filepath);
|
ESP_LOGE(TAG, "Failed to create file : %s", filepath);
|
||||||
/* Respond with 500 Internal Server Error */
|
/* Respond with 500 Internal Server Error */
|
||||||
@@ -710,7 +695,7 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
|
|||||||
zw = std::string(archive_filename);
|
zw = std::string(archive_filename);
|
||||||
zw = _target_directory + zw;
|
zw = _target_directory + zw;
|
||||||
printf("Filename to extract: %s", zw.c_str());
|
printf("Filename to extract: %s", zw.c_str());
|
||||||
FILE* fpTargetFile = fopen(zw.c_str(), "wb");
|
FILE* fpTargetFile = OpenFileAndWait(zw.c_str(), "wb");
|
||||||
fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
|
fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
|
||||||
fclose(fpTargetFile);
|
fclose(fpTargetFile);
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#include "Helper.h"
|
||||||
|
|
||||||
#include "esp_http_server.h"
|
#include "esp_http_server.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -23,9 +25,9 @@ char scratch[SCRATCH_BUFSIZE];
|
|||||||
(strcasecmp(&filename[strlen(filename) - sizeof(ext) + 1], ext) == 0)
|
(strcasecmp(&filename[strlen(filename) - sizeof(ext) + 1], ext) == 0)
|
||||||
|
|
||||||
|
|
||||||
esp_err_t send_file(httpd_req_t *req, std::string filename, struct stat * file_stat)
|
esp_err_t send_file(httpd_req_t *req, std::string filename)
|
||||||
{
|
{
|
||||||
FILE *fd = fopen(filename.c_str(), "r");
|
FILE *fd = OpenFileAndWait(filename.c_str(), "r");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
ESP_LOGE(TAG, "Failed to read existing file : %s", filename.c_str());
|
ESP_LOGE(TAG, "Failed to read existing file : %s", filename.c_str());
|
||||||
/* Respond with 500 Internal Server Error */
|
/* Respond with 500 Internal Server Error */
|
||||||
@@ -33,7 +35,7 @@ esp_err_t send_file(httpd_req_t *req, std::string filename, struct stat * file_
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Sending file : %s (%ld bytes)...", filename.c_str(), file_stat->st_size);
|
ESP_LOGI(TAG, "Sending file : %s ...", filename.c_str());
|
||||||
set_content_type_from_file(req, filename.c_str());
|
set_content_type_from_file(req, filename.c_str());
|
||||||
|
|
||||||
/* Retrieve the pointer to scratch buffer for temporary storage */
|
/* Retrieve the pointer to scratch buffer for temporary storage */
|
||||||
@@ -65,6 +67,7 @@ esp_err_t send_file(httpd_req_t *req, std::string filename, struct stat * file_
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Copies the full path into destination buffer and returns
|
/* Copies the full path into destination buffer and returns
|
||||||
* pointer to path (skipping the preceding base path) */
|
* pointer to path (skipping the preceding base path) */
|
||||||
const char* get_path_from_uri(char *dest, const char *base_path, const char *uri, size_t destsize)
|
const char* get_path_from_uri(char *dest, const char *base_path, const char *uri, size_t destsize)
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
const char* get_path_from_uri(char *dest, const char *base_path, const char *uri, size_t destsize);
|
const char* get_path_from_uri(char *dest, const char *base_path, const char *uri, size_t destsize);
|
||||||
|
|
||||||
esp_err_t send_file(httpd_req_t *req, std::string filename, struct stat * file_stat);
|
esp_err_t send_file(httpd_req_t *req, std::string filename);
|
||||||
|
|
||||||
esp_err_t set_content_type_from_file(httpd_req_t *req, const char *filename);
|
esp_err_t set_content_type_from_file(httpd_req_t *req, const char *filename);
|
||||||
@@ -31,6 +31,10 @@
|
|||||||
|
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
|
#include "Helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
// #define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
#define BUFFSIZE 1024
|
#define BUFFSIZE 1024
|
||||||
@@ -89,7 +93,7 @@ static bool ota_example_task(std::string fn)
|
|||||||
|
|
||||||
int data_read;
|
int data_read;
|
||||||
|
|
||||||
FILE* f = fopen(fn.c_str(), "rb"); // vorher nur "r"
|
FILE* f = OpenFileAndWait(fn.c_str(), "rb"); // vorher nur "r"
|
||||||
data_read = fread(ota_write_data, 1, BUFFSIZE, f);
|
data_read = fread(ota_write_data, 1, BUFFSIZE, f);
|
||||||
|
|
||||||
while (data_read > 0) {
|
while (data_read > 0) {
|
||||||
@@ -301,6 +305,10 @@ void CheckOTAUpdate(void)
|
|||||||
|
|
||||||
esp_err_t handler_ota_update(httpd_req_t *req)
|
esp_err_t handler_ota_update(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_ota_update - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
LogFile.WriteToFile("handler_ota_update");
|
LogFile.WriteToFile("handler_ota_update");
|
||||||
char _query[200];
|
char _query[200];
|
||||||
char _filename[30];
|
char _filename[30];
|
||||||
@@ -376,7 +384,11 @@ esp_err_t handler_ota_update(httpd_req_t *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_ota_update - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -412,6 +424,10 @@ void doReboot(){
|
|||||||
|
|
||||||
esp_err_t handler_reboot(httpd_req_t *req)
|
esp_err_t handler_reboot(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_reboot - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
LogFile.WriteToFile("handler_reboot");
|
LogFile.WriteToFile("handler_reboot");
|
||||||
ESP_LOGI(TAGPARTOTA, "!!! System will restart within 5 sec!!!");
|
ESP_LOGI(TAGPARTOTA, "!!! System will restart within 5 sec!!!");
|
||||||
const char* resp_str = "!!! System will restart within 5 sec!!!";
|
const char* resp_str = "!!! System will restart within 5 sec!!!";
|
||||||
@@ -419,6 +435,10 @@ esp_err_t handler_reboot(httpd_req_t *req)
|
|||||||
|
|
||||||
doReboot();
|
doReboot();
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_reboot - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,6 @@ static const char *TAGPARTOTA = "server_ota";
|
|||||||
|
|
||||||
void register_server_ota_sdcard_uri(httpd_handle_t server);
|
void register_server_ota_sdcard_uri(httpd_handle_t server);
|
||||||
void CheckOTAUpdate();
|
void CheckOTAUpdate();
|
||||||
void doReboot();
|
void doReboot();
|
||||||
|
void hard_restart();
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
|
|||||||
|
|
||||||
idf_component_register(SRCS ${app_sources}
|
idf_component_register(SRCS ${app_sources}
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
REQUIRES jomjol_tfliteclass jomjol_helper jomjol_controlcamera jomjol_mqtt jomjol_fileserver_ota)
|
REQUIRES jomjol_tfliteclass jomjol_helper jomjol_controlcamera jomjol_mqtt jomjol_fileserver_ota jomjol_image_proc connect_wlan)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,12 @@
|
|||||||
void ClassFlow::SetInitialParameter(void)
|
void ClassFlow::SetInitialParameter(void)
|
||||||
{
|
{
|
||||||
ListFlowControll = NULL;
|
ListFlowControll = NULL;
|
||||||
|
previousElement = NULL;
|
||||||
|
disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//std::vector<string> ClassFlow::ZerlegeZeile(std::string input, std::string delimiter);
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<string> ClassFlow::ZerlegeZeile(std::string input, std::string delimiter)
|
std::vector<string> ClassFlow::ZerlegeZeile(std::string input, std::string delimiter)
|
||||||
{
|
{
|
||||||
@@ -37,16 +40,18 @@ std::vector<string> ClassFlow::ZerlegeZeile(std::string input, std::string delim
|
|||||||
|
|
||||||
bool ClassFlow::isNewParagraph(string input)
|
bool ClassFlow::isNewParagraph(string input)
|
||||||
{
|
{
|
||||||
if (input[0] == '[')
|
if ((input[0] == '[') || ((input[0] == ';') && (input[1] == '[')))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClassFlow::GetNextParagraph(FILE* pfile, string& aktparamgraph)
|
bool ClassFlow::GetNextParagraph(FILE* pfile, string& aktparamgraph)
|
||||||
{
|
{
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph));
|
while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
|
||||||
|
|
||||||
if (this->isNewParagraph(aktparamgraph))
|
if (isNewParagraph(aktparamgraph))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -55,7 +60,6 @@ bool ClassFlow::GetNextParagraph(FILE* pfile, string& aktparamgraph)
|
|||||||
ClassFlow::ClassFlow(void)
|
ClassFlow::ClassFlow(void)
|
||||||
{
|
{
|
||||||
SetInitialParameter();
|
SetInitialParameter();
|
||||||
ListFlowControll = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc)
|
ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc)
|
||||||
@@ -64,6 +68,13 @@ ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc)
|
|||||||
ListFlowControll = lfc;
|
ListFlowControll = lfc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClassFlow::ClassFlow(std::vector<ClassFlow*> * lfc, ClassFlow *_prev)
|
||||||
|
{
|
||||||
|
SetInitialParameter();
|
||||||
|
ListFlowControll = lfc;
|
||||||
|
previousElement = _prev;
|
||||||
|
}
|
||||||
|
|
||||||
bool ClassFlow::ReadParameter(FILE* pfile, string &aktparamgraph)
|
bool ClassFlow::ReadParameter(FILE* pfile, string &aktparamgraph)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -100,7 +111,7 @@ bool ClassFlow::getNextLine(FILE* pfile, string *rt)
|
|||||||
}
|
}
|
||||||
*rt = zw;
|
*rt = zw;
|
||||||
*rt = trim(*rt);
|
*rt = trim(*rt);
|
||||||
while (zw[0] == '#' || (rt->size() == 0)) // Kommentarzeilen und Leerzeilen überspringen
|
while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
|
||||||
{
|
{
|
||||||
fgets(zw, 1024, pfile);
|
fgets(zw, 1024, pfile);
|
||||||
printf("%s", zw);
|
printf("%s", zw);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include "CFindTemplate.h"
|
#include "CImageBasis.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -16,7 +16,10 @@ using namespace std;
|
|||||||
struct HTMLInfo
|
struct HTMLInfo
|
||||||
{
|
{
|
||||||
float val;
|
float val;
|
||||||
|
CImageBasis *image = NULL;
|
||||||
|
CImageBasis *image_org = NULL;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
std::string filename_org;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -24,18 +27,23 @@ class ClassFlow
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
// std::vector<string> ZerlegeZeile(string input);
|
// std::vector<string> ZerlegeZeile(string input);
|
||||||
std::vector<string> ZerlegeZeile(string input, string delimiter = " =, ");
|
std::vector<string> ZerlegeZeile(string input, string delimiter = " =, \t");
|
||||||
bool isNewParagraph(string input);
|
bool isNewParagraph(string input);
|
||||||
bool GetNextParagraph(FILE* pfile, string& aktparamgraph);
|
bool GetNextParagraph(FILE* pfile, string& aktparamgraph);
|
||||||
bool getNextLine(FILE* pfile, string* rt);
|
bool getNextLine(FILE* pfile, string* rt);
|
||||||
|
|
||||||
std::vector<ClassFlow*>* ListFlowControll;
|
std::vector<ClassFlow*>* ListFlowControll;
|
||||||
|
ClassFlow *previousElement;
|
||||||
|
|
||||||
virtual void SetInitialParameter(void);
|
virtual void SetInitialParameter(void);
|
||||||
|
|
||||||
|
bool disabled;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClassFlow(void);
|
ClassFlow(void);
|
||||||
ClassFlow(std::vector<ClassFlow*> * lfc);
|
ClassFlow(std::vector<ClassFlow*> * lfc);
|
||||||
|
ClassFlow(std::vector<ClassFlow*> * lfc, ClassFlow *_prev);
|
||||||
|
|
||||||
virtual bool ReadParameter(FILE* pfile, string &aktparamgraph);
|
virtual bool ReadParameter(FILE* pfile, string &aktparamgraph);
|
||||||
virtual bool doFlow(string time);
|
virtual bool doFlow(string time);
|
||||||
virtual string getHTMLSingleStep(string host);
|
virtual string getHTMLSingleStep(string host);
|
||||||
|
|||||||
@@ -1,32 +1,64 @@
|
|||||||
#include "ClassFlowAlignment.h"
|
#include "ClassFlowAlignment.h"
|
||||||
|
#include "ClassFlowMakeImage.h"
|
||||||
|
#include "ClassFlow.h"
|
||||||
|
|
||||||
|
#include "CRotateImage.h"
|
||||||
|
|
||||||
|
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
ClassFlowAlignment::ClassFlowAlignment()
|
|
||||||
|
|
||||||
|
bool AlignmentExtendedDebugging = true;
|
||||||
|
|
||||||
|
// #define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
|
void ClassFlowAlignment::SetInitialParameter(void)
|
||||||
{
|
{
|
||||||
initalrotate = 0;
|
initalrotate = 0;
|
||||||
anz_ref = 0;
|
anz_ref = 0;
|
||||||
suchex = 40;
|
|
||||||
suchey = 40;
|
|
||||||
initialmirror = false;
|
initialmirror = false;
|
||||||
|
SaveAllFiles = false;
|
||||||
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
||||||
|
FileStoreRefAlignment = "/sdcard/config/align.txt";
|
||||||
ListFlowControll = NULL;
|
ListFlowControll = NULL;
|
||||||
|
AlignAndCutImage = NULL;
|
||||||
|
ImageBasis = NULL;
|
||||||
|
ImageTMP = NULL;
|
||||||
|
previousElement = NULL;
|
||||||
|
disabled = false;
|
||||||
|
SAD_criteria = 0.05;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassFlowAlignment::ClassFlowAlignment(std::vector<ClassFlow*>* lfc)
|
ClassFlowAlignment::ClassFlowAlignment(std::vector<ClassFlow*>* lfc)
|
||||||
{
|
{
|
||||||
initalrotate = 0;
|
SetInitialParameter();
|
||||||
anz_ref = 0;
|
|
||||||
suchex = 40;
|
|
||||||
suchey = 40;
|
|
||||||
initialmirror = false;
|
|
||||||
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
|
||||||
ListFlowControll = lfc;
|
ListFlowControll = lfc;
|
||||||
|
|
||||||
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
||||||
|
{
|
||||||
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowMakeImage") == 0)
|
||||||
|
{
|
||||||
|
ImageBasis = ((ClassFlowMakeImage*) (*ListFlowControll)[i])->rawImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ImageBasis) // die Funktion Bilder aufnehmen existiert nicht --> muss erst erzeugt werden NUR ZU TESTZWECKEN
|
||||||
|
{
|
||||||
|
if (AlignmentExtendedDebugging) printf("CImageBasis musste erzeugt werden\n");
|
||||||
|
ImageBasis = new CImageBasis(namerawimage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
|
bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||||
{
|
{
|
||||||
std::vector<string> zerlegt;
|
std::vector<string> zerlegt;
|
||||||
|
int suchex = 40;
|
||||||
|
int suchey = 40;
|
||||||
|
int alg_algo = 0;
|
||||||
|
|
||||||
|
|
||||||
aktparamgraph = trim(aktparamgraph);
|
aktparamgraph = trim(aktparamgraph);
|
||||||
|
|
||||||
@@ -39,32 +71,64 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
zerlegt = ZerlegeZeile(aktparamgraph);
|
||||||
if ((zerlegt[0] == "InitialMirror") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "INITIALMIRROR") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
if (toUpper(zerlegt[1]) == "TRUE")
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
initialmirror = true;
|
initialmirror = true;
|
||||||
}
|
}
|
||||||
if (((zerlegt[0] == "InitalRotate") || (zerlegt[0] == "InitialRotate")) && (zerlegt.size() > 1))
|
if (((toUpper(zerlegt[0]) == "INITALROTATE") || (toUpper(zerlegt[0]) == "INITIALROTATE")) && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
this->initalrotate = std::stod(zerlegt[1]);
|
this->initalrotate = std::stod(zerlegt[1]);
|
||||||
}
|
}
|
||||||
if ((zerlegt[0] == "SearchFieldX") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "SEARCHFIELDX") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
this->suchex = std::stod(zerlegt[1]);
|
suchex = std::stod(zerlegt[1]);
|
||||||
}
|
}
|
||||||
if ((zerlegt[0] == "SearchFieldY") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "SEARCHFIELDY") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
this->suchey = std::stod(zerlegt[1]);
|
suchey = std::stod(zerlegt[1]);
|
||||||
}
|
}
|
||||||
if ((zerlegt.size() == 3) && (anz_ref < 2))
|
if ((zerlegt.size() == 3) && (anz_ref < 2))
|
||||||
{
|
{
|
||||||
this->reffilename[anz_ref] = FormatFileName("/sdcard" + zerlegt[0]);
|
References[anz_ref].image_file = FormatFileName("/sdcard" + zerlegt[0]);
|
||||||
this->ref_x[anz_ref] = std::stod(zerlegt[1]);
|
References[anz_ref].target_x = std::stod(zerlegt[1]);
|
||||||
this->ref_y[anz_ref] = std::stod(zerlegt[2]);
|
References[anz_ref].target_y = std::stod(zerlegt[2]);
|
||||||
anz_ref++;
|
anz_ref++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "SAVEALLFILES") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
|
SaveAllFiles = true;
|
||||||
|
}
|
||||||
|
if ((toUpper(zerlegt[0]) == "ALIGNMENTALGO") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
std::string zw2 = "Alignmentmodus gewählt: " + zerlegt[1];
|
||||||
|
LogFile.WriteToFile(zw2);
|
||||||
|
#endif
|
||||||
|
if (toUpper(zerlegt[1]) == "HIGHACCURACY")
|
||||||
|
alg_algo = 1;
|
||||||
|
if (toUpper(zerlegt[1]) == "FAST")
|
||||||
|
alg_algo = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = "Alignmentmodus geschrieben: " + std::to_string(alg_algo);
|
||||||
|
LogFile.WriteToFile(zw2);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadReferenceAlignmentValues();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -80,72 +144,180 @@ string ClassFlowAlignment::getHTMLSingleStep(string host)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ClassFlowAlignment::doFlow(string time)
|
bool ClassFlowAlignment::doFlow(string time)
|
||||||
{
|
{
|
||||||
string input = namerawimage;
|
if (!ImageTMP)
|
||||||
string output = "/sdcard/img_tmp/rot.jpg";
|
ImageTMP = new CImageBasis(ImageBasis, 5);
|
||||||
string output3 = "/sdcard/img_tmp/rot_roi.jpg";
|
|
||||||
string output2 = "/sdcard/img_tmp/alg.jpg";
|
|
||||||
string output4 = "/sdcard/img_tmp/alg_roi.jpg";
|
|
||||||
string output1 = "/sdcard/img_tmp/mirror.jpg";
|
|
||||||
|
|
||||||
input = FormatFileName(input);
|
if (AlignAndCutImage)
|
||||||
output = FormatFileName(output);
|
delete AlignAndCutImage;
|
||||||
output2 = FormatFileName(output2);
|
AlignAndCutImage = new CAlignAndCutImage(ImageBasis, ImageTMP);
|
||||||
|
|
||||||
|
CRotateImage rt(AlignAndCutImage, ImageTMP);
|
||||||
|
|
||||||
if (initialmirror){
|
if (initialmirror){
|
||||||
CRotate *rt;
|
|
||||||
rt = new CRotate(input);
|
|
||||||
if (!rt->ImageOkay()){
|
|
||||||
LogFile.WriteToFile("ClassFlowAlignment::doFlow CRotate Inital Mirror raw.jpg not okay!");
|
|
||||||
delete rt;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
printf("do mirror\n");
|
printf("do mirror\n");
|
||||||
rt->Mirror();
|
rt.Mirror();
|
||||||
rt->SaveToFile(output1);
|
if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/mirror.jpg"));
|
||||||
input = output1;
|
|
||||||
delete rt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (initalrotate != 0)
|
if (initalrotate != 0)
|
||||||
{
|
{
|
||||||
CRotate *rt = NULL;
|
rt.Rotate(initalrotate);
|
||||||
printf("Load rotationfile: %s\n", input.c_str());
|
if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/rot.jpg"));
|
||||||
rt = new CRotate(input);
|
|
||||||
if (!rt->ImageOkay()){
|
|
||||||
LogFile.WriteToFile("ClassFlowAlignment::doFlow CRotate raw.jpg not okay!");
|
|
||||||
delete rt;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
rt->Rotate(this->initalrotate);
|
|
||||||
rt->SaveToFile(output);
|
|
||||||
delete rt;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!AlignAndCutImage->Align(&References[0], &References[1]))
|
||||||
{
|
{
|
||||||
CopyFile(input, output);
|
SaveReferenceAlignmentValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
CAlignAndCutImage *caic;
|
if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/alg.jpg"));
|
||||||
caic = new CAlignAndCutImage(output);
|
|
||||||
caic->Align(this->reffilename[0], this->ref_x[0], this->ref_y[0], this->reffilename[1], this->ref_x[1], this->ref_y[1], suchex, suchey, output3);
|
|
||||||
caic->SaveToFile(output2);
|
|
||||||
|
|
||||||
printf("Startwriting Output4:%s\n", output4.c_str());
|
if (SaveAllFiles)
|
||||||
if (output4.length() > 0)
|
|
||||||
{
|
{
|
||||||
caic->drawRect(ref_x[0], ref_y[0], caic->t0_dx, caic->t0_dy, 255, 0, 0, 2);
|
DrawRef(ImageTMP);
|
||||||
caic->drawRect(ref_x[1], ref_y[1], caic->t1_dx, caic->t1_dy, 255, 0, 0, 2);
|
ImageTMP->SaveToFile(FormatFileName("/sdcard/img_tmp/alg_roi.jpg"));
|
||||||
caic->SaveToFile(output4);
|
|
||||||
printf("Write output4: %s\n", output4.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete caic;
|
if (ImageTMP) // nuss gelöscht werden, um Speicherplatz für das Laden von tflite zu haben
|
||||||
|
{
|
||||||
|
delete ImageTMP;
|
||||||
|
ImageTMP = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadReferenceAlignmentValues();
|
||||||
|
|
||||||
// Align mit Templates
|
|
||||||
return true;
|
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-%d_%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> zerlegt;
|
||||||
|
|
||||||
|
|
||||||
|
// LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues01");
|
||||||
|
|
||||||
|
pFile = fopen(FileStoreRefAlignment.c_str(), "r");
|
||||||
|
if (pFile == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues01");
|
||||||
|
|
||||||
|
fgets(zw, 1024, pFile);
|
||||||
|
printf("%s", zw);
|
||||||
|
|
||||||
|
// zwvalue = "LoadReferenceAlignmentValues Time: " + std::string(zw);
|
||||||
|
|
||||||
|
// LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", zwvalue);
|
||||||
|
|
||||||
|
// LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues02");
|
||||||
|
|
||||||
|
fgets(zw, 1024, pFile);
|
||||||
|
zerlegt = ZerlegeZeile(std::string(zw), " \t");
|
||||||
|
if (zerlegt.size() < 6)
|
||||||
|
{
|
||||||
|
// LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "Exit 01");
|
||||||
|
fclose(pFile);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues03");
|
||||||
|
|
||||||
|
References[0].fastalg_x = stoi(zerlegt[0]);
|
||||||
|
References[0].fastalg_y = stoi(zerlegt[1]);
|
||||||
|
References[0].fastalg_SAD = stof(zerlegt[2]);
|
||||||
|
References[0].fastalg_min = stoi(zerlegt[3]);
|
||||||
|
References[0].fastalg_max = stoi(zerlegt[4]);
|
||||||
|
References[0].fastalg_avg = stof(zerlegt[5]);
|
||||||
|
|
||||||
|
fgets(zw, 1024, pFile);
|
||||||
|
zerlegt = ZerlegeZeile(std::string(zw));
|
||||||
|
if (zerlegt.size() < 6)
|
||||||
|
{
|
||||||
|
// LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "Exit 02");
|
||||||
|
fclose(pFile);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues03");
|
||||||
|
|
||||||
|
References[1].fastalg_x = stoi(zerlegt[0]);
|
||||||
|
References[1].fastalg_y = stoi(zerlegt[1]);
|
||||||
|
References[1].fastalg_SAD = stof(zerlegt[2]);
|
||||||
|
References[1].fastalg_min = stoi(zerlegt[3]);
|
||||||
|
References[1].fastalg_max = stoi(zerlegt[4]);
|
||||||
|
References[1].fastalg_avg = stof(zerlegt[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)
|
||||||
|
{
|
||||||
|
_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "ClassFlow.h"
|
#include "ClassFlow.h"
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
|
#include "CAlignAndCutImage.h"
|
||||||
|
#include "CFindTemplate.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -13,15 +15,27 @@ class ClassFlowAlignment :
|
|||||||
protected:
|
protected:
|
||||||
float initalrotate;
|
float initalrotate;
|
||||||
bool initialmirror;
|
bool initialmirror;
|
||||||
string reffilename[2];
|
RefInfo References[2];
|
||||||
int ref_x[2], ref_y[2];
|
|
||||||
int anz_ref;
|
int anz_ref;
|
||||||
int suchex, suchey;
|
|
||||||
string namerawimage;
|
string namerawimage;
|
||||||
|
bool SaveAllFiles;
|
||||||
|
CAlignAndCutImage *AlignAndCutImage;
|
||||||
|
std::string FileStoreRefAlignment;
|
||||||
|
float SAD_criteria;
|
||||||
|
|
||||||
|
void SetInitialParameter(void);
|
||||||
|
bool LoadReferenceAlignmentValues(void);
|
||||||
|
void SaveReferenceAlignmentValues();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClassFlowAlignment();
|
CImageBasis *ImageBasis, *ImageTMP;
|
||||||
|
|
||||||
ClassFlowAlignment(std::vector<ClassFlow*>* lfc);
|
ClassFlowAlignment(std::vector<ClassFlow*>* lfc);
|
||||||
|
|
||||||
|
CAlignAndCutImage* GetAlignAndCutImage(){return AlignAndCutImage;};
|
||||||
|
|
||||||
|
void DrawRef(CImageBasis *_zw);
|
||||||
|
|
||||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||||
bool doFlow(string time);
|
bool doFlow(string time);
|
||||||
string getHTMLSingleStep(string host);
|
string getHTMLSingleStep(string host);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
// #define OHNETFLITE
|
// #define OHNETFLITE
|
||||||
|
|
||||||
#ifndef OHNETFLITE
|
#ifndef OHNETFLITE
|
||||||
@@ -16,32 +16,68 @@ static const char* TAG = "flow_analog";
|
|||||||
|
|
||||||
bool debugdetailanalog = false;
|
bool debugdetailanalog = false;
|
||||||
|
|
||||||
ClassFlowAnalog::ClassFlowAnalog() : ClassFlowImage(TAG)
|
void ClassFlowAnalog::SetInitialParameter(void)
|
||||||
{
|
{
|
||||||
string cnnmodelfile = "";
|
string cnnmodelfile = "";
|
||||||
modelxsize = 1;
|
modelxsize = 1;
|
||||||
modelysize = 1;
|
modelysize = 1;
|
||||||
ListFlowControll = NULL;
|
ListFlowControll = NULL;
|
||||||
}
|
previousElement = NULL;
|
||||||
|
SaveAllFiles = false;
|
||||||
|
disabled = false;
|
||||||
|
extendedResolution = false;
|
||||||
|
}
|
||||||
|
|
||||||
ClassFlowAnalog::ClassFlowAnalog(std::vector<ClassFlow*>* lfc) : ClassFlowImage(lfc, TAG)
|
ClassFlowAnalog::ClassFlowAnalog(std::vector<ClassFlow*>* lfc) : ClassFlowImage(lfc, TAG)
|
||||||
{
|
{
|
||||||
string cnnmodelfile = "";
|
SetInitialParameter();
|
||||||
modelxsize = 1;
|
ListFlowControll = lfc;
|
||||||
modelysize = 1;
|
|
||||||
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
||||||
|
{
|
||||||
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowAlignment") == 0)
|
||||||
|
{
|
||||||
|
flowpostalignment = (ClassFlowAlignment*) (*ListFlowControll)[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ClassFlowAnalog::AnzahlROIs()
|
||||||
|
{
|
||||||
|
int zw = ROI.size();
|
||||||
|
if (extendedResolution)
|
||||||
|
zw++;
|
||||||
|
|
||||||
|
return zw;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string ClassFlowAnalog::getReadout()
|
string ClassFlowAnalog::getReadout()
|
||||||
{
|
{
|
||||||
|
string result = "";
|
||||||
|
if (ROI.size() == 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
|
||||||
|
float zahl = ROI[ROI.size() - 1]->result;
|
||||||
|
int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10;
|
||||||
|
|
||||||
int prev = -1;
|
int prev = -1;
|
||||||
string result = "";
|
|
||||||
for (int i = ROI.size() - 1; i >= 0; --i)
|
prev = ZeigerEval(ROI[ROI.size() - 1]->result, prev);
|
||||||
|
result = std::to_string(prev);
|
||||||
|
|
||||||
|
if (extendedResolution)
|
||||||
|
result = result + std::to_string(ergebnis_nachkomma);
|
||||||
|
|
||||||
|
for (int i = ROI.size() - 2; i >= 0; --i)
|
||||||
{
|
{
|
||||||
prev = ZeigerEval(ROI[i]->result, prev);
|
prev = ZeigerEval(ROI[i]->result, prev);
|
||||||
result = std::to_string(prev) + result;
|
result = std::to_string(prev) + result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,9 +116,18 @@ bool ClassFlowAnalog::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
if (aktparamgraph.compare("[Analog]") != 0) // Paragraph passt nich zu MakeImage
|
if ((aktparamgraph.compare("[Analog]") != 0) && (aktparamgraph.compare(";[Analog]") != 0)) // Paragraph passt nich zu MakeImage
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (aktparamgraph[0] == ';')
|
||||||
|
{
|
||||||
|
disabled = true;
|
||||||
|
while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
|
||||||
|
printf("[Analog] is disabled !!!\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
||||||
@@ -113,9 +158,30 @@ bool ClassFlowAnalog::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
neuroi->deltax = std::stoi(zerlegt[3]);
|
neuroi->deltax = std::stoi(zerlegt[3]);
|
||||||
neuroi->deltay = std::stoi(zerlegt[4]);
|
neuroi->deltay = std::stoi(zerlegt[4]);
|
||||||
neuroi->result = -1;
|
neuroi->result = -1;
|
||||||
|
neuroi->image = NULL;
|
||||||
|
neuroi->image_org = NULL;
|
||||||
ROI.push_back(neuroi);
|
ROI.push_back(neuroi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "SAVEALLFILES") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
|
SaveAllFiles = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "EXTENDEDRESOLUTION") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
|
extendedResolution = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < ROI.size(); ++i)
|
||||||
|
{
|
||||||
|
ROI[i]->image = new CImageBasis(modelxsize, modelysize, 3);
|
||||||
|
ROI[i]->image_org = new CImageBasis(ROI[i]->deltax, ROI[i]->deltay, 3);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +213,9 @@ string ClassFlowAnalog::getHTMLSingleStep(string host)
|
|||||||
|
|
||||||
bool ClassFlowAnalog::doFlow(string time)
|
bool ClassFlowAnalog::doFlow(string time)
|
||||||
{
|
{
|
||||||
|
if (disabled)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (!doAlignAndCut(time)){
|
if (!doAlignAndCut(time)){
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -162,81 +231,45 @@ bool ClassFlowAnalog::doFlow(string time)
|
|||||||
|
|
||||||
bool ClassFlowAnalog::doAlignAndCut(string time)
|
bool ClassFlowAnalog::doAlignAndCut(string time)
|
||||||
{
|
{
|
||||||
string input = "/sdcard/img_tmp/alg.jpg";
|
if (disabled)
|
||||||
string input_roi = "/sdcard/img_tmp/alg_roi.jpg";
|
return true;
|
||||||
string ioresize = "/sdcard/img_tmp/resize.bmp";
|
|
||||||
string output;
|
|
||||||
string nm;
|
|
||||||
input = FormatFileName(input);
|
|
||||||
input_roi = FormatFileName(input_roi);
|
|
||||||
|
|
||||||
CResizeImage *rs;
|
CAlignAndCutImage *caic = flowpostalignment->GetAlignAndCutImage();
|
||||||
CImageBasis *img_roi = NULL;
|
|
||||||
CAlignAndCutImage *caic = new CAlignAndCutImage(input);
|
|
||||||
|
|
||||||
if (!caic->ImageOkay()){
|
|
||||||
if (debugdetailanalog) LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut not okay!");
|
|
||||||
delete caic;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input_roi.length() > 0){
|
|
||||||
img_roi = new CImageBasis(input_roi);
|
|
||||||
if (!img_roi->ImageOkay()){
|
|
||||||
if (debugdetailanalog) LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut ImageRoi not okay!");
|
|
||||||
delete caic;
|
|
||||||
delete img_roi;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < ROI.size(); ++i)
|
for (int i = 0; i < ROI.size(); ++i)
|
||||||
{
|
{
|
||||||
printf("Analog %d - Align&Cut\n", i);
|
printf("Analog %d - Align&Cut\n", i);
|
||||||
output = "/sdcard/img_tmp/" + ROI[i]->name + ".jpg";
|
|
||||||
output = FormatFileName(output);
|
caic->CutAndSave(ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay, ROI[i]->image_org);
|
||||||
caic->CutAndSave(output, ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay);
|
if (SaveAllFiles) ROI[i]->image_org->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".jpg"));
|
||||||
|
|
||||||
rs = new CResizeImage(output);
|
ROI[i]->image_org->Resize(modelxsize, modelysize, ROI[i]->image);
|
||||||
if (!rs->ImageOkay()){
|
if (SaveAllFiles) ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".bmp"));
|
||||||
if (debugdetailanalog) LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut CResizeImage(output);!");
|
|
||||||
delete caic;
|
|
||||||
delete rs;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
rs->Resize(modelxsize, modelysize);
|
|
||||||
ioresize = "/sdcard/img_tmp/ra" + std::to_string(i) + ".bmp";
|
|
||||||
ioresize = FormatFileName(ioresize);
|
|
||||||
rs->SaveToFile(ioresize);
|
|
||||||
delete rs;
|
|
||||||
|
|
||||||
if (img_roi)
|
|
||||||
{
|
|
||||||
int r = 0;
|
|
||||||
int g = 255;
|
|
||||||
int b = 0;
|
|
||||||
img_roi->drawRect(ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay, r, g, b, 1);
|
|
||||||
img_roi->drawCircle((int) (ROI[i]->posx + ROI[i]->deltax/2), (int) (ROI[i]->posy + ROI[i]->deltay/2), (int) (ROI[i]->deltax/2), r, g, b, 2);
|
|
||||||
img_roi->drawLine((int) (ROI[i]->posx + ROI[i]->deltax/2), (int) ROI[i]->posy, (int) (ROI[i]->posx + ROI[i]->deltax/2), (int) (ROI[i]->posy + ROI[i]->deltay), r, g, b, 2);
|
|
||||||
img_roi->drawLine((int) ROI[i]->posx, (int) (ROI[i]->posy + ROI[i]->deltay/2), (int) ROI[i]->posx + ROI[i]->deltax, (int) (ROI[i]->posy + ROI[i]->deltay/2), r, g, b, 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
delete caic;
|
|
||||||
|
|
||||||
|
|
||||||
if (img_roi)
|
|
||||||
{
|
|
||||||
img_roi->SaveToFile(input_roi);
|
|
||||||
delete img_roi;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClassFlowAnalog::DrawROI(CImageBasis *_zw)
|
||||||
|
{
|
||||||
|
int r = 0;
|
||||||
|
int g = 255;
|
||||||
|
int b = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < ROI.size(); ++i)
|
||||||
|
{
|
||||||
|
_zw->drawRect(ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay, r, g, b, 1);
|
||||||
|
_zw->drawCircle((int) (ROI[i]->posx + ROI[i]->deltax/2), (int) (ROI[i]->posy + ROI[i]->deltay/2), (int) (ROI[i]->deltax/2), r, g, b, 2);
|
||||||
|
_zw->drawLine((int) (ROI[i]->posx + ROI[i]->deltax/2), (int) ROI[i]->posy, (int) (ROI[i]->posx + ROI[i]->deltax/2), (int) (ROI[i]->posy + ROI[i]->deltay), r, g, b, 2);
|
||||||
|
_zw->drawLine((int) ROI[i]->posx, (int) (ROI[i]->posy + ROI[i]->deltay/2), (int) ROI[i]->posx + ROI[i]->deltax, (int) (ROI[i]->posy + ROI[i]->deltay/2), r, g, b, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ClassFlowAnalog::doNeuralNetwork(string time)
|
bool ClassFlowAnalog::doNeuralNetwork(string time)
|
||||||
{
|
{
|
||||||
|
if (disabled)
|
||||||
|
return true;
|
||||||
|
|
||||||
string logPath = CreateLogFolder(time);
|
string logPath = CreateLogFolder(time);
|
||||||
|
|
||||||
string input = "/sdcard/img_tmp/alg.jpg";
|
string input = "/sdcard/img_tmp/alg.jpg";
|
||||||
@@ -265,7 +298,8 @@ bool ClassFlowAnalog::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
#ifndef OHNETFLITE
|
#ifndef OHNETFLITE
|
||||||
// LogFile.WriteToFile("ClassFlowAnalog::doNeuralNetwork vor CNN tflite->LoadInputImage(ioresize)");
|
// LogFile.WriteToFile("ClassFlowAnalog::doNeuralNetwork vor CNN tflite->LoadInputImage(ioresize)");
|
||||||
tflite->LoadInputImage(ioresize);
|
// tflite->LoadInputImage(ioresize);
|
||||||
|
tflite->LoadInputImageBasis(ROI[i]->image);
|
||||||
tflite->Invoke();
|
tflite->Invoke();
|
||||||
if (debugdetailanalog) LogFile.WriteToFile("Nach Invoke");
|
if (debugdetailanalog) LogFile.WriteToFile("Nach Invoke");
|
||||||
|
|
||||||
@@ -278,9 +312,12 @@ bool ClassFlowAnalog::doNeuralNetwork(string time)
|
|||||||
// printf("Result sin, cos, ziffer: %f, %f, %f\n", f1, f2, result);
|
// printf("Result sin, cos, ziffer: %f, %f, %f\n", f1, f2, result);
|
||||||
ROI[i]->result = result * 10;
|
ROI[i]->result = result * 10;
|
||||||
|
|
||||||
printf("Result Analog%i: %f\n", i, ROI[i]->result);
|
printf("Result Analog%i: %f\n", i, ROI[i]->result);
|
||||||
|
|
||||||
LogImage(logPath, ROI[i]->name, &ROI[i]->result, NULL, time);
|
if (isLogImage)
|
||||||
|
{
|
||||||
|
LogImage(logPath, ROI[i]->name, &ROI[i]->result, NULL, time, ROI[i]->image_org);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifndef OHNETFLITE
|
#ifndef OHNETFLITE
|
||||||
delete tflite;
|
delete tflite;
|
||||||
@@ -297,8 +334,11 @@ std::vector<HTMLInfo*> ClassFlowAnalog::GetHTMLInfo()
|
|||||||
for (int i = 0; i < ROI.size(); ++i)
|
for (int i = 0; i < ROI.size(); ++i)
|
||||||
{
|
{
|
||||||
HTMLInfo *zw = new HTMLInfo;
|
HTMLInfo *zw = new HTMLInfo;
|
||||||
zw->filename = ROI[i]->name + ".jpg";
|
zw->filename = ROI[i]->name + ".bmp";
|
||||||
|
zw->filename_org = ROI[i]->name + ".jpg";
|
||||||
zw->val = ROI[i]->result;
|
zw->val = ROI[i]->result;
|
||||||
|
zw->image = ROI[i]->image;
|
||||||
|
zw->image_org = ROI[i]->image_org;
|
||||||
result.push_back(zw);
|
result.push_back(zw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "ClassFlowImage.h"
|
#include "ClassFlowImage.h"
|
||||||
|
#include "ClassFlowAlignment.h"
|
||||||
// #include "CTfLiteClass.h"
|
// #include "CTfLiteClass.h"
|
||||||
|
|
||||||
struct roianalog {
|
struct roianalog {
|
||||||
int posx, posy, deltax, deltay;
|
int posx, posy, deltax, deltay;
|
||||||
float result;
|
float result;
|
||||||
|
CImageBasis *image, *image_org;
|
||||||
string name;
|
string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -17,20 +19,30 @@ protected:
|
|||||||
string cnnmodelfile;
|
string cnnmodelfile;
|
||||||
int modelxsize, modelysize;
|
int modelxsize, modelysize;
|
||||||
int ZeigerEval(float zahl, int ziffer_vorgaenger);
|
int ZeigerEval(float zahl, int ziffer_vorgaenger);
|
||||||
|
bool SaveAllFiles;
|
||||||
|
|
||||||
|
|
||||||
|
ClassFlowAlignment* flowpostalignment;
|
||||||
|
|
||||||
|
void SetInitialParameter(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClassFlowAnalog();
|
bool extendedResolution;
|
||||||
|
|
||||||
ClassFlowAnalog(std::vector<ClassFlow*>* lfc);
|
ClassFlowAnalog(std::vector<ClassFlow*>* lfc);
|
||||||
|
|
||||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||||
bool doFlow(string time);
|
bool doFlow(string time);
|
||||||
string getHTMLSingleStep(string host);
|
string getHTMLSingleStep(string host);
|
||||||
string getReadout();
|
string getReadout();
|
||||||
|
|
||||||
|
void DrawROI(CImageBasis *_zw);
|
||||||
|
|
||||||
bool doNeuralNetwork(string time);
|
bool doNeuralNetwork(string time);
|
||||||
bool doAlignAndCut(string time);
|
bool doAlignAndCut(string time);
|
||||||
std::vector<HTMLInfo*> GetHTMLInfo();
|
std::vector<HTMLInfo*> GetHTMLInfo();
|
||||||
int AnzahlROIs(){return ROI.size();};
|
int AnzahlROIs();
|
||||||
|
|
||||||
string name(){return "ClassFlowAnalog";};
|
string name(){return "ClassFlowAnalog";};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "ClassFlowControll.h"
|
#include "ClassFlowControll.h"
|
||||||
|
|
||||||
|
#include "connect_wlan.h"
|
||||||
|
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -9,33 +11,36 @@
|
|||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include "server_ota.h"
|
#include "server_ota.h"
|
||||||
|
|
||||||
|
#include "server_help.h"
|
||||||
|
|
||||||
|
//#define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
static const char* TAG = "flow_controll";
|
static const char* TAG = "flow_controll";
|
||||||
|
|
||||||
|
|
||||||
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
||||||
std::string _classname = "";
|
std::string _classname = "";
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
if (_stepname.compare("[MakeImage]") == 0){
|
if ((_stepname.compare("[MakeImage]") == 0) || (_stepname.compare(";[MakeImage]") == 0)){
|
||||||
_classname = "ClassFlowMakeImage";
|
_classname = "ClassFlowMakeImage";
|
||||||
}
|
}
|
||||||
if (_stepname.compare("[Alignment]") == 0){
|
if ((_stepname.compare("[Alignment]") == 0) || (_stepname.compare(";[Alignment]") == 0)){
|
||||||
_classname = "ClassFlowAlignment";
|
_classname = "ClassFlowAlignment";
|
||||||
}
|
}
|
||||||
if (_stepname.compare("[Digits]") == 0){
|
if ((_stepname.compare("[Digits]") == 0) || (_stepname.compare(";[Digits]") == 0)){
|
||||||
_classname = "ClassFlowDigit";
|
_classname = "ClassFlowDigit";
|
||||||
}
|
}
|
||||||
if (_stepname.compare("[Analog]") == 0){
|
if ((_stepname.compare("[Analog]") == 0) || (_stepname.compare(";[Analog]") == 0)){
|
||||||
_classname = "ClassFlowAnalog";
|
_classname = "ClassFlowAnalog";
|
||||||
}
|
}
|
||||||
if (_stepname.compare("[MQTT]") == 0){
|
if ((_stepname.compare("[MQTT]") == 0) || (_stepname.compare(";[MQTT]") == 0)){
|
||||||
_classname = "ClassFlowMQTT";
|
_classname = "ClassFlowMQTT";
|
||||||
}
|
}
|
||||||
// std::string zw = "Classname: " + _classname + "\n";
|
|
||||||
// printf(zw.c_str());
|
|
||||||
|
|
||||||
for (int i = 0; i < FlowControll.size(); ++i)
|
for (int i = 0; i < FlowControll.size(); ++i)
|
||||||
if (FlowControll[i]->name().compare(_classname) == 0){
|
if (FlowControll[i]->name().compare(_classname) == 0){
|
||||||
// printf(FlowControll[i]->name().c_str()); printf("\n");
|
if (!(FlowControll[i]->name().compare("ClassFlowMakeImage") == 0)) // falls es ein MakeImage ist, braucht das Bild nicht extra aufgenommen zu werden, dass passiert bei html-Abfrage automatisch
|
||||||
FlowControll[i]->doFlow("");
|
FlowControll[i]->doFlow("");
|
||||||
result = FlowControll[i]->getHTMLSingleStep(_host);
|
result = FlowControll[i]->getHTMLSingleStep(_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +73,13 @@ void ClassFlowControll::SetInitialParameter(void)
|
|||||||
AutoStart = false;
|
AutoStart = false;
|
||||||
SetupModeActive = false;
|
SetupModeActive = false;
|
||||||
AutoIntervall = 10;
|
AutoIntervall = 10;
|
||||||
|
flowdigit = NULL;
|
||||||
|
flowanalog = NULL;
|
||||||
|
flowpostprocessing = NULL;
|
||||||
|
disabled = false;
|
||||||
|
aktRunNr = 0;
|
||||||
|
aktstatus = "Startup";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClassFlowControll::isAutoStart(long &_intervall)
|
bool ClassFlowControll::isAutoStart(long &_intervall)
|
||||||
@@ -83,13 +95,25 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
|
|||||||
_type = trim(_type);
|
_type = trim(_type);
|
||||||
|
|
||||||
if (toUpper(_type).compare("[MAKEIMAGE]") == 0)
|
if (toUpper(_type).compare("[MAKEIMAGE]") == 0)
|
||||||
|
{
|
||||||
cfc = new ClassFlowMakeImage(&FlowControll);
|
cfc = new ClassFlowMakeImage(&FlowControll);
|
||||||
|
flowmakeimage = (ClassFlowMakeImage*) cfc;
|
||||||
|
}
|
||||||
if (toUpper(_type).compare("[ALIGNMENT]") == 0)
|
if (toUpper(_type).compare("[ALIGNMENT]") == 0)
|
||||||
|
{
|
||||||
cfc = new ClassFlowAlignment(&FlowControll);
|
cfc = new ClassFlowAlignment(&FlowControll);
|
||||||
|
flowalignment = (ClassFlowAlignment*) cfc;
|
||||||
|
}
|
||||||
if (toUpper(_type).compare("[ANALOG]") == 0)
|
if (toUpper(_type).compare("[ANALOG]") == 0)
|
||||||
|
{
|
||||||
cfc = new ClassFlowAnalog(&FlowControll);
|
cfc = new ClassFlowAnalog(&FlowControll);
|
||||||
|
flowanalog = (ClassFlowAnalog*) cfc;
|
||||||
|
}
|
||||||
if (toUpper(_type).compare("[DIGITS]") == 0)
|
if (toUpper(_type).compare("[DIGITS]") == 0)
|
||||||
|
{
|
||||||
cfc = new ClassFlowDigit(&FlowControll);
|
cfc = new ClassFlowDigit(&FlowControll);
|
||||||
|
flowdigit = (ClassFlowDigit*) cfc;
|
||||||
|
}
|
||||||
if (toUpper(_type).compare("[MQTT]") == 0)
|
if (toUpper(_type).compare("[MQTT]") == 0)
|
||||||
cfc = new ClassFlowMQTT(&FlowControll);
|
cfc = new ClassFlowMQTT(&FlowControll);
|
||||||
if (toUpper(_type).compare("[POSTPROCESSING]") == 0)
|
if (toUpper(_type).compare("[POSTPROCESSING]") == 0)
|
||||||
@@ -122,7 +146,7 @@ void ClassFlowControll::InitFlow(std::string config)
|
|||||||
ClassFlow* cfc;
|
ClassFlow* cfc;
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
config = FormatFileName(config);
|
config = FormatFileName(config);
|
||||||
pFile = fopen(config.c_str(), "r");
|
pFile = OpenFileAndWait(config.c_str(), "r");
|
||||||
|
|
||||||
line = "";
|
line = "";
|
||||||
|
|
||||||
@@ -139,6 +163,7 @@ void ClassFlowControll::InitFlow(std::string config)
|
|||||||
cfc = CreateClassFlow(line);
|
cfc = CreateClassFlow(line);
|
||||||
if (cfc)
|
if (cfc)
|
||||||
{
|
{
|
||||||
|
printf("Start ReadParameter\n");
|
||||||
cfc->ReadParameter(pFile, line);
|
cfc->ReadParameter(pFile, line);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -158,9 +183,7 @@ std::string ClassFlowControll::getActStatus(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClassFlowControll::doFlowMakeImageOnly(string time){
|
void ClassFlowControll::doFlowMakeImageOnly(string time){
|
||||||
bool result = true;
|
|
||||||
std::string zw_time;
|
std::string zw_time;
|
||||||
int repeat = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < FlowControll.size(); ++i)
|
for (int i = 0; i < FlowControll.size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -181,12 +204,19 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
std::string zw_time;
|
std::string zw_time;
|
||||||
int repeat = 0;
|
int repeat = 0;
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < FlowControll.size(); ++i)
|
for (int i = 0; i < FlowControll.size(); ++i)
|
||||||
{
|
{
|
||||||
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
||||||
aktstatus = zw_time + ": " + FlowControll[i]->name();
|
aktstatus = zw_time + ": " + FlowControll[i]->name();
|
||||||
|
|
||||||
|
|
||||||
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
|
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
|
||||||
LogFile.WriteToFile(zw);
|
LogFile.WriteHeapInfo(zw);
|
||||||
|
|
||||||
if (!FlowControll[i]->doFlow(time)){
|
if (!FlowControll[i]->doFlow(time)){
|
||||||
repeat++;
|
repeat++;
|
||||||
LogFile.WriteToFile("Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
|
LogFile.WriteToFile("Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
|
||||||
@@ -202,12 +232,32 @@ bool ClassFlowControll::doFlow(string time)
|
|||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow");
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
zw_time = gettimestring("%Y%m%d-%H%M%S");
|
||||||
aktstatus = zw_time + ": Flow is done";
|
aktstatus = zw_time + ": Flow is done";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClassFlowControll::UpdateAktStatus(std::string _flow)
|
||||||
|
{
|
||||||
|
aktstatus = gettimestring("%Y%m%d-%H%M%S");
|
||||||
|
aktstatus = aktstatus + "\t" + std::to_string(aktRunNr) + "\t";
|
||||||
|
|
||||||
|
if (_flow == "ClassFlowMakeImage")
|
||||||
|
aktstatus = aktstatus + "Taking Raw Image";
|
||||||
|
else
|
||||||
|
if (_flow == "ClassFlowAlignment")
|
||||||
|
aktstatus = aktstatus + "Aligning Image";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string ClassFlowControll::getReadout(bool _rawvalue = false, bool _noerror = false)
|
string ClassFlowControll::getReadout(bool _rawvalue = false, bool _noerror = false)
|
||||||
{
|
{
|
||||||
if (flowpostprocessing)
|
if (flowpostprocessing)
|
||||||
@@ -320,6 +370,25 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
setTimeZone(zerlegt[1]);
|
setTimeZone(zerlegt[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "TIMESERVER") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
string zw = "Set TimeZone: " + zerlegt[1];
|
||||||
|
reset_servername(zerlegt[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "HOSTNAME") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
if (ChangeHostName("/sdcard/wlan.ini", zerlegt[1]))
|
||||||
|
{
|
||||||
|
// reboot notwendig damit die neue wlan.ini auch benutzt wird !!!
|
||||||
|
fclose(pfile);
|
||||||
|
printf("do reboot\n");
|
||||||
|
esp_restart();
|
||||||
|
hard_restart();
|
||||||
|
doReboot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((toUpper(zerlegt[0]) == "SETUPMODE") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "SETUPMODE") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
if (toUpper(zerlegt[1]) == "TRUE")
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
@@ -328,8 +397,10 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "LOGLEVEL") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
LogFile.setLogLevel(stoi(zerlegt[1]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -362,4 +433,85 @@ int ClassFlowControll::CleanTempFolder() {
|
|||||||
ESP_LOGI(TAG, "%d files deleted", deleted);
|
ESP_LOGI(TAG, "%d files deleted", deleted);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
esp_err_t ClassFlowControll::SendRawJPG(httpd_req_t *req)
|
||||||
|
{
|
||||||
|
return flowmakeimage->SendRawJPG(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
||||||
|
{
|
||||||
|
printf("ClassFlowControll::GetJPGStream %s\n", _fn.c_str());
|
||||||
|
|
||||||
|
CImageBasis *_send = NULL;
|
||||||
|
esp_err_t result = ESP_FAIL;
|
||||||
|
bool Dodelete = false;
|
||||||
|
|
||||||
|
if (_fn == "alg.jpg")
|
||||||
|
{
|
||||||
|
_send = flowalignment->ImageBasis;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (_fn == "alg_roi.jpg")
|
||||||
|
{
|
||||||
|
CImageBasis* _imgzw = new CImageBasis(flowalignment->ImageBasis);
|
||||||
|
flowalignment->DrawRef(_imgzw);
|
||||||
|
if (flowdigit) flowdigit->DrawROI(_imgzw);
|
||||||
|
if (flowanalog) flowanalog->DrawROI(_imgzw);
|
||||||
|
_send = _imgzw;
|
||||||
|
Dodelete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<HTMLInfo*> htmlinfo;
|
||||||
|
htmlinfo = GetAllDigital();
|
||||||
|
for (int i = 0; i < htmlinfo.size(); ++i)
|
||||||
|
{
|
||||||
|
if (_fn == htmlinfo[i]->filename)
|
||||||
|
{
|
||||||
|
if (htmlinfo[i]->image)
|
||||||
|
_send = htmlinfo[i]->image;
|
||||||
|
}
|
||||||
|
if (_fn == htmlinfo[i]->filename_org)
|
||||||
|
{
|
||||||
|
if (htmlinfo[i]->image_org)
|
||||||
|
_send = htmlinfo[i]->image_org;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
htmlinfo = GetAllAnalog();
|
||||||
|
for (int i = 0; i < htmlinfo.size(); ++i)
|
||||||
|
{
|
||||||
|
if (_fn == htmlinfo[i]->filename)
|
||||||
|
{
|
||||||
|
if (htmlinfo[i]->image)
|
||||||
|
_send = htmlinfo[i]->image;
|
||||||
|
}
|
||||||
|
if (_fn == htmlinfo[i]->filename_org)
|
||||||
|
{
|
||||||
|
if (htmlinfo[i]->image_org)
|
||||||
|
_send = htmlinfo[i]->image_org;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_send)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "Sending file : %s ...", _fn.c_str());
|
||||||
|
set_content_type_from_file(req, _fn.c_str());
|
||||||
|
result = _send->SendJPGtoHTTP(req);
|
||||||
|
ESP_LOGI(TAG, "File sending complete");
|
||||||
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Dodelete)
|
||||||
|
{
|
||||||
|
delete _send;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,10 @@ class ClassFlowControll :
|
|||||||
protected:
|
protected:
|
||||||
std::vector<ClassFlow*> FlowControll;
|
std::vector<ClassFlow*> FlowControll;
|
||||||
ClassFlowPostProcessing* flowpostprocessing;
|
ClassFlowPostProcessing* flowpostprocessing;
|
||||||
|
ClassFlowAlignment* flowalignment;
|
||||||
|
ClassFlowAnalog* flowanalog;
|
||||||
|
ClassFlowDigit* flowdigit;
|
||||||
|
ClassFlowMakeImage* flowmakeimage;
|
||||||
ClassFlow* CreateClassFlow(std::string _type);
|
ClassFlow* CreateClassFlow(std::string _type);
|
||||||
|
|
||||||
bool AutoStart;
|
bool AutoStart;
|
||||||
@@ -24,6 +28,9 @@ protected:
|
|||||||
bool SetupModeActive;
|
bool SetupModeActive;
|
||||||
void SetInitialParameter(void);
|
void SetInitialParameter(void);
|
||||||
std::string aktstatus;
|
std::string aktstatus;
|
||||||
|
int aktRunNr;
|
||||||
|
|
||||||
|
void UpdateAktStatus(std::string _flow);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void InitFlow(std::string config);
|
void InitFlow(std::string config);
|
||||||
@@ -35,6 +42,9 @@ public:
|
|||||||
string GetPrevalue();
|
string GetPrevalue();
|
||||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||||
|
|
||||||
|
esp_err_t GetJPGStream(std::string _fn, httpd_req_t *req);
|
||||||
|
esp_err_t SendRawJPG(httpd_req_t *req);
|
||||||
|
|
||||||
std::string doSingleStep(std::string _stepname, std::string _host);
|
std::string doSingleStep(std::string _stepname, std::string _host);
|
||||||
|
|
||||||
bool isAutoStart(long &_intervall);
|
bool isAutoStart(long &_intervall);
|
||||||
@@ -49,3 +59,4 @@ public:
|
|||||||
string name(){return "ClassFlowControll";};
|
string name(){return "ClassFlowControll";};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "ClassFlowDigit.h"
|
#include "ClassFlowDigit.h"
|
||||||
|
|
||||||
|
|
||||||
//#include "CFindTemplate.h"
|
//#include "CFindTemplate.h"
|
||||||
//#include "CTfLiteClass.h"
|
//#include "CTfLiteClass.h"
|
||||||
|
|
||||||
@@ -15,19 +16,51 @@
|
|||||||
|
|
||||||
static const char* TAG = "flow_digital";
|
static const char* TAG = "flow_digital";
|
||||||
|
|
||||||
ClassFlowDigit::ClassFlowDigit() : ClassFlowImage(TAG)
|
|
||||||
|
void ClassFlowDigit::SetInitialParameter(void)
|
||||||
{
|
{
|
||||||
string cnnmodelfile = "";
|
string cnnmodelfile = "";
|
||||||
modelxsize = 1;
|
modelxsize = 1;
|
||||||
modelysize = 1;
|
modelysize = 1;
|
||||||
ListFlowControll = NULL;
|
ListFlowControll = NULL;
|
||||||
|
previousElement = NULL;
|
||||||
|
SaveAllFiles = false;
|
||||||
|
disabled = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassFlowDigit::ClassFlowDigit() : ClassFlowImage(TAG)
|
||||||
|
{
|
||||||
|
SetInitialParameter();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassFlowDigit::ClassFlowDigit(std::vector<ClassFlow*>* lfc) : ClassFlowImage(lfc, TAG)
|
ClassFlowDigit::ClassFlowDigit(std::vector<ClassFlow*>* lfc) : ClassFlowImage(lfc, TAG)
|
||||||
{
|
{
|
||||||
string cnnmodelfile = "";
|
SetInitialParameter();
|
||||||
modelxsize = 1;
|
ListFlowControll = lfc;
|
||||||
modelysize = 1;
|
|
||||||
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
||||||
|
{
|
||||||
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowAlignment") == 0)
|
||||||
|
{
|
||||||
|
flowpostalignment = (ClassFlowAlignment*) (*ListFlowControll)[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassFlowDigit::ClassFlowDigit(std::vector<ClassFlow*>* lfc, ClassFlow *_prev) : ClassFlowImage(lfc, _prev, TAG)
|
||||||
|
{
|
||||||
|
SetInitialParameter();
|
||||||
|
ListFlowControll = lfc;
|
||||||
|
previousElement = _prev;
|
||||||
|
|
||||||
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
||||||
|
{
|
||||||
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowAlignment") == 0)
|
||||||
|
{
|
||||||
|
flowpostalignment = (ClassFlowAlignment*) (*ListFlowControll)[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string ClassFlowDigit::getReadout()
|
string ClassFlowDigit::getReadout()
|
||||||
@@ -52,14 +85,22 @@ bool ClassFlowDigit::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
aktparamgraph = trim(aktparamgraph);
|
aktparamgraph = trim(aktparamgraph);
|
||||||
|
|
||||||
if (aktparamgraph.size() == 0)
|
if (aktparamgraph.size() == 0)
|
||||||
if (!this->GetNextParagraph(pfile, aktparamgraph))
|
if (!this->GetNextParagraph(pfile, aktparamgraph))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if ((aktparamgraph.compare("[Digits]") != 0) && (aktparamgraph.compare(";[Digits]") != 0)) // Paragraph passt nich zu MakeImage
|
||||||
if (aktparamgraph.compare("[Digits]") != 0) // Paragraph passt nich zu MakeImage
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
if (aktparamgraph[0] == ';')
|
||||||
|
{
|
||||||
|
disabled = true;
|
||||||
|
while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
|
||||||
|
printf("[Digits] is disabled !!!\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
||||||
if ((zerlegt[0] == "LogImageLocation") && (zerlegt.size() > 1))
|
if ((zerlegt[0] == "LogImageLocation") && (zerlegt.size() > 1))
|
||||||
@@ -85,9 +126,25 @@ bool ClassFlowDigit::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
neuroi->deltax = std::stoi(zerlegt[3]);
|
neuroi->deltax = std::stoi(zerlegt[3]);
|
||||||
neuroi->deltay = std::stoi(zerlegt[4]);
|
neuroi->deltay = std::stoi(zerlegt[4]);
|
||||||
neuroi->resultklasse = -1;
|
neuroi->resultklasse = -1;
|
||||||
|
neuroi->image = NULL;
|
||||||
|
neuroi->image_org = NULL;
|
||||||
ROI.push_back(neuroi);
|
ROI.push_back(neuroi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "SAVEALLFILES") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
|
SaveAllFiles = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < ROI.size(); ++i)
|
||||||
|
{
|
||||||
|
ROI[i]->image = new CImageBasis(modelxsize, modelysize, 3);
|
||||||
|
ROI[i]->image_org = new CImageBasis(ROI[i]->deltax, ROI[i]->deltay, 3);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +177,9 @@ string ClassFlowDigit::getHTMLSingleStep(string host)
|
|||||||
|
|
||||||
bool ClassFlowDigit::doFlow(string time)
|
bool ClassFlowDigit::doFlow(string time)
|
||||||
{
|
{
|
||||||
|
if (disabled)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (!doAlignAndCut(time)){
|
if (!doAlignAndCut(time)){
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -133,60 +193,20 @@ bool ClassFlowDigit::doFlow(string time)
|
|||||||
|
|
||||||
bool ClassFlowDigit::doAlignAndCut(string time)
|
bool ClassFlowDigit::doAlignAndCut(string time)
|
||||||
{
|
{
|
||||||
string input = "/sdcard/img_tmp/alg.jpg";
|
if (disabled)
|
||||||
string input_roi = "/sdcard/img_tmp/alg_roi.jpg";
|
return true;
|
||||||
string ioresize = "/sdcard/img_tmp/resize.bmp";
|
|
||||||
string output;
|
|
||||||
string nm;
|
|
||||||
input = FormatFileName(input);
|
|
||||||
input_roi = FormatFileName(input_roi);
|
|
||||||
|
|
||||||
CResizeImage *rs;
|
|
||||||
CImageBasis *img_roi = NULL;
|
|
||||||
CAlignAndCutImage *caic = new CAlignAndCutImage(input);
|
|
||||||
if (!caic->ImageOkay()){
|
|
||||||
LogFile.WriteToFile("ClassFlowDigit::doAlignAndCut not okay!");
|
|
||||||
delete caic;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input_roi.length() > 0){
|
|
||||||
img_roi = new CImageBasis(input_roi);
|
|
||||||
if (!img_roi->ImageOkay()){
|
|
||||||
LogFile.WriteToFile("ClassFlowDigit::doAlignAndCut ImageRoi not okay!");
|
|
||||||
delete caic;
|
|
||||||
delete img_roi;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
CAlignAndCutImage *caic = flowpostalignment->GetAlignAndCutImage();
|
||||||
|
|
||||||
for (int i = 0; i < ROI.size(); ++i)
|
for (int i = 0; i < ROI.size(); ++i)
|
||||||
{
|
{
|
||||||
printf("DigitalDigit %d - Align&Cut\n", i);
|
printf("DigitalDigit %d - Align&Cut\n", i);
|
||||||
output = "/sdcard/img_tmp/" + ROI[i]->name + ".jpg";
|
|
||||||
output = FormatFileName(output);
|
caic->CutAndSave(ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay, ROI[i]->image_org);
|
||||||
caic->CutAndSave(output, ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay);
|
if (SaveAllFiles) ROI[i]->image_org->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".jpg"));
|
||||||
|
|
||||||
rs = new CResizeImage(output);
|
ROI[i]->image_org->Resize(modelxsize, modelysize, ROI[i]->image);
|
||||||
rs->Resize(modelxsize, modelysize);
|
if (SaveAllFiles) ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + ROI[i]->name + ".bmp"));
|
||||||
ioresize = "/sdcard/img_tmp/rd" + std::to_string(i) + ".bmp";
|
|
||||||
ioresize = FormatFileName(ioresize);
|
|
||||||
rs->SaveToFile(ioresize);
|
|
||||||
delete rs;
|
|
||||||
|
|
||||||
if (img_roi)
|
|
||||||
{
|
|
||||||
img_roi->drawRect(ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay, 0, 0, 255, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete caic;
|
|
||||||
|
|
||||||
if (img_roi)
|
|
||||||
{
|
|
||||||
img_roi->SaveToFile(input_roi);
|
|
||||||
delete img_roi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -194,19 +214,14 @@ bool ClassFlowDigit::doAlignAndCut(string time)
|
|||||||
|
|
||||||
bool ClassFlowDigit::doNeuralNetwork(string time)
|
bool ClassFlowDigit::doNeuralNetwork(string time)
|
||||||
{
|
{
|
||||||
|
if (disabled)
|
||||||
|
return true;
|
||||||
|
|
||||||
string logPath = CreateLogFolder(time);
|
string logPath = CreateLogFolder(time);
|
||||||
|
|
||||||
string input = "/sdcard/img_tmp/alg.jpg";
|
|
||||||
string ioresize = "/sdcard/img_tmp/resize.bmp";
|
|
||||||
string output;
|
|
||||||
string nm;
|
|
||||||
input = FormatFileName(input);
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef OHNETFLITE
|
#ifndef OHNETFLITE
|
||||||
CTfLiteClass *tflite = new CTfLiteClass;
|
CTfLiteClass *tflite = new CTfLiteClass;
|
||||||
string zwcnn = "/sdcard" + cnnmodelfile;
|
string zwcnn = FormatFileName("/sdcard" + cnnmodelfile);
|
||||||
zwcnn = FormatFileName(zwcnn);
|
|
||||||
printf(zwcnn.c_str());printf("\n");
|
printf(zwcnn.c_str());printf("\n");
|
||||||
tflite->LoadModel(zwcnn);
|
tflite->LoadModel(zwcnn);
|
||||||
tflite->MakeAllocate();
|
tflite->MakeAllocate();
|
||||||
@@ -215,17 +230,18 @@ bool ClassFlowDigit::doNeuralNetwork(string time)
|
|||||||
for (int i = 0; i < ROI.size(); ++i)
|
for (int i = 0; i < ROI.size(); ++i)
|
||||||
{
|
{
|
||||||
printf("DigitalDigit %d - TfLite\n", i);
|
printf("DigitalDigit %d - TfLite\n", i);
|
||||||
ioresize = "/sdcard/img_tmp/rd" + std::to_string(i) + ".bmp";
|
|
||||||
ioresize = FormatFileName(ioresize);
|
|
||||||
// printf("output: %s, ioresize: %s\n", output.c_str(), ioresize.c_str());
|
|
||||||
|
|
||||||
ROI[i]->resultklasse = 0;
|
ROI[i]->resultklasse = 0;
|
||||||
#ifndef OHNETFLITE
|
#ifndef OHNETFLITE
|
||||||
ROI[i]->resultklasse = tflite->GetClassFromImage(ioresize);
|
ROI[i]->resultklasse = tflite->GetClassFromImageBasis(ROI[i]->image);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
printf("Result Digit%i: %d\n", i, ROI[i]->resultklasse);
|
printf("Result Digit%i: %d\n", i, ROI[i]->resultklasse);
|
||||||
|
|
||||||
LogImage(logPath, ROI[i]->name, NULL, &ROI[i]->resultklasse, time);
|
if (isLogImage)
|
||||||
|
{
|
||||||
|
LogImage(logPath, ROI[i]->name, NULL, &ROI[i]->resultklasse, time, ROI[i]->image_org);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifndef OHNETFLITE
|
#ifndef OHNETFLITE
|
||||||
delete tflite;
|
delete tflite;
|
||||||
@@ -233,6 +249,11 @@ bool ClassFlowDigit::doNeuralNetwork(string time)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClassFlowDigit::DrawROI(CImageBasis *_zw)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ROI.size(); ++i)
|
||||||
|
_zw->drawRect(ROI[i]->posx, ROI[i]->posy, ROI[i]->deltax, ROI[i]->deltay, 0, 0, 255, 2);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<HTMLInfo*> ClassFlowDigit::GetHTMLInfo()
|
std::vector<HTMLInfo*> ClassFlowDigit::GetHTMLInfo()
|
||||||
{
|
{
|
||||||
@@ -241,10 +262,14 @@ std::vector<HTMLInfo*> ClassFlowDigit::GetHTMLInfo()
|
|||||||
for (int i = 0; i < ROI.size(); ++i)
|
for (int i = 0; i < ROI.size(); ++i)
|
||||||
{
|
{
|
||||||
HTMLInfo *zw = new HTMLInfo;
|
HTMLInfo *zw = new HTMLInfo;
|
||||||
zw->filename = ROI[i]->name + ".jpg";
|
zw->filename = ROI[i]->name + ".bmp";
|
||||||
|
zw->filename_org = ROI[i]->name + ".jpg";
|
||||||
zw->val = ROI[i]->resultklasse;
|
zw->val = ROI[i]->resultklasse;
|
||||||
|
zw->image = ROI[i]->image;
|
||||||
|
zw->image_org = ROI[i]->image_org;
|
||||||
result.push_back(zw);
|
result.push_back(zw);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "ClassFlowImage.h"
|
#include "ClassFlowImage.h"
|
||||||
|
#include "ClassFlowAlignment.h"
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -8,6 +9,7 @@ struct roi {
|
|||||||
int posx, posy, deltax, deltay;
|
int posx, posy, deltax, deltay;
|
||||||
int resultklasse;
|
int resultklasse;
|
||||||
string name;
|
string name;
|
||||||
|
CImageBasis *image, *image_org;
|
||||||
roi* next;
|
roi* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,19 +20,27 @@ protected:
|
|||||||
std::vector<roi*> ROI;
|
std::vector<roi*> ROI;
|
||||||
string cnnmodelfile;
|
string cnnmodelfile;
|
||||||
int modelxsize, modelysize;
|
int modelxsize, modelysize;
|
||||||
|
bool SaveAllFiles;
|
||||||
|
|
||||||
|
ClassFlowAlignment* flowpostalignment;
|
||||||
|
|
||||||
bool doNeuralNetwork(string time);
|
bool doNeuralNetwork(string time);
|
||||||
bool doAlignAndCut(string time);
|
bool doAlignAndCut(string time);
|
||||||
|
|
||||||
|
void SetInitialParameter(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClassFlowDigit();
|
ClassFlowDigit();
|
||||||
ClassFlowDigit(std::vector<ClassFlow*>* lfc);
|
ClassFlowDigit(std::vector<ClassFlow*>* lfc);
|
||||||
|
ClassFlowDigit(std::vector<ClassFlow*>* lfc, ClassFlow *_prev);
|
||||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||||
bool doFlow(string time);
|
bool doFlow(string time);
|
||||||
string getHTMLSingleStep(string host);
|
string getHTMLSingleStep(string host);
|
||||||
string getReadout();
|
string getReadout();
|
||||||
std::vector<HTMLInfo*> GetHTMLInfo();
|
std::vector<HTMLInfo*> GetHTMLInfo();
|
||||||
|
|
||||||
|
void DrawROI(CImageBasis *_zw);
|
||||||
|
|
||||||
string name(){return "ClassFlowDigit";};
|
string name(){return "ClassFlowDigit";};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,19 +5,31 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include "time_sntp.h"
|
#include "time_sntp.h"
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
#include "CImageBasis.h"
|
||||||
|
|
||||||
ClassFlowImage::ClassFlowImage(const char* logTag)
|
ClassFlowImage::ClassFlowImage(const char* logTag)
|
||||||
{
|
{
|
||||||
this->logTag = logTag;
|
this->logTag = logTag;
|
||||||
isLogImage = false;
|
isLogImage = false;
|
||||||
|
disabled = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassFlowImage::ClassFlowImage(std::vector<ClassFlow*> * lfc, const char* logTag) : ClassFlow((std::vector<ClassFlow*>*)lfc)
|
ClassFlowImage::ClassFlowImage(std::vector<ClassFlow*> * lfc, const char* logTag) : ClassFlow(lfc)
|
||||||
{
|
{
|
||||||
this->logTag = logTag;
|
this->logTag = logTag;
|
||||||
isLogImage = false;
|
isLogImage = false;
|
||||||
|
disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClassFlowImage::ClassFlowImage(std::vector<ClassFlow*> * lfc, ClassFlow *_prev, const char* logTag) : ClassFlow(lfc, _prev)
|
||||||
|
{
|
||||||
|
this->logTag = logTag;
|
||||||
|
isLogImage = false;
|
||||||
|
disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string ClassFlowImage::CreateLogFolder(string time) {
|
string ClassFlowImage::CreateLogFolder(string time) {
|
||||||
if (!isLogImage)
|
if (!isLogImage)
|
||||||
return "";
|
return "";
|
||||||
@@ -32,7 +44,7 @@ string ClassFlowImage::CreateLogFolder(string time) {
|
|||||||
return logPath;
|
return logPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassFlowImage::LogImage(string logPath, string name, float *resultFloat, int *resultInt, string time) {
|
void ClassFlowImage::LogImage(string logPath, string name, float *resultFloat, int *resultInt, string time, CImageBasis *_img) {
|
||||||
if (!isLogImage)
|
if (!isLogImage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -50,7 +62,8 @@ void ClassFlowImage::LogImage(string logPath, string name, float *resultFloat, i
|
|||||||
string output = "/sdcard/img_tmp/" + name + ".jpg";
|
string output = "/sdcard/img_tmp/" + name + ".jpg";
|
||||||
output = FormatFileName(output);
|
output = FormatFileName(output);
|
||||||
printf("save to file: %s\n", nm.c_str());
|
printf("save to file: %s\n", nm.c_str());
|
||||||
CopyFile(output, nm);
|
_img->SaveToFile(nm);
|
||||||
|
// CopyFile(output, nm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassFlowImage::RemoveOldLogs()
|
void ClassFlowImage::RemoveOldLogs()
|
||||||
|
|||||||
@@ -12,11 +12,13 @@ protected:
|
|||||||
const char* logTag;
|
const char* logTag;
|
||||||
|
|
||||||
string CreateLogFolder(string time);
|
string CreateLogFolder(string time);
|
||||||
void LogImage(string logPath, string name, float *resultFloat, int *resultInt, string time);
|
void LogImage(string logPath, string name, float *resultFloat, int *resultInt, string time, CImageBasis *_img);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClassFlowImage(const char* logTag);
|
ClassFlowImage(const char* logTag);
|
||||||
ClassFlowImage(std::vector<ClassFlow*> * lfc, const char* logTag);
|
ClassFlowImage(std::vector<ClassFlow*> * lfc, const char* logTag);
|
||||||
|
ClassFlowImage(std::vector<ClassFlow*> * lfc, ClassFlow *_prev, const char* logTag);
|
||||||
|
|
||||||
void RemoveOldLogs();
|
void RemoveOldLogs();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
ClassFlowMQTT::ClassFlowMQTT()
|
void ClassFlowMQTT::SetInitialParameter(void)
|
||||||
{
|
{
|
||||||
uri = "";
|
uri = "";
|
||||||
topic = "";
|
topic = "";
|
||||||
@@ -15,20 +15,37 @@ ClassFlowMQTT::ClassFlowMQTT()
|
|||||||
OldValue = "";
|
OldValue = "";
|
||||||
flowpostprocessing = NULL;
|
flowpostprocessing = NULL;
|
||||||
user = "";
|
user = "";
|
||||||
password = "";
|
password = "";
|
||||||
|
previousElement = NULL;
|
||||||
|
ListFlowControll = NULL;
|
||||||
|
disabled = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassFlowMQTT::ClassFlowMQTT()
|
||||||
|
{
|
||||||
|
SetInitialParameter();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassFlowMQTT::ClassFlowMQTT(std::vector<ClassFlow*>* lfc)
|
ClassFlowMQTT::ClassFlowMQTT(std::vector<ClassFlow*>* lfc)
|
||||||
{
|
{
|
||||||
uri = "";
|
SetInitialParameter();
|
||||||
topic = "";
|
|
||||||
topicError = "";
|
|
||||||
clientname = "watermeter";
|
|
||||||
OldValue = "";
|
|
||||||
flowpostprocessing = NULL;
|
|
||||||
user = "";
|
|
||||||
password = "";
|
|
||||||
|
|
||||||
|
ListFlowControll = lfc;
|
||||||
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
||||||
|
{
|
||||||
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowPostProcessing") == 0)
|
||||||
|
{
|
||||||
|
flowpostprocessing = (ClassFlowPostProcessing*) (*ListFlowControll)[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassFlowMQTT::ClassFlowMQTT(std::vector<ClassFlow*>* lfc, ClassFlow *_prev)
|
||||||
|
{
|
||||||
|
SetInitialParameter();
|
||||||
|
|
||||||
|
previousElement = _prev;
|
||||||
ListFlowControll = lfc;
|
ListFlowControll = lfc;
|
||||||
|
|
||||||
for (int i = 0; i < ListFlowControll->size(); ++i)
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
||||||
@@ -38,9 +55,9 @@ ClassFlowMQTT::ClassFlowMQTT(std::vector<ClassFlow*>* lfc)
|
|||||||
flowpostprocessing = (ClassFlowPostProcessing*) (*ListFlowControll)[i];
|
flowpostprocessing = (ClassFlowPostProcessing*) (*ListFlowControll)[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
|
bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||||
{
|
{
|
||||||
std::vector<string> zerlegt;
|
std::vector<string> zerlegt;
|
||||||
@@ -86,7 +103,7 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
if ((uri.length() > 0) && (topic.length() > 0))
|
if ((uri.length() > 0) && (topic.length() > 0))
|
||||||
{
|
{
|
||||||
MQTTInit(uri, clientname, user, password);
|
MQTTInit(uri, clientname, user, password, topicError, 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,11 +13,13 @@ protected:
|
|||||||
std::string OldValue;
|
std::string OldValue;
|
||||||
ClassFlowPostProcessing* flowpostprocessing;
|
ClassFlowPostProcessing* flowpostprocessing;
|
||||||
std::string user, password;
|
std::string user, password;
|
||||||
|
void SetInitialParameter(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClassFlowMQTT();
|
ClassFlowMQTT();
|
||||||
ClassFlowMQTT(std::vector<ClassFlow*>* lfc);
|
ClassFlowMQTT(std::vector<ClassFlow*>* lfc);
|
||||||
|
ClassFlowMQTT(std::vector<ClassFlow*>* lfc, ClassFlow *_prev);
|
||||||
|
|
||||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||||
bool doFlow(string time);
|
bool doFlow(string time);
|
||||||
string name(){return "ClassFlowMQTT";};
|
string name(){return "ClassFlowMQTT";};
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
#include "ClassFlowMakeImage.h"
|
#include "ClassFlowMakeImage.h"
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
#include "CFindTemplate.h"
|
#include "CImageBasis.h"
|
||||||
#include "ClassControllCamera.h"
|
#include "ClassControllCamera.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
// #define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
static const char* TAG = "flow_make_image";
|
static const char* TAG = "flow_make_image";
|
||||||
|
|
||||||
esp_err_t ClassFlowMakeImage::camera_capture(){
|
esp_err_t ClassFlowMakeImage::camera_capture(){
|
||||||
@@ -16,30 +19,29 @@ esp_err_t ClassFlowMakeImage::camera_capture(){
|
|||||||
|
|
||||||
void ClassFlowMakeImage::takePictureWithFlash(int flashdauer)
|
void ClassFlowMakeImage::takePictureWithFlash(int flashdauer)
|
||||||
{
|
{
|
||||||
string nm = namerawimage;
|
Camera.CaptureToBasisImage(rawImage, flashdauer);
|
||||||
if (isImageSize && (ImageQuality > 0))
|
if (SaveAllFiles) rawImage->SaveToFile(namerawimage);
|
||||||
Camera.SetQualitySize(ImageQuality, ImageSize);
|
|
||||||
printf("Start CaptureFile\n");
|
|
||||||
Camera.CaptureToFile(nm, flashdauer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClassFlowMakeImage::SetInitialParameter(void)
|
||||||
ClassFlowMakeImage::ClassFlowMakeImage() : ClassFlowImage(TAG)
|
|
||||||
{
|
{
|
||||||
waitbeforepicture = 5;
|
waitbeforepicture = 5;
|
||||||
isImageSize = false;
|
isImageSize = false;
|
||||||
ImageQuality = -1;
|
ImageQuality = -1;
|
||||||
TimeImageTaken = 0;
|
TimeImageTaken = 0;
|
||||||
|
ImageQuality = 5;
|
||||||
|
rawImage = NULL;
|
||||||
|
ImageSize = FRAMESIZE_VGA;
|
||||||
|
SaveAllFiles = false;
|
||||||
|
disabled = false;
|
||||||
|
FixedExposure = false;
|
||||||
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ClassFlowMakeImage::ClassFlowMakeImage(std::vector<ClassFlow*>* lfc) : ClassFlowImage(lfc, TAG)
|
ClassFlowMakeImage::ClassFlowMakeImage(std::vector<ClassFlow*>* lfc) : ClassFlowImage(lfc, TAG)
|
||||||
{
|
{
|
||||||
waitbeforepicture = 5;
|
SetInitialParameter();
|
||||||
isImageSize = false;
|
|
||||||
ImageQuality = -1;
|
|
||||||
TimeImageTaken = 0;
|
|
||||||
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||||
@@ -47,6 +49,9 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
std::vector<string> zerlegt;
|
std::vector<string> zerlegt;
|
||||||
|
|
||||||
aktparamgraph = trim(aktparamgraph);
|
aktparamgraph = trim(aktparamgraph);
|
||||||
|
int _brightness = -100;
|
||||||
|
int _contrast = -100;
|
||||||
|
int _saturation = -100;
|
||||||
|
|
||||||
if (aktparamgraph.size() == 0)
|
if (aktparamgraph.size() == 0)
|
||||||
if (!this->GetNextParagraph(pfile, aktparamgraph))
|
if (!this->GetNextParagraph(pfile, aktparamgraph))
|
||||||
@@ -64,14 +69,62 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
isLogImage = true;
|
isLogImage = true;
|
||||||
}
|
}
|
||||||
if ((zerlegt[0] == "ImageQuality") && (zerlegt.size() > 1))
|
if ((zerlegt[0] == "ImageQuality") && (zerlegt.size() > 1))
|
||||||
this->ImageQuality = std::stod(zerlegt[1]);
|
ImageQuality = std::stod(zerlegt[1]);
|
||||||
|
|
||||||
if ((zerlegt[0] == "ImageSize") && (zerlegt.size() > 1))
|
if ((zerlegt[0] == "ImageSize") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
ImageSize = Camera.TextToFramesize(zerlegt[1].c_str());
|
ImageSize = Camera.TextToFramesize(zerlegt[1].c_str());
|
||||||
isImageSize = true;
|
isImageSize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "SAVEALLFILES") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
|
SaveAllFiles = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "BRIGHTNESS") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
_brightness = stoi(zerlegt[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "CONTRAST") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
_contrast = stoi(zerlegt[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "SATURATION") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
_saturation = stoi(zerlegt[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "FIXEDEXPOSURE") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
|
FixedExposure = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Camera.SetBrightnessContrastSaturation(_brightness, _contrast, _saturation);
|
||||||
|
Camera.SetQualitySize(ImageQuality, ImageSize);
|
||||||
|
|
||||||
|
image_width = Camera.image_width;
|
||||||
|
image_height = Camera.image_height;
|
||||||
|
rawImage = new CImageBasis();
|
||||||
|
rawImage->CreateEmptyImage(image_width, image_height, 3);
|
||||||
|
|
||||||
|
waitbeforepicture_store = waitbeforepicture;
|
||||||
|
if (FixedExposure)
|
||||||
|
{
|
||||||
|
printf("Fixed Exposure enabled!\n");
|
||||||
|
int flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
|
Camera.EnableAutoExposure(flashdauer);
|
||||||
|
waitbeforepicture = 0.2;
|
||||||
|
// flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
|
// takePictureWithFlash(flashdauer);
|
||||||
|
// rawImage->SaveToFile("/sdcard/init2.jpg");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,27 +137,56 @@ string ClassFlowMakeImage::getHTMLSingleStep(string host)
|
|||||||
|
|
||||||
bool ClassFlowMakeImage::doFlow(string zwtime)
|
bool ClassFlowMakeImage::doFlow(string zwtime)
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// TakeImage and Store into /image_tmp/raw.jpg TO BE DONE
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
string logPath = CreateLogFolder(zwtime);
|
string logPath = CreateLogFolder(zwtime);
|
||||||
|
|
||||||
int flashdauer = (int) waitbeforepicture * 1000;
|
int flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - Before takePictureWithFlash");
|
||||||
|
#endif
|
||||||
|
|
||||||
takePictureWithFlash(flashdauer);
|
takePictureWithFlash(flashdauer);
|
||||||
time(&TimeImageTaken);
|
|
||||||
localtime(&TimeImageTaken);
|
|
||||||
|
|
||||||
LogImage(logPath, "raw", NULL, NULL, zwtime);
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - After takePictureWithFlash");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LogImage(logPath, "raw", NULL, NULL, zwtime, rawImage);
|
||||||
|
|
||||||
RemoveOldLogs();
|
RemoveOldLogs();
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - After RemoveOldLogs");
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t ClassFlowMakeImage::SendRawJPG(httpd_req_t *req)
|
||||||
|
{
|
||||||
|
int flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
|
return Camera.CaptureToHTTP(req, flashdauer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ImageData* ClassFlowMakeImage::SendRawImage()
|
||||||
|
{
|
||||||
|
CImageBasis *zw = new CImageBasis(rawImage);
|
||||||
|
ImageData *id;
|
||||||
|
int flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
|
Camera.CaptureToBasisImage(zw, flashdauer);
|
||||||
|
id = zw->writeToMemoryAsJPG();
|
||||||
|
delete zw;
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
time_t ClassFlowMakeImage::getTimeImageTaken()
|
time_t ClassFlowMakeImage::getTimeImageTaken()
|
||||||
{
|
{
|
||||||
return TimeImageTaken;
|
return TimeImageTaken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClassFlowMakeImage::~ClassFlowMakeImage(void)
|
||||||
|
{
|
||||||
|
delete rawImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,24 +15,41 @@ class ClassFlowMakeImage :
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
float waitbeforepicture;
|
float waitbeforepicture;
|
||||||
|
float waitbeforepicture_store;
|
||||||
framesize_t ImageSize;
|
framesize_t ImageSize;
|
||||||
bool isImageSize;
|
bool isImageSize;
|
||||||
int ImageQuality;
|
int ImageQuality;
|
||||||
time_t TimeImageTaken;
|
time_t TimeImageTaken;
|
||||||
string namerawimage;
|
string namerawimage;
|
||||||
|
int image_height, image_width;
|
||||||
|
bool SaveAllFiles;
|
||||||
|
bool FixedExposure;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CopyFile(string input, string output);
|
void CopyFile(string input, string output);
|
||||||
|
|
||||||
esp_err_t camera_capture();
|
esp_err_t camera_capture();
|
||||||
void takePictureWithFlash(int flashdauer);
|
void takePictureWithFlash(int flashdauer);
|
||||||
|
|
||||||
|
|
||||||
|
void SetInitialParameter(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClassFlowMakeImage();
|
CImageBasis *rawImage;
|
||||||
|
|
||||||
ClassFlowMakeImage(std::vector<ClassFlow*>* lfc);
|
ClassFlowMakeImage(std::vector<ClassFlow*>* lfc);
|
||||||
|
|
||||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||||
bool doFlow(string time);
|
bool doFlow(string time);
|
||||||
string getHTMLSingleStep(string host);
|
string getHTMLSingleStep(string host);
|
||||||
time_t getTimeImageTaken();
|
time_t getTimeImageTaken();
|
||||||
string name(){return "ClassFlowMakeImage";};
|
string name(){return "ClassFlowMakeImage";};
|
||||||
|
|
||||||
|
ImageData* SendRawImage();
|
||||||
|
esp_err_t SendRawJPG(httpd_req_t *req);
|
||||||
|
|
||||||
|
~ClassFlowMakeImage(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,17 +14,28 @@
|
|||||||
string ClassFlowPostProcessing::GetPreValue()
|
string ClassFlowPostProcessing::GetPreValue()
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
|
bool isAnalog = false;
|
||||||
|
bool isDigit = false;
|
||||||
|
|
||||||
|
int AnzahlAnalog = 0;
|
||||||
result = RundeOutput(PreValue, -DecimalShift);
|
result = RundeOutput(PreValue, -DecimalShift);
|
||||||
|
|
||||||
for (int i = 0; i < ListFlowControll->size(); ++i)
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
||||||
{
|
{
|
||||||
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
|
||||||
{
|
{
|
||||||
int AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
isAnalog = true;
|
||||||
result = RundeOutput(PreValue, AnzahlAnalog - DecimalShift);
|
AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
||||||
|
}
|
||||||
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowDigit") == 0)
|
||||||
|
{
|
||||||
|
isDigit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDigit && isAnalog)
|
||||||
|
result = RundeOutput(PreValue, AnzahlAnalog - DecimalShift);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,17 +86,24 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|||||||
ReturnValue = to_string(Value);
|
ReturnValue = to_string(Value);
|
||||||
ReturnValueNoError = ReturnValue;
|
ReturnValueNoError = ReturnValue;
|
||||||
|
|
||||||
// falls es Analog gibt, dann die Anzahl der Nachkommastellen feststellen und entsprechend runden:
|
bool isAnalog = false;
|
||||||
|
bool isDigit = false;
|
||||||
|
int AnzahlAnalog = 0;
|
||||||
|
|
||||||
for (int i = 0; i < ListFlowControll->size(); ++i)
|
for (int i = 0; i < ListFlowControll->size(); ++i)
|
||||||
{
|
{
|
||||||
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
|
||||||
{
|
isAnalog = true;
|
||||||
int AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
|
if (((*ListFlowControll)[i])->name().compare("ClassFlowDigit") == 0)
|
||||||
ReturnValue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
|
isDigit = true;
|
||||||
ReturnValueNoError = ReturnValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDigit || isAnalog)
|
||||||
|
{
|
||||||
|
ReturnValue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
|
||||||
|
ReturnValueNoError = ReturnValue;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +126,8 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
|
|||||||
zwtime = std::string(buffer);
|
zwtime = std::string(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PreValue = value;
|
||||||
|
|
||||||
fputs(zwtime.c_str(), pFile);
|
fputs(zwtime.c_str(), pFile);
|
||||||
fputs("\n", pFile);
|
fputs("\n", pFile);
|
||||||
fputs(to_string(value).c_str(), pFile);
|
fputs(to_string(value).c_str(), pFile);
|
||||||
@@ -117,23 +137,6 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ClassFlowPostProcessing::ClassFlowPostProcessing()
|
|
||||||
{
|
|
||||||
PreValueUse = false;
|
|
||||||
PreValueAgeStartup = 30;
|
|
||||||
AllowNegativeRates = false;
|
|
||||||
MaxRateValue = 0.1;
|
|
||||||
ErrorMessage = false;
|
|
||||||
ListFlowControll = NULL;
|
|
||||||
PreValueOkay = false;
|
|
||||||
useMaxRateValue = false;
|
|
||||||
checkDigitIncreaseConsistency = false;
|
|
||||||
DecimalShift = 0;
|
|
||||||
ErrorMessageText = "";
|
|
||||||
FilePreValue = FormatFileName("/sdcard/config/prevalue.ini");
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
|
ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
|
||||||
{
|
{
|
||||||
PreValueUse = false;
|
PreValueUse = false;
|
||||||
@@ -266,6 +269,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
int AnzahlAnalog = 0;
|
int AnzahlAnalog = 0;
|
||||||
string zw;
|
string zw;
|
||||||
time_t imagetime = 0;
|
time_t imagetime = 0;
|
||||||
|
string rohwert;
|
||||||
|
|
||||||
ErrorMessageText = "";
|
ErrorMessageText = "";
|
||||||
|
|
||||||
@@ -304,6 +308,8 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
// isdigit = true; digit = "12N";
|
// isdigit = true; digit = "12N";
|
||||||
// isanalog = true; analog = "456";
|
// isanalog = true; analog = "456";
|
||||||
|
|
||||||
|
ReturnRawValue = "";
|
||||||
|
|
||||||
if (isdigit)
|
if (isdigit)
|
||||||
ReturnRawValue = digit;
|
ReturnRawValue = digit;
|
||||||
if (isdigit && isanalog)
|
if (isdigit && isanalog)
|
||||||
@@ -311,8 +317,16 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
if (isanalog)
|
if (isanalog)
|
||||||
ReturnRawValue = ReturnRawValue + analog;
|
ReturnRawValue = ReturnRawValue + analog;
|
||||||
|
|
||||||
|
|
||||||
|
if (!isdigit)
|
||||||
|
{
|
||||||
|
AnzahlAnalog = 0;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnRawValue = ShiftDecimal(ReturnRawValue, DecimalShift);
|
ReturnRawValue = ShiftDecimal(ReturnRawValue, DecimalShift);
|
||||||
|
|
||||||
|
rohwert = ReturnRawValue;
|
||||||
|
|
||||||
if (!PreValueUse || !PreValueOkay)
|
if (!PreValueUse || !PreValueOkay)
|
||||||
{
|
{
|
||||||
ReturnValue = ReturnRawValue;
|
ReturnValue = ReturnRawValue;
|
||||||
@@ -347,14 +361,14 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
|
|
||||||
if ((!AllowNegativeRates) && (Value < PreValue))
|
if ((!AllowNegativeRates) && (Value < PreValue))
|
||||||
{
|
{
|
||||||
ErrorMessageText = ErrorMessageText + "Negative Rate - Returned old value - read value: " + zwvalue + " ";
|
ErrorMessageText = ErrorMessageText + "Negative Rate - Returned old value - read value: " + zwvalue + " - raw value: " + ReturnRawValue + " - checked value: " + std::to_string(Value) + " ";
|
||||||
Value = PreValue;
|
Value = PreValue;
|
||||||
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
|
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useMaxRateValue && (abs(Value - PreValue) > MaxRateValue))
|
if (useMaxRateValue && (abs(Value - PreValue) > MaxRateValue))
|
||||||
{
|
{
|
||||||
ErrorMessageText = ErrorMessageText + "Rate too high - Returned old value - read value: " + zwvalue + " ";
|
ErrorMessageText = ErrorMessageText + "Rate too high - Returned old value - read value: " + zwvalue + " - checked value: " + RundeOutput(Value, AnzahlAnalog - DecimalShift) + " ";
|
||||||
Value = PreValue;
|
Value = PreValue;
|
||||||
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
|
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
|
||||||
}
|
}
|
||||||
@@ -390,10 +404,24 @@ string ClassFlowPostProcessing::getReadoutParam(bool _rawValue, bool _noerror)
|
|||||||
|
|
||||||
string ClassFlowPostProcessing::RundeOutput(float _in, int _anzNachkomma){
|
string ClassFlowPostProcessing::RundeOutput(float _in, int _anzNachkomma){
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
|
int _zw = _in;
|
||||||
|
// printf("AnzNachkomma: %d\n", _anzNachkomma);
|
||||||
|
|
||||||
if (_anzNachkomma < 0) {
|
if (_anzNachkomma < 0) {
|
||||||
_anzNachkomma = 0;
|
_anzNachkomma = 0;
|
||||||
}
|
}
|
||||||
stream << std::fixed << std::setprecision(_anzNachkomma) << _in;
|
|
||||||
|
if (_anzNachkomma > 0)
|
||||||
|
{
|
||||||
|
stream << std::fixed << std::setprecision(_anzNachkomma) << _in;
|
||||||
|
return stream.str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stream << _zw;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return stream.str();
|
return stream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ protected:
|
|||||||
string RundeOutput(float _in, int _anzNachkomma);
|
string RundeOutput(float _in, int _anzNachkomma);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClassFlowPostProcessing();
|
|
||||||
ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc);
|
ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc);
|
||||||
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
bool ReadParameter(FILE* pfile, string& aktparamgraph);
|
||||||
bool doFlow(string time);
|
bool doFlow(string time);
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
|
|||||||
|
|
||||||
idf_component_register(SRCS ${app_sources}
|
idf_component_register(SRCS ${app_sources}
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
REQUIRES tfmicro)
|
REQUIRES tfmicro jomjol_logfile)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
//#pragma warning(disable : 4996)
|
//#pragma warning(disable : 4996)
|
||||||
|
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -7,11 +10,91 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
|
|
||||||
|
#include "ClassLogFile.h"
|
||||||
|
//#include "ClassLogFile.h"
|
||||||
|
|
||||||
//#define ISWINDOWS_TRUE
|
//#define ISWINDOWS_TRUE
|
||||||
#define PATH_MAX_STRING_SIZE 256
|
#define PATH_MAX_STRING_SIZE 256
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
string getESPHeapInfo(){
|
||||||
|
string espInfoResultStr = "";
|
||||||
|
char aMsgBuf[80];
|
||||||
|
|
||||||
|
multi_heap_info_t aMultiHead_info ;
|
||||||
|
heap_caps_get_info (&aMultiHead_info,MALLOC_CAP_8BIT);
|
||||||
|
size_t aFreeHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t aMinFreeHeadSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t aMinFreeHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t aHeapLargestFreeBlockSize = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
|
||||||
|
sprintf(aMsgBuf," Free Heap Size: %ld", (long) aFreeHeapSize);
|
||||||
|
size_t aFreeSPIHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_SPIRAM);
|
||||||
|
size_t aFreeInternalHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
||||||
|
size_t aMinFreeInternalHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
||||||
|
|
||||||
|
sprintf(aMsgBuf," Heap: %ld", (long) aFreeHeapSize);
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf," Min Free: %ld", (long) aMinFreeHeapSize);
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf," larg. Block: %ld", (long) aHeapLargestFreeBlockSize);
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf," SPI Heap: %ld", (long) aFreeSPIHeapSize);
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf," Min Free Heap Size: %ld", (long) aMinFreeHeadSize);
|
||||||
|
sprintf(aMsgBuf," NOT_SPI Heap: %ld", (long) (aFreeHeapSize - aFreeSPIHeapSize));
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf," largest Block Size: %ld", (long) aHeapLargestFreeBlockSize);
|
||||||
|
sprintf(aMsgBuf," Internal Heap: %ld", (long) (aFreeInternalHeapSize));
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf," Internal Min Heap free: %ld", (long) (aMinFreeInternalHeapSize));
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
return espInfoResultStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t getESPHeapSize(){
|
||||||
|
size_t aFreeHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
return aFreeHeapSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t getInternalESPHeapSize() {
|
||||||
|
size_t aFreeInternalHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
||||||
|
return aFreeInternalHeapSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void memCopyGen(uint8_t* _source, uint8_t* _target, int _size)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _size; ++i)
|
||||||
|
*(_target + i) = *(_source + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FILE* OpenFileAndWait(const char* nm, char* _mode, int _waitsec)
|
||||||
|
{
|
||||||
|
FILE *pfile = fopen(nm, _mode);
|
||||||
|
|
||||||
|
if (pfile == NULL)
|
||||||
|
{
|
||||||
|
TickType_t xDelay;
|
||||||
|
xDelay = _waitsec * 1000 / portTICK_PERIOD_MS;
|
||||||
|
std::string zw = "File is locked: " + std::string(nm) + " - wait for " + std::to_string(_waitsec);
|
||||||
|
printf(zw.c_str());
|
||||||
|
printf("\n");
|
||||||
|
LogFile.WriteToFile(zw);
|
||||||
|
vTaskDelay( xDelay );
|
||||||
|
pfile = fopen(nm, _mode);
|
||||||
|
}
|
||||||
|
return pfile;
|
||||||
|
}
|
||||||
|
|
||||||
std::string FormatFileName(std::string input)
|
std::string FormatFileName(std::string input)
|
||||||
{
|
{
|
||||||
#ifdef ISWINDOWS_TRUE
|
#ifdef ISWINDOWS_TRUE
|
||||||
@@ -126,14 +209,14 @@ void CopyFile(string input, string output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char cTemp;
|
char cTemp;
|
||||||
FILE* fpSourceFile = fopen(input.c_str(), "rb");
|
FILE* fpSourceFile = OpenFileAndWait(input.c_str(), "rb");
|
||||||
if (!fpSourceFile) // Sourcefile existiert nicht sonst gibt es einen Fehler beim Kopierversuch!
|
if (!fpSourceFile) // Sourcefile existiert nicht sonst gibt es einen Fehler beim Kopierversuch!
|
||||||
{
|
{
|
||||||
printf("File %s existiert nicht!\n", input.c_str());
|
printf("File %s existiert nicht!\n", input.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* fpTargetFile = fopen(output.c_str(), "wb");
|
FILE* fpTargetFile = OpenFileAndWait(output.c_str(), "wb");
|
||||||
|
|
||||||
// Code Section
|
// Code Section
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ void FindReplace(std::string& line, std::string& oldString, std::string& newStri
|
|||||||
|
|
||||||
void CopyFile(string input, string output);
|
void CopyFile(string input, string output);
|
||||||
|
|
||||||
|
FILE* OpenFileAndWait(const char* nm, char* _mode, int _waitsec = 1);
|
||||||
|
|
||||||
size_t findDelimiterPos(string input, string delimiter);
|
size_t findDelimiterPos(string input, string delimiter);
|
||||||
//string trim(string istring);
|
//string trim(string istring);
|
||||||
string trim(string istring, string adddelimiter = "");
|
string trim(string istring, string adddelimiter = "");
|
||||||
@@ -25,3 +27,12 @@ string toUpper(string in);
|
|||||||
float temperatureRead();
|
float temperatureRead();
|
||||||
|
|
||||||
time_t addDays(time_t startTime, int days);
|
time_t addDays(time_t startTime, int days);
|
||||||
|
|
||||||
|
void memCopyGen(uint8_t* _source, uint8_t* _target, int _size);
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
size_t getInternalESPHeapSize();
|
||||||
|
size_t getESPHeapSize();
|
||||||
|
string getESPHeapInfo();
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
|||||||
207
code/components/jomjol_image_proc/CAlignAndCutImage.cpp
Normal file
207
code/components/jomjol_image_proc/CAlignAndCutImage.cpp
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
#include "CAlignAndCutImage.h"
|
||||||
|
#include "CRotateImage.h"
|
||||||
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
|
#include <math.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
//#define GET_MEMORY malloc
|
||||||
|
#define GET_MEMORY(X) heap_caps_malloc(X, MALLOC_CAP_SPIRAM)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CAlignAndCutImage::CAlignAndCutImage(CImageBasis *_org, CImageBasis *_temp)
|
||||||
|
{
|
||||||
|
rgb_image = _org->rgb_image;
|
||||||
|
channels = _org->channels;
|
||||||
|
width = _org->width;
|
||||||
|
height = _org->height;
|
||||||
|
bpp = _org->bpp;
|
||||||
|
externalImage = true;
|
||||||
|
|
||||||
|
islocked = false;
|
||||||
|
|
||||||
|
ImageTMP = _temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAlignAndCutImage::GetRefSize(int *ref_dx, int *ref_dy)
|
||||||
|
{
|
||||||
|
ref_dx[0] = t0_dx;
|
||||||
|
ref_dy[0] = t0_dy;
|
||||||
|
ref_dx[1] = t1_dx;
|
||||||
|
ref_dy[1] = t1_dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAlignAndCutImage::Align(RefInfo *_temp1, RefInfo *_temp2)
|
||||||
|
{
|
||||||
|
int dx, dy;
|
||||||
|
int r0_x, r0_y, r1_x, r1_y;
|
||||||
|
bool isSimilar1, isSimilar2;
|
||||||
|
|
||||||
|
CFindTemplate* ft = new CFindTemplate(rgb_image, channels, width, height, bpp);
|
||||||
|
|
||||||
|
r0_x = _temp1->target_x;
|
||||||
|
r0_y = _temp1->target_y;
|
||||||
|
printf("Vor ft->FindTemplate(_temp1); %s\n", _temp1->image_file.c_str());
|
||||||
|
isSimilar1 = ft->FindTemplate(_temp1);
|
||||||
|
_temp1->width = ft->tpl_width;
|
||||||
|
_temp1->height = ft->tpl_height;
|
||||||
|
|
||||||
|
r1_x = _temp2->target_x;
|
||||||
|
r1_y = _temp2->target_y;
|
||||||
|
printf("Vor ft->FindTemplate(_temp2); %s\n", _temp2->image_file.c_str());
|
||||||
|
isSimilar2 = ft->FindTemplate(_temp2);
|
||||||
|
_temp2->width = ft->tpl_width;
|
||||||
|
_temp2->height = ft->tpl_height;
|
||||||
|
|
||||||
|
delete ft;
|
||||||
|
|
||||||
|
|
||||||
|
dx = _temp1->target_x - _temp1->found_x;
|
||||||
|
dy = _temp1->target_y - _temp1->found_y;
|
||||||
|
|
||||||
|
r0_x += dx;
|
||||||
|
r0_y += dy;
|
||||||
|
|
||||||
|
r1_x += dx;
|
||||||
|
r1_y += dy;
|
||||||
|
|
||||||
|
float w_org, w_ist, d_winkel;
|
||||||
|
|
||||||
|
w_org = atan2(_temp2->found_y - _temp1->found_y, _temp2->found_x - _temp1->found_x);
|
||||||
|
w_ist = atan2(r1_y - r0_y, r1_x - r0_x);
|
||||||
|
|
||||||
|
d_winkel = (w_ist - w_org) * 180 / M_PI;
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
std::string zw = "\tdx:\t" + std::to_string(dx) + "\tdy:\t" + std::to_string(dy) + "\td_winkel:\t" + std::to_string(d_winkel);
|
||||||
|
zw = zw + "\tt1_x_y:\t" + std::to_string(_temp1->found_x) + "\t" + std::to_string(_temp1->found_y);
|
||||||
|
zw = zw + "\tpara1_found_min_avg_max_SAD:\t" + std::to_string(_temp1->fastalg_min) + "\t" + std::to_string(_temp1->fastalg_avg) + "\t" + std::to_string(_temp1->fastalg_max) + "\t"+ std::to_string(_temp1->fastalg_SAD);
|
||||||
|
zw = zw + "\tt2_x_y:\t" + std::to_string(_temp2->found_x) + "\t" + std::to_string(_temp2->found_y);
|
||||||
|
zw = zw + "\tpara2_found_min_avg_max:\t" + std::to_string(_temp2->fastalg_min) + "\t" + std::to_string(_temp2->fastalg_avg) + "\t" + std::to_string(_temp2->fastalg_max) + "\t"+ std::to_string(_temp2->fastalg_SAD);
|
||||||
|
LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", zw);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CRotateImage rt(this, ImageTMP);
|
||||||
|
rt.Translate(dx, dy);
|
||||||
|
rt.Rotate(d_winkel, _temp1->target_x, _temp1->target_y);
|
||||||
|
printf("Alignment: dx %d - dy %d - rot %f\n", dx, dy, d_winkel);
|
||||||
|
|
||||||
|
return (isSimilar1 && isSimilar2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int dx, int dy)
|
||||||
|
{
|
||||||
|
|
||||||
|
int x2, y2;
|
||||||
|
|
||||||
|
x2 = x1 + dx;
|
||||||
|
y2 = y1 + dy;
|
||||||
|
x2 = std::min(x2, width - 1);
|
||||||
|
y2 = std::min(y2, height - 1);
|
||||||
|
|
||||||
|
dx = x2 - x1;
|
||||||
|
dy = y2 - y1;
|
||||||
|
|
||||||
|
int memsize = dx * dy * channels;
|
||||||
|
uint8_t* odata = (unsigned char*) GET_MEMORY(memsize);
|
||||||
|
|
||||||
|
stbi_uc* p_target;
|
||||||
|
stbi_uc* p_source;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
for (int x = x1; x < x2; ++x)
|
||||||
|
for (int y = y1; y < y2; ++y)
|
||||||
|
{
|
||||||
|
p_target = odata + (channels * ((y - y1) * dx + (x - x1)));
|
||||||
|
p_source = rgb_image + (channels * (y * width + x));
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_target[_channels] = p_source[_channels];
|
||||||
|
}
|
||||||
|
|
||||||
|
// stbi_write_jpg(_template1.c_str(), dx, dy, channels, odata, 0);
|
||||||
|
stbi_write_bmp(_template1.c_str(), dx, dy, channels, odata);
|
||||||
|
|
||||||
|
RGBImageRelease();
|
||||||
|
|
||||||
|
stbi_image_free(odata);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAlignAndCutImage::CutAndSave(int x1, int y1, int dx, int dy, CImageBasis *_target)
|
||||||
|
{
|
||||||
|
int x2, y2;
|
||||||
|
|
||||||
|
x2 = x1 + dx;
|
||||||
|
y2 = y1 + dy;
|
||||||
|
x2 = std::min(x2, width - 1);
|
||||||
|
y2 = std::min(y2, height - 1);
|
||||||
|
|
||||||
|
dx = x2 - x1;
|
||||||
|
dy = y2 - y1;
|
||||||
|
|
||||||
|
if ((_target->height != dy) || (_target->width != dx) || (_target->channels != channels))
|
||||||
|
{
|
||||||
|
printf("CAlignAndCutImage::CutAndSave - Bildgröße passt nicht !!!!!!!!!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* odata = _target->RGBImageLock();
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
stbi_uc* p_target;
|
||||||
|
stbi_uc* p_source;
|
||||||
|
|
||||||
|
for (int x = x1; x < x2; ++x)
|
||||||
|
for (int y = y1; y < y2; ++y)
|
||||||
|
{
|
||||||
|
p_target = odata + (channels * ((y - y1) * dx + (x - x1)));
|
||||||
|
p_source = rgb_image + (channels * (y * width + x));
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_target[_channels] = p_source[_channels];
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBImageRelease();
|
||||||
|
_target->RGBImageRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CImageBasis* CAlignAndCutImage::CutAndSave(int x1, int y1, int dx, int dy)
|
||||||
|
{
|
||||||
|
int x2, y2;
|
||||||
|
|
||||||
|
x2 = x1 + dx;
|
||||||
|
y2 = y1 + dy;
|
||||||
|
x2 = std::min(x2, width - 1);
|
||||||
|
y2 = std::min(y2, height - 1);
|
||||||
|
|
||||||
|
dx = x2 - x1;
|
||||||
|
dy = y2 - y1;
|
||||||
|
|
||||||
|
int memsize = dx * dy * channels;
|
||||||
|
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
|
||||||
|
|
||||||
|
stbi_uc* p_target;
|
||||||
|
stbi_uc* p_source;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
for (int x = x1; x < x2; ++x)
|
||||||
|
for (int y = y1; y < y2; ++y)
|
||||||
|
{
|
||||||
|
p_target = odata + (channels * ((y - y1) * dx + (x - x1)));
|
||||||
|
p_source = rgb_image + (channels * (y * width + x));
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_target[_channels] = p_source[_channels];
|
||||||
|
}
|
||||||
|
|
||||||
|
CImageBasis* rs = new CImageBasis(odata, channels, dx, dy, bpp);
|
||||||
|
RGBImageRelease();
|
||||||
|
rs->SetIndepended();
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
21
code/components/jomjol_image_proc/CAlignAndCutImage.h
Normal file
21
code/components/jomjol_image_proc/CAlignAndCutImage.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include "CImageBasis.h"
|
||||||
|
#include "CFindTemplate.h"
|
||||||
|
|
||||||
|
|
||||||
|
class CAlignAndCutImage : public CImageBasis
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int t0_dx, t0_dy, t1_dx, t1_dy;
|
||||||
|
CImageBasis *ImageTMP;
|
||||||
|
CAlignAndCutImage(std::string _image) : CImageBasis(_image) {ImageTMP = NULL;};
|
||||||
|
CAlignAndCutImage(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {ImageTMP = NULL;};
|
||||||
|
CAlignAndCutImage(CImageBasis *_org, CImageBasis *_temp);
|
||||||
|
|
||||||
|
bool Align(RefInfo *_temp1, RefInfo *_temp2);
|
||||||
|
// void Align(std::string _template1, int x1, int y1, std::string _template2, int x2, int y2, int deltax = 40, int deltay = 40, std::string imageROI = "");
|
||||||
|
void CutAndSave(std::string _template1, int x1, int y1, int dx, int dy);
|
||||||
|
CImageBasis* CutAndSave(int x1, int y1, int dx, int dy);
|
||||||
|
void CutAndSave(int x1, int y1, int dx, int dy, CImageBasis *_target);
|
||||||
|
void GetRefSize(int *ref_dx, int *ref_dy);
|
||||||
|
};
|
||||||
|
|
||||||
@@ -1,547 +1,185 @@
|
|||||||
#include "CFindTemplate.h"
|
#include "CFindTemplate.h"
|
||||||
#include "Helper.h"
|
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
#include "esp_system.h"
|
// #define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
#define _USE_MATH_DEFINES
|
|
||||||
#include <math.h>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#define _ESP32_PSRAM
|
bool CFindTemplate::FindTemplate(RefInfo *_ref)
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define GET_MEMORY malloc
|
|
||||||
|
|
||||||
/*
|
|
||||||
CResizeImage::CResizeImage(std::string _image, int _new_dx, int _new_dy)
|
|
||||||
{
|
{
|
||||||
CImageBasis::CImageBasis(_image);
|
uint8_t* rgb_template = stbi_load(_ref->image_file.c_str(), &tpl_width, &tpl_height, &tpl_bpp, channels);
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint8_t CImageBasis::GetPixelColor(int x, int y, int ch)
|
// printf("FindTemplate 01\n");
|
||||||
{
|
|
||||||
stbi_uc* p_source;
|
|
||||||
p_source = this->rgb_image + (this->channels * (y * this->width + x));
|
|
||||||
return p_source[ch];
|
|
||||||
}
|
|
||||||
|
|
||||||
void CResizeImage::Resize(int _new_dx, int _new_dy)
|
|
||||||
{
|
|
||||||
int memsize = _new_dx * _new_dy * this->channels;
|
|
||||||
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
|
|
||||||
|
|
||||||
stbir_resize_uint8(this->rgb_image, this->width, this->height, 0, odata, _new_dx, _new_dy, 0, this->channels);
|
|
||||||
|
|
||||||
stbi_image_free(this->rgb_image);
|
|
||||||
this->rgb_image = (unsigned char*)GET_MEMORY(memsize);
|
|
||||||
|
|
||||||
this->memCopy(odata, this->rgb_image, memsize);
|
|
||||||
this->width = _new_dx;
|
|
||||||
this->height = _new_dy;
|
|
||||||
stbi_image_free(odata);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CRotate::Mirror(){
|
|
||||||
int memsize = this->width * this->height * this->channels;
|
|
||||||
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
|
|
||||||
|
|
||||||
int x_source, y_source;
|
|
||||||
stbi_uc* p_target;
|
|
||||||
stbi_uc* p_source;
|
|
||||||
|
|
||||||
for (int x = 0; x < this->width; ++x)
|
|
||||||
for (int y = 0; y < this->height; ++y)
|
|
||||||
{
|
|
||||||
p_target = odata + (this->channels * (y * this->width + x));
|
|
||||||
|
|
||||||
x_source = this->width - x;
|
|
||||||
y_source = y;
|
|
||||||
|
|
||||||
p_source = this->rgb_image + (this->channels * (y_source * this->width + x_source));
|
|
||||||
for (int channels = 0; channels < this->channels; ++channels)
|
|
||||||
p_target[channels] = p_source[channels];
|
|
||||||
}
|
|
||||||
|
|
||||||
// memcpy(this->rgb_image, odata, memsize);
|
|
||||||
this->memCopy(odata, this->rgb_image, memsize);
|
|
||||||
stbi_image_free(odata);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CRotate::Rotate(float _angle, int _centerx, int _centery)
|
|
||||||
{
|
|
||||||
float m[2][3];
|
|
||||||
|
|
||||||
float x_center = _centerx;
|
|
||||||
float y_center = _centery;
|
|
||||||
_angle = _angle / 180 * M_PI;
|
|
||||||
|
|
||||||
m[0][0] = cos(_angle);
|
|
||||||
m[0][1] = sin(_angle);
|
|
||||||
m[0][2] = (1 - m[0][0]) * x_center - m[0][1] * y_center;
|
|
||||||
|
|
||||||
m[1][0] = -m[0][1];
|
|
||||||
m[1][1] = m[0][0];
|
|
||||||
m[1][2] = m[0][1] * x_center + (1 - m[0][0]) * y_center;
|
|
||||||
|
|
||||||
int memsize = this->width * this->height * this->channels;
|
|
||||||
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
|
|
||||||
|
|
||||||
int x_source, y_source;
|
|
||||||
stbi_uc* p_target;
|
|
||||||
stbi_uc* p_source;
|
|
||||||
|
|
||||||
for (int x = 0; x < this->width; ++x)
|
|
||||||
for (int y = 0; y < this->height; ++y)
|
|
||||||
{
|
|
||||||
p_target = odata + (this->channels * (y * this->width + x));
|
|
||||||
|
|
||||||
x_source = int(m[0][0] * x + m[0][1] * y);
|
|
||||||
y_source = int(m[1][0] * x + m[1][1] * y);
|
|
||||||
|
|
||||||
x_source += int(m[0][2]);
|
|
||||||
y_source += int(m[1][2]);
|
|
||||||
|
|
||||||
if ((x_source >= 0) && (x_source < this->width) && (y_source >= 0) && (y_source < this->height))
|
|
||||||
{
|
|
||||||
p_source = this->rgb_image + (this->channels * (y_source * this->width + x_source));
|
|
||||||
for (int channels = 0; channels < this->channels; ++channels)
|
|
||||||
p_target[channels] = p_source[channels];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int channels = 0; channels < this->channels; ++channels)
|
|
||||||
p_target[channels] = 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// memcpy(this->rgb_image, odata, memsize);
|
|
||||||
this->memCopy(odata, this->rgb_image, memsize);
|
|
||||||
stbi_image_free(odata);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CRotate::Rotate(float _angle)
|
|
||||||
{
|
|
||||||
this->Rotate(_angle, this->width / 2, this->height / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CRotate::Translate(int _dx, int _dy)
|
|
||||||
{
|
|
||||||
int memsize = this->width * this->height * this->channels;
|
|
||||||
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
|
|
||||||
|
|
||||||
|
|
||||||
int x_source, y_source;
|
|
||||||
stbi_uc* p_target;
|
|
||||||
stbi_uc* p_source;
|
|
||||||
|
|
||||||
for (int x = 0; x < this->width; ++x)
|
|
||||||
for (int y = 0; y < this->height; ++y)
|
|
||||||
{
|
|
||||||
p_target = odata + (this->channels * (y * this->width + x));
|
|
||||||
|
|
||||||
x_source = x - _dx;
|
|
||||||
y_source = y - _dy;
|
|
||||||
|
|
||||||
if ((x_source >= 0) && (x_source < this->width) && (y_source >= 0) && (y_source < this->height))
|
|
||||||
{
|
|
||||||
p_source = this->rgb_image + (this->channels * (y_source * this->width + x_source));
|
|
||||||
for (int channels = 0; channels < this->channels; ++channels)
|
|
||||||
p_target[channels] = p_source[channels];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int channels = 0; channels < this->channels; ++channels)
|
|
||||||
p_target[channels] = 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// memcpy(this->rgb_image, odata, memsize);
|
|
||||||
this->memCopy(odata, this->rgb_image, memsize);
|
|
||||||
stbi_image_free(odata);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CFindTemplate::CFindTemplate(std::string _image)
|
|
||||||
{
|
|
||||||
this->channels = 1;
|
|
||||||
this->rgb_image = stbi_load(_image.c_str(), &(this->width), &(this->height), &(this->bpp), this->channels);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFindTemplate::FindTemplate(std::string _template, int* found_x, int* found_y)
|
|
||||||
{
|
|
||||||
this->FindTemplate(_template, found_x, found_y, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFindTemplate::FindTemplate(std::string _template, int* found_x, int* found_y, int _dx, int _dy)
|
|
||||||
{
|
|
||||||
uint8_t* rgb_template = stbi_load(_template.c_str(), &tpl_width, &tpl_height, &tpl_bpp, this->channels);
|
|
||||||
|
|
||||||
int ow, ow_start, ow_stop;
|
int ow, ow_start, ow_stop;
|
||||||
int oh, oh_start, oh_stop;
|
int oh, oh_start, oh_stop;
|
||||||
|
|
||||||
if (_dx == 0)
|
if (_ref->search_x == 0)
|
||||||
{
|
{
|
||||||
_dx = this->width;
|
_ref->search_x = width;
|
||||||
*found_x = 0;
|
_ref->found_x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_dy == 0)
|
if (_ref->search_y == 0)
|
||||||
{
|
{
|
||||||
_dy = this->height;
|
_ref->search_y = height;
|
||||||
*found_y = 0;
|
_ref->found_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ow_start = *found_x - _dx;
|
ow_start = _ref->target_x - _ref->search_x;
|
||||||
ow_start = std::max(ow_start, 0);
|
ow_start = std::max(ow_start, 0);
|
||||||
ow_stop = *found_x + _dx;
|
ow_stop = _ref->target_x + _ref->search_x;
|
||||||
if ((ow_stop + tpl_width) > this->width)
|
if ((ow_stop + tpl_width) > width)
|
||||||
ow_stop = this->width - tpl_width;
|
ow_stop = width - tpl_width;
|
||||||
ow = ow_stop - ow_start + 1;
|
ow = ow_stop - ow_start + 1;
|
||||||
|
|
||||||
oh_start = *found_y - _dy;
|
oh_start = _ref->target_y - _ref->search_y;
|
||||||
oh_start = std::max(oh_start, 0);
|
oh_start = std::max(oh_start, 0);
|
||||||
oh_stop = *found_y + _dy;
|
oh_stop = _ref->target_y + _ref->search_y;
|
||||||
if ((oh_stop + tpl_height) > this->height)
|
if ((oh_stop + tpl_height) > height)
|
||||||
oh_stop = this->height - tpl_height;
|
oh_stop = height - tpl_height;
|
||||||
oh = oh_stop - oh_start + 1;
|
oh = oh_stop - oh_start + 1;
|
||||||
|
|
||||||
uint8_t* odata = (unsigned char*)GET_MEMORY(ow * oh * this->channels);
|
float avg, SAD;
|
||||||
|
int min, max;
|
||||||
|
bool isSimilar = false;
|
||||||
|
|
||||||
|
// printf("FindTemplate 02\n");
|
||||||
|
|
||||||
|
if ((_ref->alignment_algo == 2) && (_ref->fastalg_x > -1) && (_ref->fastalg_y > -1)) // für Testzwecke immer Berechnen
|
||||||
|
{
|
||||||
|
isSimilar = CalculateSimularities(rgb_template, _ref->fastalg_x, _ref->fastalg_y, ow, oh, min, avg, max, SAD, _ref->fastalg_SAD, _ref->fastalg_SAD_criteria);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
std::string zw = "\t" + _ref->image_file + "\tt1_x_y:\t" + std::to_string(_ref->fastalg_x) + "\t" + std::to_string(_ref->fastalg_y);
|
||||||
|
zw = zw + "\tpara1_found_min_avg_max_SAD:\t" + std::to_string(min) + "\t" + std::to_string(avg) + "\t" + std::to_string(max) + "\t"+ std::to_string(SAD);
|
||||||
|
LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", zw);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// printf("FindTemplate 03\n");
|
||||||
|
|
||||||
|
|
||||||
|
if (isSimilar)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteToFile("Use FastAlignment sucessfull");
|
||||||
|
#endif
|
||||||
|
_ref->found_x = _ref->fastalg_x;
|
||||||
|
_ref->found_y = _ref->fastalg_y;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// printf("FindTemplate 04\n");
|
||||||
|
|
||||||
|
|
||||||
double aktSAD;
|
double aktSAD;
|
||||||
double minSAD = pow(tpl_width * tpl_height * 255, 2);
|
double minSAD = pow(tpl_width * tpl_height * 255, 2);
|
||||||
|
|
||||||
for (int xouter = ow_start; xouter <= ow_stop; xouter++)
|
RGBImageLock();
|
||||||
for (int youter = oh_start; youter <= oh_stop; ++youter)
|
|
||||||
|
// printf("FindTemplate 05\n");
|
||||||
|
int xouter, youter, tpl_x, tpl_y, _ch;
|
||||||
|
int _anzchannels = channels;
|
||||||
|
if (_ref->alignment_algo == 0) // 0 = "Default" (nur R-Kanal)
|
||||||
|
_anzchannels = 1;
|
||||||
|
|
||||||
|
for (xouter = ow_start; xouter <= ow_stop; xouter++)
|
||||||
|
for (youter = oh_start; youter <= oh_stop; ++youter)
|
||||||
{
|
{
|
||||||
aktSAD = 0;
|
aktSAD = 0;
|
||||||
for (int tpl_x = 0; tpl_x < tpl_width; tpl_x++)
|
for (tpl_x = 0; tpl_x < tpl_width; tpl_x++)
|
||||||
for (int tpl_y = 0; tpl_y < tpl_height; tpl_y++)
|
for (tpl_y = 0; tpl_y < tpl_height; tpl_y++)
|
||||||
{
|
{
|
||||||
stbi_uc* p_org = this->rgb_image + (this->channels * ((youter + tpl_y) * this->width + (xouter + tpl_x)));
|
stbi_uc* p_org = rgb_image + (channels * ((youter + tpl_y) * width + (xouter + tpl_x)));
|
||||||
stbi_uc* p_tpl = rgb_template + (this->channels * (tpl_y * tpl_width + tpl_x));
|
stbi_uc* p_tpl = rgb_template + (channels * (tpl_y * tpl_width + tpl_x));
|
||||||
aktSAD += pow(p_tpl[0] - p_org[0], 2);
|
for (_ch = 0; _ch < _anzchannels; ++_ch)
|
||||||
|
{
|
||||||
|
aktSAD += pow(p_tpl[_ch] - p_org[_ch], 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stbi_uc* p_out = odata + (this->channels * ((youter - oh_start) * ow + (xouter - ow_start)));
|
|
||||||
|
|
||||||
p_out[0] = int(sqrt(aktSAD / (tpl_width * tpl_height)));
|
|
||||||
if (aktSAD < minSAD)
|
if (aktSAD < minSAD)
|
||||||
{
|
{
|
||||||
minSAD = aktSAD;
|
minSAD = aktSAD;
|
||||||
*found_x = xouter;
|
_ref->found_x = xouter;
|
||||||
*found_y = youter;
|
_ref->found_y = youter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stbi_write_bmp("sdcard\\find.bmp", ow, oh, this->channels, odata);
|
// printf("FindTemplate 06\n");
|
||||||
|
|
||||||
stbi_image_free(odata);
|
|
||||||
stbi_image_free(rgb_template);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFindTemplate::FindTemplate(std::string _template, int* found_x, int* found_y, std::string _imageout)
|
|
||||||
{
|
|
||||||
this->FindTemplate(_template, found_x, found_y);
|
|
||||||
this->SaveToFile(_imageout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFindTemplate::FindTemplate(std::string _template, int* found_x, int* found_y, int _dx, int _dy, std::string _imageout)
|
|
||||||
{
|
|
||||||
this->FindTemplate(_template, found_x, found_y, _dx, _dy);
|
|
||||||
this->SaveToFile(_imageout);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
if (_ref->alignment_algo == 2)
|
||||||
|
CalculateSimularities(rgb_template, _ref->found_x, _ref->found_y, ow, oh, min, avg, max, SAD, _ref->fastalg_SAD, _ref->fastalg_SAD_criteria);
|
||||||
|
|
||||||
void CImageBasis::memCopy(uint8_t* _source, uint8_t* _target, int _size)
|
|
||||||
{
|
|
||||||
#ifdef _ESP32_PSRAM
|
|
||||||
for (int i = 0; i < _size; ++i)
|
|
||||||
*(_target + i) = *(_source + i);
|
|
||||||
#else
|
|
||||||
memcpy(_target, _source, _size);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CImageBasis::isInImage(int x, int y)
|
// printf("FindTemplate 07\n");
|
||||||
{
|
|
||||||
if ((x < 0) || (x > this->width - 1))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ((y < 0) || (y > this->height- 1))
|
_ref->fastalg_x = _ref->found_x;
|
||||||
return false;
|
_ref->fastalg_y = _ref->found_y;
|
||||||
|
_ref->fastalg_min = min;
|
||||||
|
_ref->fastalg_avg = avg;
|
||||||
|
_ref->fastalg_max = max;
|
||||||
|
_ref->fastalg_SAD = SAD;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CImageBasis::setPixelColor(int x, int y, int r, int g, int b)
|
|
||||||
{
|
|
||||||
stbi_uc* p_source;
|
|
||||||
|
|
||||||
p_source = this->rgb_image + (this->channels * (y * this->width + x));
|
|
||||||
p_source[0] = r;
|
|
||||||
if (this-> channels > 2)
|
|
||||||
{
|
|
||||||
p_source[1] = g;
|
|
||||||
p_source[2] = b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CImageBasis::drawRect(int x, int y, int dx, int dy, int r, int g, int b, int thickness)
|
|
||||||
{
|
|
||||||
int zwx1, zwx2, zwy1, zwy2;
|
|
||||||
int _x, _y, _thick;
|
|
||||||
|
|
||||||
zwx1 = x - thickness + 1;
|
|
||||||
zwx2 = x + dx + thickness - 1;
|
|
||||||
zwy1 = y;
|
|
||||||
zwy2 = y;
|
|
||||||
for (_thick = 0; _thick < thickness; _thick++)
|
|
||||||
for (_x = zwx1; _x <= zwx2; ++_x)
|
|
||||||
for (_y = zwy1; _y <= zwy2; _y++)
|
|
||||||
if (isInImage(_x, _y))
|
|
||||||
setPixelColor(_x, _y - _thick, r, g, b);
|
|
||||||
|
|
||||||
zwx1 = x - thickness + 1;
|
|
||||||
zwx2 = x + dx + thickness - 1;
|
|
||||||
zwy1 = y + dy;
|
|
||||||
zwy2 = y + dy;
|
|
||||||
for (_thick = 0; _thick < thickness; _thick++)
|
|
||||||
for (_x = zwx1; _x <= zwx2; ++_x)
|
|
||||||
for (_y = zwy1; _y <= zwy2; _y++)
|
|
||||||
if (isInImage(_x, _y))
|
|
||||||
setPixelColor(_x, _y + _thick, r, g, b);
|
|
||||||
|
|
||||||
zwx1 = x;
|
|
||||||
zwx2 = x;
|
|
||||||
zwy1 = y;
|
|
||||||
zwy2 = y + dy;
|
|
||||||
for (_thick = 0; _thick < thickness; _thick++)
|
|
||||||
for (_x = zwx1; _x <= zwx2; ++_x)
|
|
||||||
for (_y = zwy1; _y <= zwy2; _y++)
|
|
||||||
if (isInImage(_x, _y))
|
|
||||||
setPixelColor(_x - _thick, _y, r, g, b);
|
|
||||||
|
|
||||||
zwx1 = x + dx;
|
|
||||||
zwx2 = x + dx;
|
|
||||||
zwy1 = y;
|
|
||||||
zwy2 = y + dy;
|
|
||||||
for (_thick = 0; _thick < thickness; _thick++)
|
|
||||||
for (_x = zwx1; _x <= zwx2; ++_x)
|
|
||||||
for (_y = zwy1; _y <= zwy2; _y++)
|
|
||||||
if (isInImage(_x, _y))
|
|
||||||
setPixelColor(_x + _thick, _y, r, g, b);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CImageBasis::drawLine(int x1, int y1, int x2, int y2, int r, int g, int b, int thickness)
|
|
||||||
{
|
|
||||||
int _x, _y, _thick;
|
|
||||||
int _zwy1, _zwy2;
|
|
||||||
thickness = (thickness-1) / 2;
|
|
||||||
|
|
||||||
for (_thick = 0; _thick <= thickness; ++_thick)
|
|
||||||
for (_x = x1 - _thick; _x <= x2 + _thick; ++_x)
|
|
||||||
{
|
|
||||||
if (x2 == x1)
|
|
||||||
{
|
|
||||||
_zwy1 = y1;
|
|
||||||
_zwy2 = y2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_zwy1 = (y2 - y1) * (float)(_x - x1) / (float)(x2 - x1) + y1;
|
|
||||||
_zwy2 = (y2 - y1) * (float)(_x + 1 - x1) / (float)(x2 - x1) + y1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (_y = _zwy1 - _thick; _y <= _zwy2 + _thick; _y++)
|
|
||||||
if (isInImage(_x, _y))
|
|
||||||
setPixelColor(_x, _y, r, g, b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CImageBasis::drawCircle(int x1, int y1, int rad, int r, int g, int b, int thickness)
|
|
||||||
{
|
|
||||||
float deltarad, aktrad;
|
|
||||||
int _thick, _x, _y;
|
|
||||||
|
|
||||||
deltarad = 1 / (4 * M_PI * (rad + thickness - 1));
|
|
||||||
|
|
||||||
for (aktrad = 0; aktrad <= (2 * M_PI); aktrad += deltarad)
|
|
||||||
for (_thick = 0; _thick < thickness; ++_thick)
|
|
||||||
{
|
|
||||||
_x = sin(aktrad) * (rad + _thick) + x1;
|
|
||||||
_y = cos(aktrad) * (rad + _thick) + y1;
|
|
||||||
if (isInImage(_x, _y))
|
|
||||||
setPixelColor(_x, _y, r, g, b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CImageBasis::CImageBasis()
|
|
||||||
{
|
|
||||||
this->externalImage = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CImageBasis::CImageBasis(std::string _image)
|
|
||||||
{
|
|
||||||
channels = 3;
|
|
||||||
externalImage = false;
|
|
||||||
filename = _image;
|
|
||||||
// long freebefore = esp_get_free_heap_size();
|
|
||||||
|
|
||||||
rgb_image = stbi_load(_image.c_str(), &width, &height, &bpp, channels);
|
|
||||||
// if (rgb_image == NULL)
|
|
||||||
// LogFile.WriteToFile("Image Load failed:" + _image + " FreeHeapSize before: " + to_string(freebefore) + " after: " + to_string(esp_get_free_heap_size()));
|
|
||||||
// printf("CImageBasis after load\n");
|
|
||||||
// printf("w %d, h %d, b %d, c %d", this->width, this->height, this->bpp, this->channels);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CImageBasis::ImageOkay(){
|
|
||||||
return rgb_image != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
CImageBasis::CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp)
|
|
||||||
{
|
|
||||||
this->rgb_image = _rgb_image;
|
|
||||||
this->channels = _channels;
|
|
||||||
this->width = _width;
|
|
||||||
this->height = _height;
|
|
||||||
this->bpp = _bpp;
|
|
||||||
this->externalImage = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CImageBasis::Contrast(float _contrast) //input range [-100..100]
|
|
||||||
{
|
|
||||||
stbi_uc* p_source;
|
|
||||||
|
|
||||||
float contrast = (_contrast/100) + 1; //convert to decimal & shift range: [0..2]
|
#ifdef DEBUG_DETAIL_ON
|
||||||
float intercept = 128 * (1 - contrast);
|
std::string zw = "\t" + _ref->image_file + "\tt1_x_y:\t" + std::to_string(_ref->fastalg_x) + "\t" + std::to_string(_ref->fastalg_y);
|
||||||
|
zw = zw + "\tpara1_found_min_avg_max_SAD:\t" + std::to_string(min) + "\t" + std::to_string(avg) + "\t" + std::to_string(max) + "\t"+ std::to_string(SAD);
|
||||||
for (int x = 0; x < width; ++x)
|
|
||||||
for (int y = 0; y < height; ++y)
|
|
||||||
{
|
|
||||||
p_source = this->rgb_image + (this->channels * (y * this->width + x));
|
|
||||||
for (int channels = 0; channels < this->channels; ++channels)
|
|
||||||
p_source[channels] = (uint8_t) std::min(255, std::max(0, (int) (p_source[channels] * contrast + intercept)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CImageBasis::~CImageBasis()
|
|
||||||
{
|
|
||||||
if (!this->externalImage)
|
|
||||||
stbi_image_free(this->rgb_image);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CImageBasis::SaveToFile(std::string _imageout)
|
|
||||||
{
|
|
||||||
string typ = getFileType(_imageout);
|
|
||||||
|
|
||||||
if ((typ == "jpg") || (typ == "JPG")) // ACHTUNG PROBLEMATISCH IM ESP32
|
|
||||||
{
|
|
||||||
stbi_write_jpg(_imageout.c_str(), this->width, this->height, this->channels, this->rgb_image, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((typ == "bmp") || (typ == "BMP"))
|
|
||||||
{
|
|
||||||
stbi_write_bmp(_imageout.c_str(), this->width, this->height, this->channels, this->rgb_image);
|
|
||||||
}
|
|
||||||
// stbi_write_jpg(_imageout.c_str(), this->width, this->height, this->channels, this->rgb_image, 0);
|
|
||||||
// stbi_write_bmp(_imageout.c_str(), this->width, this->height, this->channels, this->rgb_image);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CAlignAndCutImage::Align(std::string _template0, int ref0_x, int ref0_y, std::string _template1, int ref1_x, int ref1_y, int deltax, int deltay, std::string imageROI)
|
|
||||||
{
|
|
||||||
int dx, dy;
|
|
||||||
int r0_x, r0_y, r1_x, r1_y;
|
|
||||||
|
|
||||||
CFindTemplate* ft = new CFindTemplate(this->filename);
|
|
||||||
|
|
||||||
r0_x = ref0_x;
|
|
||||||
r0_y = ref0_y;
|
|
||||||
ft->FindTemplate(_template0, &r0_x, &r0_y, deltax, deltay);
|
|
||||||
t0_dx = ft->tpl_width;
|
|
||||||
t0_dy = ft->tpl_height;
|
|
||||||
|
|
||||||
r1_x = ref1_x;
|
|
||||||
r1_y = ref1_y;
|
|
||||||
ft->FindTemplate(_template1, &r1_x, &r1_y, deltax, deltay);
|
|
||||||
t1_dx = ft->tpl_width;
|
|
||||||
t1_dy = ft->tpl_height;
|
|
||||||
|
|
||||||
delete ft;
|
|
||||||
|
|
||||||
|
|
||||||
dx = ref0_x - r0_x;
|
|
||||||
dy = ref0_y - r0_y;
|
|
||||||
|
|
||||||
r0_x += dx;
|
|
||||||
r0_y += dy;
|
|
||||||
|
|
||||||
r1_x += dx;
|
|
||||||
r1_y += dy;
|
|
||||||
|
|
||||||
float w_org, w_ist, d_winkel;
|
|
||||||
|
|
||||||
w_org = atan2(ref1_y - ref0_y, ref1_x - ref0_x);
|
|
||||||
w_ist = atan2(r1_y - r0_y, r1_x - r0_x);
|
|
||||||
|
|
||||||
d_winkel = (w_org - w_ist) * 180 / M_PI;
|
|
||||||
|
|
||||||
if (imageROI.length() > 0)
|
|
||||||
{
|
|
||||||
CImageBasis* imgzw = new CImageBasis(this->filename);
|
|
||||||
imgzw->drawRect(r0_x, r0_y, t0_dx, t0_dy, 255, 0, 0, 2);
|
|
||||||
imgzw->drawRect(r1_x, r1_y, t1_dx, t1_dy, 255, 0, 0, 2);
|
|
||||||
imgzw->SaveToFile(imageROI);
|
|
||||||
printf("Alignment: alignment ROI created: %s\n", imageROI.c_str());
|
|
||||||
delete imgzw;
|
|
||||||
}
|
|
||||||
|
|
||||||
string zw = "\tdx:\t" + to_string(dx) + "\tdy:\t" + to_string(dy) + "\td_winkel:\t" + to_string(d_winkel);
|
|
||||||
LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", zw);
|
LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", zw);
|
||||||
|
#endif
|
||||||
|
|
||||||
CRotate rt(this->rgb_image, this->channels, this->width, this->height, this->bpp);
|
RGBImageRelease();
|
||||||
rt.Translate(dx, dy);
|
stbi_image_free(rgb_template);
|
||||||
rt.Rotate(d_winkel, ref0_x, ref0_y);
|
|
||||||
printf("Alignment: dx %d - dy %d - rot %f\n", dx, dy, d_winkel);
|
// printf("FindTemplate 08\n");
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int dx, int dy)
|
|
||||||
|
|
||||||
|
bool CFindTemplate::CalculateSimularities(uint8_t* _rgb_tmpl, int _startx, int _starty, int _sizex, int _sizey, int &min, float &avg, int &max, float &SAD, float _SADold, float _SADcrit)
|
||||||
{
|
{
|
||||||
|
int dif;
|
||||||
|
int minDif = 255;
|
||||||
|
int maxDif = -255;
|
||||||
|
double avgDifSum = 0;
|
||||||
|
long int anz = 0;
|
||||||
|
double aktSAD = 0;
|
||||||
|
|
||||||
int x2, y2;
|
int xouter, youter, _ch;
|
||||||
|
|
||||||
x2 = x1 + dx;
|
for (xouter = 0; xouter <= _sizex; xouter++)
|
||||||
y2 = y1 + dy;
|
for (youter = 0; youter <= _sizey; ++youter)
|
||||||
x2 = min(x2, this->width - 1);
|
|
||||||
y2 = min(y2, this->height - 1);
|
|
||||||
|
|
||||||
dx = x2 - x1;
|
|
||||||
dy = y2 - y1;
|
|
||||||
|
|
||||||
int memsize = dx * dy * this->channels;
|
|
||||||
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
|
|
||||||
|
|
||||||
stbi_uc* p_target;
|
|
||||||
stbi_uc* p_source;
|
|
||||||
|
|
||||||
for (int x = x1; x < x2; ++x)
|
|
||||||
for (int y = y1; y < y2; ++y)
|
|
||||||
{
|
{
|
||||||
p_target = odata + (this->channels * ((y - y1) * dx + (x - x1)));
|
stbi_uc* p_org = rgb_image + (channels * ((youter + _starty) * width + (xouter + _startx)));
|
||||||
p_source = this->rgb_image + (this->channels * (y * this->width + x));
|
stbi_uc* p_tpl = _rgb_tmpl + (channels * (youter * tpl_width + xouter));
|
||||||
for (int channels = 0; channels < this->channels; ++channels)
|
for (_ch = 0; _ch < channels; ++_ch)
|
||||||
p_target[channels] = p_source[channels];
|
{
|
||||||
|
dif = p_tpl[_ch] - p_org[_ch];
|
||||||
|
aktSAD += pow(p_tpl[_ch] - p_org[_ch], 2);
|
||||||
|
if (dif < minDif) minDif = dif;
|
||||||
|
if (dif > maxDif) maxDif = dif;
|
||||||
|
avgDifSum += dif;
|
||||||
|
anz++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// stbi_write_jpg(_template1.c_str(), dx, dy, this->channels, odata, 0);
|
avg = avgDifSum / anz;
|
||||||
stbi_write_bmp(_template1.c_str(), dx, dy, this->channels, odata);
|
min = minDif;
|
||||||
|
max = maxDif;
|
||||||
|
SAD = sqrt(aktSAD) / anz;
|
||||||
|
|
||||||
stbi_image_free(odata);
|
float _SADdif = abs(SAD - _SADold);
|
||||||
|
|
||||||
|
printf("Anzahl %ld, avgDifSum %fd, avg %f, SAD_neu: %fd, _SAD_old: %f, _SAD_crit:%f\n", anz, avgDifSum, avg, SAD, _SADold, _SADdif);
|
||||||
|
|
||||||
|
if (_SADdif <= _SADcrit)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,98 +1,40 @@
|
|||||||
#pragma once
|
#ifndef __CFINDTEMPLATE_CLASS
|
||||||
|
#define __CFINDTEMPLATE_CLASS
|
||||||
|
|
||||||
|
#include "CImageBasis.h"
|
||||||
|
|
||||||
#ifndef __CFINDTEMPLATE
|
struct RefInfo {
|
||||||
#define __CFINGTEMPLATE
|
std::string image_file;
|
||||||
|
int target_x = 0;
|
||||||
#include <stdint.h>
|
int target_y = 0;
|
||||||
#include <string>
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
#define _USE_MATH_DEFINES
|
int found_x;
|
||||||
#include <math.h>
|
int found_y;
|
||||||
|
int search_x;
|
||||||
#include "stb_image.h"
|
int search_y;
|
||||||
#include "stb_image_write.h"
|
int fastalg_x = -1;
|
||||||
#include "stb_image_resize.h"
|
int fastalg_y = -1;
|
||||||
|
int fastalg_min = -256;
|
||||||
|
float fastalg_avg = -1;
|
||||||
class CImageBasis
|
int fastalg_max = -1;
|
||||||
{
|
float fastalg_SAD = -1;
|
||||||
protected:
|
float fastalg_SAD_criteria = -1;
|
||||||
uint8_t* rgb_image;
|
int alignment_algo = 0; // 0 = "Default" (nur R-Kanal), 1 = "HighAccurity" (RGB-Kanal), 2 = "Fast" (1.x RGB, dann isSimilar)
|
||||||
int channels;
|
|
||||||
int width, height, bpp;
|
|
||||||
bool externalImage;
|
|
||||||
std::string filename;
|
|
||||||
|
|
||||||
void memCopy(uint8_t* _source, uint8_t* _target, int _size);
|
|
||||||
bool isInImage(int x, int y);
|
|
||||||
|
|
||||||
public:
|
|
||||||
int getWidth(){return this->width;};
|
|
||||||
int getHeight(){return this->height;};
|
|
||||||
int getChannels(){return this->channels;};
|
|
||||||
void drawRect(int x, int y, int dx, int dy, int r = 255, int g = 255, int b = 255, int thickness = 1);
|
|
||||||
void drawLine(int x1, int y1, int x2, int y2, int r, int g, int b, int thickness = 1);
|
|
||||||
void drawCircle(int x1, int y1, int rad, int r, int g, int b, int thickness = 1);
|
|
||||||
void setPixelColor(int x, int y, int r, int g, int b);
|
|
||||||
void Contrast(float _contrast);
|
|
||||||
bool ImageOkay();
|
|
||||||
|
|
||||||
|
|
||||||
CImageBasis();
|
|
||||||
CImageBasis(std::string _image);
|
|
||||||
CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp);
|
|
||||||
uint8_t GetPixelColor(int x, int y, int ch);
|
|
||||||
|
|
||||||
~CImageBasis();
|
|
||||||
|
|
||||||
void SaveToFile(std::string _imageout);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CFindTemplate : public CImageBasis
|
class CFindTemplate : public CImageBasis
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int tpl_width, tpl_height, tpl_bpp;
|
int tpl_width, tpl_height, tpl_bpp;
|
||||||
CFindTemplate(std::string _image);
|
CFindTemplate(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {};
|
||||||
|
|
||||||
void FindTemplate(std::string _template, int* found_x, int* found_y, std::string _imageout);
|
bool FindTemplate(RefInfo *_ref);
|
||||||
void FindTemplate(std::string _template, int* found_x, int* found_y, int _dx, int _dy, std::string _imageout);
|
|
||||||
void FindTemplate(std::string _template, int* found_x, int* found_y);
|
bool CalculateSimularities(uint8_t* _rgb_tmpl, int _startx, int _starty, int _sizex, int _sizey, int &min, float &avg, int &max, float &SAD, float _SADold, float _SADcrit);
|
||||||
void FindTemplate(std::string _template, int* found_x, int* found_y, int _dx, int _dy);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CRotate: public CImageBasis
|
#endif
|
||||||
{
|
|
||||||
public:
|
|
||||||
CRotate(std::string _image) : CImageBasis(_image) {};
|
|
||||||
CRotate(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {};
|
|
||||||
|
|
||||||
void Rotate(float _angle);
|
|
||||||
void Rotate(float _angle, int _centerx, int _centery);
|
|
||||||
void Translate(int _dx, int _dy);
|
|
||||||
void Mirror();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CAlignAndCutImage : public CImageBasis
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int t0_dx, t0_dy, t1_dx, t1_dy;
|
|
||||||
CAlignAndCutImage(std::string _image) : CImageBasis(_image) {};
|
|
||||||
|
|
||||||
void Align(std::string _template1, int x1, int y1, std::string _template2, int x2, int y2, int deltax = 40, int deltay = 40, std::string imageROI = "");
|
|
||||||
void CutAndSave(std::string _template1, int x1, int y1, int dx, int dy);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CResizeImage : public CImageBasis
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CResizeImage(std::string _image) : CImageBasis(_image) {};
|
|
||||||
// CResizeImage(std::string _image, int _new_dx, int _new_dy);
|
|
||||||
void Resize(int _new_dx, int _new_dy);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
523
code/components/jomjol_image_proc/CImageBasis.cpp
Normal file
523
code/components/jomjol_image_proc/CImageBasis.cpp
Normal file
@@ -0,0 +1,523 @@
|
|||||||
|
#include "CImageBasis.h"
|
||||||
|
#include "Helper.h"
|
||||||
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
|
#include <esp_log.h>
|
||||||
|
|
||||||
|
#include "esp_system.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
|
#include <math.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#define _ESP32_PSRAM
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
static const char *TAG = "CImageBasis";
|
||||||
|
|
||||||
|
//#define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t * CImageBasis::RGBImageLock(int _waitmaxsec)
|
||||||
|
{
|
||||||
|
if (islocked)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
printf("Image is locked: sleep for : %ds\n", _waitmaxsec);
|
||||||
|
#endif
|
||||||
|
TickType_t xDelay;
|
||||||
|
xDelay = 1000 / portTICK_PERIOD_MS;
|
||||||
|
for (int i = 0; i <= _waitmaxsec; ++i)
|
||||||
|
{
|
||||||
|
vTaskDelay( xDelay );
|
||||||
|
if (!islocked)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (islocked)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return rgb_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CImageBasis::RGBImageRelease()
|
||||||
|
{
|
||||||
|
islocked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t * CImageBasis::RGBImageGet()
|
||||||
|
{
|
||||||
|
return rgb_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void writejpghelp(void *context, void *data, int size)
|
||||||
|
{
|
||||||
|
// printf("Size all: %d, size %d\n", ((ImageData*)context)->size, size);
|
||||||
|
ImageData* _zw = (ImageData*) context;
|
||||||
|
uint8_t *voidstart = _zw->data;
|
||||||
|
uint8_t *datastart = (uint8_t*) data;
|
||||||
|
voidstart += _zw->size;
|
||||||
|
|
||||||
|
for (int i = 0; i < size; ++i)
|
||||||
|
*(voidstart + i) = *(datastart + i);
|
||||||
|
|
||||||
|
_zw->size += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ImageData* CImageBasis::writeToMemoryAsJPG(const int quality)
|
||||||
|
{
|
||||||
|
ImageData* ii = new ImageData;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
stbi_write_jpg_to_func(writejpghelp, ii, width, height, channels, rgb_image, quality);
|
||||||
|
RGBImageRelease();
|
||||||
|
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define HTTP_BUFFER_SENT 1024
|
||||||
|
|
||||||
|
struct SendJPGHTTP
|
||||||
|
{
|
||||||
|
httpd_req_t *req;
|
||||||
|
esp_err_t res;
|
||||||
|
char buf[HTTP_BUFFER_SENT];
|
||||||
|
int size = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void writejpgtohttphelp(void *context, void *data, int size)
|
||||||
|
{
|
||||||
|
SendJPGHTTP* _send = (SendJPGHTTP*) context;
|
||||||
|
if ((_send->size + size) >= HTTP_BUFFER_SENT) // data passt nich mehr in buffer
|
||||||
|
{
|
||||||
|
httpd_req_t *_req = _send->req;
|
||||||
|
if (httpd_resp_send_chunk(_req, _send->buf, _send->size) != ESP_OK)
|
||||||
|
{
|
||||||
|
ESP_LOGE(TAG, "File sending failed!");
|
||||||
|
_send->res = ESP_FAIL;
|
||||||
|
}
|
||||||
|
_send->size = 0;
|
||||||
|
}
|
||||||
|
std::memcpy((void*) (&(_send->buf[0]) + _send->size), data, size);
|
||||||
|
_send->size+= size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
esp_err_t CImageBasis::SendJPGtoHTTP(httpd_req_t *_req, const int quality)
|
||||||
|
{
|
||||||
|
SendJPGHTTP ii;
|
||||||
|
ii.req = _req;
|
||||||
|
ii.res = ESP_OK;
|
||||||
|
ii.size = 0;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
stbi_write_jpg_to_func(writejpgtohttphelp, &ii, width, height, channels, rgb_image, quality);
|
||||||
|
RGBImageRelease();
|
||||||
|
|
||||||
|
if (ii.size > 0)
|
||||||
|
{
|
||||||
|
if (httpd_resp_send_chunk(_req, (char*) ii.buf, ii.size) != ESP_OK) // verschicke noch den Rest
|
||||||
|
{
|
||||||
|
ESP_LOGE(TAG, "File sending failed!");
|
||||||
|
ii.res = ESP_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ii.res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool CImageBasis::CopyFromMemory(uint8_t* _source, int _size)
|
||||||
|
{
|
||||||
|
int gr = height * width * channels;
|
||||||
|
if (gr != _size) // Größe passt nicht
|
||||||
|
{
|
||||||
|
printf("Kann Bild nicht von Speicher kopierte - Größen passen nicht zusammen: soll %d, ist %d\n", _size, gr);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
memCopy(_source, rgb_image, _size);
|
||||||
|
RGBImageRelease();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t CImageBasis::GetPixelColor(int x, int y, int ch)
|
||||||
|
{
|
||||||
|
stbi_uc* p_source;
|
||||||
|
p_source = rgb_image + (channels * (y * width + x));
|
||||||
|
return p_source[ch];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CImageBasis::memCopy(uint8_t* _source, uint8_t* _target, int _size)
|
||||||
|
{
|
||||||
|
#ifdef _ESP32_PSRAM
|
||||||
|
for (int i = 0; i < _size; ++i)
|
||||||
|
*(_target + i) = *(_source + i);
|
||||||
|
#else
|
||||||
|
memcpy(_target, _source, _size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CImageBasis::isInImage(int x, int y)
|
||||||
|
{
|
||||||
|
if ((x < 0) || (x > width - 1))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ((y < 0) || (y > height- 1))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CImageBasis::setPixelColor(int x, int y, int r, int g, int b)
|
||||||
|
{
|
||||||
|
stbi_uc* p_source;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
p_source = rgb_image + (channels * (y * width + x));
|
||||||
|
p_source[0] = r;
|
||||||
|
if ( channels > 2)
|
||||||
|
{
|
||||||
|
p_source[1] = g;
|
||||||
|
p_source[2] = b;
|
||||||
|
}
|
||||||
|
RGBImageRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CImageBasis::drawRect(int x, int y, int dx, int dy, int r, int g, int b, int thickness)
|
||||||
|
{
|
||||||
|
int zwx1, zwx2, zwy1, zwy2;
|
||||||
|
int _x, _y, _thick;
|
||||||
|
|
||||||
|
zwx1 = x - thickness + 1;
|
||||||
|
zwx2 = x + dx + thickness - 1;
|
||||||
|
zwy1 = y;
|
||||||
|
zwy2 = y;
|
||||||
|
for (_thick = 0; _thick < thickness; _thick++)
|
||||||
|
for (_x = zwx1; _x <= zwx2; ++_x)
|
||||||
|
for (_y = zwy1; _y <= zwy2; _y++)
|
||||||
|
if (isInImage(_x, _y))
|
||||||
|
setPixelColor(_x, _y - _thick, r, g, b);
|
||||||
|
|
||||||
|
zwx1 = x - thickness + 1;
|
||||||
|
zwx2 = x + dx + thickness - 1;
|
||||||
|
zwy1 = y + dy;
|
||||||
|
zwy2 = y + dy;
|
||||||
|
for (_thick = 0; _thick < thickness; _thick++)
|
||||||
|
for (_x = zwx1; _x <= zwx2; ++_x)
|
||||||
|
for (_y = zwy1; _y <= zwy2; _y++)
|
||||||
|
if (isInImage(_x, _y))
|
||||||
|
setPixelColor(_x, _y + _thick, r, g, b);
|
||||||
|
|
||||||
|
zwx1 = x;
|
||||||
|
zwx2 = x;
|
||||||
|
zwy1 = y;
|
||||||
|
zwy2 = y + dy;
|
||||||
|
for (_thick = 0; _thick < thickness; _thick++)
|
||||||
|
for (_x = zwx1; _x <= zwx2; ++_x)
|
||||||
|
for (_y = zwy1; _y <= zwy2; _y++)
|
||||||
|
if (isInImage(_x, _y))
|
||||||
|
setPixelColor(_x - _thick, _y, r, g, b);
|
||||||
|
|
||||||
|
zwx1 = x + dx;
|
||||||
|
zwx2 = x + dx;
|
||||||
|
zwy1 = y;
|
||||||
|
zwy2 = y + dy;
|
||||||
|
for (_thick = 0; _thick < thickness; _thick++)
|
||||||
|
for (_x = zwx1; _x <= zwx2; ++_x)
|
||||||
|
for (_y = zwy1; _y <= zwy2; _y++)
|
||||||
|
if (isInImage(_x, _y))
|
||||||
|
setPixelColor(_x + _thick, _y, r, g, b);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CImageBasis::drawLine(int x1, int y1, int x2, int y2, int r, int g, int b, int thickness)
|
||||||
|
{
|
||||||
|
int _x, _y, _thick;
|
||||||
|
int _zwy1, _zwy2;
|
||||||
|
thickness = (thickness-1) / 2;
|
||||||
|
|
||||||
|
for (_thick = 0; _thick <= thickness; ++_thick)
|
||||||
|
for (_x = x1 - _thick; _x <= x2 + _thick; ++_x)
|
||||||
|
{
|
||||||
|
if (x2 == x1)
|
||||||
|
{
|
||||||
|
_zwy1 = y1;
|
||||||
|
_zwy2 = y2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_zwy1 = (y2 - y1) * (float)(_x - x1) / (float)(x2 - x1) + y1;
|
||||||
|
_zwy2 = (y2 - y1) * (float)(_x + 1 - x1) / (float)(x2 - x1) + y1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (_y = _zwy1 - _thick; _y <= _zwy2 + _thick; _y++)
|
||||||
|
if (isInImage(_x, _y))
|
||||||
|
setPixelColor(_x, _y, r, g, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CImageBasis::drawCircle(int x1, int y1, int rad, int r, int g, int b, int thickness)
|
||||||
|
{
|
||||||
|
float deltarad, aktrad;
|
||||||
|
int _thick, _x, _y;
|
||||||
|
|
||||||
|
deltarad = 1 / (4 * M_PI * (rad + thickness - 1));
|
||||||
|
|
||||||
|
for (aktrad = 0; aktrad <= (2 * M_PI); aktrad += deltarad)
|
||||||
|
for (_thick = 0; _thick < thickness; ++_thick)
|
||||||
|
{
|
||||||
|
_x = sin(aktrad) * (rad + _thick) + x1;
|
||||||
|
_y = cos(aktrad) * (rad + _thick) + y1;
|
||||||
|
if (isInImage(_x, _y))
|
||||||
|
setPixelColor(_x, _y, r, g, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CImageBasis::CImageBasis()
|
||||||
|
{
|
||||||
|
externalImage = false;
|
||||||
|
rgb_image = NULL;
|
||||||
|
width = 0;
|
||||||
|
height = 0;
|
||||||
|
channels = 0;
|
||||||
|
islocked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CImageBasis::CreateEmptyImage(int _width, int _height, int _channels)
|
||||||
|
{
|
||||||
|
bpp = _channels;
|
||||||
|
width = _width;
|
||||||
|
height = _height;
|
||||||
|
channels = _channels;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
|
||||||
|
int memsize = width * height * channels;
|
||||||
|
rgb_image = (unsigned char*)GET_MEMORY(memsize);
|
||||||
|
|
||||||
|
|
||||||
|
stbi_uc* p_source;
|
||||||
|
|
||||||
|
for (int x = 0; x < width; ++x)
|
||||||
|
for (int y = 0; y < height; ++y)
|
||||||
|
{
|
||||||
|
p_source = rgb_image + (channels * (y * width + x));
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_source[_channels] = (uint8_t) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBImageRelease();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CImageBasis::LoadFromMemory(stbi_uc *_buffer, int len)
|
||||||
|
{
|
||||||
|
RGBImageLock();
|
||||||
|
if (rgb_image)
|
||||||
|
stbi_image_free(rgb_image);
|
||||||
|
rgb_image = stbi_load_from_memory(_buffer, len, &width, &height, &channels, 3);
|
||||||
|
bpp = channels;
|
||||||
|
printf("Image loaded from memory: %d, %d, %d\n", width, height, channels);
|
||||||
|
RGBImageRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
CImageBasis::CImageBasis(CImageBasis *_copyfrom, int _anzrepeat)
|
||||||
|
{
|
||||||
|
islocked = false;
|
||||||
|
externalImage = false;
|
||||||
|
channels = _copyfrom->channels;
|
||||||
|
width = _copyfrom->width;
|
||||||
|
height = _copyfrom->height;
|
||||||
|
bpp = _copyfrom->bpp;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
int memsize = width * height * channels;
|
||||||
|
rgb_image = (unsigned char*)GET_MEMORY(memsize);
|
||||||
|
|
||||||
|
TickType_t xDelay;
|
||||||
|
int anz = 1;
|
||||||
|
while (!rgb_image && (anz < _anzrepeat))
|
||||||
|
{
|
||||||
|
printf("Create Image from Copy - Speicher ist voll - Versuche es erneut: %d.\n", anz);
|
||||||
|
xDelay = 1000 / portTICK_PERIOD_MS;
|
||||||
|
rgb_image = (unsigned char*) malloc(memsize);
|
||||||
|
anz++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!rgb_image)
|
||||||
|
{
|
||||||
|
printf(getESPHeapInfo().c_str());
|
||||||
|
printf("\nKein freier Speicher mehr!!!! Benötigt: %d %d %d %d\n", width, height, channels, memsize);
|
||||||
|
RGBImageRelease();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memCopy(_copyfrom->rgb_image, rgb_image, memsize);
|
||||||
|
RGBImageRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
CImageBasis::CImageBasis(int _width, int _height, int _channels)
|
||||||
|
{
|
||||||
|
islocked = false;
|
||||||
|
externalImage = false;
|
||||||
|
channels = _channels;
|
||||||
|
width = _width;
|
||||||
|
height = _height;
|
||||||
|
bpp = _channels;
|
||||||
|
|
||||||
|
int memsize = width * height * channels;
|
||||||
|
|
||||||
|
rgb_image = (unsigned char*)GET_MEMORY(memsize);
|
||||||
|
if (!rgb_image)
|
||||||
|
{
|
||||||
|
printf(getESPHeapInfo().c_str());
|
||||||
|
printf("\nKein freier Speicher mehr!!!! Benötigt: %d %d %d %d\n", width, height, channels, memsize);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CImageBasis::CImageBasis(std::string _image)
|
||||||
|
{
|
||||||
|
islocked = false;
|
||||||
|
channels = 3;
|
||||||
|
externalImage = false;
|
||||||
|
filename = _image;
|
||||||
|
long zwld = esp_get_free_heap_size();
|
||||||
|
printf("freeheapsize before: %ld\n", zwld);
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
rgb_image = stbi_load(_image.c_str(), &width, &height, &bpp, channels);
|
||||||
|
RGBImageRelease();
|
||||||
|
|
||||||
|
zwld = esp_get_free_heap_size();
|
||||||
|
printf("freeheapsize after : %ld\n", zwld);
|
||||||
|
|
||||||
|
std::string zw = "Image Load failed:" + _image + "\n";
|
||||||
|
if (rgb_image == NULL)
|
||||||
|
printf(zw.c_str());
|
||||||
|
zw = "CImageBasis after load " + _image + "\n";
|
||||||
|
printf(zw.c_str());
|
||||||
|
printf("w %d, h %d, b %d, c %d\n", width, height, bpp, channels);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CImageBasis::ImageOkay(){
|
||||||
|
return rgb_image != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CImageBasis::CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp)
|
||||||
|
{
|
||||||
|
islocked = false;
|
||||||
|
rgb_image = _rgb_image;
|
||||||
|
channels = _channels;
|
||||||
|
width = _width;
|
||||||
|
height = _height;
|
||||||
|
bpp = _bpp;
|
||||||
|
externalImage = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CImageBasis::Contrast(float _contrast) //input range [-100..100]
|
||||||
|
{
|
||||||
|
stbi_uc* p_source;
|
||||||
|
|
||||||
|
float contrast = (_contrast/100) + 1; //convert to decimal & shift range: [0..2]
|
||||||
|
float intercept = 128 * (1 - contrast);
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
|
||||||
|
for (int x = 0; x < width; ++x)
|
||||||
|
for (int y = 0; y < height; ++y)
|
||||||
|
{
|
||||||
|
p_source = rgb_image + (channels * (y * width + x));
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_source[_channels] = (uint8_t) std::min(255, std::max(0, (int) (p_source[_channels] * contrast + intercept)));
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBImageRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
CImageBasis::~CImageBasis()
|
||||||
|
{
|
||||||
|
RGBImageLock();
|
||||||
|
if (!externalImage)
|
||||||
|
stbi_image_free(rgb_image);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CImageBasis::SaveToFile(std::string _imageout)
|
||||||
|
{
|
||||||
|
string typ = getFileType(_imageout);
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
if ((typ == "jpg") || (typ == "JPG")) // ACHTUNG PROBLEMATISCH IM ESP32
|
||||||
|
{
|
||||||
|
stbi_write_jpg(_imageout.c_str(), width, height, channels, rgb_image, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((typ == "bmp") || (typ == "BMP"))
|
||||||
|
{
|
||||||
|
stbi_write_bmp(_imageout.c_str(), width, height, channels, rgb_image);
|
||||||
|
}
|
||||||
|
RGBImageRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CImageBasis::Resize(int _new_dx, int _new_dy)
|
||||||
|
{
|
||||||
|
int memsize = _new_dx * _new_dy * channels;
|
||||||
|
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
|
||||||
|
stbir_resize_uint8(rgb_image, width, height, 0, odata, _new_dx, _new_dy, 0, channels);
|
||||||
|
|
||||||
|
stbi_image_free(rgb_image);
|
||||||
|
rgb_image = (unsigned char*)GET_MEMORY(memsize);
|
||||||
|
|
||||||
|
memCopy(odata, rgb_image, memsize);
|
||||||
|
RGBImageRelease();
|
||||||
|
|
||||||
|
width = _new_dx;
|
||||||
|
height = _new_dy;
|
||||||
|
stbi_image_free(odata);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CImageBasis::Resize(int _new_dx, int _new_dy, CImageBasis *_target)
|
||||||
|
{
|
||||||
|
if ((_target->height != _new_dy) || (_target->width != _new_dx) || (_target->channels != channels))
|
||||||
|
{
|
||||||
|
printf("CImageBasis::Resize - Targetbildgröße passt nicht !!!!!!!!!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
uint8_t* odata = _target->rgb_image;
|
||||||
|
stbir_resize_uint8(rgb_image, width, height, 0, odata, _new_dx, _new_dy, 0, channels);
|
||||||
|
RGBImageRelease();
|
||||||
|
}
|
||||||
|
|
||||||
94
code/components/jomjol_image_proc/CImageBasis.h
Normal file
94
code/components/jomjol_image_proc/CImageBasis.h
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef __CIMAGEBASIS
|
||||||
|
#define __CIMAGEBASIS
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
|
#include <esp_http_server.h>
|
||||||
|
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "stb_image.h"
|
||||||
|
#include "stb_image_write.h"
|
||||||
|
#include "stb_image_resize.h"
|
||||||
|
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
|
||||||
|
//#define GET_MEMORY malloc
|
||||||
|
#define GET_MEMORY(X) heap_caps_malloc(X, MALLOC_CAP_SPIRAM)
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_JPG_SIZE 128000
|
||||||
|
|
||||||
|
|
||||||
|
struct ImageData
|
||||||
|
{
|
||||||
|
uint8_t data[MAX_JPG_SIZE];
|
||||||
|
size_t size = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class CImageBasis
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
bool externalImage;
|
||||||
|
std::string filename;
|
||||||
|
|
||||||
|
void memCopy(uint8_t* _source, uint8_t* _target, int _size);
|
||||||
|
bool isInImage(int x, int y);
|
||||||
|
|
||||||
|
bool islocked;
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint8_t* rgb_image;
|
||||||
|
int channels;
|
||||||
|
int width, height, bpp;
|
||||||
|
|
||||||
|
uint8_t * RGBImageLock(int _waitmaxsec = 60);
|
||||||
|
void RGBImageRelease();
|
||||||
|
uint8_t * RGBImageGet();
|
||||||
|
|
||||||
|
int getWidth(){return this->width;};
|
||||||
|
int getHeight(){return this->height;};
|
||||||
|
int getChannels(){return this->channels;};
|
||||||
|
void drawRect(int x, int y, int dx, int dy, int r = 255, int g = 255, int b = 255, int thickness = 1);
|
||||||
|
void drawLine(int x1, int y1, int x2, int y2, int r, int g, int b, int thickness = 1);
|
||||||
|
void drawCircle(int x1, int y1, int rad, int r, int g, int b, int thickness = 1);
|
||||||
|
void setPixelColor(int x, int y, int r, int g, int b);
|
||||||
|
void Contrast(float _contrast);
|
||||||
|
bool ImageOkay();
|
||||||
|
bool CopyFromMemory(uint8_t* _source, int _size);
|
||||||
|
|
||||||
|
void SetIndepended(){externalImage = false;};
|
||||||
|
|
||||||
|
void CreateEmptyImage(int _width, int _height, int _channels);
|
||||||
|
|
||||||
|
|
||||||
|
CImageBasis();
|
||||||
|
CImageBasis(std::string _image);
|
||||||
|
CImageBasis(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp);
|
||||||
|
CImageBasis(int _width, int _height, int _channels);
|
||||||
|
CImageBasis(CImageBasis *_copyfrom, int _anzrepeat = 0);
|
||||||
|
|
||||||
|
void Resize(int _new_dx, int _new_dy);
|
||||||
|
void Resize(int _new_dx, int _new_dy, CImageBasis *_target);
|
||||||
|
|
||||||
|
void LoadFromMemory(stbi_uc *_buffer, int len);
|
||||||
|
|
||||||
|
ImageData* writeToMemoryAsJPG(const int quality = 90);
|
||||||
|
|
||||||
|
esp_err_t SendJPGtoHTTP(httpd_req_t *req, const int quality = 90);
|
||||||
|
|
||||||
|
uint8_t GetPixelColor(int x, int y, int ch);
|
||||||
|
|
||||||
|
~CImageBasis();
|
||||||
|
|
||||||
|
void SaveToFile(std::string _imageout);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
|
|||||||
|
|
||||||
idf_component_register(SRCS ${app_sources}
|
idf_component_register(SRCS ${app_sources}
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
REQUIRES jomjol_helper jomjol_logfile)
|
REQUIRES jomjol_helper jomjol_logfile esp_http_server)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
192
code/components/jomjol_image_proc/CRotateImage.cpp
Normal file
192
code/components/jomjol_image_proc/CRotateImage.cpp
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
#include "CRotateImage.h"
|
||||||
|
|
||||||
|
|
||||||
|
CRotateImage::CRotateImage(CImageBasis *_org, CImageBasis *_temp)
|
||||||
|
{
|
||||||
|
rgb_image = _org->rgb_image;
|
||||||
|
channels = _org->channels;
|
||||||
|
width = _org->width;
|
||||||
|
height = _org->height;
|
||||||
|
bpp = _org->bpp;
|
||||||
|
externalImage = true;
|
||||||
|
ImageTMP = _temp;
|
||||||
|
islocked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRotateImage::Mirror(){
|
||||||
|
int memsize = width * height * channels;
|
||||||
|
uint8_t* odata;
|
||||||
|
if (ImageTMP)
|
||||||
|
{
|
||||||
|
odata = ImageTMP->RGBImageLock();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
odata = (unsigned char*)GET_MEMORY(memsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int x_source, y_source;
|
||||||
|
stbi_uc* p_target;
|
||||||
|
stbi_uc* p_source;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
for (int x = 0; x < width; ++x)
|
||||||
|
for (int y = 0; y < height; ++y)
|
||||||
|
{
|
||||||
|
p_target = odata + (channels * (y * width + x));
|
||||||
|
|
||||||
|
x_source = width - x;
|
||||||
|
y_source = y;
|
||||||
|
|
||||||
|
p_source = rgb_image + (channels * (y_source * width + x_source));
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_target[_channels] = p_source[_channels];
|
||||||
|
}
|
||||||
|
|
||||||
|
// memcpy(rgb_image, odata, memsize);
|
||||||
|
memCopy(odata, rgb_image, memsize);
|
||||||
|
if (!ImageTMP)
|
||||||
|
stbi_image_free(odata);
|
||||||
|
|
||||||
|
if (ImageTMP)
|
||||||
|
ImageTMP->RGBImageRelease();
|
||||||
|
|
||||||
|
RGBImageRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRotateImage::Rotate(float _angle, int _centerx, int _centery)
|
||||||
|
{
|
||||||
|
float m[2][3];
|
||||||
|
|
||||||
|
float x_center = _centerx;
|
||||||
|
float y_center = _centery;
|
||||||
|
_angle = _angle / 180 * M_PI;
|
||||||
|
|
||||||
|
m[0][0] = cos(_angle);
|
||||||
|
m[0][1] = sin(_angle);
|
||||||
|
m[0][2] = (1 - m[0][0]) * x_center - m[0][1] * y_center;
|
||||||
|
|
||||||
|
m[1][0] = -m[0][1];
|
||||||
|
m[1][1] = m[0][0];
|
||||||
|
m[1][2] = m[0][1] * x_center + (1 - m[0][0]) * y_center;
|
||||||
|
|
||||||
|
int memsize = width * height * channels;
|
||||||
|
uint8_t* odata;
|
||||||
|
if (ImageTMP)
|
||||||
|
{
|
||||||
|
odata = ImageTMP->RGBImageLock();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
odata = (unsigned char*)GET_MEMORY(memsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int x_source, y_source;
|
||||||
|
stbi_uc* p_target;
|
||||||
|
stbi_uc* p_source;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
for (int x = 0; x < width; ++x)
|
||||||
|
for (int y = 0; y < height; ++y)
|
||||||
|
{
|
||||||
|
p_target = odata + (channels * (y * width + x));
|
||||||
|
|
||||||
|
x_source = int(m[0][0] * x + m[0][1] * y);
|
||||||
|
y_source = int(m[1][0] * x + m[1][1] * y);
|
||||||
|
|
||||||
|
x_source += int(m[0][2]);
|
||||||
|
y_source += int(m[1][2]);
|
||||||
|
|
||||||
|
if ((x_source >= 0) && (x_source < width) && (y_source >= 0) && (y_source < height))
|
||||||
|
{
|
||||||
|
p_source = rgb_image + (channels * (y_source * width + x_source));
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_target[_channels] = p_source[_channels];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_target[_channels] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// memcpy(rgb_image, odata, memsize);
|
||||||
|
memCopy(odata, rgb_image, memsize);
|
||||||
|
|
||||||
|
if (!ImageTMP)
|
||||||
|
{
|
||||||
|
stbi_image_free(odata);
|
||||||
|
}
|
||||||
|
if (ImageTMP)
|
||||||
|
ImageTMP->RGBImageRelease();
|
||||||
|
|
||||||
|
RGBImageRelease();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRotateImage::Rotate(float _angle)
|
||||||
|
{
|
||||||
|
// printf("width %d, height %d\n", width, height);
|
||||||
|
Rotate(_angle, width / 2, height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRotateImage::Translate(int _dx, int _dy)
|
||||||
|
{
|
||||||
|
int memsize = width * height * channels;
|
||||||
|
uint8_t* odata;
|
||||||
|
if (ImageTMP)
|
||||||
|
{
|
||||||
|
odata = ImageTMP->RGBImageLock();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
odata = (unsigned char*)GET_MEMORY(memsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int x_source, y_source;
|
||||||
|
stbi_uc* p_target;
|
||||||
|
stbi_uc* p_source;
|
||||||
|
|
||||||
|
RGBImageLock();
|
||||||
|
|
||||||
|
for (int x = 0; x < width; ++x)
|
||||||
|
for (int y = 0; y < height; ++y)
|
||||||
|
{
|
||||||
|
p_target = odata + (channels * (y * width + x));
|
||||||
|
|
||||||
|
x_source = x - _dx;
|
||||||
|
y_source = y - _dy;
|
||||||
|
|
||||||
|
if ((x_source >= 0) && (x_source < width) && (y_source >= 0) && (y_source < height))
|
||||||
|
{
|
||||||
|
p_source = rgb_image + (channels * (y_source * width + x_source));
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_target[_channels] = p_source[_channels];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int _channels = 0; _channels < channels; ++_channels)
|
||||||
|
p_target[_channels] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// memcpy(rgb_image, odata, memsize);
|
||||||
|
memCopy(odata, rgb_image, memsize);
|
||||||
|
if (!ImageTMP)
|
||||||
|
{
|
||||||
|
stbi_image_free(odata);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImageTMP)
|
||||||
|
{
|
||||||
|
ImageTMP->RGBImageRelease();
|
||||||
|
}
|
||||||
|
RGBImageRelease();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
16
code/components/jomjol_image_proc/CRotateImage.h
Normal file
16
code/components/jomjol_image_proc/CRotateImage.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#include "CImageBasis.h"
|
||||||
|
|
||||||
|
|
||||||
|
class CRotateImage: public CImageBasis
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CImageBasis *ImageTMP;
|
||||||
|
CRotateImage(std::string _image) : CImageBasis(_image) {ImageTMP = NULL;};
|
||||||
|
CRotateImage(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {ImageTMP = NULL;};
|
||||||
|
CRotateImage(CImageBasis *_org, CImageBasis *_temp);
|
||||||
|
|
||||||
|
void Rotate(float _angle);
|
||||||
|
void Rotate(float _angle, int _centerx, int _centery);
|
||||||
|
void Translate(int _dx, int _dy);
|
||||||
|
void Mirror();
|
||||||
|
};
|
||||||
@@ -10,6 +10,50 @@ static const char *TAG = "log";
|
|||||||
|
|
||||||
ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt");
|
ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt");
|
||||||
|
|
||||||
|
void ClassLogFile::WriteHeapInfo(std::string _id)
|
||||||
|
{
|
||||||
|
std::string _zw = "\t" + _id;
|
||||||
|
if (loglevel > 0)
|
||||||
|
_zw = _zw + "\t" + getESPHeapInfo();
|
||||||
|
|
||||||
|
WriteToFile(_zw);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string ClassLogFile::getESPHeapInfo(){
|
||||||
|
string espInfoResultStr = "";
|
||||||
|
char aMsgBuf[80];
|
||||||
|
|
||||||
|
multi_heap_info_t aMultiHead_info ;
|
||||||
|
heap_caps_get_info (&aMultiHead_info,MALLOC_CAP_8BIT);
|
||||||
|
size_t aFreeHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t aMinFreeHeadSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t aMinFreeHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t aHeapLargestFreeBlockSize = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
|
||||||
|
sprintf(aMsgBuf,"Free Heap Size: \t%ld", (long) aFreeHeapSize);
|
||||||
|
size_t aFreeSPIHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_SPIRAM);
|
||||||
|
size_t aFreeInternalHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
||||||
|
size_t aMinFreeInternalHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
||||||
|
|
||||||
|
sprintf(aMsgBuf,"\tHeap:\t%ld", (long) aFreeHeapSize);
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf,"\tMin Free:\t%ld", (long) aMinFreeHeapSize);
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf,"\tlarg. Block: \t%ld", (long) aHeapLargestFreeBlockSize);
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf,"\tSPI Heap:\t%ld", (long) aFreeSPIHeapSize);
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf,"\tMin Free Heap Size:\t%ld", (long) aMinFreeHeadSize);
|
||||||
|
sprintf(aMsgBuf,"\tNOT_SPI Heap:\t%ld", (long) (aFreeHeapSize - aFreeSPIHeapSize));
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf,"\tlargest Block Size: \t%ld", (long) aHeapLargestFreeBlockSize);
|
||||||
|
sprintf(aMsgBuf,"\tInternal Heap:\t%ld", (long) (aFreeInternalHeapSize));
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
sprintf(aMsgBuf,"\tInternal Min Heap free:\t%ld", (long) (aMinFreeInternalHeapSize));
|
||||||
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
return espInfoResultStr;
|
||||||
|
}
|
||||||
|
|
||||||
void ClassLogFile::WriteToDedicatedFile(std::string _fn, std::string info, bool _time)
|
void ClassLogFile::WriteToDedicatedFile(std::string _fn, std::string info, bool _time)
|
||||||
{
|
{
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
@@ -19,7 +63,10 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, std::string info, bool
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pFile = OpenFileAndWait(_fn.c_str(), "a");
|
||||||
pFile = fopen(_fn.c_str(), "a+");
|
pFile = fopen(_fn.c_str(), "a+");
|
||||||
|
printf("Logfile opened: %s\n", _fn.c_str());
|
||||||
|
|
||||||
if (pFile!=NULL) {
|
if (pFile!=NULL) {
|
||||||
if (_time)
|
if (_time)
|
||||||
{
|
{
|
||||||
@@ -54,6 +101,7 @@ void ClassLogFile::SetRetention(unsigned short _retentionInDays){
|
|||||||
|
|
||||||
void ClassLogFile::WriteToFile(std::string info, bool _time)
|
void ClassLogFile::WriteToFile(std::string info, bool _time)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
struct stat path_stat;
|
struct stat path_stat;
|
||||||
if (stat(logroot.c_str(), &path_stat) != 0) {
|
if (stat(logroot.c_str(), &path_stat) != 0) {
|
||||||
ESP_LOGI(TAG, "Create log folder: %s", logroot.c_str());
|
ESP_LOGI(TAG, "Create log folder: %s", logroot.c_str());
|
||||||
@@ -61,7 +109,7 @@ void ClassLogFile::WriteToFile(std::string info, bool _time)
|
|||||||
ESP_LOGI(TAG, "Can't create log foolder");
|
ESP_LOGI(TAG, "Can't create log foolder");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm* timeinfo;
|
struct tm* timeinfo;
|
||||||
char buffer[30];
|
char buffer[30];
|
||||||
@@ -79,12 +127,12 @@ std::string ClassLogFile::GetCurrentFileName()
|
|||||||
{
|
{
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm* timeinfo;
|
struct tm* timeinfo;
|
||||||
char buffer[30];
|
char buffer[60];
|
||||||
|
|
||||||
time(&rawtime);
|
time(&rawtime);
|
||||||
timeinfo = localtime(&rawtime);
|
timeinfo = localtime(&rawtime);
|
||||||
|
|
||||||
strftime(buffer, 30, logfile.c_str(), timeinfo);
|
strftime(buffer, 60, logfile.c_str(), timeinfo);
|
||||||
std::string logpath = logroot + "/" + buffer;
|
std::string logpath = logroot + "/" + buffer;
|
||||||
|
|
||||||
return logpath;
|
return logpath;
|
||||||
@@ -142,4 +190,5 @@ ClassLogFile::ClassLogFile(std::string _logroot, std::string _logfile)
|
|||||||
logfile = _logfile;
|
logfile = _logfile;
|
||||||
doLogFile = true;
|
doLogFile = true;
|
||||||
retentionInDays = 10;
|
retentionInDays = 10;
|
||||||
|
loglevel = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,16 @@ private:
|
|||||||
std::string logfile;
|
std::string logfile;
|
||||||
bool doLogFile;
|
bool doLogFile;
|
||||||
unsigned short retentionInDays;
|
unsigned short retentionInDays;
|
||||||
|
int loglevel;
|
||||||
public:
|
public:
|
||||||
ClassLogFile(std::string _logpath, std::string _logfile);
|
ClassLogFile(std::string _logpath, std::string _logfile);
|
||||||
|
|
||||||
|
std::string getESPHeapInfo();
|
||||||
|
|
||||||
|
void setLogLevel(int i){loglevel = i;};
|
||||||
|
|
||||||
|
void WriteHeapInfo(std::string _id);
|
||||||
|
|
||||||
void SwitchOnOff(bool _doLogFile);
|
void SwitchOnOff(bool _doLogFile);
|
||||||
void SetRetention(unsigned short _retentionInDays);
|
void SetRetention(unsigned short _retentionInDays);
|
||||||
|
|
||||||
|
|||||||
@@ -64,10 +64,18 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_
|
|||||||
mqtt_event_handler_cb((esp_mqtt_event_handle_t) event_data);
|
mqtt_event_handler_cb((esp_mqtt_event_handle_t) event_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password){
|
void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password, std::string _LWTContext, int _keepalive){
|
||||||
|
std::string _zwmessage = "connection lost";
|
||||||
|
|
||||||
|
int _lzw = _zwmessage.length();
|
||||||
|
|
||||||
esp_mqtt_client_config_t mqtt_cfg = {
|
esp_mqtt_client_config_t mqtt_cfg = {
|
||||||
.uri = _mqttURI.c_str(),
|
.uri = _mqttURI.c_str(),
|
||||||
.client_id = _clientid.c_str(),
|
.client_id = _clientid.c_str(),
|
||||||
|
.lwt_topic = _LWTContext.c_str(),
|
||||||
|
.lwt_msg = _zwmessage.c_str(),
|
||||||
|
.lwt_msg_len = _lzw,
|
||||||
|
.keepalive = _keepalive
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_user.length() && _password.length()){
|
if (_user.length() && _password.length()){
|
||||||
@@ -79,4 +87,6 @@ void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, st
|
|||||||
client = esp_mqtt_client_init(&mqtt_cfg);
|
client = esp_mqtt_client_init(&mqtt_cfg);
|
||||||
esp_mqtt_client_register_event(client, esp_mmqtt_ID, mqtt_event_handler, client);
|
esp_mqtt_client_register_event(client, esp_mmqtt_ID, mqtt_event_handler, client);
|
||||||
esp_mqtt_client_start(client);
|
esp_mqtt_client_start(client);
|
||||||
|
|
||||||
|
MQTTPublish(_LWTContext, "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user = "", std::string _password = "");
|
void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user, std::string _password, std::string _LWTContext, int _keepalive);
|
||||||
|
|
||||||
|
//void MQTTInit(std::string _mqttURI, std::string _clientid, std::string _user = "", std::string _password = "");
|
||||||
|
|
||||||
void MQTTPublish(std::string _key, std::string _content);
|
void MQTTPublish(std::string _key, std::string _content);
|
||||||
@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
|
|||||||
|
|
||||||
idf_component_register(SRCS ${app_sources}
|
idf_component_register(SRCS ${app_sources}
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
REQUIRES jomjol_image_proc jomjol_logfile esp_http_server esp32-camera-master jomjol_controlcamera jomjol_flowcontroll)
|
REQUIRES jomjol_image_proc jomjol_logfile esp_http_server esp32-camera-master jomjol_controlcamera jomjol_flowcontroll jomjol_helper)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
#include "CTfLiteClass.h"
|
#include "CTfLiteClass.h"
|
||||||
|
|
||||||
#include "bitmap_image.hpp"
|
|
||||||
|
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
#include "Helper.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
bool debugdetailtflite = false;
|
// #define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
float CTfLiteClass::GetOutputValue(int nr)
|
float CTfLiteClass::GetOutputValue(int nr)
|
||||||
{
|
{
|
||||||
@@ -19,19 +17,14 @@ float CTfLiteClass::GetOutputValue(int nr)
|
|||||||
return output2->data.f[nr];
|
return output2->data.f[nr];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CTfLiteClass::GetClassFromImageBasis(CImageBasis *rs)
|
||||||
int CTfLiteClass::GetClassFromImage(std::string _fn)
|
|
||||||
{
|
{
|
||||||
// printf("Before Load image %s\n", _fn.c_str());
|
if (!LoadInputImageBasis(rs))
|
||||||
if (!LoadInputImage(_fn))
|
|
||||||
return -1000;
|
return -1000;
|
||||||
// printf("After Load image %s\n", _fn.c_str());
|
|
||||||
|
|
||||||
Invoke();
|
Invoke();
|
||||||
printf("After Invoke %s\n", _fn.c_str());
|
|
||||||
|
|
||||||
return GetOutClassification();
|
return GetOutClassification();
|
||||||
// return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CTfLiteClass::GetOutClassification()
|
int CTfLiteClass::GetOutClassification()
|
||||||
@@ -55,7 +48,6 @@ int CTfLiteClass::GetOutClassification()
|
|||||||
zw_class = i;
|
zw_class = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// printf("Result Ziffer: %d\n", zw_class);
|
|
||||||
return zw_class;
|
return zw_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,21 +99,17 @@ void CTfLiteClass::GetOutPut()
|
|||||||
void CTfLiteClass::Invoke()
|
void CTfLiteClass::Invoke()
|
||||||
{
|
{
|
||||||
interpreter->Invoke();
|
interpreter->Invoke();
|
||||||
// printf("Invoke Done.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CTfLiteClass::LoadInputImage(std::string _fn)
|
|
||||||
|
bool CTfLiteClass::LoadInputImageBasis(CImageBasis *rs)
|
||||||
{
|
{
|
||||||
std::string zw = "ClassFlowAnalog::doNeuralNetwork nach Load Image: " + _fn;
|
std::string zw = "ClassFlowAnalog::doNeuralNetwork nach LoadInputResizeImage: ";
|
||||||
// LogFile.WriteToFile(zw);
|
|
||||||
bitmap_image image(_fn);
|
|
||||||
if (debugdetailtflite) LogFile.WriteToFile(zw);
|
|
||||||
|
|
||||||
unsigned int w = image.width();
|
unsigned int w = rs->width;
|
||||||
unsigned int h = image.height();
|
unsigned int h = rs->height;
|
||||||
unsigned char red, green, blue;
|
unsigned char red, green, blue;
|
||||||
|
|
||||||
// printf("Image: %s size: %d x %d\n", _fn.c_str(), w, h);
|
// printf("Image: %s size: %d x %d\n", _fn.c_str(), w, h);
|
||||||
|
|
||||||
input_i = 0;
|
input_i = 0;
|
||||||
@@ -130,21 +118,20 @@ bool CTfLiteClass::LoadInputImage(std::string _fn)
|
|||||||
for (int y = 0; y < h; ++y)
|
for (int y = 0; y < h; ++y)
|
||||||
for (int x = 0; x < w; ++x)
|
for (int x = 0; x < w; ++x)
|
||||||
{
|
{
|
||||||
red = image.red_channel(x, y);
|
red = rs->GetPixelColor(x, y, 0);
|
||||||
green = image.green_channel(x, y);
|
green = rs->GetPixelColor(x, y, 1);
|
||||||
blue = image.blue_channel(x, y);
|
blue = rs->GetPixelColor(x, y, 2);
|
||||||
*(input_data_ptr) = (float) red;
|
*(input_data_ptr) = (float) red;
|
||||||
input_data_ptr++;
|
input_data_ptr++;
|
||||||
*(input_data_ptr) = (float) green;
|
*(input_data_ptr) = (float) green;
|
||||||
input_data_ptr++;
|
input_data_ptr++;
|
||||||
*(input_data_ptr) = (float) blue;
|
*(input_data_ptr) = (float) blue;
|
||||||
input_data_ptr++;
|
input_data_ptr++;
|
||||||
|
|
||||||
// printf("BMP: %f %f %f\n", (float) red, (float) green, (float) blue);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debugdetailtflite) LogFile.WriteToFile("Nach dem Laden in input");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteToFile("Nach dem Laden in input");
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -152,9 +139,11 @@ bool CTfLiteClass::LoadInputImage(std::string _fn)
|
|||||||
|
|
||||||
void CTfLiteClass::MakeAllocate()
|
void CTfLiteClass::MakeAllocate()
|
||||||
{
|
{
|
||||||
// static tflite::ops::micro::AllOpsResolver resolver;
|
|
||||||
static tflite::AllOpsResolver resolver;
|
static tflite::AllOpsResolver resolver;
|
||||||
|
|
||||||
|
// printf(LogFile.getESPHeapInfo().c_str()); printf("\n");
|
||||||
this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
|
this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
|
||||||
|
// printf(LogFile.getESPHeapInfo().c_str()); printf("\n");
|
||||||
|
|
||||||
TfLiteStatus allocate_status = this->interpreter->AllocateTensors();
|
TfLiteStatus allocate_status = this->interpreter->AllocateTensors();
|
||||||
if (allocate_status != kTfLiteOk) {
|
if (allocate_status != kTfLiteOk) {
|
||||||
@@ -162,16 +151,15 @@ void CTfLiteClass::MakeAllocate()
|
|||||||
this->GetInputDimension();
|
this->GetInputDimension();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("Allocate Done.\n");
|
// printf("Allocate Done.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTfLiteClass::GetInputTensorSize(){
|
void CTfLiteClass::GetInputTensorSize(){
|
||||||
float *zw = this->input;
|
float *zw = this->input;
|
||||||
int test = sizeof(zw);
|
int test = sizeof(zw);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Input Tensor Dimension: %d\n", test);
|
printf("Input Tensor Dimension: %d\n", test);
|
||||||
|
#endif
|
||||||
printf("Input Tensor Dimension: %d\n", test);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long CTfLiteClass::GetFileSize(std::string filename)
|
long CTfLiteClass::GetFileSize(std::string filename)
|
||||||
@@ -186,24 +174,34 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn)
|
|||||||
{
|
{
|
||||||
long size;
|
long size;
|
||||||
|
|
||||||
size = this->GetFileSize(_fn);
|
size = GetFileSize(_fn);
|
||||||
|
|
||||||
if (size == -1)
|
if (size == -1)
|
||||||
{
|
{
|
||||||
printf("\nFile existiert nicht.\n");
|
printf("\nFile existiert nicht.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char *result = (unsigned char*) malloc(size);
|
unsigned char *result = (unsigned char*) malloc(size);
|
||||||
|
int anz = 1;
|
||||||
|
TickType_t xDelay;
|
||||||
|
while (!result && (anz < 6)) // maximal 5x versuchen (= 5s)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
printf("Speicher ist voll - Versuche es erneut: %d.\n", anz);
|
||||||
|
#endif
|
||||||
|
xDelay = 1000 / portTICK_PERIOD_MS;
|
||||||
|
result = (unsigned char*) malloc(size);
|
||||||
|
anz++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(result != NULL) {
|
if(result != NULL) {
|
||||||
// printf("\nSpeicher ist reserviert\n");
|
FILE* f = OpenFileAndWait(_fn.c_str(), "rb"); // vorher nur "r"
|
||||||
FILE* f = fopen(_fn.c_str(), "rb"); // vorher nur "r"
|
|
||||||
fread(result, 1, size, f);
|
fread(result, 1, size, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}else {
|
}else {
|
||||||
printf("\nKein freier Speicher vorhanden.\n");
|
printf("\nKein freier Speicher vorhanden.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -219,14 +217,11 @@ void CTfLiteClass::LoadModel(std::string _fn){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned char *rd;
|
unsigned char *rd;
|
||||||
rd = this->ReadFileToCharArray(_fn.c_str());
|
rd = ReadFileToCharArray(_fn.c_str());
|
||||||
// printf("loadedfile: %d", (int) rd);
|
|
||||||
|
|
||||||
this->model = tflite::GetModel(rd);
|
this->model = tflite::GetModel(rd);
|
||||||
free(rd);
|
free(rd);
|
||||||
TFLITE_MINIMAL_CHECK(model != nullptr);
|
TFLITE_MINIMAL_CHECK(model != nullptr);
|
||||||
// printf("tfile Loaded.\n");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -237,7 +232,7 @@ CTfLiteClass::CTfLiteClass()
|
|||||||
this->interpreter = nullptr;
|
this->interpreter = nullptr;
|
||||||
this->input = nullptr;
|
this->input = nullptr;
|
||||||
this->output = nullptr;
|
this->output = nullptr;
|
||||||
this->kTensorArenaSize = 600 * 1024;
|
this->kTensorArenaSize = 200 * 1024; /// laut testfile: 108000 - bisher 600
|
||||||
this->tensor_arena = new uint8_t[kTensorArenaSize];
|
this->tensor_arena = new uint8_t[kTensorArenaSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,6 +250,6 @@ namespace tflite {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tflite
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#include "CImageBasis.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SUPRESS_TFLITE_ERRORS // use, to avoid error messages from TFLITE
|
#define SUPRESS_TFLITE_ERRORS // use, to avoid error messages from TFLITE
|
||||||
@@ -39,7 +41,6 @@ class CTfLiteClass
|
|||||||
const tflite::Model* model;
|
const tflite::Model* model;
|
||||||
tflite::MicroInterpreter* interpreter;
|
tflite::MicroInterpreter* interpreter;
|
||||||
TfLiteTensor* output = nullptr;
|
TfLiteTensor* output = nullptr;
|
||||||
// static tflite::ops::micro::AllOpsResolver *resolver;
|
|
||||||
static tflite::AllOpsResolver resolver;
|
static tflite::AllOpsResolver resolver;
|
||||||
|
|
||||||
int kTensorArenaSize;
|
int kTensorArenaSize;
|
||||||
@@ -58,11 +59,11 @@ class CTfLiteClass
|
|||||||
void LoadModel(std::string _fn);
|
void LoadModel(std::string _fn);
|
||||||
void MakeAllocate();
|
void MakeAllocate();
|
||||||
void GetInputTensorSize();
|
void GetInputTensorSize();
|
||||||
bool LoadInputImage(std::string _fn);
|
bool LoadInputImageBasis(CImageBasis *rs);
|
||||||
void Invoke();
|
void Invoke();
|
||||||
void GetOutPut();
|
void GetOutPut();
|
||||||
int GetOutClassification();
|
int GetOutClassification();
|
||||||
int GetClassFromImage(std::string _fn);
|
int GetClassFromImageBasis(CImageBasis *rs);
|
||||||
|
|
||||||
float GetOutputValue(int nr);
|
float GetOutputValue(int nr);
|
||||||
void GetInputDimension(bool silent);
|
void GetInputDimension(bool silent);
|
||||||
|
|||||||
@@ -18,17 +18,41 @@
|
|||||||
|
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
|
//#define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
ClassFlowControll tfliteflow;
|
ClassFlowControll tfliteflow;
|
||||||
|
|
||||||
TaskHandle_t xHandleblink_task_doFlow = NULL;
|
TaskHandle_t xHandleblink_task_doFlow = NULL;
|
||||||
TaskHandle_t xHandletask_autodoFlow = NULL;
|
TaskHandle_t xHandletask_autodoFlow = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool flowisrunning = false;
|
bool flowisrunning = false;
|
||||||
|
|
||||||
long auto_intervall = 0;
|
long auto_intervall = 0;
|
||||||
bool auto_isrunning = false;
|
bool auto_isrunning = false;
|
||||||
|
|
||||||
|
|
||||||
|
int countRounds = 0;
|
||||||
|
|
||||||
|
int getCountFlowRounds() {
|
||||||
|
return countRounds;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
esp_err_t GetJPG(std::string _filename, httpd_req_t *req)
|
||||||
|
{
|
||||||
|
return tfliteflow.GetJPGStream(_filename, req);
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t GetRawJPG(httpd_req_t *req)
|
||||||
|
{
|
||||||
|
return tfliteflow.SendRawJPG(req);
|
||||||
|
}
|
||||||
|
|
||||||
bool isSetupModusActive() {
|
bool isSetupModusActive() {
|
||||||
return tfliteflow.getStatusSetupModus();
|
return tfliteflow.getStatusSetupModus();
|
||||||
return false;
|
return false;
|
||||||
@@ -37,28 +61,40 @@ bool isSetupModusActive() {
|
|||||||
|
|
||||||
void KillTFliteTasks()
|
void KillTFliteTasks()
|
||||||
{
|
{
|
||||||
printf("Handle: xHandleblink_task_doFlow: %ld\n", (long) xHandleblink_task_doFlow);
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
printf("Handle: xHandleblink_task_doFlow: %ld\n", (long) xHandleblink_task_doFlow);
|
||||||
|
#endif
|
||||||
if (xHandleblink_task_doFlow)
|
if (xHandleblink_task_doFlow)
|
||||||
{
|
{
|
||||||
vTaskDelete(xHandleblink_task_doFlow);
|
vTaskDelete(xHandleblink_task_doFlow);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Killed: xHandleblink_task_doFlow\n");
|
printf("Killed: xHandleblink_task_doFlow\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Handle: xHandletask_autodoFlow: %ld\n", (long) xHandletask_autodoFlow);
|
printf("Handle: xHandletask_autodoFlow: %ld\n", (long) xHandletask_autodoFlow);
|
||||||
|
#endif
|
||||||
if (xHandletask_autodoFlow)
|
if (xHandletask_autodoFlow)
|
||||||
{
|
{
|
||||||
vTaskDelete(xHandletask_autodoFlow);
|
vTaskDelete(xHandletask_autodoFlow);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Killed: xHandletask_autodoFlow\n");
|
printf("Killed: xHandletask_autodoFlow\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void doInit(void)
|
void doInit(void)
|
||||||
{
|
{
|
||||||
string config = "/sdcard/config/config.ini";
|
string config = "/sdcard/config/config.ini";
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Start tfliteflow.InitFlow(config);\n");
|
printf("Start tfliteflow.InitFlow(config);\n");
|
||||||
|
#endif
|
||||||
tfliteflow.InitFlow(config);
|
tfliteflow.InitFlow(config);
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Finished tfliteflow.InitFlow(config);\n");
|
printf("Finished tfliteflow.InitFlow(config);\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,13 +107,17 @@ bool doflow(void)
|
|||||||
tfliteflow.doFlow(zw_time);
|
tfliteflow.doFlow(zw_time);
|
||||||
flowisrunning = false;
|
flowisrunning = false;
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("doflow - end %s\n", zw_time.c_str());
|
printf("doflow - end %s\n", zw_time.c_str());
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void blink_task_doFlow(void *pvParameter)
|
void blink_task_doFlow(void *pvParameter)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("blink_task_doFlow\n");
|
printf("blink_task_doFlow\n");
|
||||||
|
#endif
|
||||||
if (!flowisrunning)
|
if (!flowisrunning)
|
||||||
{
|
{
|
||||||
flowisrunning = true;
|
flowisrunning = true;
|
||||||
@@ -91,8 +131,10 @@ void blink_task_doFlow(void *pvParameter)
|
|||||||
|
|
||||||
esp_err_t handler_init(httpd_req_t *req)
|
esp_err_t handler_init(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_init");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_init - Start");
|
||||||
printf("handler_doinit uri:\n"); printf(req->uri); printf("\n");
|
printf("handler_doinit uri:\n"); printf(req->uri); printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
char* resp_str = "Init started<br>";
|
char* resp_str = "Init started<br>";
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
@@ -104,12 +146,19 @@ esp_err_t handler_init(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_init - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
esp_err_t handler_doflow(httpd_req_t *req)
|
esp_err_t handler_doflow(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_doflow");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_doflow - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
char* resp_str;
|
char* resp_str;
|
||||||
|
|
||||||
printf("handler_doFlow uri: "); printf(req->uri); printf("\n");
|
printf("handler_doFlow uri: "); printf(req->uri); printf("\n");
|
||||||
@@ -127,7 +176,12 @@ esp_err_t handler_doflow(httpd_req_t *req)
|
|||||||
resp_str = "doFlow gestartet - dauert ca. 60 Sekunden";
|
resp_str = "doFlow gestartet - dauert ca. 60 Sekunden";
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_doflow - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -136,7 +190,10 @@ esp_err_t handler_doflow(httpd_req_t *req)
|
|||||||
|
|
||||||
esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_wasserzaehler");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_wasserzaehler - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
bool _rawValue = false;
|
bool _rawValue = false;
|
||||||
bool _noerror = false;
|
bool _noerror = false;
|
||||||
string zw;
|
string zw;
|
||||||
@@ -151,12 +208,16 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
// printf("Query: "); printf(_query); printf("\n");
|
// printf("Query: "); printf(_query); printf("\n");
|
||||||
if (httpd_query_key_value(_query, "rawvalue", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "rawvalue", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("rawvalue is found"); printf(_size); printf("\n");
|
printf("rawvalue is found"); printf(_size); printf("\n");
|
||||||
|
#endif
|
||||||
_rawValue = true;
|
_rawValue = true;
|
||||||
}
|
}
|
||||||
if (httpd_query_key_value(_query, "noerror", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "noerror", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("noerror is found"); printf(_size); printf("\n");
|
printf("noerror is found"); printf(_size); printf("\n");
|
||||||
|
#endif
|
||||||
_noerror = true;
|
_noerror = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,7 +232,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
string txt, zw;
|
string txt, zw;
|
||||||
|
|
||||||
txt = "<p>Aligned Image: <p><img src=\"/img_tmp/alg.jpg\"> <p>\n";
|
txt = "<p>Aligned Image: <p><img src=\"/img_tmp/alg_roi.jpg\"> <p>\n";
|
||||||
txt = txt + "Digital Counter: <p> ";
|
txt = txt + "Digital Counter: <p> ";
|
||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
|
|
||||||
@@ -205,7 +266,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
httpd_resp_sendstr_chunk(req, txt.c_str());
|
httpd_resp_sendstr_chunk(req, txt.c_str());
|
||||||
delete htmlinfo[i];
|
delete htmlinfo[i];
|
||||||
}
|
}
|
||||||
htmlinfo.clear();
|
htmlinfo.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,13 +278,18 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_wasserzaehler - Done");
|
||||||
|
#endif
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_editflow(httpd_req_t *req)
|
esp_err_t handler_editflow(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_editflow");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_editflow - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
printf("handler_editflow uri: "); printf(req->uri); printf("\n");
|
printf("handler_editflow uri: "); printf(req->uri); printf("\n");
|
||||||
|
|
||||||
@@ -235,7 +301,9 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("task is found: %s\n", _valuechar);
|
printf("task is found: %s\n", _valuechar);
|
||||||
|
#endif
|
||||||
_task = string(_valuechar);
|
_task = string(_valuechar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,11 +314,13 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
|
|
||||||
httpd_query_key_value(_query, "in", _valuechar, 30);
|
httpd_query_key_value(_query, "in", _valuechar, 30);
|
||||||
in = string(_valuechar);
|
in = string(_valuechar);
|
||||||
printf("in: "); printf(in.c_str()); printf("\n");
|
|
||||||
|
|
||||||
httpd_query_key_value(_query, "out", _valuechar, 30);
|
httpd_query_key_value(_query, "out", _valuechar, 30);
|
||||||
out = string(_valuechar);
|
out = string(_valuechar);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
printf("in: "); printf(in.c_str()); printf("\n");
|
||||||
printf("out: "); printf(out.c_str()); printf("\n");
|
printf("out: "); printf(out.c_str()); printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
in = "/sdcard" + in;
|
in = "/sdcard" + in;
|
||||||
out = "/sdcard" + out;
|
out = "/sdcard" + out;
|
||||||
@@ -269,31 +339,34 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
|
|
||||||
httpd_query_key_value(_query, "in", _valuechar, 30);
|
httpd_query_key_value(_query, "in", _valuechar, 30);
|
||||||
in = string(_valuechar);
|
in = string(_valuechar);
|
||||||
printf("in: "); printf(in.c_str()); printf("\n");
|
|
||||||
|
|
||||||
httpd_query_key_value(_query, "out", _valuechar, 30);
|
httpd_query_key_value(_query, "out", _valuechar, 30);
|
||||||
out = string(_valuechar);
|
out = string(_valuechar);
|
||||||
printf("out: "); printf(out.c_str()); printf("\n");
|
|
||||||
|
|
||||||
httpd_query_key_value(_query, "x", _valuechar, 30);
|
httpd_query_key_value(_query, "x", _valuechar, 30);
|
||||||
zw = string(_valuechar);
|
zw = string(_valuechar);
|
||||||
x = stoi(zw);
|
x = stoi(zw);
|
||||||
printf("x: "); printf(zw.c_str()); printf("\n");
|
|
||||||
|
|
||||||
httpd_query_key_value(_query, "y", _valuechar, 30);
|
httpd_query_key_value(_query, "y", _valuechar, 30);
|
||||||
zw = string(_valuechar);
|
zw = string(_valuechar);
|
||||||
y = stoi(zw);
|
y = stoi(zw);
|
||||||
printf("y: "); printf(zw.c_str()); printf("\n");
|
|
||||||
|
|
||||||
httpd_query_key_value(_query, "dx", _valuechar, 30);
|
httpd_query_key_value(_query, "dx", _valuechar, 30);
|
||||||
zw = string(_valuechar);
|
zw = string(_valuechar);
|
||||||
dx = stoi(zw);
|
dx = stoi(zw);
|
||||||
printf("dx: "); printf(zw.c_str()); printf("\n");
|
|
||||||
|
|
||||||
httpd_query_key_value(_query, "dy", _valuechar, 30);
|
httpd_query_key_value(_query, "dy", _valuechar, 30);
|
||||||
zw = string(_valuechar);
|
zw = string(_valuechar);
|
||||||
dy = stoi(zw);
|
dy = stoi(zw);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
printf("in: "); printf(in.c_str()); printf("\n");
|
||||||
|
printf("out: "); printf(out.c_str()); printf("\n");
|
||||||
|
printf("x: "); printf(zw.c_str()); printf("\n");
|
||||||
|
printf("y: "); printf(zw.c_str()); printf("\n");
|
||||||
|
printf("dx: "); printf(zw.c_str()); printf("\n");
|
||||||
printf("dy: "); printf(zw.c_str()); printf("\n");
|
printf("dy: "); printf(zw.c_str()); printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "enhance", _valuechar, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "enhance", _valuechar, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
@@ -324,16 +397,39 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
|
|
||||||
zw = "CutImage Done";
|
zw = "CutImage Done";
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_task.compare("test_take") == 0)
|
if (_task.compare("test_take") == 0)
|
||||||
{
|
{
|
||||||
std::string _host = "";
|
std::string _host = "";
|
||||||
|
std::string _bri = "";
|
||||||
|
std::string _con = "";
|
||||||
|
std::string _sat = "";
|
||||||
|
int bri = -100;
|
||||||
|
int sat = -100;
|
||||||
|
int con = -100;
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
|
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
|
||||||
_host = std::string(_valuechar);
|
_host = std::string(_valuechar);
|
||||||
}
|
}
|
||||||
|
if (httpd_query_key_value(_query, "bri", _valuechar, 30) == ESP_OK) {
|
||||||
|
_bri = std::string(_valuechar);
|
||||||
|
bri = stoi(_bri);
|
||||||
|
}
|
||||||
|
if (httpd_query_key_value(_query, "con", _valuechar, 30) == ESP_OK) {
|
||||||
|
_con = std::string(_valuechar);
|
||||||
|
con = stoi(_con);
|
||||||
|
}
|
||||||
|
if (httpd_query_key_value(_query, "sat", _valuechar, 30) == ESP_OK) {
|
||||||
|
_sat = std::string(_valuechar);
|
||||||
|
sat = stoi(_sat);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
|
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
|
||||||
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
|
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
|
||||||
|
bool changed = Camera.SetBrightnessContrastSaturation(bri, con, sat);
|
||||||
std::string zw = tfliteflow.doSingleStep("[MakeImage]", _host);
|
std::string zw = tfliteflow.doSingleStep("[MakeImage]", _host);
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
}
|
}
|
||||||
@@ -379,29 +475,43 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_editflow - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
esp_err_t handler_prevalue(httpd_req_t *req)
|
esp_err_t handler_prevalue(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("handler_prevalue");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
const char* resp_str;
|
const char* resp_str;
|
||||||
string zw;
|
string zw;
|
||||||
|
|
||||||
// printf("handler_prevalue:\n"); printf(req->uri); printf("\n");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
printf("handler_prevalue:\n"); printf(req->uri); printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
char _query[100];
|
char _query[100];
|
||||||
char _size[10] = "";
|
char _size[10] = "";
|
||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
// printf("Query: "); printf(_query); printf("\n");
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
printf("Query: "); printf(_query); printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Value: "); printf(_size); printf("\n");
|
printf("Value: "); printf(_size); printf("\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(_size) == 0)
|
if (strlen(_size) == 0)
|
||||||
zw = tfliteflow.GetPrevalue();
|
zw = tfliteflow.GetPrevalue();
|
||||||
@@ -414,6 +524,10 @@ esp_err_t handler_prevalue(httpd_req_t *req)
|
|||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("handler_prevalue - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -434,20 +548,27 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
|
|
||||||
while (auto_isrunning)
|
while (auto_isrunning)
|
||||||
{
|
{
|
||||||
LogFile.WriteToFile("task_autodoFlow - next round");
|
std::string _zw = "task_autodoFlow - next round - Round #" + std::to_string(++countRounds);
|
||||||
|
LogFile.WriteToFile(_zw);
|
||||||
printf("Autoflow: start\n");
|
printf("Autoflow: start\n");
|
||||||
fr_start = esp_timer_get_time();
|
fr_start = esp_timer_get_time();
|
||||||
|
|
||||||
if (flowisrunning)
|
if (flowisrunning)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Autoflow: doFLow laeuft bereits!\n");
|
printf("Autoflow: doFLow laeuft bereits!\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Autoflow: doFLow wird gestartet\n");
|
printf("Autoflow: doFLow wird gestartet\n");
|
||||||
|
#endif
|
||||||
flowisrunning = true;
|
flowisrunning = true;
|
||||||
doflow();
|
doflow();
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Remove older log files\n");
|
printf("Remove older log files\n");
|
||||||
|
#endif
|
||||||
LogFile.RemoveOld();
|
LogFile.RemoveOld();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,9 +581,12 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
LogFile.WriteToFile(zwtemp);
|
LogFile.WriteToFile(zwtemp);
|
||||||
printf("CPU Temperature: %.2f\n", cputmp);
|
printf("CPU Temperature: %.2f\n", cputmp);
|
||||||
fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000;
|
fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000;
|
||||||
const TickType_t xDelay = (auto_intervall - fr_delta_ms) / portTICK_PERIOD_MS;
|
if (auto_intervall > fr_delta_ms)
|
||||||
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
|
{
|
||||||
vTaskDelay( xDelay );
|
const TickType_t xDelay = (auto_intervall - fr_delta_ms) / portTICK_PERIOD_MS;
|
||||||
|
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
|
||||||
|
vTaskDelay( xDelay );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
vTaskDelete(NULL); //Delete this task if it exits from the loop above
|
vTaskDelete(NULL); //Delete this task if it exits from the loop above
|
||||||
xHandletask_autodoFlow = NULL;
|
xHandletask_autodoFlow = NULL;
|
||||||
@@ -507,5 +631,4 @@ void register_server_tflite_uri(httpd_handle_t server)
|
|||||||
camuri.handler = handler_wasserzaehler;
|
camuri.handler = handler_wasserzaehler;
|
||||||
camuri.user_ctx = (void*) "Wasserzaehler";
|
camuri.user_ctx = (void*) "Wasserzaehler";
|
||||||
httpd_register_uri_handler(server, &camuri);
|
httpd_register_uri_handler(server, &camuri);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
|
|
||||||
#include <esp_http_server.h>
|
#include <esp_http_server.h>
|
||||||
|
#include "CImageBasis.h"
|
||||||
|
|
||||||
//#include "ClassControllCamera.h"
|
//#include "ClassControllCamera.h"
|
||||||
|
|
||||||
@@ -12,4 +13,8 @@ void KillTFliteTasks();
|
|||||||
|
|
||||||
void TFliteDoAutoStart();
|
void TFliteDoAutoStart();
|
||||||
|
|
||||||
bool isSetupModusActive();
|
bool isSetupModusActive();
|
||||||
|
|
||||||
|
esp_err_t GetJPG(std::string _filename, httpd_req_t *req);
|
||||||
|
|
||||||
|
esp_err_t GetRawJPG(httpd_req_t *req);
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
#include "time_sntp.h"
|
#include "time_sntp.h"
|
||||||
|
|
||||||
/* LwIP SNTP example
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@@ -17,25 +11,19 @@
|
|||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
// #include "nvs_flash.h"
|
|
||||||
// #include "protocol_examples_common.h"
|
|
||||||
#include "esp_sntp.h"
|
#include "esp_sntp.h"
|
||||||
|
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
static const char *TAG = "sntp";
|
static const char *TAG = "sntp";
|
||||||
|
|
||||||
RTC_DATA_ATTR int boot_count = 0;
|
|
||||||
|
|
||||||
bool setTimeAlwaysOnReboot = true;
|
bool setTimeAlwaysOnReboot = true;
|
||||||
|
|
||||||
static void obtain_time(void);
|
static void obtain_time(void);
|
||||||
static void initialize_sntp(void);
|
static void initialize_sntp(void);
|
||||||
|
|
||||||
|
|
||||||
void time_sync_notification_cb(struct timeval *tv)
|
void time_sync_notification_cb(struct timeval *tv)
|
||||||
{
|
{
|
||||||
// LogFile.WriteToFile("Notification of a time synchronization event");
|
|
||||||
ESP_LOGI(TAG, "Notification of a time synchronization event");
|
ESP_LOGI(TAG, "Notification of a time synchronization event");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,9 +42,6 @@ std::string gettimestring(const char * frm)
|
|||||||
|
|
||||||
void setup_time()
|
void setup_time()
|
||||||
{
|
{
|
||||||
++boot_count;
|
|
||||||
ESP_LOGI(TAG, "Boot count: %d", boot_count);
|
|
||||||
|
|
||||||
time_t now;
|
time_t now;
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
time(&now);
|
time(&now);
|
||||||
@@ -72,8 +57,6 @@ void setup_time()
|
|||||||
char strftime_buf[64];
|
char strftime_buf[64];
|
||||||
|
|
||||||
setTimeZone("CET-1CEST,M3.5.0,M10.5.0/3");
|
setTimeZone("CET-1CEST,M3.5.0,M10.5.0/3");
|
||||||
// setTimeZone("Europe/Berlin");
|
|
||||||
// setTimeZone("Asia/Tokyo");
|
|
||||||
|
|
||||||
localtime_r(&now, &timeinfo);
|
localtime_r(&now, &timeinfo);
|
||||||
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
|
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
|
||||||
@@ -97,9 +80,6 @@ void setTimeZone(std::string _tzstring)
|
|||||||
|
|
||||||
static void obtain_time(void)
|
static void obtain_time(void)
|
||||||
{
|
{
|
||||||
// initialize_sntp();
|
|
||||||
|
|
||||||
// wait for time to be set
|
|
||||||
time_t now = 0;
|
time_t now = 0;
|
||||||
struct tm timeinfo = {};
|
struct tm timeinfo = {};
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
@@ -110,18 +90,23 @@ static void obtain_time(void)
|
|||||||
ESP_LOGI(TAG, "Waiting for system time to be set... (%d/%d)", retry, retry_count);
|
ESP_LOGI(TAG, "Waiting for system time to be set... (%d/%d)", retry, retry_count);
|
||||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
if (retry == retry_count) {
|
|
||||||
// LogFile.WriteToFile("Time Synchzronisation nicht erfolgreich ...");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// LogFile.WriteToFile("Time erfolgreich ...");
|
|
||||||
}
|
|
||||||
|
|
||||||
time(&now);
|
time(&now);
|
||||||
localtime_r(&now, &timeinfo);
|
localtime_r(&now, &timeinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reset_servername(std::string _servername)
|
||||||
|
{
|
||||||
|
printf("Set SNTP-Server: %s\n", _servername.c_str());
|
||||||
|
sntp_stop();
|
||||||
|
sntp_setoperatingmode(SNTP_OPMODE_POLL);
|
||||||
|
sntp_setservername(0, _servername.c_str());
|
||||||
|
sntp_init();
|
||||||
|
obtain_time();
|
||||||
|
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
||||||
|
printf("Time ist %s\n", zw.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
static void initialize_sntp(void)
|
static void initialize_sntp(void)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "Initializing SNTP");
|
ESP_LOGI(TAG, "Initializing SNTP");
|
||||||
|
|||||||
@@ -15,4 +15,5 @@
|
|||||||
void setup_time(void);
|
void setup_time(void);
|
||||||
|
|
||||||
std::string gettimestring(const char * frm);
|
std::string gettimestring(const char * frm);
|
||||||
void setTimeZone(std::string _tzstring);
|
void setTimeZone(std::string _tzstring);
|
||||||
|
void reset_servername(std::string _servername);
|
||||||
@@ -26,45 +26,110 @@
|
|||||||
#include "server_main.h"
|
#include "server_main.h"
|
||||||
#include "server_camera.h"
|
#include "server_camera.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define __SD_USE_ONE_LINE_MODE__
|
||||||
|
|
||||||
|
#ifdef __SD_USE_ONE_LINE_MODE__
|
||||||
|
#include "server_GPIO.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define BLINK_GPIO GPIO_NUM_33
|
||||||
|
|
||||||
static const char *TAGMAIN = "connect_wlan_main";
|
static const char *TAGMAIN = "connect_wlan_main";
|
||||||
|
|
||||||
#define FLASH_GPIO GPIO_NUM_4
|
#define FLASH_GPIO GPIO_NUM_4
|
||||||
|
|
||||||
void Init_NVS_SDCard()
|
bool Init_NVS_SDCard()
|
||||||
{
|
{
|
||||||
esp_err_t ret = nvs_flash_init();
|
esp_err_t ret = nvs_flash_init();
|
||||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
|
||||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||||
ret = nvs_flash_init();
|
ret = nvs_flash_init();
|
||||||
}
|
}
|
||||||
|
////////////////////////////////////////////////
|
||||||
|
|
||||||
ESP_LOGI(TAGMAIN, "Initializing SD card");
|
ESP_LOGI(TAG, "Using SDMMC peripheral");
|
||||||
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
|
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
|
||||||
host.flags = SDMMC_HOST_FLAG_1BIT;
|
|
||||||
// sdmmc_host_t host = SDMMC_HOST_SLOT_1();
|
|
||||||
// host.flags = SDMMC_HOST_FLAG_1BIT;
|
|
||||||
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
|
||||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = { };
|
|
||||||
mount_config.format_if_mount_failed = false;
|
|
||||||
mount_config.max_files = 5;
|
|
||||||
|
|
||||||
|
// This initializes the slot without card detect (CD) and write protect (WP) signals.
|
||||||
|
// Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
|
||||||
|
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
||||||
|
|
||||||
|
// To use 1-line SD mode, uncomment the following line:
|
||||||
|
|
||||||
|
#ifdef __SD_USE_ONE_LINE_MODE__
|
||||||
|
slot_config.width = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// GPIOs 15, 2, 4, 12, 13 should have external 10k pull-ups.
|
||||||
|
// Internal pull-ups are not sufficient. However, enabling internal pull-ups
|
||||||
|
// does make a difference some boards, so we do that here.
|
||||||
|
gpio_set_pull_mode(GPIO_NUM_15, GPIO_PULLUP_ONLY); // CMD, needed in 4- and 1- line modes
|
||||||
|
gpio_set_pull_mode(GPIO_NUM_2, GPIO_PULLUP_ONLY); // D0, needed in 4- and 1-line modes
|
||||||
|
gpio_set_pull_mode(GPIO_NUM_4, GPIO_PULLUP_ONLY); // D1, needed in 4-line mode only
|
||||||
|
gpio_set_pull_mode(GPIO_NUM_12, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only
|
||||||
|
gpio_set_pull_mode(GPIO_NUM_13, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes
|
||||||
|
|
||||||
|
// Options for mounting the filesystem.
|
||||||
|
// If format_if_mount_failed is set to true, SD card will be partitioned and
|
||||||
|
// formatted in case when mounting fails.
|
||||||
|
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||||
|
.format_if_mount_failed = false,
|
||||||
|
.max_files = 5,
|
||||||
|
.allocation_unit_size = 16 * 1024
|
||||||
|
};
|
||||||
|
|
||||||
|
// Use settings defined above to initialize SD card and mount FAT filesystem.
|
||||||
|
// Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function.
|
||||||
|
// Please check its source code and implement error recovery when developing
|
||||||
|
// production applications.
|
||||||
sdmmc_card_t* card;
|
sdmmc_card_t* card;
|
||||||
ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
|
ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
|
||||||
|
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
if (ret == ESP_FAIL) {
|
if (ret == ESP_FAIL) {
|
||||||
ESP_LOGE(TAGMAIN, "Failed to mount filesystem. If you want the card to be formatted, set format_if_mount_failed = true.");
|
ESP_LOGE(TAG, "Failed to mount filesystem. "
|
||||||
|
"If you want the card to be formatted, set format_if_mount_failed = true.");
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGE(TAGMAIN, "Failed to initialize the card (%d). Make sure SD card lines have pull-up resistors in place.", ret);
|
ESP_LOGE(TAG, "Failed to initialize the card (%s). "
|
||||||
|
"Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret));
|
||||||
}
|
}
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Card has been initialized, print its properties
|
||||||
sdmmc_card_print_info(stdout, card);
|
sdmmc_card_print_info(stdout, card);
|
||||||
|
|
||||||
|
|
||||||
// Init the GPIO
|
// Init the GPIO
|
||||||
// Flash ausschalten
|
// Flash ausschalten
|
||||||
gpio_pad_select_gpio(FLASH_GPIO);
|
gpio_pad_select_gpio(FLASH_GPIO);
|
||||||
gpio_set_direction(FLASH_GPIO, GPIO_MODE_OUTPUT);
|
gpio_set_direction(FLASH_GPIO, GPIO_MODE_OUTPUT);
|
||||||
gpio_set_level(FLASH_GPIO, 0);
|
gpio_set_level(FLASH_GPIO, 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void task_NoSDBlink(void *pvParameter)
|
||||||
|
{
|
||||||
|
gpio_pad_select_gpio(BLINK_GPIO);
|
||||||
|
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
||||||
|
|
||||||
|
|
||||||
|
TickType_t xDelay;
|
||||||
|
xDelay = 100 / portTICK_PERIOD_MS;
|
||||||
|
printf("SD-Card could not be inialized - STOP THE PROGRAMM HERE\n");
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
gpio_set_level(BLINK_GPIO, 1);
|
||||||
|
vTaskDelay( xDelay );
|
||||||
|
gpio_set_level(BLINK_GPIO, 0);
|
||||||
|
vTaskDelay( xDelay );
|
||||||
|
|
||||||
|
}
|
||||||
|
vTaskDelete(NULL); //Delete this task if it exits from the loop above
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void app_main(void)
|
extern "C" void app_main(void)
|
||||||
@@ -74,40 +139,18 @@ extern "C" void app_main(void)
|
|||||||
Camera.InitCam();
|
Camera.InitCam();
|
||||||
Camera.LightOnOff(false);
|
Camera.LightOnOff(false);
|
||||||
|
|
||||||
Init_NVS_SDCard();
|
if (!Init_NVS_SDCard())
|
||||||
// LogFile.WriteToFile("Startsequence 02");
|
{
|
||||||
|
xTaskCreate(&task_NoSDBlink, "task_NoSDBlink", configMINIMAL_STACK_SIZE * 64, NULL, tskIDLE_PRIORITY+1, NULL);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
CheckOTAUpdate();
|
CheckOTAUpdate();
|
||||||
// LogFile.WriteToFile("Startsequence 03");
|
|
||||||
std::string ssid = "";
|
|
||||||
std::string password = "";
|
|
||||||
std::string hostname = "";
|
|
||||||
std::string ip = "";
|
|
||||||
std::string gw = "";
|
|
||||||
std::string netmask = "";
|
|
||||||
std::string dns = "";
|
|
||||||
|
|
||||||
// LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname, ip, gw, netmask, dns);
|
LoadWlanFromFile("/sdcard/wlan.ini");
|
||||||
LoadWlanFromFile("/sdcard/wlan.ini", ssid, password, hostname);
|
ConnectToWLAN();
|
||||||
|
printf("\nNetparameter: IP: %s - GW: %s - NetMask %s\n", getIPAddress().c_str(), getGW().c_str(), getNetMask().c_str());
|
||||||
// LogFile.WriteToFile("Startsequence 04");
|
|
||||||
printf("To use WLan: %s, %s\n", ssid.c_str(), password.c_str());
|
|
||||||
printf("To set Hostename: %s\n", hostname.c_str());
|
|
||||||
printf("Fixed IP: %s, Gateway %s, Netmask %s\n", ip.c_str(), gw.c_str(), netmask.c_str());
|
|
||||||
|
|
||||||
if (ip.length() == 0 || gw.length() == 0 || netmask.length() == 0)
|
|
||||||
{
|
|
||||||
initialise_wifi(ssid, password, hostname);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
initialise_wifi_fixed_ip(ip, gw, netmask, ssid, password, hostname, dns);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Netparameter: IP: %s - GW: %s - NetMask %s\n", getIPAddress().c_str(), getGW().c_str(), getNetMask().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
// LogFile.WriteToFile("Startsequence 05");
|
|
||||||
|
|
||||||
TickType_t xDelay;
|
TickType_t xDelay;
|
||||||
xDelay = 2000 / portTICK_PERIOD_MS;
|
xDelay = 2000 / portTICK_PERIOD_MS;
|
||||||
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
|
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
|
||||||
@@ -115,7 +158,9 @@ extern "C" void app_main(void)
|
|||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
// LogFile.WriteToFile("Startsequence 07");
|
// LogFile.WriteToFile("Startsequence 07");
|
||||||
setup_time();
|
setup_time();
|
||||||
LogFile.WriteToFile("============================== Main Started =======================================");
|
LogFile.WriteToFile("=============================================================================================");
|
||||||
|
LogFile.WriteToFile("=================================== Main Started ============================================");
|
||||||
|
LogFile.WriteToFile("=============================================================================================");
|
||||||
LogFile.SwitchOnOff(false);
|
LogFile.SwitchOnOff(false);
|
||||||
|
|
||||||
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
||||||
@@ -132,6 +177,11 @@ extern "C" void app_main(void)
|
|||||||
register_server_tflite_uri(server);
|
register_server_tflite_uri(server);
|
||||||
register_server_file_uri(server, "/sdcard");
|
register_server_file_uri(server, "/sdcard");
|
||||||
register_server_ota_sdcard_uri(server);
|
register_server_ota_sdcard_uri(server);
|
||||||
|
|
||||||
|
#ifdef __SD_USE_ONE_LINE_MODE__
|
||||||
|
register_server_GPIO_uri(server);
|
||||||
|
#endif
|
||||||
|
|
||||||
register_server_main_uri(server, "/sdcard");
|
register_server_main_uri(server, "/sdcard");
|
||||||
|
|
||||||
TFliteDoAutoStart();
|
TFliteDoAutoStart();
|
||||||
|
|||||||
@@ -15,16 +15,22 @@
|
|||||||
|
|
||||||
#include "server_tflite.h"
|
#include "server_tflite.h"
|
||||||
|
|
||||||
|
//#define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
httpd_handle_t server = NULL;
|
httpd_handle_t server = NULL;
|
||||||
|
|
||||||
|
|
||||||
std::string starttime = "";
|
std::string starttime = "";
|
||||||
|
|
||||||
|
|
||||||
/* An HTTP GET handler */
|
/* An HTTP GET handler */
|
||||||
esp_err_t info_get_handler(httpd_req_t *req)
|
esp_err_t info_get_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("info_get_handler - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
LogFile.WriteToFile("info_get_handler");
|
LogFile.WriteToFile("info_get_handler");
|
||||||
char _query[200];
|
char _query[200];
|
||||||
char _valuechar[30];
|
char _valuechar[30];
|
||||||
@@ -125,25 +131,40 @@ esp_err_t info_get_handler(httpd_req_t *req)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("info_get_handler - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t starttime_get_handler(httpd_req_t *req)
|
esp_err_t starttime_get_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("starttime_get_handler - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
httpd_resp_send(req, starttime.c_str(), strlen(starttime.c_str()));
|
httpd_resp_send(req, starttime.c_str(), strlen(starttime.c_str()));
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("starttime_get_handler - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t hello_main_handler(httpd_req_t *req)
|
esp_err_t hello_main_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("hello_main_handler - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
char filepath[50];
|
char filepath[50];
|
||||||
struct stat file_stat;
|
|
||||||
printf("uri: %s\n", req->uri);
|
printf("uri: %s\n", req->uri);
|
||||||
int _pos;
|
int _pos;
|
||||||
|
esp_err_t res;
|
||||||
|
|
||||||
char *base_path = (char*) req->user_ctx;
|
char *base_path = (char*) req->user_ctx;
|
||||||
std::string filetosend(base_path);
|
std::string filetosend(base_path);
|
||||||
@@ -182,60 +203,38 @@ esp_err_t hello_main_handler(httpd_req_t *req)
|
|||||||
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Filename too long");
|
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Filename too long");
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
if (stat(filetosend.c_str(), &file_stat) == -1) {
|
|
||||||
/* If file not present on SPIFFS check if URI
|
|
||||||
* corresponds to one of the hardcoded paths */
|
|
||||||
ESP_LOGE(TAG, "Failed to stat file : %s", filetosend.c_str());
|
|
||||||
/* Respond with 404 Not Found */
|
|
||||||
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, "File does not exist");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
esp_err_t res;
|
|
||||||
res = httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
|
||||||
if (res != ESP_OK)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
res = send_file(req, filetosend, &file_stat);
|
res = send_file(req, filetosend);
|
||||||
if (res != ESP_OK)
|
if (res != ESP_OK)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
|
// httpd_resp_sendstr(req, "");
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("hello_main_handler - Stop");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t img_tmp_handler(httpd_req_t *req)
|
esp_err_t img_tmp_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
char filepath[50];
|
char filepath[50];
|
||||||
struct stat file_stat;
|
|
||||||
printf("uri: %s\n", req->uri);
|
printf("uri: %s\n", req->uri);
|
||||||
|
|
||||||
char *base_path = (char*) req->user_ctx;
|
char *base_path = (char*) req->user_ctx;
|
||||||
std::string filetosend(base_path);
|
std::string filetosend(base_path);
|
||||||
|
|
||||||
const char *filename = get_path_from_uri(filepath, base_path,
|
const char *filename = get_path_from_uri(filepath, base_path,
|
||||||
req->uri + sizeof("/img_tmp") - 1, sizeof(filepath));
|
req->uri + sizeof("/img_tmp/") - 1, sizeof(filepath));
|
||||||
printf("1 uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath);
|
printf("1 uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath);
|
||||||
|
|
||||||
filetosend = filetosend + "/img_tmp/" + std::string(filename);
|
filetosend = filetosend + "/img_tmp/" + std::string(filename);
|
||||||
printf("File to upload: %s\n", filetosend.c_str());
|
printf("File to upload: %s\n", filetosend.c_str());
|
||||||
|
|
||||||
if (!filename) {
|
esp_err_t res = send_file(req, filetosend);
|
||||||
ESP_LOGE(TAG, "Filename is too long");
|
|
||||||
/* Respond with 500 Internal Server Error */
|
|
||||||
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Filename too long");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
if (stat(filetosend.c_str(), &file_stat) == -1) {
|
|
||||||
/* If file not present on SPIFFS check if URI
|
|
||||||
* corresponds to one of the hardcoded paths */
|
|
||||||
ESP_LOGE(TAG, "Failed to stat file : %s", filetosend.c_str());
|
|
||||||
/* Respond with 404 Not Found */
|
|
||||||
httpd_resp_send_err(req, HTTPD_404_NOT_FOUND, "File does not exist");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t res = send_file(req, filetosend, &file_stat);
|
|
||||||
if (res != ESP_OK)
|
if (res != ESP_OK)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@@ -244,8 +243,54 @@ esp_err_t img_tmp_handler(httpd_req_t *req)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("img_tmp_virtual_handler - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char filepath[50];
|
||||||
|
|
||||||
|
printf("uri: %s\n", req->uri);
|
||||||
|
|
||||||
|
char *base_path = (char*) req->user_ctx;
|
||||||
|
std::string filetosend(base_path);
|
||||||
|
|
||||||
|
const char *filename = get_path_from_uri(filepath, base_path,
|
||||||
|
req->uri + sizeof("/img_tmp/") - 1, sizeof(filepath));
|
||||||
|
printf("1 uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath);
|
||||||
|
|
||||||
|
filetosend = std::string(filename);
|
||||||
|
printf("File to upload: %s\n", filetosend.c_str());
|
||||||
|
|
||||||
|
if (filetosend == "raw.jpg")
|
||||||
|
{
|
||||||
|
return GetRawJPG(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t zw = GetJPG(filetosend, req);
|
||||||
|
|
||||||
|
if (zw == ESP_OK)
|
||||||
|
return ESP_OK;
|
||||||
|
|
||||||
|
// File wird nicht intern bereit gestellt --> klassischer weg:
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("img_tmp_virtual_handler - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return img_tmp_handler(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
esp_err_t sysinfo_handler(httpd_req_t *req)
|
esp_err_t sysinfo_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("sysinfo_handler - Start");
|
||||||
|
#endif
|
||||||
|
|
||||||
const char* resp_str;
|
const char* resp_str;
|
||||||
std::string zw;
|
std::string zw;
|
||||||
std::string cputemp = std::to_string(temperatureRead());
|
std::string cputemp = std::to_string(temperatureRead());
|
||||||
@@ -279,7 +324,11 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
|
|||||||
httpd_resp_set_type(req, "application/json");
|
httpd_resp_set_type(req, "application/json");
|
||||||
httpd_resp_send(req, resp_str, strlen(resp_str));
|
httpd_resp_send(req, resp_str, strlen(resp_str));
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
LogFile.WriteHeapInfo("sysinfo_handler - Done");
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@@ -314,7 +363,7 @@ void register_server_main_uri(httpd_handle_t server, const char *base_path)
|
|||||||
httpd_uri_t img_tmp_handle = {
|
httpd_uri_t img_tmp_handle = {
|
||||||
.uri = "/img_tmp/*", // Match all URIs of type /path/to/file
|
.uri = "/img_tmp/*", // Match all URIs of type /path/to/file
|
||||||
.method = HTTP_GET,
|
.method = HTTP_GET,
|
||||||
.handler = img_tmp_handler,
|
.handler = img_tmp_virtual_handler,
|
||||||
.user_ctx = (void*) base_path // Pass server data as context
|
.user_ctx = (void*) base_path // Pass server data as context
|
||||||
};
|
};
|
||||||
httpd_register_uri_handler(server, &img_tmp_handle);
|
httpd_register_uri_handler(server, &img_tmp_handle);
|
||||||
|
|||||||
@@ -22,9 +22,4 @@ httpd_handle_t start_webserver(void);
|
|||||||
|
|
||||||
void register_server_main_uri(httpd_handle_t server, const char *base_path);
|
void register_server_main_uri(httpd_handle_t server, const char *base_path);
|
||||||
|
|
||||||
|
|
||||||
//void disconnect_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
|
|
||||||
//void connect_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const char* GIT_REV="bcdd0c6";
|
const char* GIT_REV="21a70c5";
|
||||||
const char* GIT_TAG="";
|
const char* GIT_TAG="";
|
||||||
const char* GIT_BRANCH="master";
|
const char* GIT_BRANCH="master";
|
||||||
const char* BUILD_TIME="2020-12-06 19:32";
|
const char* BUILD_TIME="2021-04-05 10:14";
|
||||||
@@ -13,7 +13,7 @@ extern "C"
|
|||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
const char* GIT_BASE_BRANCH = "master - v5.0.0 - 2020-12-06";
|
const char* GIT_BASE_BRANCH = "master - v6.6.1 - 2020-04-05";
|
||||||
|
|
||||||
|
|
||||||
const char* git_base_branch(void)
|
const char* git_base_branch(void)
|
||||||
|
|||||||
@@ -14,19 +14,14 @@ src_dir = main
|
|||||||
|
|
||||||
|
|
||||||
[env:esp32cam]
|
[env:esp32cam]
|
||||||
platform = espressif32
|
platform = espressif32@2.1.0
|
||||||
|
;platform = espressif32
|
||||||
board = esp32cam
|
board = esp32cam
|
||||||
framework = espidf
|
framework = espidf
|
||||||
|
|
||||||
board_build.embed_files =
|
|
||||||
main/favicon.ico
|
|
||||||
|
|
||||||
|
|
||||||
;board_build.partitions = partitions_singleapp.csv
|
;board_build.partitions = partitions_singleapp.csv
|
||||||
board_build.partitions = partitions.csv
|
board_build.partitions = partitions.csv
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
jomjol_helper
|
jomjol_helper
|
||||||
connect_wlan
|
connect_wlan
|
||||||
@@ -39,6 +34,7 @@ lib_deps =
|
|||||||
jomjol_time_sntp
|
jomjol_time_sntp
|
||||||
jomjol_logfile
|
jomjol_logfile
|
||||||
jomjol_mqtt
|
jomjol_mqtt
|
||||||
|
jomjol_controlGPIO
|
||||||
|
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
|||||||
@@ -537,8 +537,8 @@ CONFIG_FATFS_MAX_LFN=255
|
|||||||
CONFIG_FATFS_API_ENCODING_ANSI_OEM=y
|
CONFIG_FATFS_API_ENCODING_ANSI_OEM=y
|
||||||
# CONFIG_FATFS_API_ENCODING_UTF_16 is not set
|
# CONFIG_FATFS_API_ENCODING_UTF_16 is not set
|
||||||
# CONFIG_FATFS_API_ENCODING_UTF_8 is not set
|
# CONFIG_FATFS_API_ENCODING_UTF_8 is not set
|
||||||
CONFIG_FATFS_FS_LOCK=5
|
CONFIG_FATFS_FS_LOCK=10
|
||||||
CONFIG_FATFS_TIMEOUT_MS=10000
|
CONFIG_FATFS_TIMEOUT_MS=5000
|
||||||
CONFIG_FATFS_PER_FILE_CACHE=y
|
CONFIG_FATFS_PER_FILE_CACHE=y
|
||||||
CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y
|
CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y
|
||||||
# end of FAT Filesystem support
|
# end of FAT Filesystem support
|
||||||
@@ -965,7 +965,7 @@ CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y
|
|||||||
#
|
#
|
||||||
# Virtual file system
|
# Virtual file system
|
||||||
#
|
#
|
||||||
CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y
|
# CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT is not set
|
||||||
CONFIG_VFS_SUPPORT_TERMIOS=y
|
CONFIG_VFS_SUPPORT_TERMIOS=y
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1166,6 +1166,6 @@ CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread"
|
|||||||
CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y
|
CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y
|
||||||
# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set
|
# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set
|
||||||
# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set
|
# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set
|
||||||
CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y
|
# CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT is not set
|
||||||
CONFIG_SUPPORT_TERMIOS=y
|
CONFIG_SUPPORT_TERMIOS=y
|
||||||
# End of deprecated options
|
# End of deprecated options
|
||||||
|
|||||||
@@ -83,11 +83,11 @@ CONFIG_ESPTOOLPY_FLASHFREQ_40M=y
|
|||||||
# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set
|
# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set
|
||||||
CONFIG_ESPTOOLPY_FLASHFREQ="40m"
|
CONFIG_ESPTOOLPY_FLASHFREQ="40m"
|
||||||
# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set
|
# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set
|
||||||
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
|
# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set
|
||||||
# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set
|
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||||
# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
|
# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
|
||||||
# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set
|
# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set
|
||||||
CONFIG_ESPTOOLPY_FLASHSIZE="2MB"
|
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
|
||||||
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
|
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
|
||||||
CONFIG_ESPTOOLPY_BEFORE_RESET=y
|
CONFIG_ESPTOOLPY_BEFORE_RESET=y
|
||||||
# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set
|
# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set
|
||||||
@@ -315,8 +315,8 @@ CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y
|
|||||||
CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4
|
CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4
|
||||||
# CONFIG_ESP32_ULP_COPROC_ENABLED is not set
|
# CONFIG_ESP32_ULP_COPROC_ENABLED is not set
|
||||||
CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0
|
CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0
|
||||||
# CONFIG_ESP32_PANIC_PRINT_HALT is not set
|
CONFIG_ESP32_PANIC_PRINT_HALT=y
|
||||||
CONFIG_ESP32_PANIC_PRINT_REBOOT=y
|
# CONFIG_ESP32_PANIC_PRINT_REBOOT is not set
|
||||||
# CONFIG_ESP32_PANIC_SILENT_REBOOT is not set
|
# CONFIG_ESP32_PANIC_SILENT_REBOOT is not set
|
||||||
# CONFIG_ESP32_PANIC_GDBSTUB is not set
|
# CONFIG_ESP32_PANIC_GDBSTUB is not set
|
||||||
CONFIG_ESP32_DEBUG_OCDAWARE=y
|
CONFIG_ESP32_DEBUG_OCDAWARE=y
|
||||||
@@ -537,8 +537,8 @@ CONFIG_FATFS_MAX_LFN=255
|
|||||||
CONFIG_FATFS_API_ENCODING_ANSI_OEM=y
|
CONFIG_FATFS_API_ENCODING_ANSI_OEM=y
|
||||||
# CONFIG_FATFS_API_ENCODING_UTF_16 is not set
|
# CONFIG_FATFS_API_ENCODING_UTF_16 is not set
|
||||||
# CONFIG_FATFS_API_ENCODING_UTF_8 is not set
|
# CONFIG_FATFS_API_ENCODING_UTF_8 is not set
|
||||||
CONFIG_FATFS_FS_LOCK=5
|
CONFIG_FATFS_FS_LOCK=10
|
||||||
CONFIG_FATFS_TIMEOUT_MS=10000
|
CONFIG_FATFS_TIMEOUT_MS=5000
|
||||||
CONFIG_FATFS_PER_FILE_CACHE=y
|
CONFIG_FATFS_PER_FILE_CACHE=y
|
||||||
CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y
|
CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y
|
||||||
# end of FAT Filesystem support
|
# end of FAT Filesystem support
|
||||||
@@ -965,7 +965,7 @@ CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y
|
|||||||
#
|
#
|
||||||
# Virtual file system
|
# Virtual file system
|
||||||
#
|
#
|
||||||
CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y
|
# CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT is not set
|
||||||
CONFIG_VFS_SUPPORT_TERMIOS=y
|
CONFIG_VFS_SUPPORT_TERMIOS=y
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1166,6 +1166,6 @@ CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread"
|
|||||||
CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y
|
CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y
|
||||||
# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set
|
# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set
|
||||||
# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set
|
# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set
|
||||||
CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y
|
# CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT is not set
|
||||||
CONFIG_SUPPORT_TERMIOS=y
|
CONFIG_SUPPORT_TERMIOS=y
|
||||||
# End of deprecated options
|
# End of deprecated options
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PlatformIO Unit Testing and project tests.
|
|
||||||
|
|
||||||
Unit Testing is a software testing method by which individual units of
|
|
||||||
source code, sets of one or more MCU program modules together with associated
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PlatformIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
const char* GIT_REV="bcdd0c6";
|
const char* GIT_REV="21a70c5";
|
||||||
const char* GIT_TAG="";
|
const char* GIT_TAG="";
|
||||||
const char* GIT_BRANCH="master";
|
const char* GIT_BRANCH="master";
|
||||||
const char* BUILD_TIME="2020-12-06 19:32";
|
const char* BUILD_TIME="2021-04-05 10:14";
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
images/focus_adjustment.jpg
Normal file
BIN
images/focus_adjustment.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 682 KiB |
BIN
sd-card/config/ana0700s1lq.tflite
Normal file
BIN
sd-card/config/ana0700s1lq.tflite
Normal file
Binary file not shown.
@@ -4,17 +4,20 @@
|
|||||||
WaitBeforeTakingPicture = 5
|
WaitBeforeTakingPicture = 5
|
||||||
ImageQuality = 5
|
ImageQuality = 5
|
||||||
ImageSize = VGA
|
ImageSize = VGA
|
||||||
|
;Brightness = -2
|
||||||
|
FixedExposure = false
|
||||||
|
|
||||||
[Alignment]
|
[Alignment]
|
||||||
InitalRotate=180
|
InitialRotate=180
|
||||||
/config/ref0.jpg 119 273
|
/config/ref0.jpg 119 273
|
||||||
/config/ref1.jpg 456 138
|
/config/ref1.jpg 456 138
|
||||||
SearchFieldX = 20
|
SearchFieldX = 20
|
||||||
SearchFieldY = 20
|
SearchFieldY = 20
|
||||||
|
InitialMirror= false
|
||||||
|
AlignmentAlgo = Default
|
||||||
|
|
||||||
[Digits]
|
[Digits]
|
||||||
Model = /config/dig0720s1.tflite
|
Model = /config/dig0820s2q.tflite
|
||||||
;LogImageLocation = /log/digit
|
;LogImageLocation = /log/digit
|
||||||
;LogfileRetentionInDays = 3
|
;LogfileRetentionInDays = 3
|
||||||
ModelInputSize = 20 32
|
ModelInputSize = 20 32
|
||||||
@@ -23,7 +26,7 @@ digit2 355 120 37 67
|
|||||||
digit3 404 120 37 67
|
digit3 404 120 37 67
|
||||||
|
|
||||||
[Analog]
|
[Analog]
|
||||||
Model = /config/ana0630s2.tflite
|
Model = /config/ana0700s1lq.tflite
|
||||||
;LogImageLocation = /log/analog
|
;LogImageLocation = /log/analog
|
||||||
;LogfileRetentionInDays = 3
|
;LogfileRetentionInDays = 3
|
||||||
ModelInputSize = 32 32
|
ModelInputSize = 32 32
|
||||||
@@ -31,6 +34,7 @@ analog1 444 225 92 92
|
|||||||
analog2 391 329 92 92
|
analog2 391 329 92 92
|
||||||
analog3 294 369 92 92
|
analog3 294 369 92 92
|
||||||
analog4 168 326 92 92
|
analog4 168 326 92 92
|
||||||
|
ExtendedResolution = false
|
||||||
|
|
||||||
[PostProcessing]
|
[PostProcessing]
|
||||||
DecimalShift = 0
|
DecimalShift = 0
|
||||||
@@ -39,13 +43,13 @@ PreValueAgeStartup = 720
|
|||||||
AllowNegativeRates = false
|
AllowNegativeRates = false
|
||||||
MaxRateValue = 0.1
|
MaxRateValue = 0.1
|
||||||
ErrorMessage = true
|
ErrorMessage = true
|
||||||
CheckDigitIncreaseConsistency = true
|
CheckDigitIncreaseConsistency = false
|
||||||
|
|
||||||
[MQTT]
|
[MQTT]
|
||||||
Uri = mqtt://IP-ADRESS:1883
|
;Uri = mqtt://IP-ADRESS:1883
|
||||||
Topic = wasserzaehler/zaehlerstand
|
;Topic = wasserzaehler/zaehlerstand
|
||||||
TopicError = wasserzaehler/error
|
;TopicError = wasserzaehler/error
|
||||||
ClientID = wasser
|
;ClientID = wasser
|
||||||
;user = USERNAME
|
;user = USERNAME
|
||||||
;password = PASSWORD
|
;password = PASSWORD
|
||||||
|
|
||||||
@@ -59,6 +63,8 @@ LogfileRetentionInDays = 3
|
|||||||
|
|
||||||
[System]
|
[System]
|
||||||
TimeZone = CET-1CEST,M3.5.0,M10.5.0/3
|
TimeZone = CET-1CEST,M3.5.0,M10.5.0/3
|
||||||
|
;TimeServer = fritz.box
|
||||||
|
;hostname = watermeter
|
||||||
SetupMode = true
|
SetupMode = true
|
||||||
|
|
||||||
[Ende]
|
[Ende]
|
||||||
Binary file not shown.
Binary file not shown.
BIN
sd-card/config/dig0811s1.tflite
Normal file
BIN
sd-card/config/dig0811s1.tflite
Normal file
Binary file not shown.
BIN
sd-card/config/dig0820s2q.tflite
Normal file
BIN
sd-card/config/dig0820s2q.tflite
Normal file
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
[1204/185120.033:ERROR:directory_reader_win.cc(43)] FindFirstFile: Das System kann den angegebenen Pfad nicht finden. (0x3)
|
|
||||||
@@ -85,12 +85,14 @@ select {
|
|||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input class="button" type="submit" name="saveroi" onclick="SaveToConfig()" value="Save to Config.ini"></td>
|
<td colspan="2"><input class="button" type="submit" name="saveroi" onclick="SaveToConfig()" value="Save all to Config.ini"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<script type="text/javascript" src="./gethost.js"></script>
|
<script type="text/javascript" src="./gethost.js"></script>
|
||||||
<script type="text/javascript" src="./readconfig.js"></script>
|
<script type="text/javascript" src="./readconfig.js"></script>
|
||||||
|
<script type="text/javascript" src="./readconfigcommon.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
var canvas = document.getElementById('canvas'),
|
var canvas = document.getElementById('canvas'),
|
||||||
@@ -100,7 +102,8 @@ select {
|
|||||||
drag = false,
|
drag = false,
|
||||||
aktindex = 0,
|
aktindex = 0,
|
||||||
refInfo,
|
refInfo,
|
||||||
enhanceCon = false;
|
enhanceCon = false,
|
||||||
|
param;
|
||||||
basepath = "http://192.168.178.26";
|
basepath = "http://192.168.178.26";
|
||||||
basepath = "";
|
basepath = "";
|
||||||
|
|
||||||
@@ -110,60 +113,60 @@ function ChangeSelection(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function SaveToConfig(){
|
function SaveToConfig(){
|
||||||
refInfo["name"] = document.getElementById("name").value;
|
/*
|
||||||
refInfo["x"] = document.getElementById("refx").value;
|
refInfo[aktindex]["name"] = document.getElementById("name").value;
|
||||||
refInfo["y"] = document.getElementById("refy").value;
|
refInfo[aktindex]["x"] = document.getElementById("refx").value;
|
||||||
refInfo["dx"] = document.getElementById("refdx").value;
|
refInfo[aktindex]["y"] = document.getElementById("refy").value;
|
||||||
refInfo["dy"] = document.getElementById("refdy").value;
|
refInfo[aktindex]["dx"] = document.getElementById("refdx").value;
|
||||||
UpdateConfig(refInfo, aktindex, enhanceCon, basepath);
|
refInfo[aktindex]["dy"] = document.getElementById("refdy").value;
|
||||||
|
*/
|
||||||
|
UpdateConfigReference(refInfo, basepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function EnhanceContrast(){
|
function EnhanceContrast(){
|
||||||
refInfo["name"] = document.getElementById("name").value;
|
refInfo[aktindex]["name"] = document.getElementById("name").value;
|
||||||
refInfo["x"] = document.getElementById("refx").value;
|
refInfo[aktindex]["x"] = document.getElementById("refx").value;
|
||||||
refInfo["y"] = document.getElementById("refy").value;
|
refInfo[aktindex]["y"] = document.getElementById("refy").value;
|
||||||
refInfo["dx"] = document.getElementById("refdx").value;
|
refInfo[aktindex]["dx"] = document.getElementById("refdx").value;
|
||||||
refInfo["dy"] = document.getElementById("refdy").value;
|
refInfo[aktindex]["dy"] = document.getElementById("refdy").value;
|
||||||
|
|
||||||
enhanceCon = true;
|
enhanceCon = true;
|
||||||
MakeContrastImageZW(refInfo, enhanceCon, basepath);
|
MakeContrastImageZW(refInfo[aktindex], enhanceCon, basepath);
|
||||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw.jpg?" + Date.now();
|
UpdateReference();
|
||||||
document.getElementById("img_ref").src = url;
|
// var url = basepath + "/fileserver" + "/img_tmp/ref_zw.jpg?" + Date.now();
|
||||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw_org.jpg?" + Date.now();
|
// document.getElementById("img_ref").src = url;
|
||||||
document.getElementById("img_ref_org").src = url;
|
// var url = basepath + "/fileserver" + "/img_tmp/ref_zw_org.jpg?" + Date.now();
|
||||||
|
// document.getElementById("img_ref_org").src = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpdateReference(){
|
function UpdateReference(){
|
||||||
refInfo = GetCoordinates(aktindex, basepath);
|
|
||||||
document.getElementById("img_ref").onload = function () {
|
document.getElementById("img_ref").onload = function () {
|
||||||
document.getElementById("refdx").value = this.width;
|
document.getElementById("refdx").value = this.width;
|
||||||
document.getElementById("refdy").value = this.height;
|
document.getElementById("refdy").value = this.height;
|
||||||
refInfo["dx"] = this.width;
|
refInfo[aktindex]["dx"] = this.width;
|
||||||
refInfo["dy"] = this.height;
|
refInfo[aktindex]["dy"] = this.height;
|
||||||
rect.w = document.getElementById("refdx").value;
|
rect.w = document.getElementById("refdx").value;
|
||||||
rect.h = document.getElementById("refdy").value;
|
rect.h = document.getElementById("refdy").value;
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw_org.jpg?" + Date.now();
|
_filenameurl = refInfo[aktindex]["name"].replace("/config/", "/img_tmp/");
|
||||||
document.getElementById("img_ref_org").src = url;
|
|
||||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw.jpg?" + Date.now();
|
var url = basepath + "/fileserver" + _filenameurl + "?" + Date.now();
|
||||||
document.getElementById("img_ref").src = url;
|
document.getElementById("img_ref").src = url;
|
||||||
|
|
||||||
document.getElementById("name").value = refInfo["name"];
|
_filenameurl = _filenameurl.replace(".jpg", "_org.jpg");
|
||||||
document.getElementById("refx").value = refInfo["x"];
|
var url = basepath + "/fileserver" + _filenameurl + "?" + Date.now();
|
||||||
document.getElementById("refy").value = refInfo["y"];
|
document.getElementById("img_ref_org").src = url;
|
||||||
|
|
||||||
|
document.getElementById("name").value = refInfo[aktindex]["name"];
|
||||||
|
document.getElementById("refx").value = refInfo[aktindex]["x"];
|
||||||
|
document.getElementById("refy").value = refInfo[aktindex]["y"];
|
||||||
rect.startX = document.getElementById("refx").value;
|
rect.startX = document.getElementById("refx").value;
|
||||||
rect.startY = document.getElementById("refy").value;
|
rect.startY = document.getElementById("refy").value;
|
||||||
document.getElementById("enhancecontrast").disabled = true;
|
document.getElementById("enhancecontrast").disabled = true;
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
function ParseIni(_basepath) {
|
|
||||||
loadConfig(_basepath);
|
|
||||||
ParseConfig();
|
|
||||||
UpdateReference();
|
|
||||||
}
|
|
||||||
|
|
||||||
function dataURLtoBlob(dataurl) {
|
function dataURLtoBlob(dataurl) {
|
||||||
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
|
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
|
||||||
@@ -204,13 +207,21 @@ function dataURLtoBlob(dataurl) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
basepath = getbasepath();
|
basepath = getbasepath();
|
||||||
|
loadConfig(basepath);
|
||||||
|
ParseConfig();
|
||||||
|
|
||||||
canvas.addEventListener('mousedown', mouseDown, false);
|
canvas.addEventListener('mousedown', mouseDown, false);
|
||||||
canvas.addEventListener('mouseup', mouseUp, false);
|
canvas.addEventListener('mouseup', mouseUp, false);
|
||||||
canvas.addEventListener('mousemove', mouseMove, false);
|
canvas.addEventListener('mousemove', mouseMove, false);
|
||||||
loadCanvas(basepath + "/fileserver/config/reference.jpg");
|
loadCanvas(basepath + "/fileserver/config/reference.jpg");
|
||||||
ParseIni(basepath);
|
|
||||||
|
CopyReferenceToImgTmp(basepath);
|
||||||
|
refInfo = GetReferencesInfo();
|
||||||
|
|
||||||
|
UpdateReference();
|
||||||
|
|
||||||
drawImage();
|
drawImage();
|
||||||
}
|
}
|
||||||
function drawImage(){
|
function drawImage(){
|
||||||
@@ -225,17 +236,13 @@ function dataURLtoBlob(dataurl) {
|
|||||||
|
|
||||||
|
|
||||||
function CutOutReference(){
|
function CutOutReference(){
|
||||||
refInfo["x"] = document.getElementById("refx").value;
|
refInfo[aktindex]["x"] = document.getElementById("refx").value;
|
||||||
refInfo["y"] = document.getElementById("refy").value;
|
refInfo[aktindex]["y"] = document.getElementById("refy").value;
|
||||||
refInfo["dx"] = document.getElementById("refdx").value;
|
refInfo[aktindex]["dx"] = document.getElementById("refdx").value;
|
||||||
refInfo["dy"] = document.getElementById("refdy").value;
|
refInfo[aktindex]["dy"] = document.getElementById("refdy").value;
|
||||||
MakeRefZW(refInfo, basepath);
|
MakeRefZW(refInfo[aktindex], basepath);
|
||||||
var url = basepath + "/fileserver" + "/img_tmp/ref_zw.jpg?" + Date.now();
|
UpdateReference();
|
||||||
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;
|
|
||||||
document.getElementById("enhancecontrast").disabled = false;
|
document.getElementById("enhancecontrast").disabled = false;
|
||||||
draw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawGrid(){
|
function drawGrid(){
|
||||||
|
|||||||
@@ -49,13 +49,26 @@ select {
|
|||||||
th, td {
|
th, td {
|
||||||
padding: 5px 5px 5px 0px;
|
padding: 5px 5px 5px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#div2{
|
||||||
|
background-color:#777;
|
||||||
|
margin-bottom:20px;
|
||||||
|
}
|
||||||
|
.disabledDiv {
|
||||||
|
pointer-events: none;
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body style="font-family: arial; padding: 0px 10px;">
|
<body style="font-family: arial; padding: 0px 10px;">
|
||||||
|
|
||||||
<h2>Edit Analog</h2>
|
<h2><input type="checkbox" id="Category_Analog_enabled" value="1" onclick = 'EnDisableAnalog()' checked >
|
||||||
|
Edit Analog</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="div1">
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -78,8 +91,8 @@ th, td {
|
|||||||
</td>
|
</td>
|
||||||
<td>Name: <input type="text" name="name" id="name" onchange="onNameChange()" size="13"></td>
|
<td>Name: <input type="text" name="name" id="name" onchange="onNameChange()" size="13"></td>
|
||||||
<td>
|
<td>
|
||||||
<input class="move" type="submit" id="moveNext" onclick="moveNext()" value="move Next">
|
<input class="button" type="submit" id="moveNext" onclick="moveNext()" value="move Next">
|
||||||
<input class="move" type="submit" id="movePrevious" onclick="movePrevious()" value="move Previous">
|
<input class="button" type="submit" id="movePrevious" onclick="movePrevious()" value="move Previous">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -92,15 +105,19 @@ th, td {
|
|||||||
<td>dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()"></td>
|
<td>dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><input class="button" type="submit" id="saveroi" name="saveroi" onclick="SaveToConfig()" value="Save all to Config.ini"></td>
|
<td><input class="button" type="submit" id="saveroi" name="saveroi" onclick="SaveToConfig()" value="Save all to Config.ini"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript" src="./gethost.js"></script>
|
<script type="text/javascript" src="./gethost.js"></script>
|
||||||
|
<script type="text/javascript" src="./readconfigcommon.js"></script>
|
||||||
<script type="text/javascript" src="./readconfig.js"></script>
|
<script type="text/javascript" src="./readconfig.js"></script>
|
||||||
|
<script type="text/javascript" src="./jquery-3.5.1.min.js"></script>
|
||||||
|
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
var canvas = document.getElementById('canvas'),
|
var canvas = document.getElementById('canvas'),
|
||||||
@@ -114,6 +131,40 @@ th, td {
|
|||||||
lockAR = true;
|
lockAR = true;
|
||||||
basepath = "http://192.168.178.26";
|
basepath = "http://192.168.178.26";
|
||||||
|
|
||||||
|
|
||||||
|
function EnDisableAnalog() {
|
||||||
|
isEnabled = document.getElementById("Category_Analog_enabled").checked;
|
||||||
|
|
||||||
|
$("#div2").attr("disabled", "disabled").off('click');
|
||||||
|
var x1=$("#div2").hasClass("disabledDiv");
|
||||||
|
|
||||||
|
if (isEnabled)
|
||||||
|
{
|
||||||
|
$("#div2").removeClass("disabledDiv");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#div2").addClass("disabledDiv");
|
||||||
|
}
|
||||||
|
|
||||||
|
sah1(document.getElementById("div1"), !isEnabled);
|
||||||
|
if (isEnabled)
|
||||||
|
{
|
||||||
|
UpdateROIs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sah1(el, _target) {
|
||||||
|
try {
|
||||||
|
el.disabled = _target;
|
||||||
|
} catch (E) {}
|
||||||
|
if (el.childNodes && el.childNodes.length > 0) {
|
||||||
|
for (var x = 0; x < el.childNodes.length; x++) {
|
||||||
|
sah1(el.childNodes[x], _target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onNameChange(){
|
function onNameChange(){
|
||||||
ROIInfo[aktindex]["name"] = document.getElementById("name").value;
|
ROIInfo[aktindex]["name"] = document.getElementById("name").value;
|
||||||
UpdateROIs();
|
UpdateROIs();
|
||||||
@@ -172,7 +223,8 @@ function ChangeSelection(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function SaveToConfig(){
|
function SaveToConfig(){
|
||||||
SaveROIToConfig(ROIInfo, "[Analog]", basepath);
|
_enabled = document.getElementById("Category_Analog_enabled").checked;
|
||||||
|
SaveROIToConfig(ROIInfo, "[Analog]", basepath, _enabled);
|
||||||
UpdatePage();
|
UpdatePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,8 +282,18 @@ function UpdateROIs(){
|
|||||||
function ParseIni(_basepath) {
|
function ParseIni(_basepath) {
|
||||||
loadConfig(_basepath);
|
loadConfig(_basepath);
|
||||||
ParseConfig();
|
ParseConfig();
|
||||||
|
|
||||||
|
document.getElementById("Category_Analog_enabled").checked = true;
|
||||||
ROIInfo = getROIInfo("[Analog]");
|
ROIInfo = getROIInfo("[Analog]");
|
||||||
|
|
||||||
|
if (!GetAnalogEnabled())
|
||||||
|
{
|
||||||
|
document.getElementById("Category_Analog_enabled").checked = false;
|
||||||
|
EnDisableAnalog();
|
||||||
|
alert("Analog ROIs are disabled - please enable (Check box top left).\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateROIs();
|
UpdateROIs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,22 +350,33 @@ function ParseIni(_basepath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
var canvas = document.getElementById('canvas');
|
var canvas = document.getElementById('canvas');
|
||||||
var context = canvas.getContext('2d');
|
var context = canvas.getContext('2d');
|
||||||
context.drawImage(imageObj, 0, 0);
|
context.drawImage(imageObj, 0, 0);
|
||||||
lw = 4
|
if (document.getElementById("Category_Analog_enabled").checked)
|
||||||
context.lineWidth = lw;
|
{
|
||||||
context.strokeStyle = "#FF0000";
|
lw = 4
|
||||||
var x0 = parseInt(rect.startX) - parseInt(lw/2);
|
context.lineWidth = lw;
|
||||||
var y0 = parseInt(rect.startY) - parseInt(lw/2);
|
context.strokeStyle = "#FF0000";
|
||||||
var dx = parseInt(rect.w) + parseInt(lw);
|
var x0 = parseInt(rect.startX) - parseInt(lw/2);
|
||||||
var dy = parseInt(rect.h) + parseInt(lw);
|
var y0 = parseInt(rect.startY) - parseInt(lw/2);
|
||||||
context.strokeRect(x0, y0, dx, dy);
|
var dx = parseInt(rect.w) + parseInt(lw);
|
||||||
ROIInfo[aktindex]["x"] = rect.startX;
|
var dy = parseInt(rect.h) + parseInt(lw);
|
||||||
ROIInfo[aktindex]["y"] = rect.startY;
|
context.strokeRect(x0, y0, dx, dy);
|
||||||
ROIInfo[aktindex]["dx"] = rect.w;
|
context.lineWidth = 1;
|
||||||
ROIInfo[aktindex]["dy"] = rect.h;
|
context.beginPath();
|
||||||
|
context.arc(x0+dx/2, y0+dy/2, dx/2, 0, 2 * Math.PI);
|
||||||
|
context.moveTo(x0+dx/2, y0);
|
||||||
|
context.lineTo(x0+dx/2, y0+dy);
|
||||||
|
context.moveTo(x0, y0+dy/2);
|
||||||
|
context.lineTo(x0+dx, y0+dy/2);
|
||||||
|
context.stroke();
|
||||||
|
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
|
function getCoords(elem) { // crossbrowser version
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ textarea {
|
|||||||
|
|
||||||
<script type="text/javascript" src="./gethost.js"></script>
|
<script type="text/javascript" src="./gethost.js"></script>
|
||||||
<script type="text/javascript" src="./readconfig.js"></script>
|
<script type="text/javascript" src="./readconfig.js"></script>
|
||||||
|
<script type="text/javascript" src="./readconfigcommon.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var canvas = document.getElementById('canvas'),
|
var canvas = document.getElementById('canvas'),
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="MakeImage_LogImageLocation_enabled" value="1" onclick = 'document.getElementById("MakeImage_LogImageLocation_value").disabled = !document.getElementById("MakeImage_LogImageLocation_value1").disabled' unchecked >
|
<input type="checkbox" id="MakeImage_LogImageLocation_enabled" value="1" onclick = 'InvertEnableItem("MakeImage", "LogImageLocation")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="MakeImage_LogImageLocation_text" style="color:black;">LogImageLocation</class>
|
<class id="MakeImage_LogImageLocation_text" style="color:black;">LogImageLocation</class>
|
||||||
@@ -75,7 +75,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<td"><input type="checkbox" id="MakeImage_LogfileRetentionInDays_enabled" value="1" onclick = 'document.getElementById("MakeImage_LogfileRetentionInDays_value").disabled = !document.getElementById("MakeImage_LogfileRetentionInDays_value1").disabled' unchecked ></td>
|
<td"><input type="checkbox" id="MakeImage_LogfileRetentionInDays_enabled" value="1" onclick = 'InvertEnableItem("MakeImage", "LogfileRetentionInDays")' unchecked ></td>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<class id="MakeImage_LogfileRetentionInDays_text" style="color:black;">LogfileRetentionInDays</class>
|
<class id="MakeImage_LogfileRetentionInDays_text" style="color:black;">LogfileRetentionInDays</class>
|
||||||
@@ -123,13 +123,74 @@ textarea {
|
|||||||
<td>
|
<td>
|
||||||
<select id="MakeImage_ImageSize_value1">
|
<select id="MakeImage_ImageSize_value1">
|
||||||
<option value="0" selected>VGA</option>
|
<option value="0" selected>VGA</option>
|
||||||
<option value="1" >SVGA</option>
|
<option value="1" >QVGA</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td style="font-size: 80%;">
|
<td style="font-size: 80%;">
|
||||||
Picture size camera (default = "VGA")
|
Picture size camera (default = "VGA")
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="expert" id="Brightness_ex3">
|
||||||
|
<td width="20px" style="padding-left: 40px;">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<class id="MakeImage_Brightness_text" style="color:black;">Brightness</class>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="number" id="MakeImage_Brightness_value1" size="13" min="-2" max="2">
|
||||||
|
</td>
|
||||||
|
<td style="font-size: 80%;">
|
||||||
|
Image Brightness (-2 .. 2 - default = "0")
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="expert" id="MakeImage_FixedExposure_ex10">
|
||||||
|
<td width="20px" style="padding-left: 40px;">
|
||||||
|
</td>
|
||||||
|
<td width="200px">
|
||||||
|
<class id="MakeImage_FixedExposure_text" style="color:black;">FixedExposure</class>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select id="MakeImage_FixedExposure_value1">
|
||||||
|
<option value="0" selected>true</option>
|
||||||
|
<option value="1" >false</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td style="font-size: 80%;">
|
||||||
|
Fixes the illumination setting of camera at the startup and uses this later --> individual round is faster
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<tr class="expert" id="Contrast_ex3">
|
||||||
|
<td width="20px" style="padding-left: 40px;">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<class id="MakeImage_Contrast_text" style="color:black;">Contrast</class>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="number" id="MakeImage_Contrast_value1" size="13" min="-2" max="2">
|
||||||
|
</td>
|
||||||
|
<td style="font-size: 80%;">
|
||||||
|
Image Contrast (-2 .. 2 - default = "0")
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr class="expert" id="Saturation_ex3">
|
||||||
|
<td width="20px" style="padding-left: 40px;">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<class id="MakeImage_Saturation_text" style="color:black;">Saturation</class>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="number" id="MakeImage_Saturation_value1" size="13" min="-2" max="2">
|
||||||
|
</td>
|
||||||
|
<td style="font-size: 80%;">
|
||||||
|
Image Saturation (-2 .. 2 - default = "0")
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
<tr class="expert" id="ex4">
|
<tr class="expert" id="ex4">
|
||||||
<td colspan="4" style="padding-left: 20px;"><h4>Alignment</h4></td>
|
<td colspan="4" style="padding-left: 20px;"><h4>Alignment</h4></td>
|
||||||
@@ -160,9 +221,29 @@ textarea {
|
|||||||
y size (height) in which the reference is searched (default = "20")
|
y size (height) in which the reference is searched (default = "20")
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="expert" id="AlignmentAlgo_ex8">
|
||||||
|
<td width="20px" style="padding-left: 40px;">
|
||||||
|
<input type="checkbox" id="Alignment_AlignmentAlgo_enabled" value="1" onclick = 'InvertEnableItem("Alignment", "AlignmentAlgo")' unchecked >
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<class id="Alignment_AlignmentAlgo_text" style="color:black;">AlignmentAlgo</class>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select id="Alignment_AlignmentAlgo_value1">
|
||||||
|
<option value="0" selected>Default</option>
|
||||||
|
<option value="1" >HighAccurity</option>
|
||||||
|
<option value="2" >Fast</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td style="font-size: 80%;">
|
||||||
|
"Default" = use only R-Channel, "HighAccurity" = use all Channels (RGB, 3x slower), <br> "Fast" (First time RGB, then only check if image is shifted)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr class="expert" id="ex4">
|
|
||||||
<td colspan="4" style="padding-left: 20px;"><h4>Digits</h4></td>
|
<tr id="Category_Digits_ex4">
|
||||||
|
<td colspan="4" style="padding-left: 20px;">
|
||||||
|
<h4><input type="checkbox" id="Category_Digits_enabled" value="1" onclick = 'UpdateAfterCategoryCheck()' unchecked >Digits</h4></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
@@ -174,12 +255,12 @@ textarea {
|
|||||||
<input type="text" id="Digits_Model_value1">
|
<input type="text" id="Digits_Model_value1">
|
||||||
</td>
|
</td>
|
||||||
<td style="font-size: 80%;">
|
<td style="font-size: 80%;">
|
||||||
path to CNN model file for image recognition (in seconds)
|
path to CNN model file for image recognition
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="Digits_LogImageLocation_enabled" value="1" onclick = 'document.getElementById("Digits_LogImageLocation_value1").disabled = !document.getElementById("Digits_LogImageLocation_value1").disabled' unchecked >
|
<input type="checkbox" id="Digits_LogImageLocation_enabled" value="1" onclick = 'InvertEnableItem("Digits", "LogImageLocation")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<class id="Digits_LogImageLocation_text" style="color:black;">LogImageLocation</class>
|
<class id="Digits_LogImageLocation_text" style="color:black;">LogImageLocation</class>
|
||||||
@@ -193,7 +274,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<td"><input type="checkbox" id="Digits_LogfileRetentionInDays_enabled" value="1" onclick = 'document.getElementById("Digits_LogfileRetentionInDays_value1").disabled = !document.getElementById("Digits_LogfileRetentionInDays_value1").disabled' unchecked ></td>
|
<td"><input type="checkbox" id="Digits_LogfileRetentionInDays_enabled" value="1" onclick = 'InvertEnableItem("Digits", "LogfileRetentionInDays")' unchecked ></td>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<class id="Digits_LogfileRetentionInDays_text" style="color:black;">LogfileRetentionInDays</class>
|
<class id="Digits_LogfileRetentionInDays_text" style="color:black;">LogfileRetentionInDays</class>
|
||||||
@@ -221,62 +302,61 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="expert" id="ex4">
|
<tr class="expert" id="ex4">
|
||||||
<td colspan="4" style="padding-left: 20px;"><h4>Analog</h4></td>
|
<td colspan="4" style="padding-left: 20px;">
|
||||||
|
<h4><input type="checkbox" id="Category_Analog_enabled" value="1" onclick = 'UpdateAfterCategoryCheck()' unchecked > Analog</h4></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td width="20px" style="padding-left: 40px;"> </td>
|
||||||
|
<td width="200px"> <class id="Analog_Model_text" style="color:black;">Model</class> </td>
|
||||||
|
<td> <input type="text" id="Analog_Model_value1"> </td>
|
||||||
|
<td style="font-size: 80%;"> path to CNN model file for image recognition</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
|
<input type="checkbox" id="Analog_LogImageLocation_enabled" value="1" onclick = 'InvertEnableItem("Analog", "LogImageLocation")' unchecked >
|
||||||
|
</td>
|
||||||
|
<td> <class id="Analog_LogImageLocation_text" style="color:black;">LogImageLocation</class> </td>
|
||||||
|
<td> <input type="text" name="name" id="Analog_LogImageLocation_value1"> </td>
|
||||||
|
<td style="font-size: 80%;"> Location to store separated digits for logging </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td width="20px" style="padding-left: 40px;">
|
||||||
|
<td"><input type="checkbox" id="Analog_LogfileRetentionInDays_enabled" value="1" onclick = 'InvertEnableItem("Analog", "LogfileRetentionInDays")' unchecked ></td>
|
||||||
|
</td>
|
||||||
|
<td> <class id="Analog_LogfileRetentionInDays_text" style="color:black;">LogfileRetentionInDays</class> </td>
|
||||||
|
<td> <input type="number" id="Analog_LogfileRetentionInDays_value1" min="0" step="1"> </td>
|
||||||
|
<td style="font-size: 80%;"> Time to keep the separated digit images (in days -"0" = forever) </td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr class="expert" id="Analog_ExtendedResolution_ex10">
|
||||||
|
<td width="20px" style="padding-left: 40px;">
|
||||||
|
<input type="checkbox" id="Analog_ExtendedResolution_enabled" value="1" onclick = 'InvertEnableItem("Analog", "ExtendedResolution")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="Analog_Model_text" style="color:black;">Model</class>
|
<class id="Analog_ExtendedResolution_text" style="color:black;">ExtendedResolution</class>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" id="Analog_Model_value1">
|
<select id="Analog_ExtendedResolution_value1">
|
||||||
|
<option value="0" selected>true</option>
|
||||||
|
<option value="1" >false</option>
|
||||||
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td style="font-size: 80%;">
|
<td style="font-size: 80%;">
|
||||||
path to CNN model file for image recognition (in seconds)
|
Enable to use the after point resolution for the last analog counter
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td width="20px" style="padding-left: 40px;">
|
|
||||||
<input type="checkbox" id="Analog_LogImageLocation_enabled" value="1" onclick = 'document.getElementById("Analog_LogImageLocation_value1").disabled = !document.getElementById("Analog_LogImageLocation_value1").disabled' unchecked >
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<class id="Analog_LogImageLocation_text" style="color:black;">LogImageLocation</class>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input type="text" name="name" id="Analog_LogImageLocation_value1">
|
|
||||||
</td>
|
|
||||||
<td style="font-size: 80%;">
|
|
||||||
Location to store separated digits for logging
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td width="20px" style="padding-left: 40px;">
|
|
||||||
<td"><input type="checkbox" id="Analog_LogfileRetentionInDays_enabled" value="1" onclick = 'document.getElementById("Analog_LogfileRetentionInDays_value1").disabled = !document.getElementById("Analog_LogfileRetentionInDays_value1").disabled' unchecked ></td>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<class id="Analog_LogfileRetentionInDays_text" style="color:black;">LogfileRetentionInDays</class>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input type="number" id="Analog_LogfileRetentionInDays_value1" min="0" step="1">
|
|
||||||
</td>
|
|
||||||
<td style="font-size: 80%;">
|
|
||||||
Time to keep the separated digit images (in days -"0" = forever)
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
ExtendedResolution
|
||||||
|
|
||||||
<tr class="expert" id="ex10">
|
<tr class="expert" id="ex10">
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;"> </td>
|
||||||
</td>
|
<td> <class id="Analog_ModelInputSize_text" style="color:black;">ModelInputSize</class> </td>
|
||||||
<td>
|
|
||||||
<class id="Analog_ModelInputSize_text" style="color:black;">ModelInputSize</class>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
x: <input type="number" id="Analog_ModelInputSize_value1" style="width: 30px;" min="1" step="1">
|
x: <input type="number" id="Analog_ModelInputSize_value1" style="width: 30px;" min="1" step="1">
|
||||||
y: <input type="number" id="Analog_ModelInputSize_value2" style="width: 30px;" min="1" step="1">
|
y: <input type="number" id="Analog_ModelInputSize_value2" style="width: 30px;" min="1" step="1">
|
||||||
</td>
|
</td>
|
||||||
<td style="font-size: 80%;">
|
<td style="font-size: 80%;"> Size of the input image for the CNN model </td>
|
||||||
Size of the input image for the CNN model
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
@@ -284,7 +364,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="PostProcessing_DecimalShift_enabled" value="1" onclick = 'document.getElementById("PostProcessing_DecimalShift_value1").disabled = !document.getElementById("PostProcessing_DecimalShift_value1").disabled' unchecked >
|
<input type="checkbox" id="PostProcessing_DecimalShift_enabled" value="1" onclick = 'InvertEnableItem("PostProcessing", "DecimalShift")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="PostProcessing_DecimalShift_text" style="color:black;">DecimalShift</class>
|
<class id="PostProcessing_DecimalShift_text" style="color:black;">DecimalShift</class>
|
||||||
@@ -298,7 +378,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="PostProcessing_PreValueUse_enabled" value="1" onclick = 'document.getElementById("PostProcessing_PreValueUse_value1").disabled = !document.getElementById("PostProcessing_PreValueUse_value1").disabled' unchecked >
|
<input type="checkbox" id="PostProcessing_PreValueUse_enabled" value="1" onclick = 'InvertEnableItem("PostProcessing", "PreValueUse")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="PostProcessing_PreValueUse_text" style="color:black;">PreValueUse</class>
|
<class id="PostProcessing_PreValueUse_text" style="color:black;">PreValueUse</class>
|
||||||
@@ -315,7 +395,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="expert" id="ex11">
|
<tr class="expert" id="ex11">
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="PostProcessing_PreValueAgeStartup_enabled" value="1" onclick = 'document.getElementById("PostProcessing_PreValueAgeStartup_value1").disabled = !document.getElementById("PostProcessing_PreValueAgeStartup_value1").disabled' unchecked >
|
<input type="checkbox" id="PostProcessing_PreValueAgeStartup_enabled" value="1" onclick = 'InvertEnableItem("PostProcessing", "PreValueAgeStartup")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="PostProcessing_PreValueAgeStartup_text" style="color:black;">PreValueAgeStartup</class>
|
<class id="PostProcessing_PreValueAgeStartup_text" style="color:black;">PreValueAgeStartup</class>
|
||||||
@@ -329,7 +409,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="PostProcessing_AllowNegativeRates_enabled" value="1" onclick = 'document.getElementById("PostProcessing_AllowNegativeRates_value1").disabled = !document.getElementById("PostProcessing_AllowNegativeRates_value1").disabled' unchecked >
|
<input type="checkbox" id="PostProcessing_AllowNegativeRates_enabled" value="1" onclick = 'InvertEnableItem("PostProcessing", "AllowNegativeRates")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="PostProcessing_AllowNegativeRates_text" style="color:black;">AllowNegativeRates</class>
|
<class id="PostProcessing_AllowNegativeRates_text" style="color:black;">AllowNegativeRates</class>
|
||||||
@@ -346,7 +426,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="PostProcessing_MaxRateValue_enabled" value="1" onclick = 'document.getElementById("PostProcessing_MaxRateValue_value1").disabled = !document.getElementById("PostProcessing_MaxRateValue_value1").disabled' unchecked >
|
<input type="checkbox" id="PostProcessing_MaxRateValue_enabled" value="1" onclick = 'InvertEnableItem("PostProcessing", "MaxRateValue")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="PostProcessing_MaxRateValue_text" style="color:black;">MaxRateValue</class>
|
<class id="PostProcessing_MaxRateValue_text" style="color:black;">MaxRateValue</class>
|
||||||
@@ -360,7 +440,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="expert" id="ex12">
|
<tr class="expert" id="ex12">
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="PostProcessing_ErrorMessage_enabled" value="1" onclick = 'document.getElementById("PostProcessing_ErrorMessage_value1").disabled = !document.getElementById("PostProcessing_ErrorMessage_value1").disabled' unchecked >
|
<input type="checkbox" id="PostProcessing_ErrorMessage_enabled" value="1" onclick = 'InvertEnableItem("PostProcessing", "ErrorMessage")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="PostProcessing_ErrorMessage_text" style="color:black;">ErrorMessage</class>
|
<class id="PostProcessing_ErrorMessage_text" style="color:black;">ErrorMessage</class>
|
||||||
@@ -377,7 +457,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="PostProcessing_CheckDigitIncreaseConsistency_enabled" value="1" onclick = 'document.getElementById("PostProcessing_CheckDigitIncreaseConsistency_value1").disabled = !document.getElementById("PostProcessing_CheckDigitIncreaseConsistency_value1").disabled' unchecked >
|
<input type="checkbox" id="PostProcessing_CheckDigitIncreaseConsistency_enabled" value="1" onclick = 'InvertEnableItem("PostProcessing", "CheckDigitIncreaseConsistency")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="PostProcessing_CheckDigitIncreaseConsistency_text" style="color:black;">CheckDigitIncreaseConsistency</class>
|
<class id="PostProcessing_CheckDigitIncreaseConsistency_text" style="color:black;">CheckDigitIncreaseConsistency</class>
|
||||||
@@ -394,11 +474,11 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" style="padding-left: 20px;"><h4>MQTT</h4></td>
|
<td colspan="4" style="padding-left: 20px;"><h4><input type="checkbox" id="Category_MQTT_enabled" value="1" onclick = 'UpdateAfterCategoryCheck()' unchecked > MQTT</h4></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="MQTT_Uri_enabled" value="1" onclick = 'document.getElementById("MQTT_Uri_value1").disabled = !document.getElementById("MQTT_Uri_value1").disabled' unchecked >
|
<input type="checkbox" id="MQTT_Uri_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "Uri")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="MQTT_Uri_text" style="color:black;">Uri</class>
|
<class id="MQTT_Uri_text" style="color:black;">Uri</class>
|
||||||
@@ -407,12 +487,12 @@ textarea {
|
|||||||
<input type="text" id="MQTT_Uri_value1">
|
<input type="text" id="MQTT_Uri_value1">
|
||||||
</td>
|
</td>
|
||||||
<td style="font-size: 80%;">
|
<td style="font-size: 80%;">
|
||||||
URI to the MQTT broker including port: http:\\IP-ADRESS:port
|
URI to the MQTT broker including port e.g.: mqtt://IP-Address:Port
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="MQTT_Topic_enabled" value="1" onclick = 'document.getElementById("MQTT_Topic_value1").disabled = !document.getElementById("MQTT_Topic_value1").disabled' unchecked >
|
<input type="checkbox" id="MQTT_Topic_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "Topic")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="MQTT_Topic_text" style="color:black;">Topic</class>
|
<class id="MQTT_Topic_text" style="color:black;">Topic</class>
|
||||||
@@ -426,7 +506,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="MQTT_TopicError_enabled" value="1" onclick = 'document.getElementById("MQTT_TopicError_value1").disabled = !document.getElementById("MQTT_TopicError_value1").disabled' unchecked >
|
<input type="checkbox" id="MQTT_TopicError_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "TopicError")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="MQTT_TopicError_text" style="color:black;">TopicError</class>
|
<class id="MQTT_TopicError_text" style="color:black;">TopicError</class>
|
||||||
@@ -440,7 +520,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="MQTT_ClientID_enabled" value="1" onclick = 'document.getElementById("MQTT_ClientID_value1").disabled = !document.getElementById("MQTT_ClientID_value1").disabled' unchecked >
|
<input type="checkbox" id="MQTT_ClientID_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "ClientID")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="MQTT_ClientID_text" style="color:black;">ClientID</class>
|
<class id="MQTT_ClientID_text" style="color:black;">ClientID</class>
|
||||||
@@ -454,7 +534,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="MQTT_user_enabled" value="1" onclick = 'document.getElementById("MQTT_user_value1").disabled = !document.getElementById("MQTT_user_value1").disabled' unchecked >
|
<input type="checkbox" id="MQTT_user_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "user")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="MQTT_user_text" style="color:black;">user</class>
|
<class id="MQTT_user_text" style="color:black;">user</class>
|
||||||
@@ -463,12 +543,12 @@ textarea {
|
|||||||
<input type="text" id="MQTT_user_value1">
|
<input type="text" id="MQTT_user_value1">
|
||||||
</td>
|
</td>
|
||||||
<td style="font-size: 80%;">
|
<td style="font-size: 80%;">
|
||||||
user for MQTT authenficiation
|
user for MQTT authentication
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="MQTT_password_enabled" value="1" onclick = 'document.getElementById("MQTT_password_value1").disabled = !document.getElementById("MQTT_password_value1").disabled' checked >
|
<input type="checkbox" id="MQTT_password_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "password")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="MQTT_password_text" style="color:black;">password</class>
|
<class id="MQTT_password_text" style="color:black;">password</class>
|
||||||
@@ -477,7 +557,7 @@ textarea {
|
|||||||
<input type="text" id="MQTT_password_value1">
|
<input type="text" id="MQTT_password_value1">
|
||||||
</td>
|
</td>
|
||||||
<td style="font-size: 80%;">
|
<td style="font-size: 80%;">
|
||||||
password for MQTT authenficiation
|
password for MQTT authentication
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -486,7 +566,6 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="expert" id="ex13">
|
<tr class="expert" id="ex13">
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="AutoTimer_AutoStart_enabled" value="1" onclick = 'document.getElementById("AutoTimer_AutoStart_value1").disabled = !document.getElementById("AutoTimer_AutoStart_value1").disabled' unchecked >
|
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="AutoTimer_AutoStart_text" style="color:black;">AutoStart</class>
|
<class id="AutoTimer_AutoStart_text" style="color:black;">AutoStart</class>
|
||||||
@@ -503,7 +582,6 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="AutoTimer_Intervall_enabled" value="1" onclick = 'document.getElementById("AutoTimer_Intervall_value1").disabled = !document.getElementById("AutoTimerg_Intervall_value1").disabled' unchecked >
|
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="AutoTimer_Intervall_text" style="color:black;">Intervall</class>
|
<class id="AutoTimer_Intervall_text" style="color:black;">Intervall</class>
|
||||||
@@ -521,7 +599,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="Debug_Logfile_enabled" value="1" onclick = 'document.getElementById("Debug_Logfile_value1").disabled = !document.getElementById("Debug_Logfile_value1").disabled' unchecked >
|
<input type="checkbox" id="Debug_Logfile_enabled" value="1" onclick = 'InvertEnableItem("Debug", "Logfile")' unchecked >
|
||||||
</td>
|
</td>
|
||||||
<td width="200px">
|
<td width="200px">
|
||||||
<class id="Debug_Logfile_text" style="color:black;">Logfile</class>
|
<class id="Debug_Logfile_text" style="color:black;">Logfile</class>
|
||||||
@@ -538,7 +616,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<td"><input type="checkbox" id="Debug_LogfileRetentionInDays_enabled" value="1" onclick = 'document.getElementById("Debug_LogfileRetentionInDays_value").disabled = !document.getElementById("Debug_LogfileRetentionInDays_value1").disabled' unchecked ></td>
|
<td"><input type="checkbox" id="Debug_LogfileRetentionInDays_enabled" value="1" onclick = 'InvertEnableItem("Debug", "LogfileRetentionInDays")' unchecked ></td>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<class id="Debug_LogfileRetentionInDays_text" style="color:black;">LogfileRetentionInDays</class>
|
<class id="Debug_LogfileRetentionInDays_text" style="color:black;">LogfileRetentionInDays</class>
|
||||||
@@ -556,7 +634,7 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<td"><input type="checkbox" id="System_TimeZone_enabled" value="1" onclick = 'document.getElementById("System_TimeZone_value").disabled = !document.getElementById("System_TimeZone_value1").disabled' unchecked ></td>
|
<td"><input type="checkbox" id="System_TimeZone_enabled" value="1" onclick = 'InvertEnableItem("System", "TimeZone")' unchecked ></td>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<class id="System_TimeZone_text" style="color:black;">TimeZone</class>
|
<class id="System_TimeZone_text" style="color:black;">TimeZone</class>
|
||||||
@@ -570,18 +648,33 @@ textarea {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="expert" id="ex16">
|
<tr class="expert" id="ex16">
|
||||||
<td width="20px" style="padding-left: 40px;">
|
<td width="20px" style="padding-left: 40px;">
|
||||||
<input type="checkbox" id="System_TimeUpdateIntervall_enabled" value="1" onclick = 'document.getElementById("System_TimeUpdateIntervall_value1").disabled = !document.getElementById("System_TimeUpdateIntervall_value1").disabled' unchecked >
|
<td"><input type="checkbox" id="System_TimeServer_enabled" value="1" onclick = 'InvertEnableItem("System", "TimeServer")' unchecked ></td>
|
||||||
</td>
|
|
||||||
<td width="200px">
|
|
||||||
<class id="System_TimeUpdateIntervall_text" style="color:black;">TimeUpdateIntervall</class>
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="number" id="System_TimeUpdateIntervall_value1" size="13" min="0" step="1">
|
<class id="System_TimeServer_text" style="color:black;">TimeServer</class>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" id="System_TimeServer_value1">
|
||||||
</td>
|
</td>
|
||||||
<td style="font-size: 80%;">
|
<td style="font-size: 80%;">
|
||||||
Intervall for synchronizing the time with the time server (in hours)
|
Time server to synchronize system time (default: "pool.ntp.org" - used if nothing is specified)
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="expert" id="System_Hostname">
|
||||||
|
<td width="20px" style="padding-left: 40px;">
|
||||||
|
<td"><input type="checkbox" id="System_Hostname_enabled" value="1" onclick = 'InvertEnableItem("System", "Hostname")' unchecked ></td>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<class id="System_Hostname_text" style="color:black;">Hostname</class>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" id="System_Hostname_value1">
|
||||||
|
</td>
|
||||||
|
<td style="font-size: 80%;">
|
||||||
|
Hostname for server - will be transfered to wlan.ini at next startup)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@@ -597,12 +690,14 @@ textarea {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript" src="./gethost.js"></script>
|
<script type="text/javascript" src="./gethost.js"></script>
|
||||||
|
<script type="text/javascript" src="./readconfigcommon.js"></script>
|
||||||
<script type="text/javascript" src="./readconfigparam.js"></script>
|
<script type="text/javascript" src="./readconfigparam.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var canvas = document.getElementById('canvas'),
|
var canvas = document.getElementById('canvas'),
|
||||||
basepath = "http://192.168.178.22";
|
basepath = "http://192.168.178.22";
|
||||||
param;
|
param;
|
||||||
|
category;
|
||||||
|
|
||||||
|
|
||||||
function LoadConfigNeu() {
|
function LoadConfigNeu() {
|
||||||
@@ -613,12 +708,14 @@ function LoadConfigNeu() {
|
|||||||
}
|
}
|
||||||
loadConfig(basepath);
|
loadConfig(basepath);
|
||||||
ParseConfig();
|
ParseConfig();
|
||||||
|
param = getConfigParameters();
|
||||||
|
category = getConfigCategory();
|
||||||
UpdateInput();
|
UpdateInput();
|
||||||
UpdateExpertModus();
|
UpdateExpertModus();
|
||||||
document.getElementById("divall").style.display = '';
|
document.getElementById("divall").style.display = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function WriteParameter(_param, _cat, _name, _optional, _select = false, _anzpara = 1){
|
function WriteParameter(_param, _category, _cat, _name, _optional, _select = false, _anzpara = 1){
|
||||||
if (_param[_cat][_name]["found"]){
|
if (_param[_cat][_name]["found"]){
|
||||||
if (_optional) {
|
if (_optional) {
|
||||||
document.getElementById(_cat+"_"+_name+"_enabled").checked = _param[_cat][_name]["enabled"];
|
document.getElementById(_cat+"_"+_name+"_enabled").checked = _param[_cat][_name]["enabled"];
|
||||||
@@ -654,6 +751,79 @@ function WriteParameter(_param, _cat, _name, _optional, _select = false, _anzpar
|
|||||||
document.getElementById(_cat+"_"+_name+"_text").style="color:lightgrey;"
|
document.getElementById(_cat+"_"+_name+"_text").style="color:lightgrey;"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////// am Ende, falls Kategorie als gesamtes nicht ausgewählt --> deaktivieren
|
||||||
|
if (_category[_cat]["enabled"] == false)
|
||||||
|
{
|
||||||
|
if (_optional) {
|
||||||
|
document.getElementById(_cat+"_"+_name+"_enabled").disabled = true;
|
||||||
|
for (var j = 1; j <= _anzpara; ++j) {
|
||||||
|
document.getElementById(_cat+"_"+_name+"_value"+j).disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.getElementById(_cat+"_"+_name+"_text").style="color:lightgrey;"
|
||||||
|
}
|
||||||
|
EnDisableItem(_category[_cat]["enabled"], _param, _category, _cat, _name, _optional);
|
||||||
|
}
|
||||||
|
|
||||||
|
function InvertEnableItem(_cat, _param)
|
||||||
|
{
|
||||||
|
_zw = _cat + "_" + _param + "_enabled";
|
||||||
|
_isOn = document.getElementById(_zw).checked;
|
||||||
|
|
||||||
|
_color = "color:lightgrey;";
|
||||||
|
if (_isOn) {
|
||||||
|
_color = "color:black;";
|
||||||
|
}
|
||||||
|
|
||||||
|
_zw = _cat + "_" + _param + "_text";
|
||||||
|
document.getElementById(_zw).disabled = !_isOn;
|
||||||
|
document.getElementById(_zw).style = _color;
|
||||||
|
|
||||||
|
if (param[_cat][_param]["anzParam"] == 2) {
|
||||||
|
_color = "width: 30px;" + _color;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var j = 1; j <= param[_cat][_param]["anzParam"]; ++j) {
|
||||||
|
document.getElementById(_cat+"_"+_param+"_value"+j).disabled = !_isOn;
|
||||||
|
document.getElementById(_cat+"_"+_param+"_value"+j).style=_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function EnDisableItem(_status, _param, _category, _cat, _name, _optional)
|
||||||
|
{
|
||||||
|
_status = _param[_cat][_name]["found"] && _category[_cat]["enabled"];
|
||||||
|
|
||||||
|
_color = "color:lightgrey;";
|
||||||
|
if (_status) {
|
||||||
|
_color = "color:black;";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_optional) {
|
||||||
|
document.getElementById(_cat+"_"+_name+"_enabled").disabled = !_status;
|
||||||
|
document.getElementById(_cat+"_"+_name+"_enabled").style=_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_param[_cat][_name]["enabled"]) {
|
||||||
|
_status = false;
|
||||||
|
_color = "color:lightgrey;";
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById(_cat+"_"+_name+"_text").disabled = !_status;
|
||||||
|
document.getElementById(_cat+"_"+_name+"_text").style = _color;
|
||||||
|
|
||||||
|
if (_param[_cat][_name]["anzParam"] == 2) {
|
||||||
|
_color = "width: 30px;" + _color;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) {
|
||||||
|
document.getElementById(_cat+"_"+_name+"_value"+j).disabled = !_status;
|
||||||
|
document.getElementById(_cat+"_"+_name+"_value"+j).style=_color;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -667,7 +837,7 @@ function ReadParameter(_param, _cat, _name, _optional, _select = false){
|
|||||||
_param[_cat][_name]["value1"] = sel.options[sel.selectedIndex].text;
|
_param[_cat][_name]["value1"] = sel.options[sel.selectedIndex].text;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (var j = 1; j <= _param[_cat][_name]["anzpara"]; ++j) {
|
for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) {
|
||||||
_param[_cat][_name]["value"+j] = document.getElementById(_cat+"_"+_name+"_value"+j).value;
|
_param[_cat][_name]["value"+j] = document.getElementById(_cat+"_"+_name+"_value"+j).value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -675,69 +845,90 @@ function ReadParameter(_param, _cat, _name, _optional, _select = false){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function UpdateInput() {
|
function UpdateInput() {
|
||||||
param = getConfigParameters();
|
document.getElementById("Category_Analog_enabled").checked = category["Analog"]["enabled"];
|
||||||
WriteParameter(param, "MakeImage", "LogImageLocation", true);
|
document.getElementById("Category_Digits_enabled").checked = category["Digits"]["enabled"];
|
||||||
WriteParameter(param, "MakeImage", "LogfileRetentionInDays", true);
|
document.getElementById("Category_MQTT_enabled").checked = category["MQTT"]["enabled"];
|
||||||
WriteParameter(param, "MakeImage", "WaitBeforeTakingPicture", false);
|
|
||||||
WriteParameter(param, "MakeImage", "ImageQuality", false);
|
|
||||||
WriteParameter(param, "MakeImage", "ImageSize", false, true, true);
|
|
||||||
|
|
||||||
WriteParameter(param, "Alignment", "SearchFieldX", false);
|
WriteParameter(param, category, "MakeImage", "LogImageLocation", true);
|
||||||
WriteParameter(param, "Alignment", "SearchFieldY", false);
|
WriteParameter(param, category, "MakeImage", "LogfileRetentionInDays", true);
|
||||||
|
WriteParameter(param, category, "MakeImage", "WaitBeforeTakingPicture", false);
|
||||||
|
WriteParameter(param, category, "MakeImage", "ImageQuality", false);
|
||||||
|
WriteParameter(param, category, "MakeImage", "Brightness", false);
|
||||||
|
// WriteParameter(param, category, "MakeImage", "Contrast", false);
|
||||||
|
// WriteParameter(param, category, "MakeImage", "Saturation", false);
|
||||||
|
WriteParameter(param, category, "MakeImage", "ImageSize", false, true, true);
|
||||||
|
WriteParameter(param, category, "MakeImage", "FixedExposure", false, true, true);
|
||||||
|
|
||||||
WriteParameter(param, "Digits", "Model", false);
|
WriteParameter(param, category, "Alignment", "SearchFieldX", false);
|
||||||
WriteParameter(param, "Digits", "LogImageLocation", false);
|
WriteParameter(param, category, "Alignment", "SearchFieldY", false);
|
||||||
WriteParameter(param, "Digits", "LogfileRetentionInDays", false);
|
WriteParameter(param, category, "Alignment", "AlignmentAlgo", true, true, true);
|
||||||
WriteParameter(param, "Digits", "ModelInputSize", false, false, 2);
|
|
||||||
|
WriteParameter(param, category, "Digits", "Model", false);
|
||||||
|
WriteParameter(param, category, "Digits", "LogImageLocation", true);
|
||||||
|
WriteParameter(param, category, "Digits", "LogfileRetentionInDays", true);
|
||||||
|
WriteParameter(param, category, "Digits", "ModelInputSize", false, false, 2);
|
||||||
|
|
||||||
WriteParameter(param, "Analog", "Model", false);
|
WriteParameter(param, category, "Analog", "Model", false);
|
||||||
WriteParameter(param, "Analog", "LogImageLocation", false);
|
WriteParameter(param, category, "Analog", "LogImageLocation", true);
|
||||||
WriteParameter(param, "Analog", "LogfileRetentionInDays", false);
|
WriteParameter(param, category, "Analog", "LogfileRetentionInDays", true);
|
||||||
WriteParameter(param, "Analog", "ModelInputSize", false, false, 2);
|
WriteParameter(param, category, "Analog", "ExtendedResolution", true, true);
|
||||||
|
WriteParameter(param, category, "Analog", "ModelInputSize", false, false, 2);
|
||||||
|
|
||||||
WriteParameter(param, "PostProcessing", "DecimalShift", true);
|
WriteParameter(param, category, "PostProcessing", "DecimalShift", true);
|
||||||
WriteParameter(param, "PostProcessing", "PreValueUse", true, true);
|
WriteParameter(param, category, "PostProcessing", "PreValueUse", true, true);
|
||||||
WriteParameter(param, "PostProcessing", "PreValueAgeStartup", true);
|
WriteParameter(param, category, "PostProcessing", "PreValueAgeStartup", true);
|
||||||
WriteParameter(param, "PostProcessing", "AllowNegativeRates", true, true);
|
WriteParameter(param, category, "PostProcessing", "AllowNegativeRates", true, true);
|
||||||
WriteParameter(param, "PostProcessing", "MaxRateValue", true);
|
WriteParameter(param, category, "PostProcessing", "MaxRateValue", true);
|
||||||
WriteParameter(param, "PostProcessing", "ErrorMessage", true, true);
|
WriteParameter(param, category, "PostProcessing", "ErrorMessage", true, true);
|
||||||
WriteParameter(param, "PostProcessing", "CheckDigitIncreaseConsistency", true, true);
|
WriteParameter(param, category, "PostProcessing", "CheckDigitIncreaseConsistency", true, true);
|
||||||
|
|
||||||
WriteParameter(param, "MQTT", "Uri", true);
|
WriteParameter(param, category, "MQTT", "Uri", true);
|
||||||
WriteParameter(param, "MQTT", "Topic", true);
|
WriteParameter(param, category, "MQTT", "Topic", true);
|
||||||
WriteParameter(param, "MQTT", "TopicError", true);
|
WriteParameter(param, category, "MQTT", "TopicError", true);
|
||||||
WriteParameter(param, "MQTT", "ClientID", true);
|
WriteParameter(param, category, "MQTT", "ClientID", true);
|
||||||
WriteParameter(param, "MQTT", "user", true);
|
WriteParameter(param, category, "MQTT", "user", true);
|
||||||
WriteParameter(param, "MQTT", "password", true);
|
WriteParameter(param, category, "MQTT", "password", true);
|
||||||
|
|
||||||
WriteParameter(param, "AutoTimer", "AutoStart", true, true);
|
WriteParameter(param, category, "AutoTimer", "AutoStart", false, true);
|
||||||
WriteParameter(param, "AutoTimer", "Intervall", true);
|
WriteParameter(param, category, "AutoTimer", "Intervall", false);
|
||||||
|
|
||||||
WriteParameter(param, "Debug", "Logfile", true, true);
|
WriteParameter(param, category, "Debug", "Logfile", true, true);
|
||||||
WriteParameter(param, "Debug", "LogfileRetentionInDays", true);
|
WriteParameter(param, category, "Debug", "LogfileRetentionInDays", true);
|
||||||
|
|
||||||
WriteParameter(param, "System", "TimeZone", true);
|
WriteParameter(param, category, "System", "TimeZone", true);
|
||||||
WriteParameter(param, "System", "TimeUpdateIntervall", true);
|
WriteParameter(param, category, "System", "Hostname", true);
|
||||||
|
WriteParameter(param, category, "System", "TimeServer", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function WriteConfig(){
|
function ReadParameterAll()
|
||||||
|
{
|
||||||
|
category["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked;
|
||||||
|
category["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked;
|
||||||
|
category["MQTT"]["enabled"] = document.getElementById("Category_MQTT_enabled").checked;
|
||||||
|
|
||||||
ReadParameter(param, "MakeImage", "LogImageLocation", true);
|
ReadParameter(param, "MakeImage", "LogImageLocation", true);
|
||||||
ReadParameter(param, "MakeImage", "LogfileRetentionInDays", true);
|
ReadParameter(param, "MakeImage", "LogfileRetentionInDays", true);
|
||||||
ReadParameter(param, "MakeImage", "WaitBeforeTakingPicture", false);
|
ReadParameter(param, "MakeImage", "WaitBeforeTakingPicture", false);
|
||||||
ReadParameter(param, "MakeImage", "ImageQuality", false);
|
ReadParameter(param, "MakeImage", "ImageQuality", false);
|
||||||
|
ReadParameter(param, "MakeImage", "Brightness", false);
|
||||||
|
// ReadParameter(param, "MakeImage", "Contrast", false);
|
||||||
|
// ReadParameter(param, "MakeImage", "Saturation", false);
|
||||||
ReadParameter(param, "MakeImage", "ImageSize", false, true);
|
ReadParameter(param, "MakeImage", "ImageSize", false, true);
|
||||||
|
ReadParameter(param, "MakeImage", "FixedExposure", false, true);
|
||||||
|
|
||||||
ReadParameter(param, "Alignment", "SearchFieldX", false);
|
ReadParameter(param, "Alignment", "SearchFieldX", false);
|
||||||
ReadParameter(param, "Alignment", "SearchFieldY", false);
|
ReadParameter(param, "Alignment", "SearchFieldY", false);
|
||||||
|
ReadParameter(param, "Alignment", "AlignmentAlgo", true, true);
|
||||||
|
|
||||||
ReadParameter(param, "Digits", "Model", false);
|
ReadParameter(param, "Digits", "Model", false);
|
||||||
ReadParameter(param, "Digits", "LogImageLocation", false);
|
ReadParameter(param, "Digits", "LogImageLocation", true);
|
||||||
ReadParameter(param, "Digits", "LogfileRetentionInDays", false);
|
ReadParameter(param, "Digits", "LogfileRetentionInDays", true);
|
||||||
ReadParameter(param, "Digits", "ModelInputSize", false, false, 2);
|
ReadParameter(param, "Digits", "ModelInputSize", false, false, 2);
|
||||||
|
|
||||||
ReadParameter(param, "Analog", "Model", false);
|
ReadParameter(param, "Analog", "Model", false);
|
||||||
ReadParameter(param, "Analog", "LogImageLocation", false);
|
ReadParameter(param, "Analog", "LogImageLocation", true);
|
||||||
ReadParameter(param, "Analog", "LogfileRetentionInDays", false);
|
ReadParameter(param, "Analog", "LogfileRetentionInDays", true);
|
||||||
|
ReadParameter(param, "Analog", "ExtendedResolution", true, true);
|
||||||
ReadParameter(param, "Analog", "ModelInputSize", false, false, 2);
|
ReadParameter(param, "Analog", "ModelInputSize", false, false, 2);
|
||||||
|
|
||||||
ReadParameter(param, "PostProcessing", "DecimalShift", true);
|
ReadParameter(param, "PostProcessing", "DecimalShift", true);
|
||||||
@@ -755,28 +946,39 @@ function WriteConfig(){
|
|||||||
ReadParameter(param, "MQTT", "user", true);
|
ReadParameter(param, "MQTT", "user", true);
|
||||||
ReadParameter(param, "MQTT", "password", true);
|
ReadParameter(param, "MQTT", "password", true);
|
||||||
|
|
||||||
ReadParameter(param, "AutoTimer", "AutoStart", true, true);
|
ReadParameter(param, "AutoTimer", "AutoStart", false, true);
|
||||||
ReadParameter(param, "AutoTimer", "Intervall", true);
|
ReadParameter(param, "AutoTimer", "Intervall", false);
|
||||||
|
|
||||||
ReadParameter(param, "Debug", "Logfile", true, true);
|
ReadParameter(param, "Debug", "Logfile", true, true);
|
||||||
ReadParameter(param, "Debug", "LogfileRetentionInDays", true);
|
ReadParameter(param, "Debug", "LogfileRetentionInDays", true);
|
||||||
|
|
||||||
ReadParameter(param, "System", "TimeZone", true);
|
ReadParameter(param, "System", "TimeZone", true);
|
||||||
ReadParameter(param, "System", "TimeUpdateIntervall", true);
|
ReadParameter(param, "System", "Hostname", true);
|
||||||
|
ReadParameter(param, "System", "TimeServer", true);
|
||||||
|
|
||||||
FormatDecimalValue(param, "PostProcessing", "MaxRateValue");
|
FormatDecimalValue(param, "PostProcessing", "MaxRateValue");
|
||||||
|
}
|
||||||
|
|
||||||
return setConfigParameters(param);
|
function WriteConfig(){
|
||||||
|
ReadParameterAll();
|
||||||
|
return setConfigParameters(param, category);
|
||||||
}
|
}
|
||||||
|
|
||||||
function FormatDecimalValue(_param, _cat, _name) {
|
function FormatDecimalValue(_param, _cat, _name) {
|
||||||
for (var j = 1; j <= _param[_cat][_name]["anzpara"]; ++j) {
|
for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) {
|
||||||
var _val = _param[_cat][_name]["value"+j];
|
var _val = _param[_cat][_name]["value"+j];
|
||||||
_val = _val.replace(",", ".");
|
_val = _val.replace(",", ".");
|
||||||
_param[_cat][_name]["value"+j] = _val;
|
_param[_cat][_name]["value"+j] = _val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function UpdateAfterCategoryCheck() {
|
||||||
|
ReadParameterAll();
|
||||||
|
category["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked;
|
||||||
|
category["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked;
|
||||||
|
UpdateInput();
|
||||||
|
}
|
||||||
|
|
||||||
function UpdateExpertModus()
|
function UpdateExpertModus()
|
||||||
{
|
{
|
||||||
var _style = 'display:none;';
|
var _style = 'display:none;';
|
||||||
|
|||||||
@@ -55,7 +55,10 @@ th, td {
|
|||||||
|
|
||||||
<body style="font-family: arial; padding: 0px 10px;">
|
<body style="font-family: arial; padding: 0px 10px;">
|
||||||
|
|
||||||
<h2>Edit Digits</h2>
|
<h2><input type="checkbox" id="Category_Digits_enabled" value="1" onclick = 'EnDisableDigits()' checked >
|
||||||
|
Edit Digits</h2>
|
||||||
|
|
||||||
|
<div id="div1">
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -91,7 +94,9 @@ th, td {
|
|||||||
<td>y: <input type="number" name="refy" id="refy" step=1 onchange="valuemanualchanged()"></td>
|
<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>
|
<td>dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -101,6 +106,8 @@ th, td {
|
|||||||
|
|
||||||
<script type="text/javascript" src="./gethost.js"></script>
|
<script type="text/javascript" src="./gethost.js"></script>
|
||||||
<script type="text/javascript" src="./readconfig.js"></script>
|
<script type="text/javascript" src="./readconfig.js"></script>
|
||||||
|
<script type="text/javascript" src="./readconfigcommon.js"></script>
|
||||||
|
<script type="text/javascript" src="./jquery-3.5.1.min.js"></script>
|
||||||
|
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
var canvas = document.getElementById('canvas'),
|
var canvas = document.getElementById('canvas'),
|
||||||
@@ -114,6 +121,41 @@ th, td {
|
|||||||
lockAR = true;
|
lockAR = true;
|
||||||
basepath = "http://192.168.178.26";
|
basepath = "http://192.168.178.26";
|
||||||
|
|
||||||
|
|
||||||
|
function EnDisableDigits() {
|
||||||
|
isEnabled = document.getElementById("Category_Digits_enabled").checked;
|
||||||
|
|
||||||
|
$("#div2").attr("disabled", "disabled").off('click');
|
||||||
|
var x1=$("#div2").hasClass("disabledDiv");
|
||||||
|
|
||||||
|
if (isEnabled)
|
||||||
|
{
|
||||||
|
$("#div2").removeClass("disabledDiv");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#div2").addClass("disabledDiv");
|
||||||
|
}
|
||||||
|
|
||||||
|
sah1(document.getElementById("div1"), !isEnabled);
|
||||||
|
if (isEnabled)
|
||||||
|
{
|
||||||
|
UpdateROIs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sah1(el, _target) {
|
||||||
|
try {
|
||||||
|
el.disabled = _target;
|
||||||
|
} catch (E) {}
|
||||||
|
if (el.childNodes && el.childNodes.length > 0) {
|
||||||
|
for (var x = 0; x < el.childNodes.length; x++) {
|
||||||
|
sah1(el.childNodes[x], _target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function onNameChange(){
|
function onNameChange(){
|
||||||
ROIInfo[aktindex]["name"] = document.getElementById("name").value;
|
ROIInfo[aktindex]["name"] = document.getElementById("name").value;
|
||||||
UpdateROIs();
|
UpdateROIs();
|
||||||
@@ -172,7 +214,8 @@ function ChangeSelection(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function SaveToConfig(){
|
function SaveToConfig(){
|
||||||
SaveROIToConfig(ROIInfo, "[Digits]", basepath);
|
_enabled = document.getElementById("Category_Digits_enabled").checked;
|
||||||
|
SaveROIToConfig(ROIInfo, "[Digits]", basepath, _enabled);
|
||||||
UpdatePage();
|
UpdatePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,8 +273,19 @@ function UpdateROIs(){
|
|||||||
function ParseIni(_basepath) {
|
function ParseIni(_basepath) {
|
||||||
loadConfig(_basepath);
|
loadConfig(_basepath);
|
||||||
ParseConfig();
|
ParseConfig();
|
||||||
|
|
||||||
|
document.getElementById("Category_Digits_enabled").checked = true;
|
||||||
ROIInfo = getROIInfo("[Digits]");
|
ROIInfo = getROIInfo("[Digits]");
|
||||||
|
|
||||||
|
if (!GetDigitsEnabled())
|
||||||
|
{
|
||||||
|
document.getElementById("Category_Digits_enabled").checked = false;
|
||||||
|
EnDisableDigits();
|
||||||
|
alert("Digital ROIs are disabled - please enable (Check box top left).\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
UpdateROIs();
|
UpdateROIs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,22 +341,27 @@ function ParseIni(_basepath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
var canvas = document.getElementById('canvas');
|
var canvas = document.getElementById('canvas');
|
||||||
var context = canvas.getContext('2d');
|
var context = canvas.getContext('2d');
|
||||||
context.drawImage(imageObj, 0, 0);
|
context.drawImage(imageObj, 0, 0);
|
||||||
lw = 4
|
if (document.getElementById("Category_Digits_enabled").checked)
|
||||||
context.lineWidth = lw;
|
{
|
||||||
context.strokeStyle = "#FF0000";
|
lw = 4
|
||||||
var x0 = parseInt(rect.startX) - parseInt(lw/2);
|
context.lineWidth = lw;
|
||||||
var y0 = parseInt(rect.startY) - parseInt(lw/2);
|
context.strokeStyle = "#FF0000";
|
||||||
var dx = parseInt(rect.w) + parseInt(lw);
|
var x0 = parseInt(rect.startX) - parseInt(lw/2);
|
||||||
var dy = parseInt(rect.h) + parseInt(lw);
|
var y0 = parseInt(rect.startY) - parseInt(lw/2);
|
||||||
context.strokeRect(x0, y0, dx, dy);
|
var dx = parseInt(rect.w) + parseInt(lw);
|
||||||
ROIInfo[aktindex]["x"] = rect.startX;
|
var dy = parseInt(rect.h) + parseInt(lw);
|
||||||
ROIInfo[aktindex]["y"] = rect.startY;
|
context.strokeRect(x0, y0, dx, dy);
|
||||||
ROIInfo[aktindex]["dx"] = rect.w;
|
context.lineWidth = 1;
|
||||||
ROIInfo[aktindex]["dy"] = rect.h;
|
context.strokeRect(x0+dx*0.2, y0+dy*0.2, dx*0.6, dy*0.6);
|
||||||
|
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
|
function getCoords(elem) { // crossbrowser version
|
||||||
|
|||||||
@@ -29,23 +29,21 @@ p {font-size: 1em;}
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This is the first time you the digitizer. You have been automatically routed to the <b>initial setup procedure</b>.
|
This is the first time you started the digitizer after the initial installation. You have been automatically routed to the <b>initial setup procedure</b>.
|
||||||
This procedure should adjust the setting to your local counter. Basically you can customize your settings in five steps.
|
Here you adjust the setting to your local counter within five steps. In the final step the inital setup will be disabled and it will restart to the normal mode.
|
||||||
<br>
|
|
||||||
In the final step the inital setup will be disabled and it will restart to the normal mode.
|
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
Just use the buttons "Next" and "Previous" to nagivate through the process.
|
You can navigate forward and backward during the setup with the buttons "Next" and "Previous". Do not forget to save in each step.
|
||||||
<br>
|
<br>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Follow the instructions:
|
This is an overview over the five steps:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>Create reference image <br>
|
<li>Create reference image <br>
|
||||||
Basis for the position references and the marking of the digits and counters.</li>
|
Base for the position referencing and the identification of the digits and counters.</li>
|
||||||
<li>Define two unique references <br>
|
<li>Define two unique references <br>
|
||||||
Used to align the individual camera shot and identify the absolut positions</li>
|
Used to align the individual camera shot and identify the absolut positions</li>
|
||||||
<li>Define the digits <br>
|
<li>Define the digits <br>
|
||||||
@@ -53,7 +51,7 @@ p {font-size: 1em;}
|
|||||||
<li>Define the analog counters <br>
|
<li>Define the analog counters <br>
|
||||||
Analog counters to be identified</li>
|
Analog counters to be identified</li>
|
||||||
<li>General settings <br>
|
<li>General settings <br>
|
||||||
Most can stay to the default value - also MQTT connection can be specified here</li>
|
Most settings can be used with default value at the beginning. MQTT connection can be specified here</li>
|
||||||
</ol>
|
</ol>
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ p {font-size: 1em;}
|
|||||||
<br>
|
<br>
|
||||||
Once you have pushed below button, the setup modus will be left and the digitizer start to normal operation mode.
|
Once you have pushed below button, the setup modus will be left and the digitizer start to normal operation mode.
|
||||||
<br>
|
<br>
|
||||||
After a view seconds you can reload this page again and will go to normal operation mode.
|
After a view seconds you can reload this page. It will take two to four minutes, until you get the first reading.
|
||||||
<br>
|
<br>
|
||||||
All settings can be changed later on as well in the configuration menue.
|
All settings can be changed as well in the configuration menue in normal operation mode.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@@ -45,6 +45,7 @@ p {font-size: 1em;}
|
|||||||
|
|
||||||
<script type="text/javascript" src="./gethost.js"></script>
|
<script type="text/javascript" src="./gethost.js"></script>
|
||||||
<script type="text/javascript" src="./readconfigparam.js"></script>
|
<script type="text/javascript" src="./readconfigparam.js"></script>
|
||||||
|
<script type="text/javascript" src="./readconfigcommon.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var canvas = document.getElementById('canvas'),
|
var canvas = document.getElementById('canvas'),
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ table {
|
|||||||
|
|
||||||
<body style="font-family: arial; padding: 0px 10px;">
|
<body style="font-family: arial; padding: 0px 10px;">
|
||||||
<h2>Create Reference out of Raw Image</h2>
|
<h2>Create Reference out of Raw Image</h2>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><input class="button" type="button" value="Show Actual Reference" onclick="showReference()"></td>
|
<td><input class="button" type="button" value="Show Actual Reference" onclick="showReference()"></td>
|
||||||
@@ -42,17 +42,32 @@ table {
|
|||||||
<td><input class="button" type="submit" id="take" onclick="doTake()" value="Take Image"></td>
|
<td><input class="button" type="submit" id="take" onclick="doTake()" value="Take Image"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-top: 10px"><label for="mirror">Mirror Image:</label></td>
|
<td style="padding-top: 10px"><label for="mirror" id="labelmirror">Mirror Image:</label></td>
|
||||||
<td style="padding-top: 10px"><input type="checkbox" id="mirror" name="mirror" value="1" onchange="drawRotated()"></td>
|
<td style="padding-top: 10px"><input type="checkbox" id="mirror" name="mirror" value="1" onchange="drawRotated()"></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="mirror">Pre-rotate Angle:</label></td>
|
<td><label for="mirror">Pre-rotate Angle:</label></td>
|
||||||
<td><input type="number" id="prerotateangle" name="prerotateangle" value=0 min="-360" max="360" onchange="drawRotated()">Degrees</td>
|
<td><input type="number" id="prerotateangle" name="prerotateangle" value=0 min="-360" max="360" onchange="drawRotated()">Degrees</td>
|
||||||
|
<td>
|
||||||
|
<class id="MakeImage_Brightness_text" style="color:black;">Brightness: </class>
|
||||||
|
<input type="number" id="MakeImage_Brightness_value1" size="13" value=0 min="-2" max="2" style="float: right; clear: both;">
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="mirror">Fine Alignment:</label></td>
|
<td><label for="mirror">Fine Alignment:</label></td>
|
||||||
<td><input type="number" id="finerotate" name="finerotate" value=0.0 min="-1" max="1" step="0.2" onchange="drawRotated()">Degrees</td>
|
<td><input type="number" id="finerotate" name="finerotate" value=0.0 min="-1" max="1" step="0.2" onchange="drawRotated()">Degrees</td>
|
||||||
</tr>
|
<!--
|
||||||
|
<td>
|
||||||
|
<class id="MakeImage_Contrast_text" style="color:black;">Contrast</class>
|
||||||
|
<input type="number" id="MakeImage_Contrast_value1" size="13" value=0 min="-2" max="2" style="float: right; clear: both;">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<class id="MakeImage_Saturation_text" style="color:black;">Saturation</class>
|
||||||
|
<input type="number" id="MakeImage_Saturation_value1" size="13" value=0 min="-2" max="2" style="float: right; clear: both;">
|
||||||
|
</td>
|
||||||
|
-->
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
@@ -67,6 +82,10 @@ table {
|
|||||||
|
|
||||||
<script type="text/javascript" src="./gethost.js"></script>
|
<script type="text/javascript" src="./gethost.js"></script>
|
||||||
<script type="text/javascript" src="./readconfig.js"></script>
|
<script type="text/javascript" src="./readconfig.js"></script>
|
||||||
|
<script type="text/javascript" src="./readconfigcommon.js"></script>
|
||||||
|
<script type="text/javascript" src="./readconfigparam.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
var canvas = document.getElementById('canvas'),
|
var canvas = document.getElementById('canvas'),
|
||||||
@@ -74,10 +93,21 @@ table {
|
|||||||
imageObj = new Image()
|
imageObj = new Image()
|
||||||
basepath = "http://192.168.178.26";
|
basepath = "http://192.168.178.26";
|
||||||
isActReference = false;
|
isActReference = false;
|
||||||
|
param;
|
||||||
|
|
||||||
function doTake(){
|
function doTake(){
|
||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
url = basepath + "/editflow.html?task=test_take";
|
if (param["MakeImage"]["Brightness"].found && param["MakeImage"]["Brightness"].enabled)
|
||||||
|
{
|
||||||
|
_brightness = document.getElementById("MakeImage_Brightness_value1").value;
|
||||||
|
// _contrast = document.getElementById("MakeImage_Contrast_value1").value;
|
||||||
|
// _saturation = document.getElementById("MakeImage_Saturation_value1").value;
|
||||||
|
url = basepath + "/editflow.html?task=test_take&bri=" + _brightness;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
url = basepath + "/editflow.html?task=test_take";
|
||||||
|
}
|
||||||
if (basepath.length > 0){
|
if (basepath.length > 0){
|
||||||
url = url + "&host=" + basepath;
|
url = url + "&host=" + basepath;
|
||||||
}
|
}
|
||||||
@@ -87,36 +117,65 @@ table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadRawImage(){
|
function loadRawImage(){
|
||||||
url = basepath + "/fileserver/img_tmp/raw.jpg" + "?session=" + Math.floor((Math.random() * 1000000) + 1);
|
url = basepath + "/img_tmp/raw.jpg" + "?session=" + Math.floor((Math.random() * 1000000) + 1);
|
||||||
document.getElementById("finerotate").value = 0;
|
|
||||||
document.getElementById("prerotateangle").value = getPreRotate();
|
|
||||||
document.getElementById("mirror").checked = getMirror();
|
|
||||||
document.getElementById("finerotate").disabled = false;
|
document.getElementById("finerotate").disabled = false;
|
||||||
document.getElementById("prerotateangle").disabled = false;
|
document.getElementById("prerotateangle").disabled = false;
|
||||||
document.getElementById("updatereferenceimage").disabled = false;
|
document.getElementById("updatereferenceimage").disabled = false;
|
||||||
document.getElementById("take").disabled = false;
|
document.getElementById("take").disabled = false;
|
||||||
document.getElementById("mirror").disabled = false;
|
if (param["Alignment"]["InitialMirror"].found)
|
||||||
|
document.getElementById("mirror").disabled = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
document.getElementById("labelmirror").style = "color:lightgrey;";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param["MakeImage"]["Brightness"].found && param["MakeImage"]["Brightness"].enabled)
|
||||||
|
document.getElementById("MakeImage_Brightness_value1").disabled = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
document.getElementById("MakeImage_Brightness_value1").type = "hidden";
|
||||||
|
document.getElementById("MakeImage_Brightness_text").style.visibility = "hidden";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (param["MakeImage"]["Saturation"].found)
|
||||||
|
// document.getElementById("MakeImage_Saturation_value1").disabled = false;
|
||||||
|
// if (param["MakeImage"]["Contrast"].found)
|
||||||
|
// document.getElementById("MakeImage_Contrast_value1").disabled = false;
|
||||||
|
|
||||||
// document.getElementById("ButtonRotate").disabled = false;
|
|
||||||
isActReference = false;
|
isActReference = false;
|
||||||
loadCanvas(url);
|
loadCanvas(url);
|
||||||
drawRotated();
|
drawRotated();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showReference(){
|
function showReference(_param){
|
||||||
url = basepath + "/fileserver/config/reference.jpg" + "?session=" + Math.floor((Math.random() * 1000000) + 1);;
|
url = basepath + "/fileserver/config/reference.jpg" + "?session=" + Math.floor((Math.random() * 1000000) + 1);;
|
||||||
document.getElementById("finerotate").value = 0;
|
document.getElementById("finerotate").value = 0;
|
||||||
document.getElementById("prerotateangle").value = 0;
|
document.getElementById("prerotateangle").value = _param["Alignment"]["InitialRotate"].value1;
|
||||||
|
|
||||||
|
if (_param["Alignment"]["InitialMirror"].found && (_param["Alignment"]["InitialMirror"].value1 == "true"))
|
||||||
|
document.getElementById("mirror").checked = true;
|
||||||
|
|
||||||
document.getElementById("finerotate").disabled = true;
|
document.getElementById("finerotate").disabled = true;
|
||||||
document.getElementById("prerotateangle").disabled = true;
|
document.getElementById("prerotateangle").disabled = true;
|
||||||
document.getElementById("updatereferenceimage").disabled = true;
|
document.getElementById("updatereferenceimage").disabled = true;
|
||||||
document.getElementById("take").disabled = true;
|
document.getElementById("take").disabled = true;
|
||||||
|
document.getElementById("MakeImage_Brightness_value1").disabled = true;
|
||||||
|
// document.getElementById("MakeImage_Saturation_value1").disabled = true;
|
||||||
|
// document.getElementById("MakeImage_Contrast_value1").disabled = true;
|
||||||
|
document.getElementById("mirror").disabled = false;
|
||||||
|
if (!(param["MakeImage"]["Brightness"].found))
|
||||||
|
{
|
||||||
|
document.getElementById("MakeImage_Brightness_value1").type = "hidden";
|
||||||
|
document.getElementById("MakeImage_Brightness_text").style.visibility = "hidden";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("mirror").disabled = true;
|
document.getElementById("mirror").disabled = true;
|
||||||
|
|
||||||
isActReference = true;
|
isActReference = true;
|
||||||
loadCanvas(url);
|
loadCanvas(url);
|
||||||
ParseConfig();
|
drawRotated(false, true);
|
||||||
drawRotated();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dataURLtoBlob(dataurl) {
|
function dataURLtoBlob(dataurl) {
|
||||||
@@ -130,11 +189,26 @@ table {
|
|||||||
|
|
||||||
function SaveReference(){
|
function SaveReference(){
|
||||||
if (confirm("Are you sure you want to update the reference image?")) {
|
if (confirm("Are you sure you want to update the reference image?")) {
|
||||||
setPreRotate(document.getElementById("prerotateangle").value);
|
param["Alignment"]["InitialRotate"].value1 = document.getElementById("prerotateangle").value;
|
||||||
setMirror(document.getElementById("mirror").checked);
|
if ((param["Alignment"]["InitialMirror"].found == true) && (document.getElementById("mirror").checked))
|
||||||
UpdateConfigFileReferenceChange(basepath);
|
param["Alignment"]["InitialMirror"].value1 = "true";
|
||||||
|
else
|
||||||
|
param["Alignment"]["InitialMirror"].value1 = "false";
|
||||||
|
|
||||||
|
if (param["MakeImage"]["Brightness"].found && param["MakeImage"]["Brightness"].enabled)
|
||||||
|
{
|
||||||
|
ReadParameter(param, "MakeImage", "Brightness", false);
|
||||||
|
// ReadParameter(param, "MakeImage", "Contrast", false);
|
||||||
|
// ReadParameter(param, "MakeImage", "Saturation", false);
|
||||||
|
}
|
||||||
|
|
||||||
var canvas = document.getElementById("canvas");
|
var canvas = document.getElementById("canvas");
|
||||||
drawRotated(false);
|
drawRotated(false);
|
||||||
|
|
||||||
|
var textToSave = setConfigParameters(param);
|
||||||
|
FileDeleteOnServer("/config/config.ini", basepath);
|
||||||
|
FileSendContent(textToSave, "/config/config.ini", basepath);
|
||||||
|
|
||||||
SaveCanvasToImage(canvas, "/config/reference.jpg", true, basepath);
|
SaveCanvasToImage(canvas, "/config/reference.jpg", true, basepath);
|
||||||
showReference();
|
showReference();
|
||||||
UpdatePage();
|
UpdatePage();
|
||||||
@@ -173,10 +247,75 @@ table {
|
|||||||
basepath = getbasepath();
|
basepath = getbasepath();
|
||||||
loadConfig(basepath);
|
loadConfig(basepath);
|
||||||
ParseConfig();
|
ParseConfig();
|
||||||
showReference();
|
param = getConfigParameters();
|
||||||
|
UpdateInput();
|
||||||
|
showReference(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawRotated(_grid = true){
|
function UpdateInput() {
|
||||||
|
WriteParameter(param, category, "MakeImage", "Brightness", false);
|
||||||
|
// WriteParameter(param, category, "MakeImage", "Contrast", false);
|
||||||
|
// WriteParameter(param, category, "MakeImage", "Saturation", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function ReadParameter(_param, _cat, _name, _optional, _select = false){
|
||||||
|
if (_param[_cat][_name]["found"]){
|
||||||
|
if (_optional) {
|
||||||
|
_param[_cat][_name]["enabled"] = document.getElementById(_cat+"_"+_name+"_enabled").checked;
|
||||||
|
}
|
||||||
|
if (_select) {
|
||||||
|
var sel = document.getElementById(_cat+"_"+_name+"_value1");
|
||||||
|
_param[_cat][_name]["value1"] = sel.options[sel.selectedIndex].text;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) {
|
||||||
|
_param[_cat][_name]["value"+j] = document.getElementById(_cat+"_"+_name+"_value"+j).value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function WriteParameter(_param, _category, _cat, _name, _optional, _select = false, _anzpara = 1){
|
||||||
|
if (_param[_cat][_name]["found"]){
|
||||||
|
if (_optional) {
|
||||||
|
document.getElementById(_cat+"_"+_name+"_enabled").checked = _param[_cat][_name]["enabled"];
|
||||||
|
for (var j = 1; j <= _anzpara; ++j) {
|
||||||
|
document.getElementById(_cat+"_"+_name+"_value"+j).disabled = !_param[_cat][_name]["enabled"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.getElementById(_cat+"_"+_name+"_text").style="color:black;"
|
||||||
|
if (_select) {
|
||||||
|
var textToFind = _param[_cat][_name]["value1"];
|
||||||
|
var dd = document.getElementById(_cat+"_"+_name+"_value1");
|
||||||
|
for (var i = 0; i < dd.options.length; i++) {
|
||||||
|
if (dd.options[i].text.toLowerCase() === textToFind.toLowerCase()) {
|
||||||
|
dd.selectedIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (var j = 1; j <= _anzpara; ++j) {
|
||||||
|
document.getElementById(_cat+"_"+_name+"_value"+j).value = _param[_cat][_name]["value"+j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (_optional) {
|
||||||
|
document.getElementById(_cat+"_"+_name+"_enabled").disabled = true;
|
||||||
|
for (var j = 1; j <= _anzpara; ++j) {
|
||||||
|
document.getElementById(_cat+"_"+_name+"_value"+j).disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.getElementById(_cat+"_"+_name+"_text").style="color:lightgrey;"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function drawRotated(_grid = true, _isreference = false){
|
||||||
finerot= parseFloat(document.getElementById("finerotate").value);
|
finerot= parseFloat(document.getElementById("finerotate").value);
|
||||||
prerot = parseFloat(document.getElementById("prerotateangle").value);
|
prerot = parseFloat(document.getElementById("prerotateangle").value);
|
||||||
mirror = document.getElementById("mirror").checked;
|
mirror = document.getElementById("mirror").checked;
|
||||||
@@ -198,18 +337,26 @@ table {
|
|||||||
|
|
||||||
context.clearRect(0,0,imageObj.width,imageObj.height);
|
context.clearRect(0,0,imageObj.width,imageObj.height);
|
||||||
context.save();
|
context.save();
|
||||||
|
|
||||||
|
if (isActReference)
|
||||||
|
{
|
||||||
|
context.drawImage(imageObj,0,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mirror) {
|
||||||
|
context.scale(-1, 1);
|
||||||
|
context.translate(-imageObj.width/2,imageObj.height/2);
|
||||||
|
context.rotate(-degrees*Math.PI/180);
|
||||||
|
context.drawImage(imageObj, imageObj.width/2,-imageObj.height/2, -imageObj.width, imageObj.height);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
context.translate(imageObj.width/2,imageObj.height/2);
|
||||||
|
context.rotate(degrees*Math.PI/180);
|
||||||
|
context.drawImage(imageObj,-imageObj.width/2,-imageObj.height/2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mirror) {
|
|
||||||
context.scale(-1, 1);
|
|
||||||
context.translate(-imageObj.width/2,imageObj.height/2);
|
|
||||||
context.rotate(-degrees*Math.PI/180);
|
|
||||||
context.drawImage(imageObj, imageObj.width/2,-imageObj.height/2, -imageObj.width, imageObj.height);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
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();
|
context.restore();
|
||||||
if (_grid == true && !isActReference){
|
if (_grid == true && !isActReference){
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ p {font-size: 1em;}
|
|||||||
<body style="font-family: arial">
|
<body style="font-family: arial">
|
||||||
|
|
||||||
<h4>Reference Image</h4>
|
<h4>Reference Image</h4>
|
||||||
The reference image is needed to define the digits, counters and references for alignment.
|
The reference image is the base to define the digits, counters and references positions.
|
||||||
<p>
|
<p>
|
||||||
The last taken raw image from the camera is taken. Use the Button "Create New Reference" to make your own reference.<br>
|
Firstly you see the default image. Use the Button "Create New Reference" to start to create your own reference image.<br>
|
||||||
Most important feature is a straight alignment of the image. Use the Pre roate Angle and the fine alignment to fine tune the rotation of the image<br>
|
Most important feature is a straight alignment of the image. Use the Pre-rotate angle and the fine alignment to adjust the rotation of the image<br>
|
||||||
Finish the step by pushing <b>"Update Reference Image"</b>.
|
Store the reference image by pushing <b>"Update Reference Image"</b>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ function getbasepath(){
|
|||||||
var host = window.location.hostname;
|
var host = window.location.hostname;
|
||||||
if ((host == "127.0.0.1") || (host == "localhost"))
|
if ((host == "127.0.0.1") || (host == "localhost"))
|
||||||
{
|
{
|
||||||
host = "http://192.168.178.26"; // jomjol interner test
|
// host = "http://192.168.2.118"; // jomjol interner test
|
||||||
// host = "http://192.168.178.22"; // jomjol interner Real
|
// host = "http://192.168.178.26"; // jomjol interner test
|
||||||
|
host = "http://192.168.178.26"; // jomjol interner Real
|
||||||
// host = "."; // jomjol interner localhost
|
// host = "."; // jomjol interner localhost
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,9 +8,15 @@ var ref = new Array(2);
|
|||||||
var digit = new Array(0);
|
var digit = new Array(0);
|
||||||
var analog = new Array(0);
|
var analog = new Array(0);
|
||||||
var initalrotate = new Object();
|
var initalrotate = new Object();
|
||||||
|
var analogEnabled = false;
|
||||||
|
var posAnalogHeader;
|
||||||
|
var digitsEnabled = false;
|
||||||
|
var posDigitsHeader;
|
||||||
|
|
||||||
function MakeRefZW(zw, _basepath){
|
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"];
|
_filetarget = zw["name"].replace("/config/", "/img_tmp/");
|
||||||
|
_filetarget = _filetarget.replace(".jpg", "_org.jpg");
|
||||||
|
url = _basepath + "/editflow.html?task=cutref&in=/config/reference.jpg&out="+_filetarget+"&x=" + zw["x"] + "&y=" + zw["y"] + "&dx=" + zw["dx"] + "&dy=" + zw["dy"];
|
||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
try {
|
try {
|
||||||
xhttp.open("GET", url, false);
|
xhttp.open("GET", url, false);
|
||||||
@@ -18,25 +24,39 @@ function MakeRefZW(zw, _basepath){
|
|||||||
catch (error)
|
catch (error)
|
||||||
{
|
{
|
||||||
// alert("Deleting Config.ini failed");
|
// alert("Deleting Config.ini failed");
|
||||||
}
|
}
|
||||||
FileCopyOnServer("/img_tmp/ref_zw_org.jpg", "/img_tmp/ref_zw.jpg", _basepath);
|
_filetarget2 = zw["name"].replace("/config/", "/img_tmp/");
|
||||||
|
// _filetarget2 = _filetarget2.replace(".jpg", "_org.jpg");
|
||||||
|
FileCopyOnServer(_filetarget, _filetarget2, _basepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetCoordinates(index, _basepath){
|
function CopyReferenceToImgTmp(_basepath)
|
||||||
FileCopyOnServer(ref[index]["name"], "/img_tmp/ref_zw.jpg", _basepath);
|
{
|
||||||
|
for (index = 0; index < 2; ++index)
|
||||||
|
{
|
||||||
|
_filenamevon = ref[index]["name"];
|
||||||
|
_filenamenach = _filenamevon.replace("/config/", "/img_tmp/");
|
||||||
|
FileDeleteOnServer(_filenamenach, _basepath);
|
||||||
|
FileCopyOnServer(_filenamevon, _filenamenach, _basepath);
|
||||||
|
|
||||||
|
_filenamevon = _filenamevon.replace(".jpg", "_org.jpg");
|
||||||
|
_filenamenach = _filenamenach.replace(".jpg", "_org.jpg");
|
||||||
|
FileDeleteOnServer(_filenamenach, _basepath);
|
||||||
|
FileCopyOnServer(_filenamevon, _filenamenach, _basepath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FileDeleteOnServer("/img_tmp/ref_zw_org.jpg", _basepath);
|
function GetReferencesInfo(){
|
||||||
var namezw = ref[index]["name"].replace(".jpg", "_org.jpg");
|
return ref;
|
||||||
FileCopyOnServer(namezw, "/img_tmp/ref_zw_org.jpg", _basepath);
|
|
||||||
|
|
||||||
return ref[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ParseConfigAlignment(_aktline){
|
function ParseConfigAlignment(_aktline){
|
||||||
var akt_ref = 0;
|
var akt_ref = 0;
|
||||||
++_aktline;
|
++_aktline;
|
||||||
|
|
||||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
while ((_aktline < config_split.length)
|
||||||
|
&& !(config_split[_aktline][0] == "[")
|
||||||
|
&& !((config_split[_aktline][0] == ";") && (config_split[_aktline][1] == "["))) {
|
||||||
var linesplit = ZerlegeZeile(config_split[_aktline]);
|
var linesplit = ZerlegeZeile(config_split[_aktline]);
|
||||||
if ((linesplit[0].toUpperCase() == "INITIALMIRROR") && (linesplit.length > 1))
|
if ((linesplit[0].toUpperCase() == "INITIALMIRROR") && (linesplit.length > 1))
|
||||||
{
|
{
|
||||||
@@ -67,7 +87,9 @@ function ParseConfigDigit(_aktline){
|
|||||||
++_aktline;
|
++_aktline;
|
||||||
digit.length = 0;
|
digit.length = 0;
|
||||||
|
|
||||||
while ((_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
while ((_aktline < config_split.length)
|
||||||
|
&& !(config_split[_aktline][0] == "[")
|
||||||
|
&& !((config_split[_aktline][0] == ";") && (config_split[_aktline][1] == "["))) {
|
||||||
var linesplit = ZerlegeZeile(config_split[_aktline]);
|
var linesplit = ZerlegeZeile(config_split[_aktline]);
|
||||||
if (linesplit.length >= 5)
|
if (linesplit.length >= 5)
|
||||||
{
|
{
|
||||||
@@ -86,12 +108,23 @@ function ParseConfigDigit(_aktline){
|
|||||||
return _aktline;
|
return _aktline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GetAnalogEnabled() {
|
||||||
|
return analogEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function GetDigitsEnabled() {
|
||||||
|
return digitsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function ParseConfigAnalog(_aktline){
|
function ParseConfigAnalog(_aktline){
|
||||||
++_aktline;
|
++_aktline;
|
||||||
analog.length = 0;
|
analog.length = 0;
|
||||||
|
|
||||||
while ((_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
while ((_aktline < config_split.length)
|
||||||
|
&& !(config_split[_aktline][0] == "[")
|
||||||
|
&& !((config_split[_aktline][0] == ";") && (config_split[_aktline][1] == "["))) {
|
||||||
var linesplit = ZerlegeZeile(config_split[_aktline]);
|
var linesplit = ZerlegeZeile(config_split[_aktline]);
|
||||||
if (linesplit.length >= 5)
|
if (linesplit.length >= 5)
|
||||||
{
|
{
|
||||||
@@ -121,11 +154,21 @@ function getROIInfo(_typeROI){
|
|||||||
return targetROI.slice(); // Kopie senden, nicht orginal!!!
|
return targetROI.slice(); // Kopie senden, nicht orginal!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
function SaveROIToConfig(_ROIInfo, _typeROI, _basepath){
|
function SaveROIToConfig(_ROIInfo, _typeROI, _basepath, _enabled){
|
||||||
|
if (_enabled) {
|
||||||
|
text = _typeROI;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
text = ";" + _typeROI;
|
||||||
|
}
|
||||||
|
|
||||||
if (_typeROI == "[Digits]"){
|
if (_typeROI == "[Digits]"){
|
||||||
|
config_split[posDigitsHeader] = text;
|
||||||
targetROI = digit;
|
targetROI = digit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_typeROI == "[Analog]"){
|
if (_typeROI == "[Analog]"){
|
||||||
|
config_split[posAnalogHeader] = text;
|
||||||
targetROI = analog;
|
targetROI = analog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,16 +208,24 @@ function ParseConfig() {
|
|||||||
var aktline = 0;
|
var aktline = 0;
|
||||||
|
|
||||||
while (aktline < config_split.length){
|
while (aktline < config_split.length){
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[ALIGNMENT]") {
|
if ((config_split[aktline].trim().toUpperCase() == "[ALIGNMENT]") || (config_split[aktline].trim().toUpperCase() == ";[ALIGNMENT]")){
|
||||||
aktline = ParseConfigAlignment(aktline);
|
aktline = ParseConfigAlignment(aktline);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[DIGITS]") {
|
if ((config_split[aktline].trim().toUpperCase() == "[DIGITS]") || (config_split[aktline].trim().toUpperCase() == ";[DIGITS]")){
|
||||||
|
posDigitsHeader = aktline;
|
||||||
|
if (config_split[aktline][0] == "[") {
|
||||||
|
digitsEnabled = true;
|
||||||
|
}
|
||||||
aktline = ParseConfigDigit(aktline);
|
aktline = ParseConfigDigit(aktline);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[ANALOG]") {
|
if ((config_split[aktline].trim().toUpperCase() == "[ANALOG]") || (config_split[aktline].trim().toUpperCase() == ";[ANALOG]")) {
|
||||||
|
posAnalogHeader = aktline;
|
||||||
|
if (config_split[aktline][0] == "[") {
|
||||||
|
analogEnabled = true;
|
||||||
|
}
|
||||||
aktline = ParseConfigAnalog(aktline);
|
aktline = ParseConfigAnalog(aktline);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -284,21 +335,31 @@ function UpdateConfigFileReferenceChange(_basepath){
|
|||||||
SaveConfigToServer(_basepath);
|
SaveConfigToServer(_basepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpdateConfig(zw, _index, _enhance, _basepath){
|
function UpdateConfigReference(zw, _basepath){
|
||||||
var zeile = zw["name"] + " " + zw["x"] + " " + zw["y"];
|
for (var index = 0; index < 2; ++index)
|
||||||
var _pos = ref[_index]["pos_ref"];
|
{
|
||||||
config_split[_pos] = zeile;
|
var zeile = zw[index]["name"] + " " + zw[index]["x"] + " " + zw[index]["y"];
|
||||||
|
var _pos = zw[index]["pos_ref"];
|
||||||
|
config_split[_pos] = zeile;
|
||||||
|
|
||||||
|
_filenamenach = ref[index]["name"];
|
||||||
|
_filenamevon = _filenamenach.replace("/config/", "/img_tmp/");
|
||||||
|
FileDeleteOnServer(_filenamenach, _basepath);
|
||||||
|
FileCopyOnServer(_filenamevon, _filenamenach, _basepath);
|
||||||
|
|
||||||
|
_filenamenach = _filenamenach.replace(".jpg", "_org.jpg");
|
||||||
|
_filenamevon = _filenamevon.replace(".jpg", "_org.jpg");
|
||||||
|
FileDeleteOnServer(_filenamenach, _basepath);
|
||||||
|
FileCopyOnServer(_filenamevon, _filenamenach, _basepath);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
SaveConfigToServer(_basepath);
|
SaveConfigToServer(_basepath);
|
||||||
|
|
||||||
var namezw = zw["name"];
|
|
||||||
FileCopyOnServer("/img_tmp/ref_zw.jpg", namezw, _basepath);
|
|
||||||
var namezw = zw["name"].replace(".jpg", "_org.jpg");
|
|
||||||
FileCopyOnServer("/img_tmp/ref_zw_org.jpg", namezw, _basepath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function MakeContrastImageZW(zw, _enhance, _basepath){
|
function MakeContrastImageZW(zw, _enhance, _basepath){
|
||||||
url = _basepath + "/editflow.html?task=cutref&in=/config/reference.jpg&out=/img_tmp/ref_zw.jpg" + "&x=" + zw["x"] + "&y=" + zw["y"] + "&dx=" + zw["dx"] + "&dy=" + zw["dy"];
|
_filename = zw["name"].replace("/config/", "/img_tmp/");
|
||||||
|
url = _basepath + "/editflow.html?task=cutref&in=/config/reference.jpg&out=" + _filename + "&x=" + zw["x"] + "&y=" + zw["y"] + "&dx=" + zw["dx"] + "&dy=" + zw["dy"];
|
||||||
if (_enhance == true){
|
if (_enhance == true){
|
||||||
url = url + "&enhance=true";
|
url = url + "&enhance=true";
|
||||||
}
|
}
|
||||||
@@ -313,19 +374,6 @@ function MakeContrastImageZW(zw, _enhance, _basepath){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createReader(file) {
|
|
||||||
var image = new Image();
|
|
||||||
reader.onload = function(evt) {
|
|
||||||
var image = new Image();
|
|
||||||
image.onload = function(evt) {
|
|
||||||
var width = this.width;
|
|
||||||
var height = this.height;
|
|
||||||
alert (width); // will produce something like 198
|
|
||||||
};
|
|
||||||
image.src = evt.target.result;
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
function GetReferenceSize(name){
|
function GetReferenceSize(name){
|
||||||
img = new Image();
|
img = new Image();
|
||||||
@@ -346,83 +394,6 @@ function GetReferenceSize(name){
|
|||||||
return [img.width, img.height];
|
return [img.width, img.height];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function ZerlegeZeile(input)
|
|
||||||
{
|
|
||||||
var Output = Array(0);
|
|
||||||
delimiter = " =,";
|
|
||||||
|
|
||||||
input = trim(input, delimiter);
|
|
||||||
var pos = findDelimiterPos(input, delimiter);
|
|
||||||
var token;
|
|
||||||
while (pos > -1) {
|
|
||||||
token = input.substr(0, pos);
|
|
||||||
token = trim(token, delimiter);
|
|
||||||
Output.push(token);
|
|
||||||
input = input.substr(pos+1, input.length);
|
|
||||||
input = trim(input, delimiter);
|
|
||||||
pos = findDelimiterPos(input, delimiter);
|
|
||||||
}
|
|
||||||
Output.push(input);
|
|
||||||
|
|
||||||
return Output;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function findDelimiterPos(input, delimiter)
|
|
||||||
{
|
|
||||||
var pos = -1;
|
|
||||||
var zw;
|
|
||||||
var akt_del;
|
|
||||||
|
|
||||||
for (var anz = 0; anz < delimiter.length; ++anz)
|
|
||||||
{
|
|
||||||
akt_del = delimiter[anz];
|
|
||||||
zw = input.indexOf(akt_del);
|
|
||||||
if (zw > -1)
|
|
||||||
{
|
|
||||||
if (pos > -1)
|
|
||||||
{
|
|
||||||
if (zw < pos)
|
|
||||||
pos = zw;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
pos = zw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function trim(istring, adddelimiter)
|
|
||||||
{
|
|
||||||
while ((istring.length > 0) && (adddelimiter.indexOf(istring[0]) >= 0)){
|
|
||||||
istring = istring.substr(1, istring.length-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((istring.length > 0) && (adddelimiter.indexOf(istring[istring.length-1]) >= 0)){
|
|
||||||
istring = istring.substr(0, istring.length-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return istring;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function loadConfig(_basepath) {
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
try {
|
|
||||||
url = _basepath + '/fileserver/config/config.ini';
|
|
||||||
xhttp.open("GET", url, false);
|
|
||||||
xhttp.send();
|
|
||||||
config_gesamt = xhttp.responseText;
|
|
||||||
}
|
|
||||||
catch (error)
|
|
||||||
{
|
|
||||||
// alert("Deleting Config.ini failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getConfig() {
|
function getConfig() {
|
||||||
return config_gesamt;
|
return config_gesamt;
|
||||||
@@ -438,76 +409,7 @@ function dataURLtoBlob(dataurl) {
|
|||||||
}
|
}
|
||||||
return new Blob([u8arr], {type:mime});
|
return new Blob([u8arr], {type:mime});
|
||||||
}
|
}
|
||||||
|
|
||||||
function FileCopyOnServer(_source, _target, _basepath = ""){
|
|
||||||
url = _basepath + "/editflow.html?task=copy&in=" + _source + "&out=" + _target;
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
try {
|
|
||||||
xhttp.open("GET", url, false);
|
|
||||||
xhttp.send(); }
|
|
||||||
catch (error)
|
|
||||||
{
|
|
||||||
// alert("Deleting Config.ini failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function FileDeleteOnServer(_filename, _basepath = ""){
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
var okay = false;
|
|
||||||
|
|
||||||
xhttp.onreadystatechange = function() {
|
|
||||||
if (xhttp.readyState == 4) {
|
|
||||||
if (xhttp.status == 200) {
|
|
||||||
okay = true;
|
|
||||||
} else if (xhttp.status == 0) {
|
|
||||||
// alert("Server closed the connection on delete abruptly!");
|
|
||||||
// location.reload()
|
|
||||||
} else {
|
|
||||||
// alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
|
||||||
// location.reload()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
var url = _basepath + "/delete" + _filename;
|
|
||||||
xhttp.open("POST", url, false);
|
|
||||||
xhttp.send();
|
|
||||||
}
|
|
||||||
catch (error)
|
|
||||||
{
|
|
||||||
// alert("Deleting Config.ini failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
return okay;
|
|
||||||
}
|
|
||||||
|
|
||||||
function FileSendContent(_content, _filename, _basepath = ""){
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
var okay = false;
|
|
||||||
|
|
||||||
xhttp.onreadystatechange = function() {
|
|
||||||
if (xhttp.readyState == 4) {
|
|
||||||
if (xhttp.status == 200) {
|
|
||||||
okay = true;
|
|
||||||
} else if (xhttp.status == 0) {
|
|
||||||
alert("Server closed the connection abruptly!");
|
|
||||||
} else {
|
|
||||||
alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
upload_path = _basepath + "/upload" + _filename;
|
|
||||||
xhttp.open("POST", upload_path, false);
|
|
||||||
xhttp.send(_content);
|
|
||||||
}
|
|
||||||
catch (error)
|
|
||||||
{
|
|
||||||
// alert("Deleting Config.ini failed");
|
|
||||||
}
|
|
||||||
return okay;
|
|
||||||
}
|
|
||||||
|
|
||||||
function SaveReferenceImage(_id_canvas, _filename, _doDelete, _basepath = ""){
|
function SaveReferenceImage(_id_canvas, _filename, _doDelete, _basepath = ""){
|
||||||
if (_doDelete){
|
if (_doDelete){
|
||||||
|
|||||||
264
sd-card/html/readconfigcommon.js
Normal file
264
sd-card/html/readconfigcommon.js
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
function readconfig_Version(){
|
||||||
|
return "1.0.0 - 20200910";
|
||||||
|
}
|
||||||
|
|
||||||
|
function SaveConfigToServer(_basepath){
|
||||||
|
// leere Zeilen am Ende löschen
|
||||||
|
var zw = config_split.length - 1;
|
||||||
|
while (config_split[zw] == "") {
|
||||||
|
config_split.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
var config_gesamt = "";
|
||||||
|
for (var i = 0; i < config_split.length; ++i)
|
||||||
|
{
|
||||||
|
config_gesamt = config_gesamt + config_split[i] + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
FileDeleteOnServer("/config/config.ini", _basepath);
|
||||||
|
|
||||||
|
FileSendContent(config_gesamt, "/config/config.ini", _basepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
function UpdateConfigFileReferenceChange(_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 = "InitialRotate = " + initalrotate["angle"];
|
||||||
|
var _pos = initalrotate["pos_config"];
|
||||||
|
config_split[_pos] = zeile;
|
||||||
|
|
||||||
|
var mirror = false;
|
||||||
|
if (initalrotate.hasOwnProperty("mirror")) {
|
||||||
|
mirror = initalrotate["mirror"];
|
||||||
|
}
|
||||||
|
var mirror_pos = -1;
|
||||||
|
if (initalrotate.hasOwnProperty("pos_config_mirror")) {
|
||||||
|
mirror_pos = initalrotate["pos_config_mirror"];
|
||||||
|
}
|
||||||
|
if (mirror_pos > -1) {
|
||||||
|
if (mirror) {
|
||||||
|
config_split[mirror_pos] = "InitialMirror = true";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
config_split[mirror_pos] = "InitialMirror = false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (mirror) { // neue Zeile muss an der richtigen Stelle eingefügt werden - hier direct nach [Alignment]
|
||||||
|
var aktline = 0;
|
||||||
|
|
||||||
|
while (aktline < config_split.length){
|
||||||
|
if (config_split[aktline].trim() == "[Alignment]") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
aktline++
|
||||||
|
}
|
||||||
|
|
||||||
|
// fuege neue Zeile in config_split ein
|
||||||
|
var zw = config_split[config_split.length-1];
|
||||||
|
config_split.push(zw);
|
||||||
|
for (var j = config_split.length-2; j > aktline + 1; --j){
|
||||||
|
config_split[j] = config_split[j-1];
|
||||||
|
}
|
||||||
|
|
||||||
|
config_split[aktline + 1] = "InitialMirror = True"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
var namezw = zw["name"].replace(".jpg", "_org.jpg");
|
||||||
|
FileCopyOnServer("/img_tmp/ref_zw_org.jpg", namezw, _basepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function createReader(file) {
|
||||||
|
var image = new Image();
|
||||||
|
reader.onload = function(evt) {
|
||||||
|
var image = new Image();
|
||||||
|
image.onload = function(evt) {
|
||||||
|
var width = this.width;
|
||||||
|
var height = this.height;
|
||||||
|
alert (width); // will produce something like 198
|
||||||
|
};
|
||||||
|
image.src = evt.target.result;
|
||||||
|
};
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function ZerlegeZeile(input)
|
||||||
|
{
|
||||||
|
var Output = Array(0);
|
||||||
|
delimiter = " =,\r";
|
||||||
|
|
||||||
|
input = trim(input, delimiter);
|
||||||
|
var pos = findDelimiterPos(input, delimiter);
|
||||||
|
var token;
|
||||||
|
while (pos > -1) {
|
||||||
|
token = input.substr(0, pos);
|
||||||
|
token = trim(token, delimiter);
|
||||||
|
Output.push(token);
|
||||||
|
input = input.substr(pos+1, input.length);
|
||||||
|
input = trim(input, delimiter);
|
||||||
|
pos = findDelimiterPos(input, delimiter);
|
||||||
|
}
|
||||||
|
Output.push(input);
|
||||||
|
|
||||||
|
return Output;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function findDelimiterPos(input, delimiter)
|
||||||
|
{
|
||||||
|
var pos = -1;
|
||||||
|
var zw;
|
||||||
|
var akt_del;
|
||||||
|
|
||||||
|
for (var anz = 0; anz < delimiter.length; ++anz)
|
||||||
|
{
|
||||||
|
akt_del = delimiter[anz];
|
||||||
|
zw = input.indexOf(akt_del);
|
||||||
|
if (zw > -1)
|
||||||
|
{
|
||||||
|
if (pos > -1)
|
||||||
|
{
|
||||||
|
if (zw < pos)
|
||||||
|
pos = zw;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pos = zw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function trim(istring, adddelimiter)
|
||||||
|
{
|
||||||
|
while ((istring.length > 0) && (adddelimiter.indexOf(istring[0]) >= 0)){
|
||||||
|
istring = istring.substr(1, istring.length-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((istring.length > 0) && (adddelimiter.indexOf(istring[istring.length-1]) >= 0)){
|
||||||
|
istring = istring.substr(0, istring.length-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return istring;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function loadConfig(_basepath) {
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
try {
|
||||||
|
url = _basepath + '/fileserver/config/config.ini';
|
||||||
|
xhttp.open("GET", url, false);
|
||||||
|
xhttp.send();
|
||||||
|
config_gesamt = xhttp.responseText;
|
||||||
|
config_gesamt = config_gesamt.replace("InitalRotate", "InitialRotate"); // Korrigiere Schreibfehler in config.ini !!!!!
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
// alert("Deleting Config.ini failed");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 FileCopyOnServer(_source, _target, _basepath = ""){
|
||||||
|
url = _basepath + "/editflow.html?task=copy&in=" + _source + "&out=" + _target;
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
try {
|
||||||
|
xhttp.open("GET", url, false);
|
||||||
|
xhttp.send(); }
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
// alert("Deleting Config.ini failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileDeleteOnServer(_filename, _basepath = ""){
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
var okay = false;
|
||||||
|
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (xhttp.readyState == 4) {
|
||||||
|
if (xhttp.status == 200) {
|
||||||
|
okay = true;
|
||||||
|
} else if (xhttp.status == 0) {
|
||||||
|
// alert("Server closed the connection on delete abruptly!");
|
||||||
|
// location.reload()
|
||||||
|
} else {
|
||||||
|
// alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
||||||
|
// location.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
var url = _basepath + "/delete" + _filename;
|
||||||
|
xhttp.open("POST", url, false);
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
// alert("Deleting Config.ini failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
return okay;
|
||||||
|
}
|
||||||
|
|
||||||
|
function FileSendContent(_content, _filename, _basepath = ""){
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
var okay = false;
|
||||||
|
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (xhttp.readyState == 4) {
|
||||||
|
if (xhttp.status == 200) {
|
||||||
|
okay = true;
|
||||||
|
} else if (xhttp.status == 0) {
|
||||||
|
alert("Server closed the connection abruptly!");
|
||||||
|
} else {
|
||||||
|
alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
upload_path = _basepath + "/upload" + _filename;
|
||||||
|
xhttp.open("POST", upload_path, false);
|
||||||
|
xhttp.send(_content);
|
||||||
|
}
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
// alert("Deleting Config.ini failed");
|
||||||
|
}
|
||||||
|
return okay;
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ function readconfig_Version(){
|
|||||||
var config_gesamt;
|
var config_gesamt;
|
||||||
var config_split;
|
var config_split;
|
||||||
var param;
|
var param;
|
||||||
|
var category;
|
||||||
var ref = new Array(2);
|
var ref = new Array(2);
|
||||||
|
|
||||||
function ParseConfig() {
|
function ParseConfig() {
|
||||||
@@ -12,35 +13,59 @@ function ParseConfig() {
|
|||||||
var aktline = 0;
|
var aktline = 0;
|
||||||
|
|
||||||
param = new Object();
|
param = new Object();
|
||||||
|
category = new Object();
|
||||||
|
|
||||||
var catname = "MakeImage";
|
var catname = "MakeImage";
|
||||||
|
category[catname] = new Object();
|
||||||
|
category[catname]["enabled"] = false;
|
||||||
|
category[catname]["found"] = false;
|
||||||
param[catname] = new Object();
|
param[catname] = new Object();
|
||||||
ParamAddValue(param, catname, "LogImageLocation");
|
ParamAddValue(param, catname, "LogImageLocation");
|
||||||
ParamAddValue(param, catname, "WaitBeforeTakingPicture");
|
ParamAddValue(param, catname, "WaitBeforeTakingPicture");
|
||||||
ParamAddValue(param, catname, "LogfileRetentionInDays");
|
ParamAddValue(param, catname, "LogfileRetentionInDays");
|
||||||
|
ParamAddValue(param, catname, "Brightness");
|
||||||
|
ParamAddValue(param, catname, "Contrast");
|
||||||
|
ParamAddValue(param, catname, "Saturation");
|
||||||
ParamAddValue(param, catname, "ImageQuality");
|
ParamAddValue(param, catname, "ImageQuality");
|
||||||
ParamAddValue(param, catname, "ImageSize");
|
ParamAddValue(param, catname, "ImageSize");
|
||||||
|
ParamAddValue(param, catname, "FixedExposure");
|
||||||
|
|
||||||
var catname = "Alignment";
|
var catname = "Alignment";
|
||||||
|
category[catname] = new Object();
|
||||||
|
category[catname]["enabled"] = false;
|
||||||
|
category[catname]["found"] = false;
|
||||||
param[catname] = new Object();
|
param[catname] = new Object();
|
||||||
|
ParamAddValue(param, catname, "InitialRotate");
|
||||||
|
ParamAddValue(param, catname, "InitialMirror");
|
||||||
ParamAddValue(param, catname, "SearchFieldX");
|
ParamAddValue(param, catname, "SearchFieldX");
|
||||||
ParamAddValue(param, catname, "SearchFieldY");
|
ParamAddValue(param, catname, "SearchFieldY");
|
||||||
|
ParamAddValue(param, catname, "AlignmentAlgo");
|
||||||
|
|
||||||
var catname = "Digits";
|
var catname = "Digits";
|
||||||
|
category[catname] = new Object();
|
||||||
|
category[catname]["enabled"] = false;
|
||||||
|
category[catname]["found"] = false;
|
||||||
param[catname] = new Object();
|
param[catname] = new Object();
|
||||||
ParamAddValue(param, catname, "Model");
|
ParamAddValue(param, catname, "Model");
|
||||||
ParamAddValue(param, catname, "LogImageLocation");
|
ParamAddValue(param, catname, "LogImageLocation");
|
||||||
ParamAddValue(param, catname, "LogfileRetentionInDays");
|
ParamAddValue(param, catname, "LogfileRetentionInDays");
|
||||||
ParamAddValue(param, catname, "ModelInputSize");
|
ParamAddValue(param, catname, "ModelInputSize", 2);
|
||||||
|
|
||||||
var catname = "Analog";
|
var catname = "Analog";
|
||||||
|
category[catname] = new Object();
|
||||||
|
category[catname]["enabled"] = false;
|
||||||
|
category[catname]["found"] = false;
|
||||||
param[catname] = new Object();
|
param[catname] = new Object();
|
||||||
ParamAddValue(param, catname, "Model");
|
ParamAddValue(param, catname, "Model");
|
||||||
ParamAddValue(param, catname, "LogImageLocation");
|
ParamAddValue(param, catname, "LogImageLocation");
|
||||||
ParamAddValue(param, catname, "LogfileRetentionInDays");
|
ParamAddValue(param, catname, "LogfileRetentionInDays");
|
||||||
ParamAddValue(param, catname, "ModelInputSize");
|
ParamAddValue(param, catname, "ModelInputSize", 2);
|
||||||
|
ParamAddValue(param, catname, "ExtendedResolution");
|
||||||
|
|
||||||
var catname = "PostProcessing";
|
var catname = "PostProcessing";
|
||||||
|
category[catname] = new Object();
|
||||||
|
category[catname]["enabled"] = false;
|
||||||
|
category[catname]["found"] = false;
|
||||||
param[catname] = new Object();
|
param[catname] = new Object();
|
||||||
ParamAddValue(param, catname, "DecimalShift");
|
ParamAddValue(param, catname, "DecimalShift");
|
||||||
ParamAddValue(param, catname, "PreValueUse");
|
ParamAddValue(param, catname, "PreValueUse");
|
||||||
@@ -51,6 +76,9 @@ function ParseConfig() {
|
|||||||
ParamAddValue(param, catname, "CheckDigitIncreaseConsistency");
|
ParamAddValue(param, catname, "CheckDigitIncreaseConsistency");
|
||||||
|
|
||||||
var catname = "MQTT";
|
var catname = "MQTT";
|
||||||
|
category[catname] = new Object();
|
||||||
|
category[catname]["enabled"] = false;
|
||||||
|
category[catname]["found"] = false;
|
||||||
param[catname] = new Object();
|
param[catname] = new Object();
|
||||||
ParamAddValue(param, catname, "Uri");
|
ParamAddValue(param, catname, "Uri");
|
||||||
ParamAddValue(param, catname, "Topic");
|
ParamAddValue(param, catname, "Topic");
|
||||||
@@ -60,226 +88,77 @@ function ParseConfig() {
|
|||||||
ParamAddValue(param, catname, "password");
|
ParamAddValue(param, catname, "password");
|
||||||
|
|
||||||
var catname = "AutoTimer";
|
var catname = "AutoTimer";
|
||||||
|
category[catname] = new Object();
|
||||||
|
category[catname]["enabled"] = false;
|
||||||
|
category[catname]["found"] = false;
|
||||||
param[catname] = new Object();
|
param[catname] = new Object();
|
||||||
ParamAddValue(param, catname, "AutoStart");
|
ParamAddValue(param, catname, "AutoStart");
|
||||||
ParamAddValue(param, catname, "Intervall");
|
ParamAddValue(param, catname, "Intervall");
|
||||||
|
|
||||||
var catname = "Debug";
|
var catname = "Debug";
|
||||||
|
category[catname] = new Object();
|
||||||
|
category[catname]["enabled"] = false;
|
||||||
|
category[catname]["found"] = false;
|
||||||
param[catname] = new Object();
|
param[catname] = new Object();
|
||||||
ParamAddValue(param, catname, "Logfile");
|
ParamAddValue(param, catname, "Logfile");
|
||||||
ParamAddValue(param, catname, "LogfileRetentionInDays");
|
ParamAddValue(param, catname, "LogfileRetentionInDays");
|
||||||
|
|
||||||
var catname = "System";
|
var catname = "System";
|
||||||
|
category[catname] = new Object();
|
||||||
|
category[catname]["enabled"] = false;
|
||||||
|
category[catname]["found"] = false;
|
||||||
param[catname] = new Object();
|
param[catname] = new Object();
|
||||||
ParamAddValue(param, catname, "TimeZone");
|
ParamAddValue(param, catname, "TimeZone");
|
||||||
|
ParamAddValue(param, catname, "TimeServer");
|
||||||
ParamAddValue(param, catname, "AutoAdjustSummertime");
|
ParamAddValue(param, catname, "AutoAdjustSummertime");
|
||||||
ParamAddValue(param, catname, "TimeUpdateIntervall");
|
ParamAddValue(param, catname, "Hostname");
|
||||||
ParamAddValue(param, catname, "SetupMode");
|
ParamAddValue(param, catname, "SetupMode");
|
||||||
|
|
||||||
while (aktline < config_split.length){
|
while (aktline < config_split.length){
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[MAKEIMAGE]") {
|
for (var cat in category) {
|
||||||
aktline = ParseConfigParamMakeImage(aktline);
|
zw = cat.toUpperCase();
|
||||||
continue;
|
zw1 = "[" + zw + "]";
|
||||||
|
zw2 = ";[" + zw + "]";
|
||||||
|
if ((config_split[aktline].trim().toUpperCase() == zw1) || (config_split[aktline].trim().toUpperCase() == zw2)) {
|
||||||
|
if (config_split[aktline].trim().toUpperCase() == zw1) {
|
||||||
|
category[cat]["enabled"] = true;
|
||||||
|
}
|
||||||
|
category[cat]["found"] = true;
|
||||||
|
category[cat]["line"] = aktline;
|
||||||
|
aktline = ParseConfigParamAll(aktline, cat);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[ALIGNMENT]") {
|
|
||||||
aktline = ParseConfigParamAlignment(aktline);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[DIGITS]") {
|
|
||||||
aktline = ParseConfigParamDigit(aktline);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[ANALOG]") {
|
|
||||||
aktline = ParseConfigParamAnalog(aktline);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[POSTPROCESSING]") {
|
|
||||||
aktline = ParseConfigParamPostProcessing(aktline);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[MQTT]") {
|
|
||||||
aktline = ParseConfigParamMQTT(aktline);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[AUTOTIMER]") {
|
|
||||||
aktline = ParseConfigParamAutoTimer(aktline);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[DEBUG]") {
|
|
||||||
aktline = ParseConfigParamDebug(aktline);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config_split[aktline].trim().toUpperCase() == "[SYSTEM]") {
|
|
||||||
aktline = ParseConfigParamSystem(aktline);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
aktline++;
|
aktline++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ParamAddValue(param, _cat, _param){
|
function ParamAddValue(param, _cat, _param, _anzParam = 1){
|
||||||
param[_cat][_param] = new Object();
|
param[_cat][_param] = new Object();
|
||||||
param[_cat][_param]["found"] = false;
|
param[_cat][_param]["found"] = false;
|
||||||
param[_cat][_param]["enabled"] = false;
|
param[_cat][_param]["enabled"] = false;
|
||||||
param[_cat][_param]["line"] = -1;
|
param[_cat][_param]["line"] = -1;
|
||||||
|
param[_cat][_param]["anzParam"] = _anzParam;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function ParseConfigParamSystem(_aktline){
|
|
||||||
var akt_ref = 0;
|
function ParseConfigParamAll(_aktline, _catname){
|
||||||
++_aktline;
|
++_aktline;
|
||||||
|
|
||||||
var catname = "System";
|
while ((_aktline < config_split.length)
|
||||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
&& !(config_split[_aktline][0] == "[")
|
||||||
var _input = config_split[_aktline];
|
&& !((config_split[_aktline][0] == ";") && (config_split[_aktline][1] == "["))) {
|
||||||
let [isCom, input] = isCommented(_input);
|
|
||||||
var linesplit = ZerlegeZeile(input, " =");
|
|
||||||
|
|
||||||
ParamExtractValue(param, linesplit, catname, "TimeZone", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "AutoAdjustSummertime", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "TimeUpdateIntervall", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "SetupMode", _aktline, isCom);
|
|
||||||
|
|
||||||
++_aktline;
|
|
||||||
}
|
|
||||||
return _aktline;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ParseConfigParamDebug(_aktline){
|
|
||||||
var akt_ref = 0;
|
|
||||||
++_aktline;
|
|
||||||
|
|
||||||
var catname = "Debug";
|
|
||||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
|
||||||
var _input = config_split[_aktline];
|
var _input = config_split[_aktline];
|
||||||
let [isCom, input] = isCommented(_input);
|
let [isCom, input] = isCommented(_input);
|
||||||
var linesplit = ZerlegeZeile(input);
|
var linesplit = ZerlegeZeile(input);
|
||||||
|
ParamExtractValueAll(param, linesplit, _catname, _aktline, isCom);
|
||||||
ParamExtractValue(param, linesplit, catname, "Logfile", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "LogfileRetentionInDays", _aktline, isCom);
|
|
||||||
|
|
||||||
++_aktline;
|
++_aktline;
|
||||||
}
|
}
|
||||||
return _aktline;
|
return _aktline;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ParseConfigParamAutoTimer(_aktline){
|
|
||||||
var akt_ref = 0;
|
|
||||||
++_aktline;
|
|
||||||
|
|
||||||
var catname = "AutoTimer";
|
|
||||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
|
||||||
var _input = config_split[_aktline];
|
|
||||||
let [isCom, input] = isCommented(_input);
|
|
||||||
var linesplit = ZerlegeZeile(input);
|
|
||||||
|
|
||||||
ParamExtractValue(param, linesplit, catname, "AutoStart", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "Intervall", _aktline, isCom);
|
|
||||||
|
|
||||||
++_aktline;
|
|
||||||
}
|
|
||||||
return _aktline;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ParseConfigParamMQTT(_aktline){
|
|
||||||
var akt_ref = 0;
|
|
||||||
++_aktline;
|
|
||||||
|
|
||||||
var catname = "MQTT";
|
|
||||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
|
||||||
var _input = config_split[_aktline];
|
|
||||||
let [isCom, input] = isCommented(_input);
|
|
||||||
var linesplit = ZerlegeZeile(input);
|
|
||||||
|
|
||||||
ParamExtractValue(param, linesplit, catname, "Uri", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "Topic", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "TopicError", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "ClientID", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "user", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "password", _aktline, isCom);
|
|
||||||
|
|
||||||
++_aktline;
|
|
||||||
}
|
|
||||||
return _aktline;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ParseConfigParamPostProcessing(_aktline){
|
|
||||||
var akt_ref = 0;
|
|
||||||
++_aktline;
|
|
||||||
|
|
||||||
var catname = "PostProcessing";
|
|
||||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
|
||||||
var _input = config_split[_aktline];
|
|
||||||
let [isCom, input] = isCommented(_input);
|
|
||||||
var linesplit = ZerlegeZeile(input);
|
|
||||||
|
|
||||||
ParamExtractValue(param, linesplit, catname, "DecimalShift", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "PreValueUse", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "PreValueAgeStartup", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "AllowNegativeRates", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "MaxRateValue", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "ErrorMessage", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "CheckDigitIncreaseConsistency", _aktline, isCom);
|
|
||||||
|
|
||||||
++_aktline;
|
|
||||||
}
|
|
||||||
return _aktline;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ParseConfigParamAnalog(_aktline){
|
|
||||||
var akt_ref = 0;
|
|
||||||
++_aktline;
|
|
||||||
|
|
||||||
var catname = "Analog";
|
|
||||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
|
||||||
var _input = config_split[_aktline];
|
|
||||||
let [isCom, input] = isCommented(_input);
|
|
||||||
var linesplit = ZerlegeZeile(input);
|
|
||||||
|
|
||||||
ParamExtractValue(param, linesplit, catname, "Model", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "LogImageLocation", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "LogfileRetentionInDays", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "ModelInputSize", _aktline, isCom, 2);
|
|
||||||
|
|
||||||
++_aktline;
|
|
||||||
}
|
|
||||||
return _aktline;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ParseConfigParamDigit(_aktline){
|
|
||||||
var akt_ref = 0;
|
|
||||||
++_aktline;
|
|
||||||
|
|
||||||
var catname = "Digits";
|
|
||||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
|
||||||
var _input = config_split[_aktline];
|
|
||||||
let [isCom, input] = isCommented(_input);
|
|
||||||
var linesplit = ZerlegeZeile(input);
|
|
||||||
|
|
||||||
ParamExtractValue(param, linesplit, catname, "Model", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "LogImageLocation", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "LogfileRetentionInDays", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "ModelInputSize", _aktline, isCom, 2);
|
|
||||||
|
|
||||||
++_aktline;
|
|
||||||
}
|
|
||||||
return _aktline;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function ParamExtractValue(_param, _linesplit, _catname, _paramname, _aktline, _iscom, _anzvalue = 1){
|
function ParamExtractValue(_param, _linesplit, _catname, _paramname, _aktline, _iscom, _anzvalue = 1){
|
||||||
if ((_linesplit[0].toUpperCase() == _paramname.toUpperCase()) && (_linesplit.length > _anzvalue))
|
if ((_linesplit[0].toUpperCase() == _paramname.toUpperCase()) && (_linesplit.length > _anzvalue))
|
||||||
{
|
{
|
||||||
@@ -293,66 +172,40 @@ function ParamExtractValue(_param, _linesplit, _catname, _paramname, _aktline, _
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ParamExtractValueAll(_param, _linesplit, _catname, _aktline, _iscom){
|
||||||
function ParseConfigParamAlignment(_aktline){
|
for (var paramname in _param[_catname]) {
|
||||||
var akt_ref = 0;
|
if ((_linesplit[0].toUpperCase() == paramname.toUpperCase()) && (_linesplit.length > _param[_catname][paramname]["anzParam"]))
|
||||||
++_aktline;
|
{
|
||||||
|
_param[_catname][paramname]["found"] = true;
|
||||||
var catname = "Alignment";
|
_param[_catname][paramname]["enabled"] = !_iscom;
|
||||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
_param[_catname][paramname]["line"] = _aktline;
|
||||||
var _input = config_split[_aktline];
|
for (var j = 1; j <= _param[_catname][paramname]["anzParam"]; ++j) {
|
||||||
let [isCom, input] = isCommented(_input);
|
_param[_catname][paramname]["value"+j] = _linesplit[j];
|
||||||
var linesplit = ZerlegeZeile(input);
|
}
|
||||||
|
}
|
||||||
ParamExtractValue(param, linesplit, catname, "SearchFieldX", _aktline, isCom);
|
}
|
||||||
ParamExtractValue(param, linesplit, catname, "SearchFieldY", _aktline, isCom);
|
|
||||||
|
|
||||||
++_aktline;
|
|
||||||
}
|
|
||||||
return _aktline;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ParseConfigParamMakeImage(_aktline){
|
|
||||||
var akt_ref = 0;
|
|
||||||
++_aktline;
|
|
||||||
|
|
||||||
var catname = "MakeImage";
|
|
||||||
while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
|
|
||||||
var _input = config_split[_aktline];
|
|
||||||
let [isCom, input] = isCommented(_input);
|
|
||||||
var linesplit = ZerlegeZeile(input);
|
|
||||||
|
|
||||||
ParamExtractValue(param, linesplit, catname, "LogImageLocation", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "WaitBeforeTakingPicture", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "LogfileRetentionInDays", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "ImageQuality", _aktline, isCom);
|
|
||||||
ParamExtractValue(param, linesplit, catname, "ImageSize", _aktline, isCom);
|
|
||||||
|
|
||||||
++_aktline;
|
|
||||||
}
|
|
||||||
return _aktline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConfigParameters() {
|
function getConfigParameters() {
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setConfigParameters(_param) {
|
function setConfigParameters(_param, _category = "") {
|
||||||
for (var cat in _param) {
|
for (var cat in _param) {
|
||||||
for (var name in _param[cat]) {
|
for (var name in _param[cat]) {
|
||||||
param[cat][name]["found"] = _param[cat][name]["found"];
|
param[cat][name]["found"] = _param[cat][name]["found"];
|
||||||
param[cat][name]["enabled"] = _param[cat][name]["enabled"];
|
param[cat][name]["enabled"] = _param[cat][name]["enabled"];
|
||||||
param[cat][name]["line"] = _param[cat][name]["line"];
|
param[cat][name]["line"] = _param[cat][name]["line"];
|
||||||
|
|
||||||
param[cat][name]["anzpara"] = _param[cat][name]["anzpara"];
|
param[cat][name]["anzParam"] = _param[cat][name]["anzParam"];
|
||||||
for (var j = 1; j <= _param[cat][name]["anzpara"]; ++j) {
|
for (var j = 1; j <= _param[cat][name]["anzParam"]; ++j) {
|
||||||
param[cat][name]["value"+j] = _param[cat][name]["value"+j];
|
param[cat][name]["value"+j] = _param[cat][name]["value"+j];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param[cat][name]["found"]) {
|
if (param[cat][name]["found"]) {
|
||||||
var text = name + " ="
|
var text = name + " ="
|
||||||
|
|
||||||
for (var j = 1; j <= _param[cat][name]["anzpara"]; ++j) {
|
for (var j = 1; j <= _param[cat][name]["anzParam"]; ++j) {
|
||||||
text = text + " " + param[cat][name]["value"+j];
|
text = text + " " + param[cat][name]["value"+j];
|
||||||
}
|
}
|
||||||
if (!param[cat][name]["enabled"]) {
|
if (!param[cat][name]["enabled"]) {
|
||||||
@@ -363,6 +216,19 @@ function setConfigParameters(_param) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (var cat in _category) {
|
||||||
|
if (category[cat]["found"])
|
||||||
|
{
|
||||||
|
category[cat]["enabled"] = _category[cat]["enabled"];
|
||||||
|
text = "[" + cat + "]";
|
||||||
|
if (!category[cat]["enabled"]) {
|
||||||
|
text = ";" + text;
|
||||||
|
}
|
||||||
|
config_split[category[cat]["line"]] = text;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
config_gesamt = config_split[0];
|
config_gesamt = config_split[0];
|
||||||
for (var i = 1; i < config_split.length; ++i){
|
for (var i = 1; i < config_split.length; ++i){
|
||||||
config_gesamt = config_gesamt + "\n" + config_split[i];
|
config_gesamt = config_gesamt + "\n" + config_split[i];
|
||||||
@@ -396,171 +262,16 @@ function SaveConfigToServer(_basepath){
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileDeleteOnServer("/config/config.ini", _basepath);
|
FileDeleteOnServer("/config/config.ini", _basepath);
|
||||||
|
|
||||||
FileSendContent(config_gesamt, "/config/config.ini", _basepath);
|
FileSendContent(config_gesamt, "/config/config.ini", _basepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createReader(file) {
|
|
||||||
var image = new Image();
|
|
||||||
reader.onload = function(evt) {
|
|
||||||
var image = new Image();
|
|
||||||
image.onload = function(evt) {
|
|
||||||
var width = this.width;
|
|
||||||
var height = this.height;
|
|
||||||
alert (width); // will produce something like 198
|
|
||||||
};
|
|
||||||
image.src = evt.target.result;
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ZerlegeZeile(input, delimiter = " =,")
|
|
||||||
{
|
|
||||||
var Output = Array(0);
|
|
||||||
// delimiter = " =,";
|
|
||||||
|
|
||||||
input = trim(input, delimiter);
|
|
||||||
var pos = findDelimiterPos(input, delimiter);
|
|
||||||
var token;
|
|
||||||
while (pos > -1) {
|
|
||||||
token = input.substr(0, pos);
|
|
||||||
token = trim(token, delimiter);
|
|
||||||
Output.push(token);
|
|
||||||
input = input.substr(pos+1, input.length);
|
|
||||||
input = trim(input, delimiter);
|
|
||||||
pos = findDelimiterPos(input, delimiter);
|
|
||||||
}
|
|
||||||
Output.push(input);
|
|
||||||
|
|
||||||
return Output;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function findDelimiterPos(input, delimiter)
|
|
||||||
{
|
|
||||||
var pos = -1;
|
|
||||||
var zw;
|
|
||||||
var akt_del;
|
|
||||||
|
|
||||||
for (var anz = 0; anz < delimiter.length; ++anz)
|
|
||||||
{
|
|
||||||
akt_del = delimiter[anz];
|
|
||||||
zw = input.indexOf(akt_del);
|
|
||||||
if (zw > -1)
|
|
||||||
{
|
|
||||||
if (pos > -1)
|
|
||||||
{
|
|
||||||
if (zw < pos)
|
|
||||||
pos = zw;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
pos = zw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
function trim(istring, adddelimiter)
|
|
||||||
{
|
|
||||||
while ((istring.length > 0) && (adddelimiter.indexOf(istring[0]) >= 0)){
|
|
||||||
istring = istring.substr(1, istring.length-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((istring.length > 0) && (adddelimiter.indexOf(istring[istring.length-1]) >= 0)){
|
|
||||||
istring = istring.substr(0, istring.length-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return istring;
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadConfig(_basepath) {
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
config_gesamt = "";
|
|
||||||
try {
|
|
||||||
url = _basepath + '/fileserver/config/config.ini';
|
|
||||||
xhttp.open("GET", url, false);
|
|
||||||
xhttp.send();
|
|
||||||
config_gesamt = xhttp.responseText;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (error)
|
|
||||||
{
|
|
||||||
// alert("Deleting Config.ini failed");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getConfig() {
|
function getConfig() {
|
||||||
return config_gesamt;
|
return config_gesamt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getConfigCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function FileCopyOnServer(_source, _target, _basepath = ""){
|
|
||||||
url = _basepath + "/editflow.html?task=copy&in=" + _source + "&out=" + _target;
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
try {
|
|
||||||
xhttp.open("GET", url, false);
|
|
||||||
xhttp.send(); }
|
|
||||||
catch (error)
|
|
||||||
{
|
|
||||||
// alert("Deleting Config.ini failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function FileDeleteOnServer(_filename, _basepath = ""){
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
var okay = false;
|
|
||||||
|
|
||||||
xhttp.onreadystatechange = function() {
|
|
||||||
if (xhttp.readyState == 4) {
|
|
||||||
if (xhttp.status == 200) {
|
|
||||||
okay = true;
|
|
||||||
} else if (xhttp.status == 0) {
|
|
||||||
// alert("Server closed the connection on delete abruptly!");
|
|
||||||
// location.reload()
|
|
||||||
} else {
|
|
||||||
// alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
|
||||||
// location.reload()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
var url = _basepath + "/delete" + _filename;
|
|
||||||
xhttp.open("POST", url, false);
|
|
||||||
xhttp.send();
|
|
||||||
}
|
|
||||||
catch (error)
|
|
||||||
{
|
|
||||||
// alert("Deleting Config.ini failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
return okay;
|
|
||||||
}
|
|
||||||
|
|
||||||
function FileSendContent(_content, _filename, _basepath = ""){
|
|
||||||
var xhttp = new XMLHttpRequest();
|
|
||||||
var okay = false;
|
|
||||||
|
|
||||||
xhttp.onreadystatechange = function() {
|
|
||||||
if (xhttp.readyState == 4) {
|
|
||||||
if (xhttp.status == 200) {
|
|
||||||
okay = true;
|
|
||||||
} else if (xhttp.status == 0) {
|
|
||||||
alert("Server closed the connection abruptly!");
|
|
||||||
} else {
|
|
||||||
alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
upload_path = _basepath + "/upload" + _filename;
|
|
||||||
xhttp.open("POST", upload_path, false);
|
|
||||||
xhttp.send(_content);
|
|
||||||
}
|
|
||||||
catch (error)
|
|
||||||
{
|
|
||||||
// alert("Deleting Config.ini failed");
|
|
||||||
}
|
|
||||||
return okay;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html style="width: fit-content">
|
|
||||||
<head>
|
|
||||||
<title>jomjol - AI on the edge</title>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
|
|
||||||
div {
|
|
||||||
text-align:center;
|
|
||||||
width:995px;
|
|
||||||
height: 600px;
|
|
||||||
}
|
|
||||||
.iframe_work {
|
|
||||||
display:inline-block;
|
|
||||||
margin: 0px auto;
|
|
||||||
width:70%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.iframe_info {
|
|
||||||
display:inline-block;
|
|
||||||
margin: 0px auto;
|
|
||||||
width:20%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body style="font-family: arial">
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<iframe class="iframe_work" name="iframe_work" id="iframe_work" src="/wasserzaehler_roi.html" allowfullscreen></iframe>
|
|
||||||
<iframe class="iframe_info" name="iframe_info" id="iframe_info" src="/wasserzaehler_roi.html" allowfullscreen></iframe>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user