I am trying to use a Pi Camera to take various pictures, but only if the overall picture is not pitch black or really dark (as I will mount it in my office and do not want it going while I'm away). I've got a Raspberry Pi Zero with no internet and do not have access to the graphical interface while it is mounted. The camera runs on a
for loop within a sentinel
while loop (to keep tabs on a counter variable) that takes a picture at constant intervals and names the images based on the actual loop iteration to create a time lapse-like stream of photos.
How can I access the raw camera data, preferably in a 1D array, and use it to determine if a picture should be taken before it actually is. I don't want the picture to be taken then compared for storage reasons. I'm using the standard
from picamera import PiCamera to use the package for the camera.
I can use this algorithm (https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color) to determine particular pixel's grey colour value and compare it to a threshold to determine if it is considered "dark". I will probably find the average colour of the entire picture and then compare that to a threshold.
I am looking for a simple implementation in Python that will help solve this problem. If you've got anything please let me know. I am sort of new to Python but I have 3 years experience with vanilla Java self-taught.