Real Time Occupancy Detection

Naga Surya Praveen E
2 min readJan 7, 2018
Raspberry Pi and Camera

What’s this about?

This small project is about counting the number of people present in a room. I didn’t invent anything new. I combined different things and made them to work together. This project was done during my initial learning stages and hence it will not be a complex or advanced one.

What did I use for this?

Raspberry Pi
Pi NoIR Camera — 5MP IR Camera
Programming — OpenCV using Python

Working:

  • A python program will take snapshot from camera during regular intervals
  • Another python program will import this snapshot and process the image to find the count
  • This calculated count will be displayed on the screen and also emailed to a prescribed email ID

Prerequisites:

Install OpenCV on your Raspberry pi. Even if you don’t have Raspberry, this can be run on any computer with a camera.

Setup I used when I did the project. Pic contains Raspberry pi, pi camera, power bank for power supply, Keyboard and a Mouse

This program first converts the image into a grayscale image. After that it will detect human faces using Haarcascade library. Haarcascade library has been pre trained for detecting human faces. If we want to detect anything other than human faces, we can train the model by feeding it with several input training examples.

For example, if we want to make this program detect Mobile phones, first we should teach the library how a mobile phone looks like. For this we need to give several images of mobile phones for this so that it can classify how a mobile phone looks like.

Program for Snapshots

Program for Processing

Result

Program detected three persons

--

--

Naga Surya Praveen E

Programmer | Math lover | Positive thinker | I am not a robot 🤖