Saving Energy Via Webcam-Based Meter Reading?
squoozer writes "Like many people, I am trying to cut down on the amount of energy my family and I use in order to save both the environment and my pay packet. Since I want to do this in as scientific a way as possible, I'm taking meter readings every day and recording them in a spreadsheet (OOo Calc naturally). Currently, in the UK at least, neither gas nor electricity meters can be hooked up to any sort of device that can query the meter for its current reading. Rather than climb down into the cellar every day to read the meters, it would be great if I could simply position a webcam in front of each meter and have the value logged automatically each day. The problem is that while I am a software developer (Java mostly) I have no experience in image processing (dials from the electricity meter) and don't really know where to start with this project." Does anyone have any advice for analyzing the visual data this reader would be gathering?
Take a look at the Java Media Framework. http://java.sun.com/javase/technologies/desktop/media/jmf/
But you must not block the meter dials from view. Someone goes to check the values manually, every once in a while (monthly?).
If you have the same kind of "spinning wheel with a mark" under the small dials, it might be easier to check for the number of revolutions of that wheel.
My meter reads in kilowatt hours, not amperes.
Give me Classic Slashdot or give me death!
I need to capture alphanumeric digits in a captcha for my spam business. Please give me all the tips you have on this subject.
Thank you!
vc: bombed
I'd say your approach completely depends on your goal. If your goal is as stated, then I'd use the webcams to get shots of the meters, then I'd take the 2-3 minutes or whatever it takes a week to pull up those images and transcribe their values into the spreadsheet. If the goal is a programming exercise, then go to town with figuring out some way to automate that few-minutes-a-week task. Of course, in order to do that, you'll expend a whole lot more energy than you'd take to read the meters (via the webcam shots) yourself.
This guy's the limit!
Post the images as CAPTCHAs that protect porn pictures. You'll have the values typed in for you in no time.
UTF-8: There and Back Again
Depending on the color of the faceplate and the hand, you might be able to mask off everything you don't care about (say everything but a small area around the center of the dial), run it through a hi/low filter to map the faceplate to white and the hand to black, and then just calculate the angle of the hand by searching the edge of the image for black pixels. So long as the cam is fixed and you know the coordinates of the pivot point it should be trivially easy to determine the angle of the hand based on the point at which it crosses the edge of the detection area. Once you've got the angle it should be trivially easy to map that back to a set of values.
Curiosity was framed, Ignorance killed the cat.
If it's digital I don't see any problems (except maybe proper lighting unless using an IR camera) but if it has dials I see a problem if it's somewhere between two digits.
There are a few tutorials on the net about image-processing (some very interesting using ANNs[artificial neural networks])
mov ax,4c00h
int 21h
Rubbish. Look up smart meters gas & electric meters which update the utility company continously on usage which they can provide to you as well. (currently insanely popular after the recent documentry on smart meters)
If your supplier is reluctant to include you in the trials, for electrical use try "Wattson" or other similar personal wireless power meters (also sold out everywhere, but there a cheaper more functional equivalents around)
A Kill-A-Watt might be a better choice for "power trimming", since you can get an instant reading of the power used by anything that plugs in.
On my website I have a couple of webcams that I grab the image from at a specific interval and store the result. Basically, if you get a Trendnet TV-IP201 and a Pentax 10mm f/1.2 lens with a C-mount to CS-mount adapter, you can just wget the image however often you want. Image processing is another issue, but I don't know anything about that.
If I have nothing to hide, don't search me
Your power company is probably already looking into standards like Homeplug (main org site) (wiki link) that provide meter data much more accurately than a webcam and image analysis software. This allows them to save money on paying sneaker-net meter readers, and real-time usage data for load balancing and prediction.
Whether or not they'll specifically give you access to the data is somewhat moot, since it's network-over-powerline and there are already consumer devices that can access the same network and (eventually if not already) be hacked to reveal the data being sent from your meter.
It's an exploding industry (like 20-30% CAGR in the US alone, higher in other less-developed areas where the first power meters will be homeplug-capable) so I wouldn't suggest putting too much effort into your image-analysis idea at least for a few months to see what happens in homeplug-world.
everything in moderation
There are many open source OCR tools available. Write a script to capture a JPG or PNG image every day from your camera and run it through one of the command-line OCR tools..
As long as your web cam doesn't get moved, you can set static cropping on the image so only the numbers are in the jpg file without a huge complicated border than might confuse the OCR engine.
"Saving Energy via Web-Cam Based Meter Reading? "
I'd put an induction clamp onto the line in my box and get the data from that point.
Shai Schticks:"You don't make peace with friends, you make peace with enemies"
Often the meter supports some sort of data export mechanism, and you just need to tie into it. Hacker extraordinaire Poul-Henning Kamp did this with his gas meter.
-bugg
I found this lower down, since it's IR, you can probably achieve the same thing with a web cam.
http://hackaday.com/2007/05/30/uk-power-meter-monitor/
The labor costs of checking meters is pretty significant to utility companies. One thing many municipality companies are trying is WiFi enabled meters that will report consumption to a meter truck as it drives down the street, saving hours apon hours of labor every day.
I haven't tried to tap into my own meter, but if they can read it, with sufficient time and effort I'm sure most of the readers of /. could read it as well.
-Rick
"Most people in the U.S. wouldn't know they live in a tyrannical state if it walked up and grabbed their junk." - MyFirs
Dear /.
Like so many others, I have a project I want to do. The project involves doing X, but alas I can not do X myself. Have any other /.ers done this and have some sample code I can look at and learn how to do this myself?
regards,
someGuyWhoWantsToBeABetterGeek
whois gawk date unzip strip find touch finger mount join nice man top fsck grep eject more yes exit umount sleep dump
Use a networked microcontroller connected to current transformers. That way, you could keep a nice log without even having to bother with image processing. A tiny uC could take care of all the ADC, and a Lantronix module could serve it to your network.
The "pygame" library in Python has a surfarray class that allows you to parse images as arrays.
Convert the image to black and white, with a tolerance level above the black of the circle and below the black of the dials.
Then you'll just have dials, so do a vertical scan then a horizontal scan.. whichever point has the least black pixels in common between both scans is the tip of the dial. Whichever has the most black points in common is the center of the dial.
Draw a line between those two points, measure the angle. Gotcha.
Prolly to complicated but i'd do it.. it would be a fun project.
Use ImageJ! It's free, JAVA based and easy.
I don't know if it is possible but can a ammeter that just goes around one of the conductors be adapted for this purpose? I used to work in the plating industry and we had something we called tong testers. It measured the amps at various points in the system. The beauty was that there was no physical connection with the conductors (I think it measured the magnetic flux that was created.). It might only work with DC. I am sure that there are some electrical engineers that know about such devices. What say you, could this work?
Lots of tools for Java image analysis in ImageJ - http://rsbweb.nih.gov/ij/
Source & docs are there too
I am a bioengineer not a programmer, but have had a to do a fair bit of automated image analysis, and it's a great resource for useful software parts.
take the pictures, and do human-OCR yourself when you want to look at the data.
I saw this on This Old House a while ago. I don't see a way to snarf it out into a spreadsheet automatically, but it brings the data to you wirelessly and logs/aggregates some of it for a while.
if the meter is digital it's easy:
-put the camera in a fronto-parallel position w.r.t the meter.
-identify, by hand, the bounding box of each digit.
-proceed to a learning stage, by acquiring images of the 10 digits (0..9).
-After removing image's noise, your problem reduces to: read each digit and compare it to your databse you have learned earlier.
Forget the OCR, you need to just monitor the lowest ticks of the meter. Monitor when the dial makes a complete revolution and you can base all your calculations off of that. I believe this meter is different than yours but it may give you some ideas. http://www.btinternet.com/~jon00/electmon.shtml
For the sake of your family sanity.
What you would do is first segment out all the dials, so that you have a separate image for each of them - this would be easy to do, given that you are using a webcam - just define the rectangles (bounding boxes) that surround the dials, and clip each from the image. Next, convert each of the dial images to gray scale, and threshold - convert to just two values, black and white - using a dividing value that will eliminate just about all but the dial pointer. Then, find the angle the pointer makes with horizontal (or vertical). That will give you one half of the answer, then determine (via the center of pixels representing the pointer) whether you are on one side of your horizon or the other. From this, you can assign a value. Rinse and repeat.
Did that solve the homework? It's really a simple problem...
Yes, it's windows only but it works wonders: http://www.roborealm.com/tutorial/Digital_Reader/slide010.php Point a webcam at it and use this for the vision processing.
Does anyone else find it ironic that he's concerned about his energy usage and that his solution involves using more energy?
There are power transducers like these:
http://www.crmagnetics.com/newprod/power_transducers.htm
The smaller ones have RS485 digital outputs so you can directly read out voltages, currents, active power and reactive power, frequency etc etc, but are limited to 25A for each of the three phases, so you need multiple transducers and sum up afterwards. Up to 16 transducers can use the same RS485 bus.
The larger ones have analog outputs 4-20mA or 0-10V proportial to the active power. You'd need an ADC in order to get your readings.
Without proper education you really should call an Electrician for installation.
As others have suggested, ImageJ is a good place to start. You could easily place multiple Regions of Interest (ROI's) around each dial, and output the pixel intensity of each. When the needle passes through a ROI, the pixel intensity will drop, since the needle is black. The readout will be a bit coarse, but should be sufficient for your needs. You can then take the results from each image, and translate those values using simple logic checks into digital numbers.
You'd probably be better off putting a split-core current transformer around one of the mains coming into your breaker panel, then using some kind of data logging multimeter to log the output. A quick search turned up this for $90, it's almost exactly what you'd need, PC interface too! If you could find a version of that with the ammeter clamp detachable from the body, you'd be set.
http://www.wescotools.com/p-6812-1000a-data-logging-clamp-on-multimeter-trms.aspx
The image analysis question is interesting. You are trying to read dial positions, so conventional OCR is probably useless (unless there is a package to do exactly that?).
What you can do is use image processing commands (in your favorite programming language; a shell script, Python, etc.) to crop the image to generate a small image for each dial. Then convert to grayscale (and maybe increase the contrast to highlight the dial). To then calculate the preferred orientation in the image, you calculate gradients along different directions. There will be a much higher value for the gradient along directions perpendicular to the preferred axis. This procedure is described very briefly in this paper:
Harrison, C.; Cheng, Z.; Sethuraman, S.; Huse, D. A.; Chaikin, P. M.; Vega, D. A.; Sebastian, J. M.; Register, R. A.; Adamson, D. H. "Dynamics of pattern coarsening in a two-dimensional smectic system" Physical Review E 2002, 66, (1), 011706. DOI: 10.1103/PhysRevE.66.011706
This is easiest to do if you use a graphics package that has directional gradients built-in (but coding it yourself probably wouldn't be too hard). Basically you create copies of the image and on one you do a differentiation in the x-direction, and for the other one a differentiation in the y-direction. Let's call these images DIFX and DIFY. Then you compose two new images:
NUMERATOR = 2*DIFX*DIFY
DENOMINATOR = DIFX^2-DIFY^2
Then you calculate a final image:
ANGLES = atan2( NUMERATOR, DENOMINATOR )
(All the above calculations are done in a pixel-by-pixel mode.) The final image will have an angle map (with values between -pi to pi) for the image. It should be easy to then use the avg or max over that image to pull out the preferred direction. You may also improve results by tweaking the initial thresholding, or by adding an initial "Sharpen Edges" step, or by blurring the NUMERATOR and DENOMINATOR images slightly before doing the next step.
In any case, the above procedure has worked for me when coding image analysis for orientation throughout an image (coding was done in Igor Pro in my case). So maybe it is useful for you.
How is it lame to ask other people questions when learning how to do something yourself?
...as if webcams are more efficient than software screen captures...
Here's a crazy idea: TURN OFF THE CAMERA AND COMPUTERS!!
Seriously, is it really that hard to read the meter every once in a while?
Here is my take on this ... for what it's worth.
Rigidly mount the camera in front of it, and use some constant lighting. You want everything to be the same. Note that the light can be off, except when you want a reading.
Take a bunch of baseline readings, as many as possible. Combine these using Gimp or Photoshop to edit out the dial needles (assuming analog needles). If your meter is anything like older US meters, the needles on the left will hardly budge. No problem. Ignore the left-most digits and concentrate on the right-most digits.
At this point, you have an image without needles, and you can take an image with the current reading. Make sure both images have the same brightness, and subtract the images. At this point, you can convert this gray-scale difference into a one-bit image easily enough. You might even want to eliminate any "on" pixel not connected to another "on" pixel to eliminate noise. The needles should pop out like crazy. This data should be easy to process. You have a couple of options.
First, would be to find the centroid of the blobs, and then computer the direction to the centroid from the base of the needle (since you mounted the camera rigidly, you should know the pixel coordinates of the needle bases). Some simple trig, and you have the angle. Some simple algebra to get the number.
The second option would be to somehow compute the actual line. I can imagine taking each point of the blob as a data point, and using basic statistics (least squares) to find the angle. Of course, this may blow up when the needle is vertical, so you also do a least squares on the transpose of your data, and take the better number. This will only give you an angle. Since rotating the needle 180 degrees will still result in the same angle, you will have to fall back on centroids. to possibly add/subtract 180 degrees as needed.
To summarize, not too conceptually difficult, but a time-consuming pain in the butt. I hope this helps.
"-1 Troll" is the apparently the same as "-1 I disagree with you."
Once you have your OCR working, I think you should use a database to store the data, not a OO Spreadsheet.
sqlite might be the easiest.
Stephan
http://stephan.sugarmotor.org
This along with the Computer Interface will be much more reliable. It is sophisticated enough to learn what appliances turn on and for how long and breaks down the usage detail for each.
This does require opening your breaker box and installing a loop around the incoming hot lines. This can kill you if you do not know what you are doing. If you are not familiar with working in hot boxes I recommend having an electrician install it.
My utility provides a box with a smart card that shows real time power usage, balance left on the card and approximate minutes until disconnect. Check with your utility for something similar. I like it much more than the monthly bill.
If you have a Mac with OS X you could have a webcam take a picture and save it to a particular folder. Then have a worklow in place that automatically takes the image of the meter, adds it to an email and sends it to you. You could then receive the email, see the picture and replay back with the meter reading typed in. You could then have another workflow that monitors for the reply email, copies the meter reading from it and then opens the excel and copies the value to the spreadsheet. This would take some "fooling around" to get right, but would not be that bad to do...
Build a little porn website and use the images as captchas. Someone will read the meter for you :-)
I have a problem with the premise of your question - how would this data help you? Obviously, it could tell you how much you're saving, but whether or not you're being efficient is simply a factor of how many things you have plugged in at a time.
This method also won't tell you which devices/appliances are the ones sucking the most juice. This is where a Kill-A-Watt can come in handy.
I recently trimmed my energy usage by:
-dialing up (or down) the thermostats - a/c, water heater, fridge
-switched to CF light bulbs
-used Kill-A-Watt on my computer equipment*
-started regularly changing my air filter in my furnace
-started using cold water for the clothes washer, and a low-temp setting for the dryer
*The Kill-A-Watt showed me that turning off my laser printer when I wasn't using it was worth $20/yr. Turning off my subwoofer when I wasn't watching a movie was another $20/yr. Turning off my cable modem and router at night is a few bucks/yr.
Mechanical or Spinning disk type meters can be read optically or magnetically, or if you have a dig meter with LED interface you can monitor the LED frequency; Both allow for real time monitoring of your homes load. Monitoring the aggregate by collecting at all load points would be better, but that's a bit more complicated. try: http://web.archive.org/web/20060509092108/http://www.seanadams.com/pge/ ...for a head start.
SLR-
take a look at the RoboRealm free machine vision program. It's very simple to use. Also do a google search for "OpenCV" for a more robust vision platform.
Mechanical Turk. Post the pictures and let people transcribe them for you.
Buy a killawatt or any other watt meter.
http://www.amazon.com/gp/search?&index=electronics&keywords=kill%20a%20watt&_encoding=UTF8
I found out that all of my speakers (computer speakers / external tv speakers) drain 5 watts when they are off (but pluged in). I through them on a power strip. It is not much, but everything adds up. .14$/kWh * .010kW * 24h/d * 365d/year = 12$ a year
With 2 sets of speakers:
My electric meter (and most everyone else's by now) uses pulses of IR light. The transmitter is either pointed upwards, or out the face. The blink pattern is very simple to decode; it's basically 1 blink per energy unit (I forget how much.)
I have a wireless power meter I bought through the power company which uses the blinks to show me how much energy I'm using. The only downside was that it was a royal, complete, and total fucking pain in the ass to get the receiver's sensor positioned correctly. The sensor's sensitivity is so bad, it has to be positioned very, very precisely.
Please help metamoderate.
Looking at the picture I would think the simplest place to start would be to process each pixel in the image looking for the pins at the centre of each dial (they all appear to be a different colour to the rest of the image so this should be easy).
After this it should be simple to read a circle around each of these points just far enough to be outside the central black hub but not as far out as the text (you don't care about the text just the position of the dials). By finding the middle of the black area returned by this circle you will have the position of the dial.
This can be pretty easy if the camera location is fixed and you can count on the dials being in the same part of the picture every time.
- Take a picture and note the pixels that define rectangles containing each dial.
- Set a threshold and turn the image into a binary black/white image so that the background is white and the dial (and numbers and circle) are black.
- Create a 'test dial arm', the same size and shape as an actual dial.
- Put the 'test dial' in the center of each rectangle and rotate it around in whatever increment you like (36 degrees would give a resolution of 0.1 on each dial).
- At each position, calculate the amount of overlap. Just do a pixel-wise AND of the test dial and actual image together and take the sum of the result.
- The position with the maximum overlap is your current reading.
It may be far easier to measure the current in the two mains power conductors with a current clamp and use that to estimate the power. You don't need to mess with the live wires as it works inductively.If you want it to be more accurate, measure the line voltage with a digital volt meter as well.
Both of these things should be available online and have convenient DC outputs that can be digitized, if not already digitized and available on RS-232 serial or USB.
From looking at your image, this doesn't seem like it should be very difficult to implement, unless you want extreme precision on the 10's dial. The dials themselves aren't moving, and you don't need to actually read the numbers. You just need to know where the tip of the needle is, then use that position relative to the center of the dial to get a reading. The first thing I would do is subtract the background. Use a couple different images to patch together a "background" image, where the needles are missing. Inconsistent lighting may pose an issue here, however, so controlling the lighting makes the software side much easier.
After subtracting the background and hopefully leaving you with a bunch of plain needles, apply a low-pass filter (smoothing) to remove and noise and cruft, then convert the image into a binary image. Dilate followed by an erosion to fill in holes left behind by numbers overlapping the needle (this may not be necessary). Then find the most extreme black blob (the one furthest from the center) on a dial (easy, as this is now a binary image). You now know where the point of the needle is. Convert the angle between point and center into a reading.
I'm just throwing out an idea based on the computer vision classes I took in college. It may not work at all. Other approaches may use a Harris corner detector and/or an edge detector.
I found this http://www.eissq.com/DialADC.html while reading hack-a-day. This may be exactly what you are looking for. Enjoy. http://hackaday.com/2006/02/18/digitally-reading-analog-gauges/
Of course others pick the solutions like momentum comparisons, directional gradients and so on. They are very nice mathematically and elegant solutions, but... DAMNED UNRELIABLE. They work very well in theory. In practice, you spend 90% time fighting white noise, 9% replacing computationally intensive algorithms with predefined results, and 1% by doing solid (but rather simple) maths to get the final result.
Oh, and second that much to get image from the camera into a format where you can read or set value of a single pixel in the image, but that's up to you.
First, mount the camera in a consistent way and give it consistent light so that the image doesn't change. Will save a LOT of work with aligning the picture you take and finding the arrows.
You work on b&w. If it's RGB, just average (r+g+b)/3.
- Take a few pics of the meter, combine them removing the arrows from the shots (using shop). That is your "neutral" picture. You keep one, forever.
- Take "current" picture. The one to be read.
- Run both through median (replace pixel value at (x,y) with the middle out of sorted pixel values from square (x-1,y-1):(x+1,y+1) - removing extreme noise pixels.
- Run both through gaussian blur (average value over square square (x-1,y-1):(x+1,y+1), softens edges getting rid of off-by-one errors on various edge areas.
- extract the arrows by substracting one from the other: dif(x,y)=abs(org(x,y)-cur(x,y)).
- binarize: change grayscale to 1-bit palette (p(x,y)=(p(x,y)thr)?0:1) pick threshold that gives clearest images of the arrows.
- median again to clean up the edges.
- denote detection zones - count each arrow as a separate image.
Now you have a set of images ready for proper recognition. You might calculate center of mass if you wish, by averaging the position of all the set pixels, or just preset the center in the axis.
Calculate distance from center to edge (nearest transition from 1 to 0) for all angles (transform radial-euclidean where applicable). The angle with maximum distance is the direction of the arrow. Alternatively you may examine a circle at fixed distance from center, detecting pixels set on the circumference.
Transform the result (in radians) to decimal. Round down (preferably basing on result from lower value). Add up results from the wheels.
45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
Some people learn from their mistakes, but smart people learn from other people's mistakes.
Because he wants to learn IN HIS FREE TIME. What a tool.
This is a joke. I am joking. Joke joke joke.
Just build an led and photo resistor to watch for the black mark on the wheel that spins around - every revolution is so much power used - hook this to a counter and you have a really simple power meter.
Building this hardware is simple - faster than programming - and cheaper than your solution.
look at
http://www.telusplanet.net/public/jacobs2/jake/projel/pwrmtr/
I once purchased a device for a mac (macos) that I believe was called ADControl. It was a box that had several analog and digital inputs and outputs. They sold an IR based sensor that you glued/taped to the outside of the meter which sensed the black mark on the "wheel" spinning in the older style electric meters. You then calibrated the pulses into watt-hours based on the number of pulses in a set time vs the increment on the dials. I would imagine such a sensor would not be hard to recreate.
Move to New Zealand where most electricity meters are readable electronically.
Itron/Schlumberger Centron meters have an infrared usage indicator facing upwards out of the top of the meter. It blinks briefly for each watt-hour used.
The LCD display also has a watt-hour indicator, either three blocks that "rotate" to simulate an old wheel meter or a single triangle. An indicator turns on or turns off for each watt-hour used (i.e. if you see the single triangle turn on and then turn off, that's two watt-hours used).
This web page has more info.
Just a thought.
Attack its weak point for massive damage!
I got a hall-effect ampmeter for the purpose of measuring power usage. It works pretty well, you just clamp it around the wire you want to measure.
The one caveat, though, which makes it far less convenient to use than it would otherwise be, is that it doesn't work if it surrounds both the positive and negative wires at the same time. I ended up modifying a power strip by cutting open the rubberized outer coating of the power cord so I could clamp the meter around just the postive cord.
In retrospect, the kill-a-watt would have been about equally useful, and I wouldn't have to convert amps to watts.
If I were having a new house wired, I would perhaps ask to have the main power cables into the circuit breaker box routed through some kind of enclosure that would allow me to use a hall-effect sensor directly.
Another interesting device if you just want to know how much power your computer is using: the power supply I'm currently using has an analog watt meter that fits in one of 3.5" drive bays in the front of my computer. It pretty much sits at 100-120 watts day or night. If I'm stressing the graphics card, it sometimes goes up to 180 or so.
I got it at a garage sale. I don't think the company sells them anymore, but here's a link. (Click on "gallery" to see the power meter.) I wish more power supplies were made this way.
How long will it take you to complete this project? How many times could you walk to the basement in that amount of time?
put the camera in a fixed position with consistent lighting. figure out the pixel coord of the center of each dial. pick a fixed radius from that center point where there is minimal interference (there is either dial, or its that off white color). now just look at all the pixels in the circle around that point at that radius, and it should be easy to figure out if you're pixel is part of the dial or not. it is going to be sort of close to white #ffffff or sort of close to black #000000, either way, there will be an easy to detect dramatic difference. figure out the angular range that the dial covers (eg it covers from 61 deg to 66 deg) average that, and you have a fairly precise direction its pointing, then convert that to whatever scale the dial is using.
to make it easier you could run the image through some imagemagick filters (command line image processing) to reduce noise or simplify the colors.
The meter should have an LED that pulses at a rate equal to the rate of consumption (the pulses/kWh will be written on the meter near the LED). It's an easier programming exercise to measure this, but you have to continuously monitor it and can't just take snapshots.
If the meter is really old it might have a rotating disk with a mark on it. You still get a pulse, but the image-processing exercise isn't much simpler than reading the numbers.
This is a perfect project for Amazon's Mechanical Turk -- http://mturk.com/
If you can get access to the meter hands, then you could put a red blob of ink at the end of the hands, and a blue blob in the centre. This would make determining the angle of each of the meters much easier.
To do this you could use simple image processing tools to guillotine the image up into the respective meters. Then find out the pixel location of the blue and red blobs by filtering out just those colours. From these two x/y pixel locations you could use simple trigonometry to calculate the angle.
If you cannot put a blob of ink on the hands, then you could process the image at the pixel level to find out the top most, left most, right most and bottom most pixel position that has black (i.e. the colour of the meter hand) on it. This would give you the approximate hand position, and hence the angle. It wouldn't be very accurate if the hand were either perfectly horizontal or perfectly vertical.
You have known lighting conditions and a strictly limited camera orientation and object configurations.
You can take the inverse of the pixel values as they would be if the hands weren't there (you can mock up the pixel values under the hands by hand since you only need an approximate inverse of the background plate). Then you add that inverse to an image and threshold to get black hands on white background.
Now you can use a hough transform to find all potential hands and you know the locations of the centres of the dials so you can sieve the potential hands down to actual hands. You can then do some simple trigonometry as you know which angles relate to which numbers.
Done.
Lots of folks have suggested methods for developing an algorithm so I'll point you to some software that is free and very powerful. ImageJ is funded by the National Institutes of health, it is freely available and more than capable of the degree of image analysis you'll require. As others have mentioned image quality and consistency can be a huge hurdle so make life easier by setting everything up with care.
mine (UK) does. flashes at 1/100th kwh usage IIRC (cant be bothered to look). always thought it would be a neat project, hook up a photodiode to a microcontroller to read/store uses, hook to a pc once a day or so to see how things pan out and for graphing.
If you want to go the image processing way, here is a suggestion for getting it done:
1. Use the MSER feature detector to segment out the needles.
(a binary implementation is available here: http://www.robots.ox.ac.uk/~vgg/research/affine/detectors.html#binaries
A Matlab version here: http://vision.ucla.edu/~vedaldi/code/mser/mser.html
Otherwise, google it and read the papers on it.)
MSER will return a set of features it found in the image. By simply filtering for a limited size range, you can select the needles. Here is what I get: http://lh3.ggpht.com/_z9CT12wxXK8/SRt0UtEF2eI/AAAAAAAAAJg/XhN_si8uqp4/s800/needles.png
The image shows ellipses fit to the needles, but MSER can give you the raw pixel segmentation as well.
2. Since you will only be working with this one meter, the rest of the job should simply consist of assigning the dials to their respective power of ten based on relative position and reading the dials by means of their orientation.
MSER is also fairly robust, so if you take care of step 2 properly, then moving the camera or changing lighting conditions slightly wont break it.
I used a microcontroller to watch the flashing LED on my wattmeter. Had it running for a year before I moved. I froze the webpage so you can still watch the log. Check it out: http://indigo.ed.ntnu.no/jalla/power Open source and everything! Woohoo!
I'm not familiar with UK AC wiring, but my circuit breaker box (CU) contains two incoming hot leads around which a clamp meter could be affixed. This could provide real-time data.
You could do anything from using a relatively high-end meter with built-in data output, to breaking down a cheap-ass analog meter and tapping the meter's needle/armature contacts for your data.
If you go this route, note that you'll need a pricier RMS meter to accurately measure AC watts with power factor accounted for, else you'll measure volt-amps, preferable only if you're billed for kVA/hrs instead of kW/hrs.
Thank you, Edward Snowden.
"Arguments from authority are worthless." —Carl Sagan
http://en.wikipedia.org/wiki/Hough_transform
ImageJ will handle capture, processing, and output. It has a very well-developed set of plugins and other tools as well: I wouldn't be surprised if someone already has a tool that does almost what you're looking for.
And really smart people trick other people into making mistakes for them so they can learn from said mistakes.
I love how two opposite comments have both been equally modded +4 Insightful. I guess that's Newton's Third Law of Message Boards or something......
This sounds almost exactly like the project I've just started on, but here I have the benefit of an electronic meter, which flashes a LED for each watt-hour of electricity consumed.
What I've done is use a fibre optic experiment kit (basically, a photodiode and a length of plastic FO cable) to convert the light pulses into pulses feeding into a this card [http://www.velleman.be/ot/en/product/view/?id=351346] . Then I'll read the counted pulses from the card every 5 minutes (or whatever period you want)
The trick is that you can't modify or hack into the meter at all - the supply companies are very serious about meter tampering, and I wonder how they'll react to seeing this optical-only coupling device.
If you've only got a mechanical electricity meter, there is more than likely a spinning disc that's driving the cogs behind the dials. Typically the disc is silver with a black section, and is visible via a window on the meter. If you were to shine a LED onto the disc, and measure the reflection back off the disc (both via fibre-optic cables) then you might be able to generate one pulse per disc rotation. Meters are generally marked with how many rotations are made per kWh.
To those suggesting kill-a-watt meters - that's fine for appliances, but if you want to measure whole-of-house usage ( including things like 3-phase air-conditioning units, lighting, wall ovens ) then the meter box is THE place to do it.
I found the Power Cost Monitor that reads the meter in a simpler way: count the revolutions of the spinning disc. Unfortunately, the UI seems a bit clunky though. Ideally you could hook it up to a computer and plot usage against time, and have alerts when your consumption is exceptional.
The first approach I can think of would be to imagine a vector (a ray) going from the center of each dial to its circumference. Step the angle of the vector, from 0 to 360 degrees, and for each step, iterate along the vector from the center out, find pixel coordinates along the vector, and count how many dark pixels (darker than some threshold) you find along that vector. When you find several vector angles which all have high dark-pixel counts, take the middle one as being the angle of that dial.
The critical thing in that case will be positioning the camera solidly so that the centers are always aligned the same way in the webcam pics, unless you find a way to recognize the centers of the dials too.
You're making this far too hard.
The way to do this is to use a split-core current transformer. You need two of these, one for each hot lead coming into your house, usually placed after the main switch. They clamp around one conductor of the power cable, but don't contact it, so they're safe. Out comes a voltage from 0-5V, proportional to the current. You can wire them in series, to get a single signal (phasing matters). Run the output (which is AC) through a full-wave bridge, and put a capacitor of about 100ufd across the output for filtering. Feed the output into some low-end microcontroller with an A/D. Transmit the data somewhere else for further processing.
You could do it like this. Just try to crop the image so it will only show the numbers. Next generate images with numbers and start comparing them to the images from the webcam :-D
http://it.slashdot.org/article.pl?sid=08/10/08/2132212
Don't go nuts with trying to resolve the arrow then figuring out where it's pointing. That can be fairly hard because you're dealing with a bitmap that you have to convert to vectors. I think the best approach is more simple:
1. Use the webcam to film the meters. What you want is to record at least one full revolution of one of the dials. You want a set of images that show the dial in just about every position. Ideally you'll have enough images that the dial could never be completely between two images, i.e. the dial overlaps itself in subsequent images. Write your java code to read each one of these into an array of Image objects, and store the corresponding value of each Image in a Hashmap (this is the most tedious part of the project, I think)
2. Does the webcam have an api to snap an image? If not, you'll need to have the webcam take an image and save it to a dir every x minutes, then use java to read the image.
3. The image that you grab in (2) will have several dials that you want to read. Play around until you isolate the regions that contain each dial. Photoshop is actually the best way to do this, you can just move the cursor to the area you want and read the coordinates. The idea here is that you want to read each dial in such a way that it looks exactly like the others. You create a new Image from the first for each dial, the images should look almost exactly the same except for the position of the dials.
4. The images you got in (1) should be stored in an array. When you need to read each dial Image that you got in (3), just loop through the stored dials and XOR each one as a Bitmap with the one you're trying to read. Then sum the resulting 1's. The lowest total is the closest image, use it's value. After you try this a few times you can tweak it by dumping the results of all the comparisons to a csv and using a spreadsheet to look at what's happening. If it's fairly consistent you might be able to get away with some performance optimization such as getting rid of some Images or stopping when you get a recognized hit.
-t.
You actually have a pretty nice setup -- assuming your webcam sits still, the dials will always be in the same location in the image. Grab some software like Octave to try out a few algorithms. I'd try running a Canny edge detection on the circularly masked regions corresponding to the dials. You'll have strong edge response from the two edges of the pointer for the dial. At that point, you'll have to write some sort of clever algorithm to find out which direction the dials are pointed in.
The more I think about it, there's an even simpler solution: mask out everything except the very inner circle of the dials. Then run a threshold on that image and you should get all white (where the pointer is not) and a black segment. Sample around that circular region and the mid-way point of the black section is where your dial is pointing. I'm not sure if that made very much sense...
There are a few ways to go about it, but luckily you have incredibly controlled conditions -- you know exactly where the dials are and the lighting will most likely stay very constant over time (this is an assumption I'm making). With all of that knowledge about the problem, a bit of time reading about image processing (and honestly, it's quite a solvable problem!) and you'll have yourself a solid solution in no time.
Good luck! Hope this gave you some keywords to look up.
Use your vision balls that you keep in your skull case! [Hint: if you can't find them look above your food taster]
Quick check of "automated webcam" pulls this:
Dim imageURL
imageURL = "http://www.mtbachelor.com/@@/cams/wvskycam.jpg"
Function SaveBinaryData(FileName, ByteArray)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeBinary
BinaryStream.Open
BinaryStream.Write ByteArray
BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
End Function
Function BinaryGetURL(URL)
Dim Http
Set Http = CreateObject("WinHttp.WinHttpRequest.5.1")
Http.Open "GET", URL, False
Http.Send
BinaryGetURL = Http.ResponseBody
End Function
Function doSave()
Dim image, fName, p_month, p_day, p_hour, p_minute, p_second
image = BinaryGetURL(imageURL)
p_month = padZero(Month(Now))
p_day = padZero(Day(Now))
p_hour = padZero(Hour(Now))
p_minute = padZero(Minute(Now))
p_second = padZero(Second(Now))
fName = p_month & "_" & p_day & "_" & Year(Now) & "-" & p_hour & "_" & p_minute & "_" & p_second & ".jpg"
SaveBinaryData fName,image
End Function
Function padZero(val)
If(Len(val) 2) Then
val = "0" & val
End If
padZero = val
End Function
doSave()
What's the point of trying to save energy if you spend so much energy trying to know how much you spend? Having a webcam 24/7 online, probably a small computer behind, some router, PLUS the energy that was needed to produce all this stuff -- that's insane! Cool geeky idea, but think about it: why don't you make some real effort for the planet and give yourself a 2-minutes exercise a day?!?
I use an EON Energy Monitor. EON have being given them away "free" when you sign up to getting energy from them. It is infact a re-branded Current Cost Energy Monitor. http://www.currentcost.co.uk/ The one problem is that it does not easily allow me to check the meter reading against the energy that has been used, but it does mean that I can see the energy usage. I noticed that on the bottom was an RJ45 connector, after a bit of Googling, I found that its a TTL level serial port: http://www.retallack.org.uk/dokuwiki/doku.php?id=energymonitor
The total power usage of your house gives you no clue of what the biggest contributors are, unless you're prepared to spend a few weeks running only one appliance at a time. This data would only help to see if the energy-saving measures you're taking have worked.
Get a Kill-A-Watt and take some time to learn the characteristics of your appliances. The even simpler approach would be to read the appliance's type plate or manual. Hell, any website on in-house power usage will have a list of the biggest power hogs in an average household. Start with those.
And there's another approach: spend some time observing your family. Do they leave the lights etc. on in empty rooms? Do computers run 24/7 instead of when they're needed? Are the laundry/dishwasher programs they use appropriate, or can a shorter/more economical program be used with satisfactory results?
I have made code that does just what you want, but with digital display. Code is here if you want to take a peek. http://www.rouvali.com/fileadmin/Download/CNCMittari.zip
(code heavily relies on apearance of measure dial I am using, so you can't use this code?)
Basically what you want to do is:
Figure out where your dials are in web cam picture. Maybe try finding edges or draw some blue dots so you can scan for. After you know position for two dows, you can calculate dial center position in picture. With every dial, draw imaginary circle around centers. Diameter so small that it goes 'inside' numbers. Within this circle, find darkest dots. There you got direction where pointers are pointing. And that can be converted to numbers. Be careful with light, if possible avoid reflections. (light thru paper is good trick, make sure it does not burn anything) As you can see in your picture, pointers in your picture are black, but whitest dots in your picture are in those black pointers.
http://rubenlaguna.com/wp/2008/07/18/voltcraft-energy-control-3000/
The opencv (cv=computer vision) library has many functions that will aid you in your quest.
There's an active group to discuss algorithms and implementing opencv: opencv at yahoogroups
Something like this might be useful (it is in German):
http://www.elv.de/Stromz%C3%A4hler/x.aspx/cid_74/detail_1/detail2_437
we constantly do this kind of stuff in http://www.resourcekraft.com/
The easiest thing to do here is to forget about your existing meter. Just use one of the new modbus over TCP meters and install it in series after your existing utility meter. Some of these have embedded webservers so you don't even need to do programming. see here for a rather advanced example: http://www.electroind.com/shark100s.html/
Liam
Dear /.
Like so many others, I have a project I want to do. The project involves doing X, but alas I can not do X myself. Have any other /.ers done this and have some sample code I can look at and learn how to do this myself?
regards,
someGuyWhoWantsToBeABetterGeek
As it turns out, yes, and I am that guy. smellsofbikes was kind enough to point this out in an earlier post. So sounds as if this were a perfect strategy to leverage some other /.er's existing project into something cool and potentially useful.
I say this as a "young scientist" (the EU's term for us) who eschews the traditional publication factories-- I mean scientific journals-- in favor of publishing online where the audience is more likely to use my research. This is how science is supposed to work... this is how science originally worked. Galileo didn't publish in a "journal of science", he published in the open and then people said, "Cool, I wonder if I can do that?" So what better medium for this effect in the modern world than /. ?
www.eissq.com/BandP.html Ball and Plate System. Amuse your friends. Crush your enemies.
Some electricity meters have a LED that blinks at a different rate depending on how much power is being used. If yours has one it would be easier to hook up a light detector rather than an entire image processing setup.
The meter gauges look identical to the ones in the U.S., so if it's read the same way, all you need is a program to analyze a piece of a photograph for presence or absence of an image.
In the U.S., the rule is 'read down', if a needle is between two numbers you count it as being as the lower of the two. If it's on the number line then you count it as that.
The example picture shown is read as 375,064.4; I originally wasn't sure whether the segment I read as 5 (because the needle was very close to but I wasn't sure if it was on the line) was on or just before the 5, except the number 'below' it was between the 9 and the 0; since it was past 9 and back to zero, that means it was no longer 4 so it had to be 5; at that close if it was still 4 the number below it should have been at least an 8 or more likely a 9.
In fact, (at least in this area) the tariff schedules for most utilities require meters be replaced (at no cost to the customer), about every 30 years or so, because as they get older they tend to favor the customer more by reading 'slow'. Especially gas meters, they're more mechanical than electric ones, but the use of a photograph works the same for both types of meters too.
You need something to take a 'snapshot' of the meter. By positioning the camera, you can fix it so that it takes the same image. Since you know where the dials are, you fix it so that you isolate the portion of the dial which is normally blank except for the needle indicating the reading for that segment (100,000 hours, 1,000 hours, etc.) Where the area is other than blank, that's the number, so that the area between 3 and 4 is the '3' value for that digit. Each segment only has one of the 10 possible values as something other than blank because it only has one needle. If you get something else you've got a contamination problem, e.g. something got in the way or the camera moved.
So once you have the particular segments, and the slices of each segment representing each digit, then you can check each slice to see which is other than a blank image. Set that value, then you can go on to the next digit. It ain't hard to have something analyze an image to determine if it's empty or not, you just have to select what part of each image is a digit segment and which is a slice of that segment representing the number from 0 to 9. It's basically one or more bounding boxes representing a curve-shaped rectangle for each slice. Then once you know what each segment is, you multiply the segment's value by its multiplier, e.g. 100,000 for the 100,000 hour segment, etc.
Then you just check what the value is, and take a snapshot, say, 4 times every day or however often you want to check usage. More often than probably every 6 hours won't tell you much as you're unlikely to use more than about 8 KW in a 6-hour period based on the average home, at least in the U.S. at an average of 960KWH per month, and U.K. usage probably isn't much different or might be less.
If you're interested in average hourly usage, you take a snapshot each hour; if you want peaks, try every 15 minutes. Otherwise once every six hours or once a day or however often you want an idea of how much you use and how fast. Processing time for the image shouldn't be more than 10 seconds at most.
---- Paul Robinson <paul@paul-robinson.us> My Blog
The lessons of history teach us - if they teach us anything - that nobody learns the lessons that history teaches us.
My electricity supplpier (Southern Electric) in the UK sent me one of these meters in the post when I joined.
I've did some rough image analysis this way: if you have a jpeg, png, bmp, etc of the image dials, use ImageLoader to create a java.awt.Image object. Loop through each pixel, converting from RGB to HSB (methods in Image). Then, check the value for brighness (B): if it's > 0.5, then consider the pixel to be 'black' (or is it 0.5, I can't remember). You'll have to do some vector calculations and some thinking, but you should be able to determine where the arrows are pointing.
Look at the front of your meter and read the name plate. It will have a bunch of gibberish like meter class, meter form, service voltages and something called Kh with a number beside it. It will most commonly have a 1.0, 7.2, 14.4, 21.6, or 10.0. This number is representative that each time the disk turns that number of watt hours has been registered. If you meter is solid state there is a test led either on the top of the meter or in the hog nose (but not limited too) that flashes infared when it registers that number of watt hours. All you need to do is count the pulses or turns of the disk. This tells you in a Wh resolution how much energy you are consuming. This is way better because with that resolution you can record things such as load profile and demand and analyze your energy usage throughout the day. All you need is a pin diode to detect these pulses. This is a much much easier solution than messing with image processing and trying to control the lighting on your meter that most likely resides outside in the sunlight. And it allows you to read your meter at night.
...have the value logged automatically each day.
Really? You really need OCR or image processing to automatically convert a once daily number?
Set up the webcam to take a daily picture, and type in the number yourself. It'll take what, 15 seconds per day? 2 minutes for an entire week, less than 10 minutes for an entire month's worth of data? You'll end up spending more time configuring the automatic reader than you would typing in an entire year's worth of data.
Poul Henning-Kamp has already done that, check his page:
http://phk.freebsd.dk/Gasdims/
Black & Decker EM100B Energy Saver Series Power Monitor.
This has a meter reader gizmo powered by a couple of AA batteries that attaches to your electrical meter and then sends data wirelessly to a small portable lcd display.
The meter reading gizmo does not interfere with the ability of your power company to read the meter when they stop by periodically.
Amazon sells them for $99.
I have had one for about 2 weeks now and it is really interesting to see what my hourly usage is when various household appliances kick on/off.
You could use a k nearest neighbor algorithm to compare dial positions. The problem is that you would need pictures of all the possible dial positions to use as a training set, and the camera couldn't be moved much, or it would error.
I've been investigating ways to measure electricity consumption as well. There's the Kill-A-Watt and the T.E.D. (The Energy Dectective).
http://www.theenergydetective.com/what/overview.html
get one of these: https://www.ecogadgetshop.co.uk/ShowProducts.aspx?Category=ecoProducts It's not documented, but you can also get a cable to hook the receiver up to a serial port. You can pick a cable up from ebay (google for currentcost meter). A quick google for currentcost meter will bring up some hacking sites showing how to get the data from the meter.
It is quite cheap (30 UKP), and is a very geek-friendly product. It has the all important serial interface which sends out the data every 6 seconds, but it is a TTL-level interface, which gives purchasers the oportunity to exercise or develop their hardware skills, by constructing their own interface with the widely available MAX232 chip and a few capacitors. It also provides an oportunity to exercise software skills when parsing and displaying the XML data the port sends out.
It's almost as if the designers decided to provide an interface, but also wanted to provide a few challenges for users to solve.
Here are some more links from CurrentCost fans:
http://currentcost.wetpaint.com/?t=anon
http://www.sgurr.co.uk/lundycam/energy_monitor_interface.html
Out her in California, PG&E is replacing 5 million electric meters with Smart Meters, but they are only about 10% done. It should take another 5 years. They transmit the data back through radio waves. I was thinking the same thing regarding using a camera that would read the meter, take a picture of it and send the data to a website. It could be a new cover for the existing meter and your done. This would be a great invention. I know that there are many patents out there for automatic reading. Check out freepatentsonline.com to search. Anyhow, our iPhone app, MeterRead allows you to simply match the dials to your meter, then you record the data and get feedback such as elapsed time since last read, total kW-h's used, average watt load and and a 30 day estimated usage based on the current read. You will like it if you try it! We have a YouTube video if you want to see it in "action" (the video is pretty boring, but informative).
http://www.telusplanet.net/public/jacobs2/jake/projel/pwrmtr/
http://web.archive.org/web/20040603190403/http://www.seanadams.com/pge/
uses a laser pointer to count the holes in a disk that spins on many power meters. much easier than OCR the analog dials
It happens that, some time ago, I completed a similar project to read my natural gas meter using a usb webcam. I've finally gotten around to posting a quick writeup, and implementation in Python: http://www.jjoseph.org/misc_projects/meter_reading_with_a_webcam.html. I'd be pleased to hear any feedback regarding my own or better methods. ~Jacob