You could use a cli php script and the libgd support to average out all the pixels. And produce an average of a sample of the pixels. Shouldn't be too difficult to code if processing power isn't an issue.. Simple to code as well. I did something similar a while ago for a simple 'machine vision' experiment..

imagecolorat() will return the RGB value of a single pixel, and you can load the image into memory with imagecreatefromjpeg() or similar...

I use php/libgd for quite a bit of image work, and it handles all my thumbnailing, watermarking and proof printing requirements just fine, although on 16 and 8 Mp images it's a bit rough on processor load for the initial scaling process, so I scale all the images down using imagemagick and a n execute() first...

Cheers, Me.

Andrew Errington wrote:
Hi,

Can anyone comment knowledgably on determining the light level in a JPG image snapped by a webcam?

I have the simple requirement of taking hourly snapshots from my webcam in the back garden and posting them on my webpage. At the moment I have a cron job, which I tweak during the year to adjust when it takes a picture (i.e from 8 to 5 in winter to 5 till 10 in summer), but really it should be automated. I could rig up a light sensor, and the PC could query it before taking a webcam image, but really, the webcam itself is a light sensor (duh!).

I am thinking of the imagemagick 'identify' command, and maybe extracting the mean value of the red, green and blue channels and comparing them to a hard limit. Does this idea have merit, or is there a better tool?

I could also just look at the file size: at night the images are mostly black, which compresses to a very small file size.

Comments are welcome,

Thanks,

Andrew




Reply via email to