Files
AI-on-the-edge-device-docs/ROI-Configuration/index.html
2023-01-02 23:05:54 +00:00

318 lines
17 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/ROI-Configuration/" />
<link rel="shortcut icon" href="../img/favicon.ico" />
<title>ROI (Region of Interest) Configuration - 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/10.5.0/styles/github.min.css" />
<script>
// Current page data
var mkdocs_page_name = "ROI (Region of Interest) Configuration";
var mkdocs_page_input_path = "ROI-Configuration.md";
var mkdocs_page_url = "/AI-on-the-edge-device-docs/ROI-Configuration/";
</script>
<script src="../js/jquery-3.6.0.min.js" defer></script>
<!--[if lt IE 9]>
<script src="../js/html5shiv.min.js"></script>
<![endif]-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</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">
<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" title="Type search term here" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Home/">Welcome to the AI-on-the-edge-device!</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Links</span></p>
<ul>
<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">Place an Issues</a>
</li>
<li class="toctree-l1"><a class="" href="https://github.com/jomjol/AI-on-the-edge-device/discussions">Join a Discussions</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Asorted Pages</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../AI-on-the-edge/">Welcome to the AI-on-the-edge-device wiki!</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Addditional-Information/">Addditional Information</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="../Build-Instructions/">New</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Choosing-the-Model/">Which model should I use?</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Configuration-Parameter-Details/">Configuration Parameter Details</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Configuration/">Configuration</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Correction%20Algorithm/">Correction Algorithm</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Demo-Mode/">Demo Mode</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Error-Codes/">Error Codes</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Error-Debugging/">Error Debugging</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="../FAQs/">Frequently Asked Questions</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Frequent%20Reboots/">Frequent reboots</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Gasmeter-Log-Downloader/">Gasmeter Log Downloader</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Graphical-configuration/">Graphical configuration</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="../Install-a-rolling-%28unstable%29-release/">:bangbang: Living on the edge :bangbang:</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Installation/">Installation</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Integrated%20Functions/">Integrated Functions</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="../Learn-models-with-your-own-images/">Learn models with your own images</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../MQTT-API/">General Information</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Migrate-Old-Config-To-New-Config/">Migration from water-meter „old“ to water-meter “AI-on-the-edge-device”</a>
</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="../OTA---Update-Firmware-and-Web-Interface/">Over-The-Air (OTA) Update</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../REST-API/">REST API</a>
</li>
<li class="toctree-l1 current"><a class="reference internal current" href="./">ROI (Region of Interest) Configuration</a>
<ul class="current">
<li class="toctree-l2"><a class="reference internal" href="#1-correct-setup-of-roi">1. Correct Setup of ROI</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#1-image-sharpness">1. Image Sharpness</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#2-horizontal-alignment">2. Horizontal Alignment</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#3-correct-size-for-roi">3. Correct Size for ROI</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#4-model-selection">4. Model Selection</a>
<ul>
<li class="toctree-l4"><a class="reference internal" href="#dig-class11-configuration">dig-class11 Configuration</a>
</li>
<li class="toctree-l4"><a class="reference internal" href="#dig-class100-dig-cont-configuration">dig-class100 / dig-cont Configuration</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Release-creation/">Release creation</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Testing/">Testing</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../Watermeter-specific-analog---digital-transition/">Understanding the problem</a>
</li>
</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" alt="Docs"></a> &raquo;</li>
<li>Asorted Pages &raquo;</li>
<li>ROI (Region of Interest) Configuration</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/jomjol/AI-on-the-edge-device-docs/edit/main/doc/ROI-Configuration.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="roi-region-of-interest-configuration">ROI (Region of Interest) Configuration</h1>
<p>General remark:</p>
<blockquote>
<p>You are using a neural network approach which is trained to fit as many different type of meters as possible. The accuracy will never be 100%. It is normal to see a missing reading once in a while. There there are several precautions to detect this. For details see the section <code>PostProcessing</code> on the configuration page.</p>
</blockquote>
<p>The most critical settings for accurate detection are:</p>
<ol>
<li>Correct setting of the <strong>R</strong>egions <strong>O</strong>f <strong>I</strong>nterest (ROIs) for detection of the image.<blockquote>
<p>This must be done manually for each meter!</p>
</blockquote>
</li>
<li>Number type is part of the training set.<blockquote>
<p>Have a look on the <a href="https://jomjol.github.io/neural-network-digital-counter-readout/">Digital Counters</a> resp. <a href="https://jomjol.github.io/neural-network-analog-needle-readout">Analog Needles</a> to check if your types are contained. If your number types are <strong>not</strong> contained, you should take the effort to record them so we can add them to the training data. See: <a href="https://github.com/jomjol/AI-on-the-edge-device/wiki/Learn-models-with-your-own-images">Learn models with your own images</a> on how to create new input.</p>
</blockquote>
</li>
</ol>
<hr />
<h2 id="1-correct-setup-of-roi">1. Correct Setup of ROI</h2>
<p>Please proceed in the following order!</p>
<p>Don't forget to save after each step!</p>
<h3 id="1-image-sharpness">1. Image Sharpness</h3>
<p>Ensure a sharp image of the camera by adjusting the focal length of the ESP OV2640 camera.
<strong>Adjust the focus for the clearest possible image</strong> See <a href="https://github.com/jomjol/water-meter-picture-provider/blob/master/ESP32-CAM_Lens_Modification.md">these instructions</a> for help.</p>
<h3 id="2-horizontal-alignment">2. Horizontal Alignment</h3>
<p>Ensure an <strong>exact horizontal alignment</strong> of the number via the alignment / reference setup:</p>
<table>
<thead>
<tr>
<th><img alt="✔" class="twemoji" src="https://twemoji.maxcdn.com/v/latest/svg/2714.svg" title=":heavy_check_mark:" /> Okay</th>
<th><img alt="❌" class="twemoji" src="https://twemoji.maxcdn.com/v/latest/svg/274c.svg" title=":x:" /> Not Okay</th>
</tr>
</thead>
<tbody>
<tr>
<td><img alt="" src="../img/alignment_okay.jpg" /></td>
<td><img alt="" src="../img/alignment_not_okay.jpg" /></td>
</tr>
</tbody>
</table>
<h3 id="3-correct-size-for-roi">3. Correct Size for ROI</h3>
<p>Choose the right size of the ROI:</p>
<blockquote>
<p>The configuration of ROIs differs a bit on the model you choose. Below you find the differences between the different AI models. Pick the one you think fits best your purpose. If you don't get to good result, try another model.</p>
</blockquote>
<h3 id="4-model-selection">4. Model Selection</h3>
<h4 id="dig-class11-configuration">dig-class11 Configuration</h4>
<p>dig-class11 - Models recognize the <strong>complete digit only</strong>. Here it is not relevant if the ROI fits the Border of the digit window.</p>
<p>For this model, there should be a border of 20% of the image size around the number itself. This border is shown in the ROI setup image by the inner thinner rectangle. This rectangle should fit perfectly around the number when the number has not started to rotate to the next position: </p>
<p><img width="300px" src=https://github.com/jomjol/AI-on-the-edge-device/wiki/images/ROI_drawing.jpg></p>
<table>
<thead>
<tr>
<th></th>
<th>Example 1</th>
<th>Example 2</th>
</tr>
</thead>
<tbody>
<tr>
<td><img alt="✔" class="twemoji" src="https://twemoji.maxcdn.com/v/latest/svg/2714.svg" title=":heavy_check_mark:" /> <strong>Okay</strong></td>
<td><img alt="" src="../img/bw_okay.jpg" /></td>
<td><img alt="" src="../img/wb_okay.jpg" /></td>
</tr>
<tr>
<td><img alt="❌" class="twemoji" src="https://twemoji.maxcdn.com/v/latest/svg/274c.svg" title=":x:" /> <strong>Not</strong> Okay</td>
<td><img alt="" src="../img/bw_not_okay_small.jpg" /></td>
<td><img alt="" src="../img/wb_not_okay_small.jpg" /></td>
</tr>
<tr>
<td><img alt="❌" class="twemoji" src="https://twemoji.maxcdn.com/v/latest/svg/274c.svg" title=":x:" /> <strong>Not</strong> Okay</td>
<td><img alt="" src="../img/bw_not_okay_big.jpg" /></td>
<td><img alt="" src="../img/wb_not_okay_big.jpg" /></td>
</tr>
</tbody>
</table>
<p>If you have perfect alignment you and are not getting satisfying results, most probably your numbers are not part of the training data yet. Read on <a href="https://github.com/jomjol/AI-on-the-edge-device/wiki/Learn-models-with-your-own-images">Learn models with your own images</a> how to add your meter's type of numbers to the training set.</p>
<h4 id="dig-class100-dig-cont-configuration">dig-class100 / dig-cont Configuration</h4>
<p>These models recognize the tenths (fractions) between the numbers. This model requires a different ROI setup; the height must be set differently and more accurately.</p>
<p>First, the width can be set as for dig-class11, i.e. 20% margin left and right.</p>
<p><img width="455" alt="ROI-setup" src="https://user-images.githubusercontent.com/412645/199028748-c48ef5bb-a8d4-4c77-9faf-763e6cf77351.png"></p>
<p>The height of the outer rectangle should be set to the upper and lower edge of the number window. To achieve this setting, you need to unlock the aspect ratio:</p>
<p><img width="168" alt="unlockAspectRatio" src="https://user-images.githubusercontent.com/412645/199028590-21708ff3-15a3-4415-89b1-c2affcfce003.png"></p>
<p>Here an example:</p>
<table>
<thead>
<tr>
<th></th>
<th>Example 1</th>
</tr>
</thead>
<tbody>
<tr>
<td><img alt="✔" class="twemoji" src="https://twemoji.maxcdn.com/v/latest/svg/2714.svg" title=":heavy_check_mark:" /> <strong>Okay</strong></td>
<td><img width="125" alt="dig-class100_OK" src="https://user-images.githubusercontent.com/412645/199028380-7623776e-59b9-4356-ab55-3852253609df.png"></td>
</tr>
<tr>
<td><img alt="❌" class="twemoji" src="https://twemoji.maxcdn.com/v/latest/svg/274c.svg" title=":x:" /> <strong>Not</strong> Okay</td>
<td><img width="125" alt="dig-class100_NOK" src="https://user-images.githubusercontent.com/412645/199028469-3a69ed31-e5c9-4038-a8dc-6d44a42437ed.png"></td>
</tr>
</tbody>
</table>
</div>
</div><footer>
<div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
<a href="../REST-API/" class="btn btn-neutral float-left" title="REST API"><span class="icon icon-circle-arrow-left"></span> Previous</a>
<a href="../Release-creation/" class="btn btn-neutral float-right" title="Release creation">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="../REST-API/" style="color: #fcfcfc">&laquo; Previous</a></span>
<span><a href="../Release-creation/" style="color: #fcfcfc">Next &raquo;</a></span>
</span>
</div>
<script>var base_url = '..';</script>
<script src="../js/theme_extra.js" defer></script>
<script src="../js/theme.js" defer></script>
<script src="../search/main.js" defer></script>
<script defer>
window.onload = function () {
SphinxRtdTheme.Navigation.enable(true);
};
</script>
</body>
</html>