Skip to content

This project is specifically designed to read gas meters. Initially using HoughCircles for feature detection, the project has evolved to incorporate a machine learning model, significantly improving accuracy.

Notifications You must be signed in to change notification settings

jddayley/gasmeter_reader

Repository files navigation

Gas Meter Reader

Dial 1

Background

This project is an enhanced adaptation of David Padbury's Power Meter Reader, specifically designed to read gas meters provided by Eversource in Hopkinton, MA. Initially using HoughCircles for feature detection, the project has evolved to incorporate a machine learning model, significantly improving accuracy. The process involves cropping to the meter's dials, normalization, and advanced image processing techniques.

Files and Their Functionalities

image_class_gpt.py

  • Purpose: Image classification.
  • Features: Configures the device for image processing using torchvision, torch, and transforms.

image_predict.py

  • Purpose: Manages the prediction process in image classification.
  • Features: Employs torchvision, torch, and PIL to perform image classification tasks.
  • Output: Processes data from gas_meter_reader, delivering four distinct predictions, one for each dial.

gasmeter.py

  • Purpose: Responsible for reading the gas meter and managing the publication of these readings.
  • Features: Utilizes system and data handling libraries such as sys, os, and json for integration with data publishing systems.
  • Output: Executes the publication of meter readings using MQTT, facilitating real-time data sharing.

gas_meter_reader.py

  • Purpose: Primary script for reading the gas meter using machine vision.
  • Features: Implements image processing and machine vision techniques.
  • Output: Dial 1 Dial 2 Dial 3 Dial 4

globals.py

  • Purpose: Manages global variables of the project.
  • Features: Defines variables like flags, error thresholds, sleep times, and dataset paths.

threshtransform.py

  • Purpose: Applies a threshold transform to images.
  • Features: Includes the ThresholdTransform class for image thresholding.

Usage

Training the Model

  • Setting Up Global Variables: Configure parameters in globals.py, including the training dataset path, error thresholds, etc., before training.
  • Executing Training: Utilize image_class_gpt.py and image_predict.py for training. The training utilizes images from the dataset path in globals.py, ensuring they represent the meter readings accurately.
  • Model Training Considerations: The model learns to recognize the gas meter's specific characteristics from the provided images. It's crucial for the images to encompass various readings and lighting conditions for robustness.

Deployment

Deploy the trained model using gasmeter.py and gas_meter_reader.py for actual meter reading and data publishing. The trained model interprets the gas meter readings and, if configured, publishes them using MQTT.

Hardware

  • Webcam: Using a Wyze v3 USB webcam, modified for close focus based on a YouTube tutorial (link).
  • Lighting: Employing LED lighting (Amazon link).
  • Enclosure: Housed in a Register Duck Boot (Lowes link).
  • Custom 3D Printed Enclosure: An enclosure created with a 3D printer. STL file included: STL Download

Data Errors and Solutions

  • Assumption of Increasing Readings: The system assumes a continual increase in gas readings.
  • Limitation on Reading Increase: Presumes that readings should not increase by more than 3 units since the last value.
  • Correction Method: Corrects discrepancies by replacing the first digit with the first digit from the previous reading and reassessing. This process is repeated for the second and third digits as needed.

Next Steps

  • Using RL: Using Reinforcement Learning to improve Prediction.

About

This project is specifically designed to read gas meters. Initially using HoughCircles for feature detection, the project has evolved to incorporate a machine learning model, significantly improving accuracy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages