Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction of analog readings with calibrated error model #2716

Open
jakobs opened this issue Nov 26, 2023 · 4 comments · May be fixed by #2727
Open

Correction of analog readings with calibrated error model #2716

jakobs opened this issue Nov 26, 2023 · 4 comments · May be fixed by #2727
Labels
enhancement New feature or request

Comments

@jakobs
Copy link

jakobs commented Nov 26, 2023

The Feature

I have noticed that I don't get reliable readings from the analog part of my water meter. The 4 dials seem to be out of sync.
Here is an example of what I mean:
image.
The fractional reading of the 0,1 dial does not match the 0,01 dials value.
The 0,1 dial is at 4.1 and the 0,01 dial is at 6.5. This doesn't match, as the 0,01 dial should be closer to 1. This leads to the generation of wrong readings as the reading formulation seems to be using an error threshold of 3 to disambiguate.
Based on the images, I've identified 2 sources of errors:

  1. the parallax of the dial above the scale - especially when the dial is not pointing to the image center or away from it.
  2. an offset error in the meter itself, e.g. the dial being rotated to what it should be - likely this is a manufacturer quality issue, but I'm not sure if I am the only one that has this.

I've done a bit of analysis on 3 days worth of analog dial data:
image
The orange readings are the original readings, and show the offset and the generally wide error spread that I thought was due to the parallax error.

I have written a python script to calculate correction parameters based on a model assumption:

def ana_correction( ana, params ):
    dx, dy, dval = params.T
    theta = ana/10 * (np.pi*2)
    corrected = np.arctan2(np.sin(theta) + dy, np.cos(theta) + dx) # corrects the parallax error
    corrected_val = corrected / (np.pi*2) * 10 + dval # corrects the offset error
    return corrected_val % 10

the params [parallax_x, parallax_y, rotary_offset], I have calculated using an optimization that tries to minimize the difference between the fractional part of a dial and the value of the next dial. The result is shown in the graph above and results in a significant improvement of the readings. The reconstruction of meter reading values in python resulted in far less errors:
image

I would like to add this correction model to the code now. Ideally the model parameters would be added to the roi struct, and the correction could be applied in ClassFlowCNNGeneral::getReadout.

I thought I'd ask first before implementing this, and see if this is interesting to others, and if so what would be the preferred way to integrate it so you would accept a merge request.

@jakobs jakobs added the enhancement New feature or request label Nov 26, 2023
@jakobs jakobs changed the title Correction of analog readings before formation of value Correction of analog readings with calibrated error model Nov 26, 2023
@caco3
Copy link
Collaborator

caco3 commented Nov 27, 2023

I don't think its an issue of the parallax, you camera looks quite straight to the meter. Better than on many other pictures I have seen!

The pointer indicates it is around 0.41, but the 0.01 pointer sais its more 0.465, so this clearly looks like to be a manufacturers quality issue. Also I never have seen such discrepancy before.

An offset calibration might solve it, but it would have to be implemented extra and I fear it would be challenging with all the existing algorithms. I am not too experienced with the algorithms, @JoMol would know better.
In general I would propose you create a (hard coded) prove of concept for your case and then we can have a look on it. We are happy for contributions, but it also should involve the creation and documentation of the new parameters as needed.

@jomjol
Copy link
Owner

jomjol commented Dec 1, 2023

There is a sligth tolerance for the alignment of the different analog meters (I think it's +/- 0.2). Currently it cannot be parametrized.

@rainman110
Copy link
Contributor

rainman110 commented Dec 21, 2023

@jakobs I am very much interested. In my case, I don't have the problem that the analog meters are out of sync but the 0.1 analog meter is not in sync with the last digit (see #2743 ).

An example: In my case the last digit (x1) already shows 3.9, when first analog (x0.1) shows 0.4. What I am looking for is a generic correction procedure. We can assume, that all values v have an error delta_v that needs to be corrected, similar to what you suggest, but without parallax correction for digits.

I am currently wrapping my head around the processing code in ClassFlowPostProcessing::doFlow which processes the whole number, and ClassFlowCNNGeneral::getReadout that processes a single value based on the predecessor (the next smaller meter digit / value ).

@p0macs
Copy link

p0macs commented Oct 1, 2024

I second that some meters need this correction, see my exact same issue: #3255
(unfortunately I created a new issue, didn't found this one before)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
5 participants