Singapore Polytechnic - Centroid Counter using OpenCV in Python
Link to github: Github link
Introduction
The aim of the project is to develop a simple algorithm to count the number of people in the room. This algorithm was part of a bigger project, for the Engineering Academy Programme but his post will only focus on the algorithm.
The team
The following are members of the team(As of 7 Sep 2021)
- Khiu Kim Hong, Diploma in Electrical and Electronic Engineering
- Cheam Zhi Kai, Diploma in Engineering with Business
- Ang Yong En, Diploma in Computer Engineering
- Chan Qing Yi, Diploma in Mechanical Engineering
- Ngo Bing Han, Diploma in Electrical and Electronic Engineering
Solution
OpenCV OpenCV is an open source computer vision and machine learning software library. opencv.org/about/
Using OpenCV and python, the team achieved the aim by counting centroids. The way we ‘count’ the number of people in the room is to detect centroids moving pass a given threshold. A centroid is created and given and ID number when moving is detected. If the centroid moves past the ‘entry’ threshold, the program considers it as a person entering the room. Similarly, if a centroid moves past the ‘exit’ threshold, the program considers it as a person leaving the room.
If movement is detected near an existing centroid, that centroid is reused instead of making a new one.
Video demonstration