Files
AI-on-the-edge-device-docs/ROI-Configuration/index.html
2023-02-03 19:36:11 +00:00

352 lines
19 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) - 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)";
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">
<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" 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">Place 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 class="current">
<li class="toctree-l1 current"><a class="reference internal current" href="./">ROI (Region of Interest)</a>
<ul class="current">
<li class="toctree-l2"><a class="reference internal" href="#correct-setup-of-roi">Correct Setup of ROI</a>
<ul>
<li class="toctree-l3"><a class="reference internal" href="#image-sharpness">Image Sharpness</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#horizontal-alignment">Horizontal Alignment</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#correct-size-for-roi">Correct Size for ROI</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#model-selection">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="../Choosing-the-Model/">Model Selection</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/">Over-The-Air (OTA) Update</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Advanced</span></p>
<ul>
<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="../rolling-installation/">Living on the Edge</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="../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"><a class="reference internal" href="../Correction%20Algorithm/">Correction Algorithm</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/">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="../Frequent-Reboots/">Frequent Reboots</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>
<li class="toctree-l1"><a class="reference internal" href="../outdated--Gasmeter-Log-Downloader/">Gas Meter Log Downloader</a>
</li>
<li class="toctree-l1"><a class="reference internal" href="../outdated--Migrate-Old-Config-To-New-Config/">Migration from water-meter „old“ to water-meter “AI-on-the-edge-device”</a>
</li>
</ul>
<p class="caption"><span class="caption-text">Assorted Pages</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../Graphical-Configuration/">Graphical Configuration</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>Configuration &raquo;</li>
<li>ROI (Region of Interest)</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/jomjol/AI-on-the-edge-device-docs/edit/main/docs/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">ROI (Region of Interest)</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="../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="correct-setup-of-roi">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="image-sharpness">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></p>
<p>In order to use it for reading a meter, the focal-length of the OV2640 camera has to be manipulated, as by default it only results in sharp image for distance bigger than ~40cm, causing the image of the water meter to be too small for automated readout processing.</p>
<p><strong>ATTENTION:</strong> this modification will void any warranty, as the sealing of the lens objective is broken!</p>
<p><strong>ATTENTION:</strong> This modification will render the camera unsuitable for general, web-cam type applications unless the focal length is changed back to the original setting.</p>
<p><img alt="" src="../img/focus_adjustment.jpg" /></p>
<p>Remove the fixing glue of the OV2640 lens with a sharp knife. After this you can screw the lens in and out. Rotating it by about a quarter of a turn counterclockwise results in a focus plane of about 10cm. You need to figure out your best setting with a little bit of trial and error for your specific environment.</p>
<h3 id="horizontal-alignment">Horizontal Alignment</h3>
<p>Ensure an <strong>exact horizontal alignment</strong> of the number via the alignment / reference setup:</p>
<table>
<thead>
<tr>
<th>✔️ Okay</th>
<th>❌ 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="correct-size-for-roi">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="model-selection">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=../img/ROI_drawing.jpg></p>
<table>
<thead>
<tr>
<th></th>
<th>Example 1</th>
<th>Example 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>✔️ <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><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><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="../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>✔️ <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><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="../FAQs/" class="btn btn-neutral float-left" title="Frequently Asked Questions"><span class="icon icon-circle-arrow-left"></span> Previous</a>
<a href="../Choosing-the-Model/" class="btn btn-neutral float-right" title="Model Selection">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="../FAQs/" style="color: #fcfcfc">&laquo; Previous</a></span>
<span><a href="../Choosing-the-Model/" 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>