Meter Project Follow-Up
One day of meter reads. |
The Realtime Metering
program has been collecting data for the last eight months. I am fairly happy
with the results. Most of the time the program recorded the meter values
correctly. Though, there were still a few misreads that show up as zero readings on the graphs.
Meter cover. |
Placing a black plastic
bucket over the meter instead using a black trash bag helps to keep the camera images more consistent. The placement of the camera was pretty sensitive. For
whatever reason, I found myself wanting to fiddle with the camera alignment all
too often. The new warp calibration (as explained below) is much less finicky about camera position.
I started thinking again,
about what it means to see and to understand an image. Surely it is more than a
rigid algorithm that turns a numeric image into it’s text equivalent. When a
person looks at an image, they “know” what it means. I think of it as a person
comparing what they are presently seeing to an internal idealized cartoon of
what they may expect. There is a grading process involved. If the
grade is low then this cartoon is not like what you are looking at. Better
think of another cartoon of an image and try again. Eventually, a person finds
a cartoon of a remembered image that compares well with what is being seen. The
understanding part comes from labels that are already assigned to parts of the
cartoon, that match one-to-one with the
real-time image. A label is assigned to a defined area of the cartoon. If the cartoon was, lets say
of a man, then the set of pixels that make up the left leg might be labeled
“left leg”. When the cartoon image is
matched well to the real-time image then you instantly know the location of the
left leg and all the other labeled parts.
The calibration cartoon image has each segment drawn with a unique RGB color. |
This technique works
excellently for identifying the 35 segments that make up the five imaged digits of the Smart-Meter display. I drew a bitmapped cartoon of an ideal ‘Test’ image using
a different RGB color for each segment. For each color used, the most
significant digit of the red color component corresponds to one of the five digits
to which the segment belongs. The most significant digit of the green color component
corresponds to which one of the seven segments you are looking at. If a cartoon
pixel contains any blue color component then the pixel is ignored.
Warping the cartoon demo. |
During the calibration
process, the cartoon is warped until it matches the shape of the real image. I
start by aligning the centers of the cartoon and live image. The live image is
divided into fifteen (5x3) square blocks of 1024 pixels each (32x32). I warp
the cartoon image to fit the real image, one block at a time, starting with the
center block and then working outward. I make small changes to the block corner pixel positions and then count how many of the 1024 pixels are the same for both images. When the cartoon fits the real image block the best, the block corners are fixed in place; then on to the next block. Adjacent blocks have fewer corners to wiggle into place because at least two of their corners are already fixed.
The calibration process takes about a second of computing time, but calibrations
very rarely need to be performed. Once the calibration is complete, any image
from the meter can be quickly decoded by using that image’s pixel coordinates and the corresponding cartoon’s RGB values. If fifteen pixels in a
segment are detected then that segment is considered active. The active
segments are decoded to text by a binary look-up table.
Nonsense image |
My code for this program is embarrassingly gangly but seems to work well. Someday I may rewrite the program to be more structured and/or write a VB6 module that contains general computer image recognition routines that I could use in this and other image recognition projects.