Home

Awesome

<span style="color: red;">This code is depreciated and will not be maintained any more!</span>

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

LabelContentComments
rollingExperimental version for amd64-systems (e.g. Intel processors)newest features, not fully tested
raspi-rollingExperimental version for armv7-systems (Raspberry PI3 and higher)newest features, not fully tested
latestLatest stable version for amd64-systems (e.g. Intel processors)Currently identical to 6.1.1 (2020-04-23)
raspi-latestLatest stable version for armv7-systems (Raspberry PI3 and higher)Currently identical to 6.1.1 (2020-04-23)
v5.xPersistant prevalue, modified docker structureDetails see below
v4.xUpdate to Tensorflow 2.0, fully automated buildDetails see below
v3.xTensorflow 1.4, manual buildDetails 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

ParameterMeaningExample
PATH_TO_LOCAL_CONFIGConfiguration parameters are stored in this path - easeast way to handle is a local copy of this directory/home/pi/config
PATH_TO_LOCAL_LOGLogging paramters and images are stored in in this path - easeast way to handle is a local copy of this directory/home/pi/config
DOCKER_TAGDocker tag for the correct docker versionraspi-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)
6.1.0 (2020-04-17)
6.0.0 (2020-03-16)

Full Changelog

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:

<img src="https://raw.githubusercontent.com/jomjol/water-meter-system-complete/master/images/signal_flow.png" width="800">

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:

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:

ParameterMeaningexample
server-ipaddress of the node-server running the scriptlocalhost

Without any parameter and correct setting in the CONFIG.INI the server responses with an readout of the water meter: <img src="https://raw.githubusercontent.com/jomjol/water-meter-system-complete/master/images/server_output.png" width="400">

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

NumberMeaning
First numberFull readout, including main digits and subdigits, leading zeros are suppresed
Second numberDirect readout of the digital digits, including leading zeros
Third numberpost 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

ParameterMeaningexample
urlurl to a dedicated picture to be analysedurl=http://picture-server/image.jpg
fullresponse extended by details on readout processfull
usePreValueif available the last fully valid readout is used to complete unambigoius digits ('N'). The prevalue can be set manuelly by 'setPreValue.html' - see belowusePreValue
singleonly a singel number is given back instead of combinded value, digital and analog readouotsingle

The paramaters can be combined arbitrary.

Example with parameter full:

<img src="https://raw.githubusercontent.com/jomjol/water-meter-system-complete/master/images/sever_output_full.png" width="400">

Additional Settings

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

<img src="https://raw.githubusercontent.com/jomjol/water-meter-system-complete/master/images/roi_masked.jpg" width="400">

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.

ParameterMeaningexample
valuevalid setting of water meter readoutvalue=401.57

The page version.html returns a version number.