AI-on-the-edge-device icon indicating copy to clipboard operation
AI-on-the-edge-device copied to clipboard

Add optional termination condition when alignment markers are not discovered

Open detzen opened this issue 1 year ago • 8 comments

The Feature

Hello, I have a new digital watermeter which shows the water consumption as m³ with 3 decimal places on its display per default. Approximately every 3 minutes, the device starts a sequence in which the firmware status, display test, daily statistics, weekly statistics and a few other things are shown on one after another. For more details, please see discussion #3382.

As described in the mentioned discussion, I choosed aligment markers which only appear during the display test and the display of the current counter reading, because I initially thought, that digit detection will only take place when those markers are detected. But unfortunately, this is actually not the case and I have to deal with incorrectly recognized digits, when the picture has been taken at a time where e.g. the weekly stats are displayed.

I think the described problem could be solved (or prevented), if there would be a configuration option for a termination condition like "Don't try to detect digits, when alignment markers were not recognized". In addition to false detections, such an option would also save CPU cycles on the ESP.

detzen avatar Nov 17 '24 16:11 detzen

here's something to test if you feel like it: AI-on-the-edge-device__update__test_(32d2fbb).zip (based on version 16.0.0-RC4)

SybexX avatar Nov 18 '24 03:11 SybexX

I installed the modified firmware and as I can tell so far, it's working as desired. I'll continue to monitor it. Is there a way to access your code to keep track what has been modified? Or will you raise a pull-request to implement it in a future release?

detzen avatar Nov 18 '24 22:11 detzen

Great idea! It'll also prevent wrong meter readings through e.g. shifted esp holder. Hope it will make it in the next release ;)

pidator avatar Nov 20 '24 16:11 pidator

As explained in https://github.com/jomjol/AI-on-the-edge-device/discussions/3382#discussioncomment-11218614, there is no such thing as "marker not found". The only way would be to have kind of a threshold.

@SybexX Since I don't see your code change, I have no clue how your approach looks like. Can you provide it as a brach or PR?

caco3 avatar Dec 01 '24 22:12 caco3

@SybexX Will there be any chance, that your enhancement will be implemented in a future release?

detzen avatar Dec 15 '24 21:12 detzen

@SybexX does the current release in this repo containing your additional termination condition? I've got notified by mail about your last and already deleted answer here in this issue and unfortunatly the provided links to the github action aren't working anymore too.

pidator avatar Jan 10 '25 12:01 pidator

@SybexX @caco3 Can you please give a short update, if there will be any chance, that the enhancement made by Sybexx will be implemented in a future release? Thanks.

detzen avatar Jan 23 '25 21:01 detzen

@detzen This depends if @SybexX has the time and will to provide it. Currently he is busy with some other issues.

caco3 avatar Jan 24 '25 08:01 caco3

@SybexX @caco3 I just noticed, that 16.0.0 was released recently. Because there are lots of new useful features implemented, I would like to upgrade. Because of my described problem, I'm currently bound to Sybexx's version AI-on-the-edge-device__update__test(32d2fbb) which is based on 16.0.0-RC4. I wonder if there are any new features in 16.0.0 that could solve my problem?

detzen avatar Apr 29 '25 20:04 detzen

I wonder if there are any new features in 16.0.0 that could solve my problem?

If you think about a termination feature, then the answer is no. Else please check the changelog.

caco3 avatar Apr 29 '25 21:04 caco3

https://github.com/SybexX/AI-on-the-edge-device/actions/runs/14817593066 (not tested by me yet)

SybexX avatar May 01 '25 04:05 SybexX

Hi @SybexX many thanks for your efforts. I installed your provided version and as far I can tell, it works as expected. Is there a chance, that you will implement it in a official future release? That would be really nice. Regards, Alex

detzen avatar May 02 '25 08:05 detzen

https://github.com/SybexX/AI-on-the-edge-device/actions/runs/14817593066 (not tested by me yet)

the termination of further processing when aligning failed does work for me too - as aspected:

2025-05-06T09:31:19+0200,main,,,9641.000000,,0,Alignment failed,3.5,0.6,-1.0,6.7,4.6,4.7
2025-05-06T09:34:19+0200,main,,,9641.000000,,0,Alignment failed,3.5,0.5,-1.0,6.7,4.6,4.8
2025-05-06T09:37:19+0200,main,,,9641.000000,,0,Alignment failed,3.5,0.5,0.7,6.8,4.6,4.8
2025-05-06T09:40:19+0200,main,,,9641.000000,,0,Alignment failed,3.5,0.6,-1.0,6.6,4.7,4.7
2025-05-06T09:43:19+0200,main,,,9641.000000,,0,Alignment failed,3.6,0.5,0.6,6.8,4.6,4.7
2025-05-06T09:46:19+0200,main,,,9641.000000,,0,Alignment failed,3.5,0.5,-1.0,6.6,4.7,4.7
2025-05-06T09:49:19+0200,main,,,9641.000000,,0,Alignment failed,3.5,0.5,-1.0,6.7,4.6,4.7
2025-05-06T09:52:44+0200,main,,,9641.000000,,0,Alignment failed,3.5,0.5,-1.0,6.7,4.6,4.6
2025-05-06T10:03:28+0200,main,009665,9665,9665,0.000000,0,no error,0.1,0.1,9.0,6.0,6.0,5.2
2025-05-06T10:06:28+0200,main,009665,9665,9665,0.000000,0,no error,0.1,0.1,9.0,6.0,6.0,5.3
2025-05-06T10:09:28+0200,main,009665,9665,9665,0.000000,0,no error,0.1,0.2,9.0,6.0,6.0,5.2
2025-05-06T10:12:28+0200,main,009665,9665,9665,0.000000,0,no error,0.1,0.1,9.0,6.0,6.0,5.2
2025-05-06T10:15:28+0200,main,009665,9665,9665,0.000000,0,no error,0.2,0.2,9.0,6.0,5.9,5.1
2025-05-06T10:18:28+0200,main,009665,9665,9665,0.000000,0,no error,0.1,0.2,9.0,6.0,6.0,5.2
2025-05-06T10:21:28+0200,main,009665,9665,9665,0.000000,0,no error,0.2,0.1,9.0,6.0,5.9,5.2

Great, I love this feature :) But my ESP seems to run in other problems after updating to this 16.0 based version now

[0d00h00m03s] 2025-05-06T09:56:45 <WRN> [MAIN] Camera init failed (0x105), retrying...
[0d00h00m05s] 2025-05-06T09:56:47 <ERR> [MAIN] Camera init failed (0x105)! Check camera module and/or proper electrical connection
[0d00h00m05s] 2025-05-06T09:56:47 <ERR> [HELPER] New System Status: 0x00000004

Following the advice https://github.com/jomjol/AI-on-the-edge-device/issues/3714 https://github.com/jomjol/AI-on-the-edge-device/issues/3633 https://github.com/jomjol/AI-on-the-edge-device/discussions/3476 to power off the ESP completely for some minutes brought back the frontend. Reboots (4-8) didn't help at all! But my previously working camera isn't detected nevertheless and the processing only started after ~2min and the following log entries:

[0d00h00m15s] 2025-05-06T11:56:58 <ERR> [MAIN] Initialization failed. Flow task start aborted. Loading reduced web interface...
[0d00h00m24s] 2025-05-06T11:57:06 <ERR> [MAIN SERVER] We have a critical error, not serving main page!
[0d00h00m25s] 2025-05-06T11:57:07 <ERR> [MAIN SERVER] We have a critical error, not serving main page!
[0d00h00m26s] 2025-05-06T11:57:09 <ERR> [MAIN SERVER] We have a critical error, not serving main page!
[0d00h00m29s] 2025-05-06T11:57:11 <ERR> [MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m09s] 2025-05-06T11:58:51 <ERR> [MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m12s] 2025-05-06T11:58:55 <ERR> [MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m14s] 2025-05-06T11:58:56 <ERR> [MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m15s] 2025-05-06T11:58:58 <ERR> [MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m16s] 2025-05-06T11:58:58 <ERR> [MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m16s] 2025-05-06T11:58:58 <ERR> [MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m16s] 2025-05-06T11:58:59 <ERR> [MAIN SERVER] We have a critical error, not serving main page!

Any hints?

pidator avatar May 06 '25 12:05 pidator

[0d00h02m14s] 2025-05-06T11:58:56 <ERR> [MAIN SERVER] We have a critical error, not serving main page!

This message comes if the SYSTEM_STATUS is PSRAM_BAD or CAM_BAD or SDCARD_CHECK_BAD or FOLDER_CHECK_BAD. What do the log entries say before these?

SybexX avatar May 06 '25 13:05 SybexX

Probably the CAM_BAD failure posted above... here's the full log:

[0d00h00m00s] 2025-05-06T09:56:42	<INF>	[MAIN] =================================================
[0d00h00m00s] 2025-05-06T09:56:42	<INF>	[MAIN] ==================== Start ======================
[0d00h00m00s] 2025-05-06T09:56:42	<INF>	[MAIN] =================================================
[0d00h00m00s] 2025-05-06T09:56:42	<INF>	[SDCARD] Basic R/W check started...
[0d00h00m00s] 2025-05-06T09:56:42	<INF>	[SDCARD] Basic R/W check successful
[0d00h00m00s] 2025-05-06T09:56:43	<INF>	[MAIN] PSRAM size: 8388608 byte (8MB / 64MBit)
[0d00h00m00s] 2025-05-06T09:56:43	<INF>	[MAIN] Total heap: 4378411 byte
[0d00h00m03s] 2025-05-06T09:56:45	<WRN>	[MAIN] Camera init failed (0x105), retrying...
[0d00h00m05s] 2025-05-06T09:56:47	<ERR>	[MAIN] Camera init failed (0x105)! Check camera module and/or proper electrical connection
[0d00h00m05s] 2025-05-06T09:56:47	<ERR>	[HELPER] New System Status: 0x00000004
[0d00h00m05s] 2025-05-06T09:56:47	<INF>	[SNTP] TimeServer not defined, using default: pool.ntp.org
[0d00h00m05s] 2025-05-06T09:56:47	<INF>	[SNTP] Configuring NTP Client...
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[SNTP] Time zone set to CET-1CEST,M3.5.0,M10.5.0/3
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[SNTP] time zone: +0200 Delta to UTC: 7200 seconds
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[SNTP] Time is already set: 2025-05-06 11:56:47
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[MAIN] CPU frequency: 160 MHz
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[SDCARD] Folder/file presence check started...
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[SDCARD] Folder/file presence check successful
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[MAIN] Development-Branch: add_demolition_condition_for_image_alignment (Commit: 8516356), Date/Time: 2025-05-01 04:11, Web UI: Development-Branch: add_demolition_condition_for_image_alignment (Commit: 8516356)
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[MAIN] Reset reason: Via esp_restart
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[WLANINI] SSID: XXXXXXXX
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[WLANINI] Password: XXXXXXXX
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[WLANINI] Hostname: watermeter
[0d00h00m05s] 2025-05-06T11:56:47	<INF>	[WLANINI] RSSIThreshold: -75
[0d00h00m05s] 2025-05-06T11:56:48	<INF>	[MAIN] WLAN config loaded, init WIFI...
[0d00h00m05s] 2025-05-06T11:56:48	<INF>	[WIFI] Automatic interface config --> Use DHCP service
[0d00h00m05s] 2025-05-06T11:56:48	<INF>	[WIFI] Set hostname to: watermeter
[0d00h00m05s] 2025-05-06T11:56:48	<INF>	[WIFI] Init successful
[0d00h00m08s] 2025-05-06T11:56:50	<INF>	[WIFI] Connected to: XXXXXXXX, RSSI: -66
[0d00h00m09s] 2025-05-06T11:56:52	<INF>	[WIFI] Assigned IP: 192.168.xxx.xxx
[0d00h00m12s] 2025-05-06T11:56:54	<INF>	[SNTP] Time is synced with NTP Server pool.ntp.org: 2025-05-06 11:56:54
[0d00h00m13s] 2025-05-06T11:56:56	<INF>	[MAIN] Device info: CPU cores: 2, Chip revision: 301
[0d00h00m13s] 2025-05-06T11:56:56	<INF>	[MAIN] SD card info: Name: SU08G, Capacity: 7580MB, Free: 7552MB
[0d00h00m15s] 2025-05-06T11:56:58	<ERR>	[MAIN] Initialization failed. Flow task start aborted. Loading reduced web interface...
[0d00h00m24s] 2025-05-06T11:57:06	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h00m25s] 2025-05-06T11:57:07	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h00m26s] 2025-05-06T11:57:09	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h00m29s] 2025-05-06T11:57:11	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m09s] 2025-05-06T11:58:51	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m12s] 2025-05-06T11:58:55	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m14s] 2025-05-06T11:58:56	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m15s] 2025-05-06T11:58:58	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m16s] 2025-05-06T11:58:58	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m16s] 2025-05-06T11:58:58	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h02m16s] 2025-05-06T11:58:59	<ERR>	[MAIN SERVER] We have a critical error, not serving main page!
[0d00h01m16s] 2025-05-06T13:11:31	<ERR>	[POSTPROC] main: Raw: 009664, Value: , Status: Neg. Rate - Read: 9664 - Raw: 009664 - Pre: 9665 
[0d00h04m16s] 2025-05-06T13:14:31	<ERR>	[POSTPROC] main: Raw: 009664, Value: , Status: Neg. Rate - Read: 9664 - Raw: 009664 - Pre: 9665

pidator avatar May 06 '25 14:05 pidator

does it work again if you revert to the official v16.0.0?

caco3 avatar May 06 '25 16:05 caco3

does it work again if you revert to the official v16.0.0?

thanks for pointing me to this idea: I was updating my ESP from an old 15.7.x rolling version directly to the version provided by @SybexX. After flashing the official v16.0.0 my camera gots detected directly now.

[0d00h00m03s] 2025-05-06T20:02:21 <INF> [MAIN] Camera info: PID: 0x26, VER: 0x42, MIDL: 0x7f, MIDH: 0xa2

Everything is working without any errors.

Then I installed the 8bd1800 version again and this time, the systems starts with detected camera and no errors too. Sorry for the confusion and thanks for the help.

pidator avatar May 06 '25 20:05 pidator