- Overview
- Programming the ESP32-CAM
- Setting up the server
- Creating training datasets for the models
- Training the Object Detector
- Training the Image Classifier Model
- Steps of Prediction
- Results in flask web app
- The ESP-CAM captures images of an analog gas meter.
- The camera communicates with a Linux server via MQTT at regular intervals.
- The server instructs the camera to take a photo.
- The camera sends the photo to the server.
- The server processes the image.
- the server sends a sleep command to the camera.
- The server processes the image
- OpenCV is used to preprocess the image.
TensorFlow Lite model
detects the dial plate's location.- The dial plate is cut into 8 pieces.
- A
simple CNN model
classifies each piece.
-
Object Detection (Tensorflow Lite - EfficientDet)
- The dataset is labeled using the labelImg tool.
-
Image Classification (Tensorflow - CNN)
-
Set Up Google Colab:
- Open the Model Maker Object Detection for Android Figurine notebook in Google Colab.
- Some changes are needed to train the model with the custom dataset.
-
Prepare the Dataset:
- Upload the labeled dataset to Google Colab.
-
Train the Model:
- Follow the steps in the Colab notebook to train the object detection model.
- Download the trained TensorFlow Lite model.
Use the train/number_classification/train_and_eval.ipynb
notebook to train the model.
-
If the image is tilted, the object detector marks a bigger area. Therefor it is important to balance the images. For this task, Hugh lines algorithm is used.
- The detected images are resized to 140x1000 pixels.
-
To find the coordinates of the numbers we utilize the contours of the threshold image. On the basis of the found contours' coordinates, the 140x1000 px images are cut into 8 pieces.
-
A tensorflow CNN model classifies the images into 10 classes.
-
The sharpened image of the dial plate is saved in the
/results
folder with the filename constructed from asequential number
, thepredictions
and thetimestamp
.
Pattern:<seq_num>_<first_5_nums>_<last_3_nums>_<timestamp>.jpg
Example:8_13678_902_1668970881.jpg
The images from the /results
folder are copied to the flask app's static/images
folder. The images are displayed on the web page.