Development of a portable community video surveillance system

ABSTRACT


INTRODUCTION
Royal Malaysia Police (PDRM) suggested that installation of surveillance system would deter potential burglaries as well as facilitate police investigation in obtaining evidence and facial identification of suspects in the event that it did happen. However, basic surveillance system is still priced relatively expensive in Malaysia, approximately RM1400 for a basic monitoring system and at least RM1800 with added live mobile viewing. Thus, a low-cost video surveillance system is proposed to increase the affordability and widen the user base for such system. This project is to study and implement a low-cost video surveillance system based on Raspberry Pi 3 by using image-based motion detection algorithm as well as Telegram as the mobile application.
This project uses Raspberry Pi 3 Model B, released in 2016 and costing a mere RM170 for the single board computer. As depicted in Table 1, the processor has had major upgrade from the previous version, from 32-bit ARMv8 to 64-bit Quad Core Broadcom, effectively increasing the processor speed from 900MHz on the Pi 2 to up to 1.2GHz on the Pi 3. In addition to that, it is also now equipped with built-in Wi-Fi chip and Bluetooth Low Energy (BLE) chip, which facilitates our surveillance system to connect to Wi-Fi without needing any additional dongle [1]. An 8 megapixels Raspberry Pi camera is attached to the on-board Raspberry Pi camera connector, and this creates an image capture system with embedded computing that can extract information from images without the need for an external processing unit. Considering the requirements of image processing compared to the Raspberry Pi's processing module and its peripherals, it is decided that the system is capable on executing the tasks specified.
For the remote interface, Telegram Bot will be used as it enables machine and user to interface seamlessly. The Telegram app can be installed on intended user's mobile phone, then it is ready to go. Telegram Bot has artificial intelligence features like replying a message with images via Image Bot. The bot is also designed for programming purposes and can communicate with other Bots. According to Telegram, the messages and requests sent to Bots are connected with an intermediary server and are linked via HTTPS interface which comes with Telegram API [2].
OpenCV, an open source computer vision library developed by visual interaction group from Intel is used as digital image processing library. It allows Raspberry Pi to handle image processing algorithms directly from inside the Pi environment [3].
Earlier work by Patoliya, Mehta and Patel propose a system consisting of night vision wireless camera to transmit videos is proposed [4]. It uses Arduino as the controller which is connected to servo motor for camera movement and Bluetooth module for transmitting images to Android phones. However, the Bluetooth signal is found to be not stable when compared to Wi-Fi. Dong, Yang, Wang and Xu proposed another surveillance system for elderly with fall and inactivity detection. The project uses Raspberry Pi as the controller utilizing Gaussian Mixture Model for background subtraction method which will send email or SMS to inform family members should an incident occurs [5]. Rashid, Abir, Shourove and Muntaha proposed a home security system which identify visitors by image processing. The project uses Raspberry Pi as the controller with OpenCV library for background subtraction method and also Pocketsphinx, a speech recognition software that runs natively on Raspberry Pi for voice recognition [6].

PROPOSED DESIGN 2.1. Block diagram
The block diagram in Figure 1 shows the overall system components including the Raspberry Pi 3 as the central platform for the system. An 8 megapixels night vision pi camera with infrared illuminators act as the image acquisition device to the system. When the system detects possible intrusion, the buzzer will emit alert sound and additionally an alert message will be sent from the Raspberry Pi 3 to the group members in Telegram app. Additionally, any Telegram group members can request images and recorded videos from the system at any time by sending a get request in Telegram which will be handled by Telegram Bot.

Motion detection algorithm
Ansari, Sedky, Sharma and Tyagi suggest that motion detection algorithm can be set to detect physical movement of objects in a given range by determining object movement on successive and progressive images. The algorithm compares only the grey frames after converting colour images from RGB  [7], [8]. Jyothi and Vardhan suggest that motion detection algorithm applies principles of differencing frame where the algorithm compares pixels on how they change location after each frame [9]. A study conducted by Islam, Nahiyan and Kiber also agreed on the concept that considering frames of video as images, motion can be detected by performing absolute image difference [10], [11]. There is a more reliable method based on background subtraction and frame difference, a fusion to more precisely detect motion. Liu, Fan and Wang designed a technique based on background subtraction and three-frame difference to detect motions underwater by producing a different image to determine pixels from non-moving objects [12]. The function of three frame difference is less sensitive to background noise, and the authors proved that the two combined methods work well in their experiment. This project will also apply background subtraction with frame difference for the motion detection.
The authors agreed that separation process between foreground and background is a key factor in computer vision applications, for example in surveillance use, motion capture, action recognizing and video compressing. However, the acceptable separation process faces many challenges. Factors that resulted in failure in motion detection includes sudden changes in illumination like cloud movement, motion change like waving branches of trees, camera shake, and also background geometry change like shadows and parked cars. Therefore, image pre-processing is crucial to reduce error in motion detection. Small changes in pixel will easily lead to failure in motion detection. For example, noise always happen in the background and it changes the value of pixels. Further explained by the authors, noise results in difference in pixels with the correct pixel value in an image. Consider Equation (1) for an image f with scene s and noise n: The equation explained that any acquired image can be affected by scene and noise. If there is no change in intensity, no change is observed. But if one pixel is brighter, and has higher pixel values than its neighbours, this will result in noise. The authors stated that image pre-processing should be done before actual image processing to suppress distortions.

IMPLEMENTATION 3.1. Hardware design
The hardware will be run on a Raspberry Pi 3 as the central computer with Raspbian Jessie OS installed and additional peripherals of an 8 megapixels camera to capture image, and a buzzer as an audible alarm. The system is intended to be portable so it is powered by connecting it to a mobile powerbank. Figure 2 shows the prototype of the video surveillance system in development mode, while Figure 3 shows the prototype in normal running mode, with the LCD monitor, keyboard and mouse removed. Figure 4 shows the prototype running in pitch black darkness with only the IR LEDs visible.

Software design
In addition to the Python programming language that is natively used in Raspberry Pi environment, this system will also use OpenCV, a computer vision simulation from Intel to help with image pre-processing that is designed with criterias of resource optimization, low power consumption and improved speed.  Figure 5(a) shows the image capture from the system during day time. The colour of the image can be seen to be slightly pink in color because of the discarded IR filter. Figure 5(b) shows the image capture during night time without night vision turned on where the image is in total pitch black, while Figure 5(c) shows the image capture when the IR illuminator is turned on where we can see some objects in the image albeit the dark lighting.  Figure 7, but the image capture is done during night time and in total darkness. An image is captured with frame difference than the previous capture as shown in Figure 8(a), pre-threshold as in Figure 8(b), and the result is a detected motion of white blob in Figure 8

Interaction between hardware and software
Once motion detects possible intruder, an image capture is automatically sent to a predefined Telegram group chat together with a 3 seconds video of the incident. Figure 9(a) shows the group chat containing family members as well as the Raspberry Pi as a user. Figure 9(b) shows the alert message notification has arrived into the Telegram group, and Figure 9(c) shows the report from Raspberry Pi with captured image as well as a 3 seconds video that triggers the alarm which can be viewed and downloaded by anyone in that particular Telegram group.

Reaction time from Pi to Telegram versus distance
Based on the experiment, it is found that reaction time to transmit picture and video from Raspberry Pi to Telegram is not affected by distance as detailed in Table 2 (day time) and Table 3 (night time). The reaction time is only affected by the speed of the available wifi connection. Within the set distance of 8 meters, the motion detection system works very well during day time. Results in Table 3 shows that night surveillance is not available for distances over 4 meters due to the infrared illuminator lighting which is only effective within 5 meters ideally. Thus, objects moving between 4 meters to 8 meters during night time can be seen from recorded video, but the motion will not be detected.   Figure 10 illustrates the reaction time in seconds versus distance in meters for day time and night time analysis of the system respectively. It is observed that given a stable wifi signal is available for the Raspberry Pi to piggyback on, any motion detection alert notification will be delivered to Telegram app in user's mobile phone within 1 to 2 seconds.  Table 4 and Table 5 shows the accuracy test results for day time and night time surveillance tested directly for 10 consecutive days. According to Table 4, day time surveillance scored 95.42%, which is more accurate than at night time with score of 89.82%. The project shows high accuracy, and the system is able to differentiate intrusion and normal cases correctly. Based on sensitivity test, day time surveillance scored 98.33%, which is more sensitive to motion than in night time with 92.33%. For specificity test, day time surveillance scored 92.67%, which is more specific than in night time with 86.81%. The system scores high percentage and is able to determine normal cases correctly. Figure 11 summarizes the test results of measuring accuracy, sensitivity, and specificity during day time, while Figure 12 summarizes the same test but done during night time. It is found that night time surveillance performs poorer than during day time mainly because of the insufficient night vision lighting provided by the infrared illuminator causing the frame difference to be too small and neglected in greyscale images.  Figure 11. Accuracy, sensitivity, specificity versus days (day time) Figure 12. Accuracy, sensitivity, specificity versus days (night time)

CONCLUSION
The development of a portable community video surveillance system using Raspberry Pi 3 is demonstrated in this article, implementing OpenCV as the core image processing software. At the correct setup the system performs wonderfully, especially since the whole system costs within a budget of RM500 compared to surveillance systems sold in the market which sells for around RM1800. The notification system also employs an open source chat app, Telegram, which is free and can be easily installed by the user.