Detect blue sky?

I have no idea if this is the right place for this, but here goes:

I’ve been thinking it would be very cool if there was a way to detect (from a camera) if the sky is blue or overcast. It seems to me that it would be a matter of identifying the dominant color in a part of a camera feed (the part of the picture that shows the sky).

A sensor that tells you if the sky is clear (blue) or overcast would be so cool.

Any ideas or thoughts on this?

I haven’t built this myself, but briefly looked into detecting clouds: The recommendations I found use an infrared sensor to measure the sky temperature and compare that to the ambient temperature. For example mentioned here:

1 Like

This is not a direct solution like you are asking, but I use dark sky’s micro-weather to tell me the UV and cloud cover. I then use that to control skylight and window shades - either shielding the sun on a hot day or retaining heat on a cold night.

I don’t know what parts of the world have good micro-weather from the platform though.

I was thinking something along the lines:

(shell script maybe):

  • Download a snapshot of the camera feed every so often
  • crop part of the snapshot that shows the sky
  • Run something that can process a picture to tell me what the “dominant color” is? (ImageMagick?)
  • If white/gray - publish “overcast” via mqtt
  • If blue/azure - publish “clear sky” vi mqtt

Maybe this topic about object detection may be helpful:

That’s cool but ideally I’d want to stay away from cloud services.

http://www.imagemagick.org/Usage/quantize/

and

http://www.imagemagick.org/discourse-server/viewtopic.php?t=16936

might be helpful. I’ll report back here what I find.

I’m not so familiar with object detection, but maybe this is better:

I keep meaning to do something like this. I’ve got a few lamps set to turn on at sunset, but up here in the gloriously grey-skied UK it’s usually dark enough to require illumination long before the sun actually sets.

I was thinking of an ambient light sensor rather than some kind of sky-colour analysis. Of course, weather services can provide an ‘overcast’ reading, but it can’t really say if it’s dark enough in my living room to need the lamp on.

The problem with “dark enough in my living room” is that, even if you could accurately detect the brightness of the sky and the number of clouds, this will never account for the room your in, the windows you have, and how much of that light neighboring buildings block.

If you need to know how bright a room is, a light sensor in that room is the best way to go. If you don’t want this expense, a formula using sun elevation, cloud cover, and a specific coefficient for each room will likely get you close enough.

One of my bathrooms, for instance, would have a coefficient of 0, because it has no windows. If the lights are off, it’s dark in there. Always. My front living room, however, faces South. It gets a lot of light here in the Northern Hemisphere. And there is a street in front of it so neighboring houses are farther away. It has a much higher coefficient. But even that changes based on time of year, as the trees get more leaves and block more light. So, without a light sensor in the room, there’s no way to get this perfect. You have to settle for “close enough” which can be done with weather APIs, a calculation, and some fine tuning.

To the OP… this is an interesting project. As far as usability goes, in most parts of the world this can be fairly accurately determined using APIs. No sensor/camera needed. But, for the fun of the project, and the utmost accuracy, I find it interesting and look forward to seeing your development of this.

1 Like

Oh, my usecase wasn’t at all to measure how dark/bright a room is. (I have light sensors for that) - but rather to sense of the sky is blue or overcast.

Ie answer the question “is it sunny out?” With a high level of certainty.

What is your use case for this?

Literally this. Weather services will never be local or accurate enough.

Did you find a solution for this?

The problem i see with the camera identifying a “blue sky” is with the sun position. If the sun is directly oposite the camera, the sky is rarelly blue due to the brightness.

My suggestion is to use the sun elevation to achive what you are seeking.