Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine height of Coffee in the pot using Python imaging

Tags:

We have a web-cam in our office kitchenette focused at our coffee maker. The coffee pot is clearly visible. Both the location of the coffee pot and the camera are static. Is it possible to calculate the height of coffee in the pot using image recognition? I've seen image recognition used for quite complex stuff like face-recognition. As compared to those projects, this seems to be a trivial task of measuring the height.

(That's my best guess and I have no idea of the underlying complexities.)

How would I go about this? Would this be considered a very complex job to partake? FYI, I've never done any kind of imaging-related work.

like image 561
Mridang Agarwalla Avatar asked Jul 12 '10 10:07

Mridang Agarwalla


1 Answers

Since the coffee pot position is stationary, get a sample frame and locate a single column of pixels where the minimum and maximum coffee quantities can easily be seen, in a spot where there are no reflections. Check the green vertical line segment in the following picture:


(source: nullnetwork.net)

The easiest way is to have two frames, one with the pot empty, one with the pot full (obviously under the same lighting conditions, which typically would be the case), convert to grayscale (colorsys.rgb_to_hsv each RGB pixel and keep only the v (3rd) component) and sum the luminosity of all pixels in the chosen line segment. Let's say the pot-empty case reaches a sum of 550 and the pot-full case a sum of 220 (coffee is dark). By comparing an input frame sum to these two sums, you can have a rough estimate of the percentage of coffee in the pot.

I wouldn't bet my life on the accuracy of this method, though, and the fluctuations even from second to second might be wild :)

N.B: in my example, the green column of pixels should extend to the bottom of the pot; I just provided an example of what I meant.

like image 200
tzot Avatar answered Sep 21 '22 14:09

tzot