# Webcam Night & Day detection

**URL:** <https://forum.kirupa.com/t/webcam-night-day-detection/326062>\
**Category:** flash\
**Created:** [November 20, 2011, 9:31pm UTC](https://forum.kirupa.com/t/webcam-night-day-detection/326062 "2011-11-20T21:31:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruck](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@Bruck](https://forum.kirupa.com/u/Bruck)\
**Post date:** [November 20, 2011, 9:31pm UTC](https://forum.kirupa.com/t/webcam-night-day-detection/326062/1 "2011-11-20T21:31:19Z")

</div>

Hi, so I’m having a bit of trouble implementing a system that can detect night and day through webcam.

I’ve decided the best approach would be to detect the average colour of the webcam image, and through this it can be converted to grayscale and if its closer to black the background will be dark or if its white it’ll be brighter.

What I’m having trouble doing is working out how to achieve this, I’ve been using the kirupa webcam tutorial but I’ve got no idea how to actually go about working out the average colour.

[http://www.kirupa.com/flash/getting\_started\_with\_the\_webcam.htm](http://www.kirupa.com/flash/getting_started_with_the_webcam.htm)

I’ve seen a tutorial that actually applies filters to the webcam image so manipulating the webcam is possible.

> **[Flash AS3: Apply bitmap filters to a webcam image ⋆ Kasper Kamperman](https://www.kasperkamperman.com/blog/flash-code/as3-apply-bitmap-filters-to-a-webcam-image/)**
>
> Simple (beginner-intermediate) Flash Actionscript 3.0 code example on how to apply a bitmap filter on a webcam image. Also image rotation and simple motion detection (activityLevel) is included.

Anyone want to give us some help? It would be much appreciated.
