Files
AI-on-the-edge-device-docs/Correction Algorithm/index.html
2023-08-11 17:53:28 +00:00

316 lines
20 KiB
HTML

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><link rel="canonical" href="https://jomjol.github.io/AI-on-the-edge-device-docs/Correction%20Algorithm/" />
<link rel="shortcut icon" href="../img/favicon.ico" />
<title>Correction Algorithm - AI on the Edge Device</title>
<link rel="stylesheet" href="../css/theme.css" />
<link rel="stylesheet" href="../css/theme_extra.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github.min.css" />
<script>
// Current page data
var mkdocs_page_name = "Correction Algorithm";
var mkdocs_page_input_path = "Correction Algorithm.md";
var mkdocs_page_url = "/AI-on-the-edge-device-docs/Correction%20Algorithm/";
</script>
<!--[if lt IE 9]>
<script src="../js/html5shiv.min.js"></script>
<![endif]-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<img src=https://jomjol.github.io/AI-on-the-edge-device-docs//img/logo.png>
<a href=".." class="icon icon-home"> AI on the Edge Device
</a><div role="search">
<form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" title="Type search term here" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption"><span class="caption-text">Getting Started</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="..">Welcome</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Installation/">Installation</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../initial-setup/">Initial Setup</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Hardware-Compatibility/">Hardware Compatibility</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Best-Practice/">Best Practice</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../FAQs/">Frequently Asked Questions</a>
</li>
</ul>
<p class="caption"><span class="caption-text">External Links</span></p>
<ul>
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/releases">Releases</a>
</li>
<li class="toctree-l1"><a class="" href="https://jomjol.github.io/AI-on-the-edge-device/index.html">Web Installer/Console</a>
</li>
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/issues">Create an Issue</a>
</li>
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/discussions">Join a Discussion</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Configuration</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Reference-Image/">Reference Image</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Alignment/">Alignment References</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../ROI-Configuration/">ROIs (Regions of Interest)</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Configuration/">Graphical Configuration</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Choosing-the-Model/">Model Selection</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../ota/">Over-The-Air (OTA) Update</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Advanced</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../Parameters/">Parameters</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Integration-Home-Assistant/">Integration into Home Assistant</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../External-LED/">External LED</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../data-logging/">Data Logging</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../rolling-installation/">Living on the Edge</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Watermeter-specific-analog---digital-transition/">Analog/Digital Transition on Water Meters</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../collect-new-images/">Collect images to improve the models</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Learn-models-with-your-own-images/">Learn a model with your own images</a>
</li>
<li class="toctree-l1 current"><a class="reference internal current" href="./">Correction Algorithm</a>
<ul class="current">
<li class="toctree-l2"><a class="reference internal" href="#terms-and-definitions">Terms and definitions</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#prevalue">PreValue</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#digits">Digits</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#analogs">Analogs</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#checkdigitincreaseconsistency">CheckDigitIncreaseConsistency</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#allownegativerates">AllowNegativeRates</a>
<ul>
<li class="toctree-l4"><a class="reference internal" href="#decimalshift">DecimalShift</a>
</li>
<li class="toctree-l4"><a class="reference internal" href="#analogdigitaltransitionstart">AnalogDigitalTransitionStart</a>
</li>
<li class="toctree-l4"><a class="reference internal" href="#maxratevalue-and-maxratetype">MaxRateValue and MaxRateType</a>
</li>
<li class="toctree-l4"><a class="reference internal" href="#extendedresolution">ExtendedResolution</a>
</li>
<li class="toctree-l4"><a class="reference internal" href="#ignoreleadingnan">IgnoreLeadingNaN</a>
</li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#flow-chart">Flow Chart</a>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#checkdigitincreaseconsistency-algorithm">CheckDigitIncreaseConsistency Algorithm</a>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Neural-Network-Types/">Neural Network Types</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Additional-Information/">Additional Information</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../New-Releases-Notification/">Notification about new Releases</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Troubleshooting</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Error-Codes/">Reduced webinterface (error codes)</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../StatusLED-BlinkCodes/">Board status LED (blink codes)</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../WLAN-disconnect-reason/">WLAN disconnect reasons</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Error-Debugging/">Often observed issues</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Frequent-Reboots/">Basic hardware/config issues</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Demo-Mode/">Demo mode</a>
</li>
</ul>
<p class="caption"><span class="caption-text">API's</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../REST-API/">REST API</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../MQTT-API/">MQTT API</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Influx-DB/">Influx DB</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Build-Instructions/">Build the Project</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Upload-files-by-script/">Scripted File Upload</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Testing/">Testing</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Release-creation/">Preparing for Release</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Old Pages (no longer maintained)</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../outdated--Integrated-Functions/">Integrated Functions</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Assorted Pages</span></p>
<ul>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="Mobile navigation menu">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="..">AI on the Edge Device</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href=".." class="icon icon-home" aria-label="Docs"></a> &raquo;</li>
<li>Advanced &raquo;</li>
<li class="breadcrumb-item active">Correction Algorithm</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/jomjol/AI-on-the-edge-device-docs/edit/main/docs/Correction Algorithm.md" class="icon icon-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div class="section" itemprop="articleBody">
<h1 id="correction-algorithm">Correction Algorithm</h1>
<p>After the digitization of the images and the composition to a number a checking and correction algorithm is applied. This is explained here.</p>
<p>There are several reasons, that a check might be necessary:</p>
<ol>
<li>In case of digits there is the output of "N" (=NaN = Not-a-Number) in case the digit cannot be detected correctly. This happens for example if the image shows a digit between to states</li>
<li>The replacement of the "N" with a previous value could be not sufficient, due to the fact, that it might have changed.</li>
<li>There is a misreading of one one of the numbers. This can always happen in case of neural network processing.</li>
</ol>
<h3 id="terms-and-definitions">Terms and definitions</h3>
<h5 id="prevalue">PreValue</h5>
<p>The last correct read value. PreValue is here a bit missleading, because normally it is the same as the last value. In the next round of reading it will be used to check nagtive rates, high rates (MaxRateValue / MaxRateType) and CCheckDigitIncreaseConsistency (dig-class11 only). Either from a previous correctly identified value or manual setting by the user.</p>
<h5 id="digits">Digits</h5>
<p>Value that are digitized from a digital number. There are 11 allowed values for this: </p>
<ol>
<li>Digits: 0, 1, 2, ... 9</li>
<li>N = Not-a-Number - representing a not unique state between two numbers</li>
</ol>
<h5 id="analogs">Analogs</h5>
<p>This are value derived from a pointer like meter. This never has the state "N".</p>
<h5 id="checkdigitincreaseconsistency">CheckDigitIncreaseConsistency</h5>
<p>If this is enabled an "intelligent" algorithm is used to derive from zero-crossing of discrete digit positions, if the number should have been increased. This is relevant because in some of the digit meters, the increase of a digit to the next number can be seen, before the sub-digit has gone through zero.</p>
<p>For example: 16.6 --&gt; 16.7 --&gt; 1N.8 --&gt; <strong>17.9</strong> corrected to 16.9 --&gt; 17.0 --&gt; 17.1 </p>
<p>As you can see, the 17.9 is a false reading as the 7 is assumed to be already readable, although the sub-digit has not crossed the zero. In this case the CheckDigitIncreaseConsistency algorithm will correct this to 16.9</p>
<p>A detailed description of the algorithm can be found below (not yet ready!)</p>
<h5 id="allownegativerates"><code>AllowNegativeRates</code></h5>
<p>Most of the meters only have increasing numbers and do not count backwards. Therefore a negative rate (= negative change compared to the PreValue) is surely a false value. This can be checked an flagged as false reading</p>
<p>The <code>AllowNegativeRates</code> property ensures that the result does not become negative in the event of incorrect readings. This can happen, for example, if the alignment of the image did not work properly. But also the neural networks sometimes flip between two states for similar images.</p>
<p>If <code>AllowNegativeRates = true</code>, the result is discarded if it is smaller than the pre-value of the last readout and the output shows an error "Negative rate.."</p>
<p>If the <code>ExtendedResolution</code> setting is true, there is an exception where the value does not become smaller, but no error is output. This only applies if the value +/- 0.2 of the last digit is inaccurate.</p>
<h6 id="decimalshift"><code>DecimalShift</code></h6>
<p>The <code>DecimalShift</code> setting puts the decimal point in the right place. It acts like a shift. Negative values shift the decimal point to the left. Positive values move the decimal point to the right, filling with zero.</p>
<h6 id="analogdigitaltransitionstart"><code>AnalogDigitalTransitionStart</code></h6>
<p>For detailed description see <a href="../Watermeter-specific-analog---digital-transition/">Analog-digital-transition</a>.</p>
<h6 id="maxratevalue-and-maxratetype"><code>MaxRateValue</code> and <code>MaxRateType</code></h6>
<p>Here the maximum change from one to the next reading can be limited. If a false reading of the neural network results in a change larger than this, the reading is flagged as false. There a two types of comparisons possible</p>
<p>1) <strong>AbsolutChange</strong>: Here the difference between the PreValue and the current reading is compared directly, independent how much time has passed since the last reading.
2) <strong>RelativeRate</strong>: in this case a change rate in the unit of change/minute is calculated, taking the time between the last and the current reading into account. Be careful, that with increasing time, the absolute allowed change increases.
Example: relative rate of 0.05 m³/minute --&gt; after 20 minutes a maximum change of 20 minutes * 0.05 m³/minute = 1 m³ is possible. That means that a false reading of 1 m³ cannot be detected false after about 20 minutes in this case
Assume, that there might be no change in the meter for hours (e.g. during the night) a much bigger change could also be accepted. </p>
<h6 id="extendedresolution"><code>ExtendedResolution</code></h6>
<p>Newer models such as dig-cont and dig-class100 have a high resolution of the values and can thus represent another digit by using the value of the last digit or pointer (ex. 7.8 in the last digit). </p>
<p>If the value is set to true, the result of the last digit is used completely. </p>
<p>When using dig-class11 models, the setting is ignored.</p>
<p>Due to inaccuracies of the neural networks, it sometimes happens that the results jump back and forth between two decimal places. Therefore, when using `ÀllowNegatives``= false, no error is output if the value is only off by 0.2. Nevertheless, the value then remains at the higher determined value.</p>
<h6 id="ignoreleadingnan"><code>IgnoreLeadingNaN</code></h6>
<p>The parameter is only be used, if a dig-class11 model is selected. <code>ÌgnoreLeadingNaN</code> removes in the CheckDigitIncreaseConsistency process the leading <code>N</code> values.</p>
<h4 id="flow-chart">Flow Chart</h4>
<p><img alt="" src="../img/correct_algo_1.jpg" /></p>
<p><img alt="" src="../img/correct_algo_2.jpg" /></p>
<p><img alt="" src="../img/correct_algo_3.jpg" /></p>
<h2 id="checkdigitincreaseconsistency-algorithm">CheckDigitIncreaseConsistency Algorithm</h2>
<p>The check digit increase consistency algorithm is functional for the digits only. Due to the fact, that the rotation might be a little bit earlier or later compared to the zero crossing of the digit before, errors during the reading before and after a zero crossing can be wrong. Therefore a simple algorithm can be applied, checking the consistency of zero crossing and changes in the following digit. This is applied to one after the other digit, starting with the lowest priority digits.</p>
<p><img alt="" src="../img/correct_algo_zero_crossing.jpg" /></p>
</div>
</div><footer>
<div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
<a href="../Learn-models-with-your-own-images/" class="btn btn-neutral float-left" title="Learn a model with your own images"><span class="icon icon-circle-arrow-left"></span> Previous</a>
<a href="../Neural-Network-Types/" class="btn btn-neutral float-right" title="Neural Network Types">Next <span class="icon icon-circle-arrow-right"></span></a>
</div>
<hr/>
<div role="contentinfo">
<!-- Copyright etc -->
</div>
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<div class="rst-versions" role="note" aria-label="Versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span>
<a href="https://github.com/jomjol/AI-on-the-edge-device-docs" class="fa fa-github" style="color: #fcfcfc"> GitHub</a>
</span>
<span><a href="../Learn-models-with-your-own-images/" style="color: #fcfcfc">&laquo; Previous</a></span>
<span><a href="../Neural-Network-Types/" style="color: #fcfcfc">Next &raquo;</a></span>
</span>
</div>
<script src="../js/jquery-3.6.0.min.js"></script>
<script>var base_url = "..";</script>
<script src="../js/theme_extra.js"></script>
<script src="../js/theme.js"></script>
<script src="../search/main.js"></script>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>