Journal of Multimedia Information System
Korea Multimedia Society
Section B

People Counting System using Raspberry Pi

Md Israfil Ansari1,*, Shim Jaechang1
1Department of Computer Science, Andong National University, Andong, Republic of Korea, israfila3@hotmail.com, jcshim@andong.ac.kr
*Corresponding Author: Israfil Ansari, 1375 Gyeongdong-ro, Andong-si, Gyeongbuk, israfila3@hotmail.com.

© Copyright 2017 Korea Multimedia Society. This is an Open-Access article distributed under the terms of the Creative Commons Attribution Non-Commercial License (http://creativecommons.org/licenses/by-nc/4.0/) which permits unrestricted non-commercial use, distribution, and reproduction in any medium, provided the original work is properly cited.

Received: Dec 02, 2017 ; Revised: Dec 06, 2017 ; Accepted: Dec 09, 2017

Published Online: Dec 31, 2017

Abstract

This paper proposes a low-cost method for counting people based on blob detection and blob tracking. Here background subtraction is used to detected blob and then the blob is classified with its width and height to specify that the blob is a person. In this system we first define the area of entry and exit point in the video frame. The counting of people starts when midpoint of the people blob crosses the defined point. Finally, total number of people entry and exit from the place is displayed. Experiment result of this proposed system has high accuracy in real-time performance.

Keywords: People counting; Raspberry Pi; Blob Detection; Mixture of Gaussian

I. INTRODUCTION

Video analysis covers many research topics such as people tracking, crowd analysis etc. Traditionally people counting systems uses laser sensor [1] for detection but they need more resources and it is not that effective. In [2] the authors proposed a real-time crowd density estimator based on Markov Random Fields. By the rapid growth of surveillance system in public and private place, human and human behavior detection became most popular research area. People counting techniques includes counting by detection, counting by statistics, and counting by tracking. In recent years, human detection using deep-learning became most popular method to work on. But it is very expensive and difficult to implement in raspberry pi. Raspberry pi 3b has Quad Core 1.2GHz Broadcom BCM2837 64bit CPU with 1GB RAM through which deep learning process will be difficult to implement. Raspberry Pi3 made computer vision possible on the Pi platform using Python and OpenCV perspective. It also has Integrated 802.11n wireless and Bluetooth which also help to implement computer vision in various dimensions.

Some people counting system has been made based on face detection. In paper [3], the author used face detection to locate people, then Kalman filter to track people movement and then counts people according to movement paths. But faces detection is possible when a camera is set on a location where people face appears to the frame. Face detection based system has not been successful because for face detection camera should always install towards face area.

Counting the number of people that enter and exit from some commercial area or private area is very important in today’s surveillance system. To count the camera is either installed on the ceiling or on the wall with different angle. In this case face detection will be very challenging task.

In this paper, we process the people counting system where the raspberry pi along with pi camera will be mounted on the ceiling at the entrance of the laboratories, commercial place, etc. this will help to detect the number of people entered to particular place and also tracks the number of people came out from the place. Firstly, in order to reduce computation costs and cope with various complex surveillance situations for foreground extraction, an adaptive components number selection strategy for mixture of Gaussians model is proposed. Secondly, blob detection is done to classify people. Thirdly, each pedestrian is tracked through consecutive frames using the Kalman filter techniques and cost function. Finally, the resulting trajectories are analyzed to count people entering or leaving the room. Every business with a physical space should count customer traffic in order to see the bigger picture of what is going on in their business. Entry and exit number will help commercial place like supermarkets to track their customer. This proposed system separates the counts by entrance, it utilizes readers mounted at the entrances to count people as the walk into the facility or zone. It will also help to generate business intelligent report with the help of its data and enabling store owner and business managers to make informed business decision.

II. PROPOSED SYSTEM

People counting is a challenging task and has attracted much attention in the area of video surveillance. The proposed system presents an automatic people counting system based on face detection, where the number of people passing through a gate or door is counted by setting a video camera. System of people counting is important for security application (for example, in the circumstance of a clearing, it is key to know what number of individuals are available inside the observation zone at any given time), passerby activity administration, visitors stream estimation. The counter requires two stages: discovery of individuals and following to check individuals directionally. It also focuses on an implementation of OpenCV in an embedded system like raspberry Pi to create a mini-standalone station for counting people. The basic idea is to first use the frame difference to detect the rough edges of moving people and then use the blob detection along with erode and dilation to classify people. Person will be tracked by following the detected human blob and then this person will have counted if its touches the counting line. It is mainly containing five modules i.e. getting video frames, setting tracking area, detecting human and counting people.

jmis-4-4-239-g1
Fig. 1. System Framework.
Download Original Figure
2.1. Computer video frame

In this proposed system opencv3.1 and pi-camera is used to capture video frames. Pi-camera is used to make the whole system a compact which can be installed in any place. In OpenCV, a video can be read either by using the feed from a camera connected to a computer or by reading a video file. The first step towards reading a video file is to create a VideoCapture object. Its argument can be either the device index or the name of the video file to be read.

2.2. Setting tracking area

Here four lines has been initialized as shown in Figure 2. Red line denotes the entry point of people, if people blob cross the red line it counts one person enters. Blue line denotes exit point i.e. if a person crosses it will count as one person exited. Other two lines denotes entry and exit limit point. The lines are drawn using OpenCV polylines method of imgproc class. In polylines method the parameters are as follows: where is the object being drawn to, the coordinates, should we “connect” the final and starting dot, the color, and again the thickness.

jmis-4-4-239-g2
Fig. 2. Setting Tracking Area.
Download Original Figure
2.3. Human detection

Human detection is done using background subtraction. For background subtraction Mixture of Gaussian [4] technique is used. After background subtraction threshold is used to understand the moving object more clearly. Then we find the human blob by searching the contour in the frame. Blob i.e. Binary Large OBject and refers to a group of connected pixels in a binary image. The term "Large" indicates that only objects of a certain size are of interest and that the other "small" binary objects are usually noise. The contour detector combines multiple local cues into a globalization framework based on spectral clustering. Here contour has been classified to detect human. Contours can be explained simply as a curve joining all the continuous points (along the boundary), having same color or intensity. The contours are a useful tool for shape analysis and object detection and recognition

jmis-4-4-239-g3
Fig. 3. Human Detection Using Background Subtraction.
Download Original Figure
2.4. Human location tracking

After human detection we find the midpoint of the contour and then we track the X and Y position in the frame. To find the centroid of contours, moments function of in OpenCV is used. After moments Centroid is given by the relations, Cx=M10/M00 and Cy=M01/M00. This will return the centroid X and Y position. The tracking starts from the entry and exit limit point. When a person appears crosses the limit line, the location of the person is tracked as he moves forward. All the tracked location is saved so that we can check whether the person has crossed the entry or exit point. Along with tracking point an id is assigned to all the moving person. When person is located on limit point and it is checked whether the person was located on entry limit or exit limit. Using the limit point it is then tracked whether the detected person moving towards entry or exit point. This X and Y axis location helps us to find whether the person has crossed the defined area or not. Here tracking starts from the entry-limit point to exit-limit point. If the person crossed the entry or exit point it will counted respectively.

jmis-4-4-239-g4
Fig. 4. The result of human detection using proposed method.
Download Original Figure

III. Conclusion

This paper presents a people counting system using raspberry pi based background subtraction and blob tracking. A counting line is defined on the video frame and tracks the detected people who crossed that line. Finally, we display the number of people has entered and exited from a place. By testing the system in the laboratory and few videos, experiment results show that this system has impressive real-time performance and high accuracy. However, the is some issue on wrong counting. The experimental results show that this raspberry Pi-based system can be used as a simple people counter station.

REFERENCES

[1].

Daniel Hernández-Sosa, Modesto Castrillón-Santana, Javier Lorenzo-Navarro, “Multi-sensor People Counting,” Iberian Conference on Pattern Recognition and Image Analysis, pp. 321-328, 2011.

[2].

Guo J, Wu X, Cao T, Yu S, and Xu Y, “Crowd Density Estimation via Markov Random Field (MRF),” Proceedings of 8th World Congress on Intelligent Control and Automation, pp. 258-263, 2010.

[3].

Zhao Xi, Dellandr’ea E, Chen Liming, “A People Counting System Based on Face Detection and Tracking in a Video,” IEEE International Conference on Advanced Video and Signal-based Surveillance, pp.67-72, Italy, 2009

[4].

Zoran Zivkovic, “Improved adaptive Gaussian mixture model for background subtraction,” 17th International Conference on Pattern Recognition, pp. 28-31, 2004.

[5].

Hsieh Jun-Wei, Peng Cheng-Shuang, Fan Kao-Chin, “Grid-based Template Matching for People Counting,” 9th Workshop on Multimedia Signal, pp.316-319, 2007