I'm capturing images using picamera and I need to detect when the sensor is covered by a hand, so almost full black image. what is the easier way to do that in python?

  • I have the same problem. I am using PIR and Pi Camera to detect my two naughty cats coming into the bed room. Usually the fat cat covers the whole view, while thin cat only half view. So I need to use python to monitor if the fat cat is coming in. I have written a simple statistical pattern recognition function. PIR triggers Rpi python which counts the black pixels. More that 70% black means fat cat, else thin cat. And I count the number of times fat cat coming in every day , staying for how long each time, .. My smart cat food dispenser has a cat face detector to / continue, ... – tlfong01 Jun 11 '19 at 1:35
  • And this is my fat cat dieting food dispenser design notes - CAT HOME DIY Q&A - SOLENOID HOW TO Postby tlfong01 » 2019-Jan-11 Fri 3:31 pm raspberrypi.org/forums/… – tlfong01 Jun 11 '19 at 1:47

There is nothing specific to a Raspberry in the question, but you can add the values of all pixels in the image, and if the result is below your threshold, it is considered too dark. Usually, a black pixel is represented by the value zero.

| improve this answer | |
  • 1
    Off-topic questions should not be answered, per the help: raspberrypi.stackexchange.com/help/how-to-answer – Brick Jun 10 '19 at 15:00
  • You may answer off topic questions in a comment. – Ingo Jun 12 '19 at 12:13
  • that's what I meant but how do I read the values of all pixels in the image? – Miky Jun 13 '19 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.