Giter VIP home page Giter VIP logo

water-meter-system-complete's Introduction

This code is depreciated and will not be maintained any more!

water-meter-system-complete


Update 04.09.2020: There is an update version available, which is more compact on the hardware side and much easier from software side, because it is an all in one device. It does not need a docker container for image analysis any more as everything, including a web based configuration server is running on the ESP32

Software: https://github.com/jomjol/AI-on-the-edge-device/wiki

Hardware: https://www.thingiverse.com/thing:4573481


This repository describes a readout of an analog water meter with the help of a camera and image processing, including neural network processing to extract the values. The interface is a local HTTP-server, that takes an image as input, processes it and gives as an output the readout of the water meter counter, including the subdigits.

Although the server can be installed manually in a windows as well as an Linux system, it is strongly recommended to use the provided docker containers. The installation is due to the use of image processing (OpenCV, ...) and Neural Network Systems (Tensorflow) not really straight forward and I needed a lot of try and error.

Therefore I have decided to capsule the server in a docker container.

This is available for an Intel based System (e.g. Synology Docker) as well as an Raspberry PI Version.

Docker-Versions

Label Content Comments
rolling Experimental version for amd64-systems (e.g. Intel processors) newest features, not fully tested
raspi-rolling Experimental version for armv7-systems (Raspberry PI3 and higher) newest features, not fully tested
latest Latest stable version for amd64-systems (e.g. Intel processors) Currently identical to 6.1.1 (2020-04-23)
raspi-latest Latest stable version for armv7-systems (Raspberry PI3 and higher) Currently identical to 6.1.1 (2020-04-23)
v5.x Persistant prevalue, modified docker structure Details see below
v4.x Update to Tensorflow 2.0, fully automated build Details see below
v3.x Tensorflow 1.4, manual build Details see below

Running docker

Choose for the fitting docker tag and run the server with the following parameters:

sudo docker run -p 3000:3000 --mount type=bind,source=/PATH_TO_LOCAL_CONFIG,target=/config --mount type=bind,source=/PATH_TO_LOCAL_LOG,target=/log jomjol/wasserzaehler:DOCKER_TAG

Paramters

Parameter Meaning Example
PATH_TO_LOCAL_CONFIG Configuration parameters are stored in this path - easeast way to handle is a local copy of this directory /home/pi/config
PATH_TO_LOCAL_LOG Logging paramters and images are stored in in this path - easeast way to handle is a local copy of this directory /home/pi/config
DOCKER_TAG Docker tag for the correct docker version raspi-latest

The config and the log directory can be empty at the very first start. They will be loaded with a default configuratio, that can be modified afterwards.

Changelog - lastest version

Attention: 6.1.1 is the last version, with h5-files support. Future versions will only support h5-files!!!

6.1.1 (2020-04-23)
  • Update CNN-Files to v6.0.0, v6.0.1
6.1.0 (2020-04-17)
  • MinImageSize configuration parameters added. This will detect damaged images. (Extension from Zwer2k)
6.0.0 (2020-03-16)
  • Update Tensorflow to v2.1 - downgrade Python to v3.6 (to enable compiling for Synology (w/o AVX2))

The overall system with description of the single steps is described here: https://github.com/jomjol/water-meter-measurement-system

A graphical overview about the steps is shown in the following flow:

Setup

To run the Python code copy the whole code directory including subdirectory.

Path are relative, so it should run immediately with the following command:

  • pip install requirements.txt
  • python wasserzaehler.py

Configuration

The configuration is stored in the subdirectory config. In the Ini-file the CNN-Network to be loaded is listed. Configuration of the neural network (*.h5) itself is stored in the subdirectory neuralnets. Detailed information on config.ini see Config_Description.md

Consistency Check

There is a consistency check of the readout value implemented. Prequesite for this check is a storage of the last full readout (without "N"), which can be achieved by the parameter "usePreValue".

Running the server

The server is listening to port 3000 and accepts requests in the following syntac:

Parameter Meaning example
server-ip address of the node-server running the script localhost

Without any parameter and correct setting in the CONFIG.INI the server responses with an readout of the water meter:

The output of the server are 3 numbers, separated by a tabulator.

Number Meaning
First number Full readout, including main digits and subdigits, leading zeros are suppresed
Second number Direct readout of the digital digits, including leading zeros
Third number post digit numbers
Remark

If a digit cannot be recognized, e.g. because it is half between 2 digits, then instead of the number a "N" is written at the corresponding position. In this case a direct conversion to a number will not work. Additional information (e.g. last valid full reading) needs to be used to extrapolate the missing digit (see below).

Optional parameters

Parameter Meaning example
url url to a dedicated picture to be analysed url=http://picture-server/image.jpg
full response extended by details on readout process full
usePreValue if available the last fully valid readout is used to complete unambigoius digits ('N'). The prevalue can be set manuelly by 'setPreValue.html' - see below usePreValue
single only a singel number is given back instead of combinded value, digital and analog readouot single

The paramaters can be combined arbitrary.

Example with parameter full:

Additional Settings

The page roi.html return the image including the ROIs visible. This is usefull to check for correct setting:

The page setPreValue.html stores the number given in the parameter value to initiate the internal storage of a valid data. This can be used, in case the digital counter is between two number and cannot be readout uniquely at the moment.

Parameter Meaning example
value valid setting of water meter readout value=401.57

The page version.html returns a version number.

water-meter-system-complete's People

Contributors

baschdl avatar dependabot[bot] avatar jomjol avatar rkotulan-ksy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

water-meter-system-complete's Issues

Add JSON output

Add JSON endpoint, for easy integration to 3rd party system like the home assistant.

Rechnerisches Vermeiden von Ausgaben mit N in Ziffer 5

es kommt ja doch relativ oft vor, dass die Ziffer 5 wechselt. Bei meiner Wasseruhr startet der Wechsel circa 50 Liter vorher (also z.B. bei 422,9500 und die Erkennung funktioniert wieder circa 10 Liter nach dem Wechsel (also bei z.B. 423,0100). Dazwischen kommt das N bei der Auswertung der Ziffer 5 (z.B. 42N,9990). Könnte man nicht in diesem Bereich, also von xxxxx,09500 bis xxxxx,0100 dieses N automatisch mit dem "richtigen" Wert ersetzen? Also 422,9999 und dann weiter mit 423.0000 ....
Den Bereich könnte man dann vielleicht in der config.ini einstellbar machen (Liter vorher / Liter nachher) da wahrscheinlich jede Wasseruhr anders ist.

Error in ZaehlerstandClass.py

My config:
[AnalogReadOut]
#If enabled analog counters will be read, if disabled only digital counters will be read.
Enabled=False

[PreValue]
time = 2000-01-01_00-00-00
lastvorkomma = 0000
lastnachkomma = 0000

After success reading, I got the error in:
ZaehlerstandClass.py

def prevalueStoreToFile(self, logtime):
config = configparser.ConfigParser()
config.read('./config/prevalue.ini')
config['PreValue']['LastVorkomma'] = self.LastVorkomma
config['PreValue']['LastNachkomma'] = self.LastNachkomma
config['PreValue']['Time'] = logtime
with open('./config/prevalue.ini', 'w') as cfg:
config.write(cfg)

The expected value is not a string.

Source from USB cam

Hi, pretty cool project! I have an endoscope camera that I can plug to the RaspberryPi via USB. Is there a way for the server to use it directly ?

I was thinking to have a webpage that is using the camera then give that URL to the server. Would that work? or is there an easier way?

Possibility to dim LED

the flash LED is quite bright. I used some tissue, to dim the light, but the light is still too bright.
Would be great, if there would be some possibility to dim the white LED.
IMG_4175

Image is torn & mirrored after Pre-aligment

Hi,

the image is torn and also mirrored in some cases after the Pre alignment. I tried different angles in the config.ini and also used both docker versions on my Pi 4 ( raspi-rolling and raspi-latest). I tried different test pictures from URLs.

It seems like i get some OK pictures if i choose around 220° in the config, which is weird.
If i choose 0° (which should be right) or 180° the preview (&full) is complety torn

Is there something else I could have probably done wrong? Btw I am a total beginner in this.

Great work and thank you in advance
Best regards

2020-03-20-155400_1920x1080_scrot

2020-03-20-181101_1920x1080_scrot

FR: Mqtt interface

It would be nice to have the possibility to communicate with the system over MQTT.

The server would subscribe to a certain topic (config). The messages contain the picture in the payload and the server publishes the processed data as json on another topic (config).

clockotherwise and mirroring photo

Good day! i was installed docker version with that compose

version: "3"

services:
    mlcnt:
      restart: always
      image: jomjol/wasserzaehler:latest
      ports:
        - 3000:3000
      volumes:
        - "/opt:/config"
        - "/opt:/log"

also try to run single docker at
docker run -p 3000:3000 --mount type=bind,source=/opt,target=/config --mount type=bind,source=/opt,target=/log jomjol/wasserzaehler:latest
no luck... picture is the same crumpled

whold you be i pice of kind explain why this behavior still appear...
Снимок экрана 2021-04-02 в 03 30 17

screen that was make as example correctly
counter

why server crumpled and mirroring it?
where in config is parametrs to normalize photo?

Readout not updating

I noticed that sometimes readout on top of the website is not updating even when picture has changed and also readout next to the digits and analog meters have changed correctly. Only restarting server has resolved this issue and readout is corrected after restart. Running on rasbian with docker on raspberrypi 3b

Error in wasseruhr.py: No module named http.server

When starting the container I get the following error:

Traceback (most recent call last):
File "./wasseruhr.py", line 1, in
from http.server import HTTPServer, BaseHTTPRequestHandler
ImportError: No module named http.server

The problem seems to be, that in the Dockerfile the wasseruhr.py is called with python. Python 2.7 doesn't have the HTTPServer.
Following change in the Dockerfile seems to fix the problem:
CMD ["python3", "./wasseruhr.py"]

Digit detection NaN

Hello, first of all congratulations to this awesome project.
I run into a problem: The last digit to be recognized is changing from 4 to 5 which results in NaN.
Is there something to fix this ?

image
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.