jomjol / AI-on-the-edge-device

Easy to use device for connecting "old" measuring units (water, power, gas, ...) to the digital world
https://jomjol.github.io/AI-on-the-edge-device-docs/
5.27k stars 580 forks source link

Support for reading analogue guages #2954

Open CarbonCollins opened 4 months ago

CarbonCollins commented 4 months ago

The Feature

I have my own water well at home so do not have a water meter installed. However I do have a pressure vessel which water is pumped into where I do have an analogue pressure gauge installed measuring the pressure in bar. A crappy example of the gauge below:

image

Would it be possible to add support to reading one of these gauges so that i can interpret the current pressure value?

Slider0007 commented 4 months ago

@CarbonCollins: In principle, this is already supported by the firmware, but you have to train your own tflite model.

I have something similar in place (garden water pressure). This is working for over a year now. image

CarbonCollins commented 4 months ago

Do you by chance have an example of the configuration options you have set for this analog ROI processing?

also any pointers and/or the data set you used for your model so that I can figure out how to do mine? Ive not trained a model before. I'm going to start collecting images over the next few days at least. they are not as clear and crisp as the one you posted but are generally in this quiality:

alg_roi and 7 0_ana1_20240229-214409

Slider0007 commented 4 months ago

@CarbonCollins: In terms of configuration of analog ROI there is nothing special.

image

In first instance you could test if my trained model is also working for you. I doubt because your pointer and scale looks different, but at least you can try. (Be aware: I only trained from 0.0 - 4.5bar).

ana-pressure-0-6_0003_s1.zip

Here you can find some infos how to train analog pointer: https://github.com/jomjol/neural-network-analog-needle-readout

I collected images, labeled them correctly (be very precise, e.g. 0.7_anyimagename.jpg for a pressure of 0.7 bar) and processed one of the jupyter scripts of github repo. For more detailed info, I have to check my archives (Performed this the last time over a year ago ;-))

BTW: Before you start collecting images I would recommend to improve your image quality.

CarbonCollins commented 4 months ago

0-4.5 is still a larger range than what my gauge is used for, pretty much max out a 3 bar :) ill give it a try at least.

as for the image quality im not sure how much more I can improve it, its all running on an ESP32-CAM and I cant seem to get the image any clearer...

in either case Ive given your model a whirl and its a lot closer than what the default model was reporting: image the default model was reporting 6 all the time :P

Slider0007 commented 4 months ago

Looks not so bad, result is at least quite close :-)

As long the result is acceptable the image quality is also acceptable ;-) But it could be an improvement in terms of evalutation stability...

For me image looks a little blurry (focus adjustment? -> https://jomjol.github.io/AI-on-the-edge-device-docs/Reference-Image/#focus) and you maybe could get a bit closer, physically or using the new digital zoom functionality which in place since 15.7.0. (Be careful: There are still some quirks in v15.7.0, https://github.com/jomjol/AI-on-the-edge-device/discussions/2926#discussioncomment-8631527 -> produces system crashes and potential timing issues while taking new reference image, just repeat until you're happy with the result)

CarbonCollins commented 4 months ago

I managed to get a proper printed casing which allowed me to get it a bit closer and time to re-adjust the focus a bit so hopefully a bit less blurry now: alg_roi Only thing I have to do now is empty my pressure tank to get images for the guage that is lower than 1.5 bar T.T

CarbonCollins commented 4 months ago

Just as a thing going forward, is it worth adding these images to a training repo so a more general 0-6 bar guage can be trained? there is at least two of us doing this now :P

Slider0007 commented 4 months ago

@CarbonCollins: Image looks better than before.

Training image set should at least cover same range than I use 0.0 - 4.5. Send the images (upload here as zipped file) and I'll give it a try to add to the model.

CarbonCollins commented 3 months ago

Finally had a chance to flush the tank so I have a collection of images

images.tar.gz

Slider0007 commented 3 months ago

@CarbonCollins: Please find attached the trained model including your images. ana-pressure-0-6_0004_s2.zip

I wasn't able to fully test on my pressure gauge because garden water is not yet switched on ;-)

CarbonCollins commented 2 months ago

Im not sure that model is spitting out the right values currently, it seems much closer than before but also not quite right

image

Slider0007 commented 2 months ago

@CarbonCollins: I figured out, that there were some wrong labeled images in this region. I removed them and retrained again. Please verify...

  1. Only your images: ana-pressure-0-6_0005_s2_CarbonCollins_only.zip
  2. Including my images: ana-pressure-0-6_0006_s2.zip
CarbonCollins commented 2 months ago

No problem,

we are off to a good start at least :) image this is with model 1. Ill try it out for a few pressure cycles and then Ill also try out model 2 :)

gobenedikt commented 2 months ago

Hi, is it possible to train the model on number with two decimals? I am trying to read a gauge from a scale. So for this to properly make sense, I would need a second decimal digit as well:

image

Is this theoretically possible with this model? or is it limited at 1 decimal? I cant find any information on it. Thanks so much :)

Or to put differently, can I go beyond 100 digits (0-0.99) to 1000 digits? 0-0.999 ?

CarbonCollins commented 1 month ago

@Slider0007 Ive tried both models now, the one with just my images in seems to work quite well, the combined one not so much it seems to get a bit confused with the gradation marks. I am assuming that its because my gauge has half the amount of gradation marks as your gauge but that's just a pure guess.

In general though with the combined model I was getting 2.1 when it should have been 2.2 and was also getting 2.2 when it should have been 2.4

Slider0007 commented 1 month ago

@CarbonCollins

Recently I also figured out that the combined model is not working as good as my old dedicated model. It seems that our gauges are too different to combine in one model, at least with my knowledge of model generation.

hassdevil commented 4 weeks ago

Hi, i have a similar problem. I have this pressure gauge. wasserpressure I tried both of your generated models, gut i think they are too different, cause it didnt worked. Soo i decided to train my own model. i got the pictures and i have labeld them. Now i am struggeling with the howto from https://github.com/haverland/Tenth-of-step-of-a-meter-digit/issues/12. Would one of you be so kind as to help me through the installation anf training as you have already trained your own models?