mirror of
https://github.com/jomjol/AI-on-the-edge-device-docs.git
synced 2025-12-09 13:06:56 +03:00
.
This commit is contained in:
@@ -1,51 +1,125 @@
|
||||
# ROI (Region of Interest)
|
||||
|
||||
General remark:
|
||||
> 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 `PostProcessing` on the configuration page.
|
||||
!!! Notes
|
||||
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 are several precautions to detect this. For details see the section `PostProcessing` on the configuration page.
|
||||
|
||||
The most critical settings for accurate detection are:
|
||||
The most critical components for an accurate detection are:
|
||||
|
||||
1. Correct setting of the **R**egions **O**f **I**nterest (ROIs) for detection of the image.
|
||||
> This must be done manually for each meter!
|
||||
2. Number type is part of the training set.
|
||||
> Have a look on the [Digital Counters](https://jomjol.github.io/neural-network-digital-counter-readout/) resp. [Analog Needles](https://jomjol.github.io/neural-network-analog-needle-readout) to check if your types are contained. If your number types are **not** contained, you should take the effort to record them so we can add them to the training data. See: [Learn models with your own images](../Learn-models-with-your-own-images) on how to create new input.
|
||||
|
||||
_____
|
||||
**This must be done manually for each device/installation!**
|
||||
|
||||
## Correct Setup of ROI
|
||||
Please proceed in the following order!
|
||||
2. Well trained Models.
|
||||
|
||||
Have a look on the [Digital Counters](https://jomjol.github.io/neural-network-digital-counter-readout/) resp. [Analog Needles](https://jomjol.github.io/neural-network-analog-needle-readout) to check if your types are contained. If your number types are **not** contained, you should take the effort to record them so we can add them to the training data. See [Collect images to improve the models](../Learn-models-with-your-own-images) on how to collect new training data.
|
||||
|
||||
Don't forget to save after each step!
|
||||
|
||||
### Image Sharpness
|
||||
Ensure a sharp image of the camera by adjusting the focal length of the ESP OV2640 camera. **Adjust the focus for the clearest possible image!**
|
||||
## Precondition
|
||||
Please make sure to have:
|
||||
|
||||
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.
|
||||
1. Setup your camera properly and taken a good [Reference Image](../Reference-Image).
|
||||
1. Selected good [Alignment References](../Alignment).
|
||||
|
||||
**ATTENTION:** this modification will void any warranty, as the sealing of the lens objective is broken!
|
||||
|
||||
**ATTENTION:** This modification will render the camera unsuitable for general, web-cam type applications unless the focal length is changed back to the original setting.
|
||||
## Define the ROIs
|
||||
For each digit or analog pointer, a ROI must be defined.
|
||||
|
||||

|
||||
You can even have multiple independent **Numbers** (eg. electerical meters mostly have 2 numbers for the high and low tariff).
|
||||
|
||||
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.
|
||||
Depending if you have only one of those types, you can `enable/disable (1)` it on the top left corner:
|
||||
|
||||
### Horizontal Alignment
|
||||
Ensure an **exact horizontal alignment** of the number via the alignment / reference setup:
|
||||
{: style="width:500px"}
|
||||
|
||||
| :heavy_check_mark: Okay | :x: Not Okay |
|
||||
| ------------------------------ | ---------------------------------- |
|
||||
|  |  |
|
||||
You can switch between the ROIs with the `Drop down box (2)`. If you need additional ROIs or delete them you can do this with the `control at (2)`.
|
||||
|
||||
### Correct Size for ROI
|
||||
Choose the right size of the ROI:
|
||||
> 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.
|
||||
!!! Warning
|
||||
The order of the ROIs defines how the individual digits are combined to the total number. The first ROI is the digit with the highest order (left side), then the second and so on. You can control the order in the selector tab and change it with the buttons `"move Next"` or `"move Previous"`.
|
||||
|
||||
### Model Selection
|
||||
#### dig-class11 Configuration
|
||||
dig-class11 - Models recognize the **complete digit only**. Here it is not relevant if the ROI fits the Border of the digit window.
|
||||
|
||||
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:
|
||||
|
||||
|
||||
|
||||
TODO rework
|
||||
|
||||
|
||||
As for the reference images you can change position, size and name of the ROI in the text fields or define them via drag and drop through the mouse button.
|
||||
|
||||
In most cases the digits are ordered in a equidistantly and have the same size, you can synchronize them with the `control in (4)`.
|
||||
|
||||
Don' t forget to save the settings with "Save" and do not reboot at this stage.
|
||||
|
||||
|
||||
|
||||
### Detail for ROI configuration - Analog Meters
|
||||
|
||||
For analog meters the ROI setting is rather straight forward as the meter is usually quadratic with a clear center. The circle should exactly fit to the outer size of the meter and the cross should be in the middle.
|
||||
|
||||
Here is an example with the details for the ROI "ana1":
|
||||
|
||||
{: style="width:500px"}
|
||||
|
||||
|
||||
### Detail for ROI configuration - Digital Meters
|
||||
|
||||
For the digital meters it is a little bit more complicated, as there are different options of digital models, that you can choose.
|
||||
|
||||
1. Digital meter, that only recognized full digits (0, 1, 2, 3, ... 9) - Naming: `dig-class11-....tfl`
|
||||
|
||||
**Advantage:** broad variety of types included in the training
|
||||
|
||||
**Disadvantage:** partially rotated numbers cannot be detected
|
||||
2. Model with sub-digit resolution (0.0, 0.1, 0.2, .... 9.8, 9.9) - Naming: `dig-cont-....tfl` or `dig-class100-....tfl`
|
||||
|
||||
**Advantage:** partial numbers can be detected and a better post processing is possible
|
||||
|
||||
**Disadvantage:** only limited types of meter types are trained due to the high effort for the training data
|
||||
|
||||
Details and the corresponding "perfect" setting is explained here: [Details ROI Configuration](https://jomjol.github.io/AI-on-the-edge-device-docs/ROI-Configuration/)
|
||||
|
||||
For a first run you can choose the following general settings:
|
||||
|
||||
* There is an inner and an outer frame for the ROIs.
|
||||
* Make the inner frame exactly the size of the number.
|
||||
|
||||
| |Example 1|Example 2|
|
||||
|---|---|---|
|
||||
| :heavy_check_mark: **Okay** | {: style="width:80px"} | {: style="width:80px"} |
|
||||
| :x: **Not** Okay | {: style="width:80px"} | {: style="width:80px"} |
|
||||
| :x: **Not** Okay | {: style="width:80px"}| {: style="width:80px"}|
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Correct Size for ROI
|
||||
Choose the right size of the ROI.
|
||||
The configuration of ROIs differs a bit on the selected model.
|
||||
|
||||
If you are in the initial setup, the model will be selectable in the next step. By default it is a `dig-cont` resp. `ana-cont` model.
|
||||
|
||||
In [Model Selection](../Choosing-the-Model) you find the differences between the different available models. Pick the one you think fits best your purpose. If you don't get to good result, try another model.
|
||||
|
||||
Here we only show the different configuration of the ROIs.
|
||||
|
||||
## Digit Model Selection
|
||||
### dig-class11 Configuration
|
||||
`dig-class11` - Models recognize the **complete digit only**. Here it is not relevant if the ROI fits the Border of the digit window.
|
||||
|
||||
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:
|
||||
|
||||
<img width="300px" src=../img/ROI_drawing.jpg>
|
||||
|
||||
@@ -56,15 +130,14 @@ For this model, there should be a border of 20% of the image size around the num
|
||||
| :x: **Not** Okay |  |  |
|
||||
|
||||
|
||||
|
||||
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 [Learn models with your own images](../Learn-models-with-your-own-images) how to add your meter's type of numbers to the training set.
|
||||
If you have perfect alignment and still are not getting satisfying results, most probably your numbers are not part of the training data yet. See [Collect images to improve the models](../Learn-models-with-your-own-images) on how to collect new training data.
|
||||
|
||||
|
||||
#### dig-class100 / dig-cont Configuration
|
||||
### dig-class100 / dig-cont Configuration
|
||||
|
||||
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.
|
||||
|
||||
First, the width can be set as for dig-class11, i.e. 20% margin left and right.
|
||||
First, the width can be set as for `dig-class11`, i.e. `20%` margin left and right.
|
||||
|
||||
<img width="455" alt="ROI-setup" src="https://user-images.githubusercontent.com/412645/199028748-c48ef5bb-a8d4-4c77-9faf-763e6cf77351.png">
|
||||
|
||||
@@ -79,3 +152,11 @@ Here an example:
|
||||
| ------------ | --------------------------------- |
|
||||
| :heavy_check_mark: **Okay** | <img width="125" alt="dig-class100_OK" src="https://user-images.githubusercontent.com/412645/199028380-7623776e-59b9-4356-ab55-3852253609df.png"> |
|
||||
| :x: **Not** Okay | <img width="125" alt="dig-class100_NOK" src="https://user-images.githubusercontent.com/412645/199028469-3a69ed31-e5c9-4038-a8dc-6d44a42437ed.png"> |
|
||||
|
||||
### Analog Model Selection
|
||||
Proceed the same way as with the Digit Model Selection.
|
||||
|
||||
### Saving
|
||||
To save push `"Save`.
|
||||
|
||||
A reboot is required to apply the changed configuration!
|
||||
Reference in New Issue
Block a user