because the CCTV uses a web camera and streaming video technology to monitor such ..... In the running system, a motion must be configured first. The.
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 8 (2016) pp 5419-5424 © Research India Publications. http://www.ripublication.com
Low Cost Real Time Monitoring System and Storing Image Data Using Motion Detection 1,2
Ferry Wahyu Wibowo1, Muhammad Andari Ardiansyah2 Department of Informatics Engineering, STMIK AMIKOM Yogyakarta, Yogyakarta 55283, Indonesia.
may be a solution that is easier and appropriate as a warning system in case of monitoring because it is available to be accessed using smartphone nowadays6. The email could be completed with attachment and text including warning of intruder who is captured as such motion activities in the room7. So the monitoring system is quite well to be implemented and connected to the server. The server could process a digital video data and send the warning text to the email. The requirement to make a server can be implemented a single board computer (SBC) as a server alternative of the monitoring system. The SBC could be a mini and tiny computer e.g. Raspberry Pi, Banana Pi, etc. In this paper employs Raspberry Pi as a server because the Raspberry Pi features have capability as a personal computer (PC), although it isn‟t so very complex as PC. Beside that the price of the Raspberry Pi is cheaper than closed circuit television digital video recorder (CCTV-DVR) and internet protocol (IP) camera which has a millions prices. A webcam attached to the Raspberry Pi is applied to detect a motion in the room. Capturing motion image is using a webcam in real-time, thus the image data will be processed and computed by the Raspberry Pi. As long as there is no motion detected in the room, the Raspberry Pi will never process the image data and send the text with captured image and video to the email.
Abstract The monitoring system fields have taken role in the control and security aspects. The monitoring systems are usually implemented in the high activity areas. A real-time monitoring will effect on loading the storage space in the server because the recorded video files will consume much spaces. The monitoring system applied on mini computer of Raspberry Pi and webcam is to detect an activities. Principle of the motion detection in this paper is changing of the video image that could be obtained from previous video image and new video image. The video streaming has format of mpeg and swf, the video streaming is functioned as a real-time images within accessing of internet protocol. A data storing of video files applying cloud storage in order to reduce storage space of secured data card. Keywords: Image, Monitoring System, Motion Detection, Data Storing, Video.
Introduction A closed circuit television (CCTV) is usually used in the offices, banks, industries, public facilities, supermarkets, homes, etc. For small sizes of the CCTV are deployed in the homes. The utilization of the CCTV has a good feature because the CCTV uses a web camera and streaming video technology to monitor such monitored places which can be monitored every where and every time when it is connected to internet1. The operational of the CCTV is used in recording an activities in real-time. The monitoring systems are more proper applied in the areas of high activities such as supermarkets, industries, and traffic light. But for low activities such as warehouses, schools, rooms, or homes, the monitoring systems are lack of utilizations caused by consuming many resources in the recording storage. A realtime monitoring will effect burdening on the recording storage in the server because the recorded video files size will be large and consuming much spaces2. These activities will make unefficient works of the server.
Related Works In this section contains of the related works which are utilized in this paper. Some used applications and terms related to this works are Raspbian, motion application, email, webcam, and Google drive application programming interface (API). Raspbian : A Raspbian is an open-source operating system which is derivative of Debian based-on ARM (armhf)-Debian architecture, but it has been optimized for ARMv6 utilized in the hardware of Raspberry Pi. The Raspbian is the result of collaboration of both Raspberry Pi and Debian. This operating system has provided more than 35,000 packages of available deb software and pre-compiled for easily installation on Raspberry Pi and specified for ARM hardware of Raspberry Pi.
A solution to prevent burdening of the server works is making an image recording devices that would record such image when it is needed. The webcam will record image when someone is entering a room, in this case the webcam will detect and capture the motion. It can be utilized to alert the owner which shows that the room has been entered by someone. The notification of this could be sent as an email, short message service (SMS), or missed-call3,4,5. The email
Motion Application: A motion is an application that is able to monitor video signal from a camera and detecting a change of the video slices. The
5419
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 8 (2016) pp 5419-5424 © Research India Publications. http://www.ripublication.com a)
A serial/parallel port webcam, which uses serial or parallel port. This webcam model is not produced anymore b) A universal serial bus (USB) webcam, which is generally found and using USB port for its connection. This kind of webcam also supports plug and play feature c) A firewire webcam, which utilizes firewire port and has capability to result a high frame rate, so the resulted video has a fine motion. But this kind of webcam is still expensive. d) A network/wireless webcam, which has network/wireless facilities. This webcam doesn‟t need a computer to run on. This webcam can be connected directly to the internet network.
motion application is firstly developed by Jeroen Vreeken and enhanced by Folkert van Heusden and Kenneth Lavrsen. The application itself is written using C-language and its output as jpg image or mpg video8. The motion application is a text mode and could be downloaded as free of charge on the site of http://www.lavrsen.dk/foswiki/bin/view/Motion/DownloadFil es9. The work principle of the motion in this paper is comparing pixel intensity from the new image and the reference image (previous image). When there is no a changing of the pixel intensity, the reference image is zero (0), but when there is changing structure, so the reference image is change and detected as a motion. In order to prevent uncorrected image data from capturing image, it needs to set an image motion in the pixel changing constraints for initial image data10. In this case, comparison on coloring and imaging just take black and white imaging. A motion application has utilization feature as motion detection, live streaming webcam, motion tracking, threshold controlling, and screenshot feature in such intervals. Video streaming is an important media applied on the internet and contains of frames11.
Google Drive API A Google drive application programming interface (API) has been released by Google, in which the software developer can implement the service due to this drive easily. Google drive is cloud storage utilized to store such files. Google released API for Google drive in the form of library for several kinds of programming language. With this Google drive API, some software or system developers can upload, download, reload, and delete some file(s) in the Google drive. In this paper, the Google drive functioned as a video files storage which the video files has been captured by the webcam, so it can minimalize the usage space of the storage device attached on the Raspberry Pi.
The referenced frame is renewed recursively with new image frame, so after renewing within frame of N it will consist of ½ * (frame of N) + ¼ * (frame of N-1) + 1/8 * (frame of N-2) and so on. From all pixels has been changed between both referenced frames and new frames, the average number of x and y will be counted. After it is activated, the pixel location will be counted based-on all of labeled area sizes above the default constraints. The streaming is such technology to play video file or audio directly in the real-time condition. It means that the video and audio files stored in the server could be played directly without storing in the user storage devices. When the video and audio files are streamed, it will make a buffer and those files will be downloaded into buffer in the client machine. In a seconds or it depends on the internet access acceleration, the buffer will be filled those files and playable.
Methodology The monitoring systems apply Raspberry Pi and webcam. The webcam is used to detect a motion activity in the rooms, so if there is changing of the video image it will warn the administrator via email and store the files to the Google drive. The room monitoring systems are an alternative method that may use in the security. This system is built using a mini computer of Raspberry Pi which is embedded operating system of Raspbian. The benefits of this system are easily access and system control. The interface application has been built based on the web, so the administrator or user could access using computers, laptops, or smart-phones. The usage of wireless and internet access is easier to monitor such rooms within a long distance. The monitoring systems have some features i.e. notification report to the user via email, capturing image and video when it detects a motion, control panel is accessible using wireless and internet, and real-time video streaming could also be done by the systems. Video streaming is played on web browser, it employs the motion application program based-on Phyton. The motion application is a program based on web protocol to do video streaming. Video streaming has format of mpeg and swf. The captured image when there is a detected motion will be processed by the Raspberry Pi, thus enhanced to the library of videodev to be sent via internet. The library of videodev is also handling a video streaming input/output (I/O), so the system could monitor in real-time within accessing of internet protocol (IP) from Raspberry Pi and webcam port.
Email: An electronic mail or known as email is an electronic mail delivering services protocol sent via internet. A protocol used in the process of delivering email known as simple mail transfer protocol (SMTP). This protocol has been basic rules to delivering email and applied in the transmission control protocol/internet protocol (TCP/IP) network arbitrating how the email moved from a host to other destined host(s). The email is utilized to send notification and attachment of recorded files from the monitoring system. Webcam: A web camera or also known as webcam is a mini video camera functioned as picture taking or monitoring device. In this paper, a webcam employed as image or video input device and a motion detection sensor. The webcam used for this monitoring system is the webcam Logitech C170. The webcam has resolution of 320x460 up-to 768x1024 pixels with frame-rate up-to 30 frames per second (fps). This frame rate effects on the resulted video, the higher frame rate, the finer resulted video motion. Some kinds of webcam i.e.
5420
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 8 (2016) pp 5419-5424 © Research India Publications. http://www.ripublication.com The notification is given by the system to the administrator or user through email. The sent notification is a text of detected motion with the attachment of the image and video which is stored in the Google drive. Before sending the email, the notification must be converted into format of base64. A libraries which needed by this program are smtplib and base64. The notification system was designed as apart of interactive functions between both system and administrator. It is done automatically when there is a detected motion by the camera. Flowchart of the notification principle of the detected motion is resumed on the Figure 1. The principle of video uploading aims to secure and backup data due to the monitoring system12,13. The video files sent to the Google drive has duration time of 5 seconds started when the camera has caught the motion from the difference of previous and new images. The duration time could be set as long as needed. Then the video files are uploaded and stored to the Google drive. The storage process in the cloud drive aims to reduce the Raspberry Pi storage capacity usage, because the video files have a big capacity.
Experimental Result The monitoring system consists of the hardware and software implementations. The hardware implementation carried out the laptop and Raspberry Pi, and the software implementation carried out the software program that is programmed in the Raspberry Pi and the client computer, in order the devices were able to communicate each other it needs some configurations in the applications and network testing which has been done. The Raspberry Pi was employed as a server in the capturing the image data using webcam (see Figure 2), thus the image data as an image or video sent via wireless local area network (WLAN) to the client computer. Raspberry Pi and computer connected using integrated network of 802.11n. In this paper, the monitoring systems are not only implemented on the wireless local area network (WLAN), but the monitoring systems are also implemented on the internet access. So it can be accessed and monitored using gadgets at anytime and anywhere as long as connected to the internet.
Figure 2: Connection Between Raspberry Pi and Webcam
Connection between both client and server to obtain a good data communication in the WLAN must be tested to know the performance. The testing step in this case employed a secure shell (SSH). The SSH is a protocol to secure accessing to the computers. The application to test the SSH can utilized a PuTTY application which has capability to connect devices wirelessly in the WLAN. PuTTY is an open-source program to do SSH network protocol, Rlogin and Telnet. This program is used to connect, simulate, and test something due to the network. In this paper, The PuTTY application configured by entering address of Raspberry Pi internet protocol (IP) as shown on figure 3. The Raspberry Pi IP address obtained from dynamic host configuration protocol (DHCP) router was 192.168.1.11 and using port of 22 as shown. It shows that the network was accessible and could be utilized in the network connection.
Figure 1: Flowchart of the Notification Principle
5421
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 8 (2016) pp 5419-5424 © Research India Publications. http://www.ripublication.com enacted whether on the reference frames or new frames. The aim to do this is to check the motion on the frames rapidly. The streaming video could be implemented by addressing of the Raspberry Pi internet protocol, in this paper, streaming address and port used 192.168.1.3:8888. The streaming feature controlled by a main function of stream_put. This function has two main duties, i.e. handling a new client and sending last frame or streaming to all clients. Before sending image, streaming buffer made as size of image, the used code to make resizing is “tmpbuffer = stream_tmpbuffer(cnt>imgs.size);”, it is resized because the used streaming is based-on the web protocol. Buffer sending via the hypertext transfer protocol (HTTP) needs header for image data on the buffer. In the running system, a motion must be configured first. The motion configuration positioned as motion detection and simple streaming process that are configuring a frame size video. The configuration of the frame size video was using resolution of 320x240 to maximize quality of the streaming image. A script for this configuration written as “memset(u, 320, width);” and “memset(v, 240, height);}”. When there is a motion it will use gap delay time for 5 seconds, in order not to long to be tested. Beside that, the benefit of the small gap delay time in capturing frame could be sent and uploaded as soon as possible without waiting too long in its process. Meanwhile the small captured video gap must be encoded rapidly, so the motion feature configuration for encoding realtime video could be ran.
Figure 3: PuTTY Configuration In the detection of motion, the motion application program was installed on the Raspberry Pi device to handle detection motion in such rooms and live streaming. Basically, the detection has been done is using the comparison between both reference and new captured image frames. The difference of both will determine a detected motion on those frames. In this case could be coded to loop as “for (;i > 0; -=step)”, where i is the frame size that is pixel numbers of the frames and step is pixel numbers on those frames divided by 10000 coded as “step = imgs-> motionsize/10000”. It means that the number of i will be subtracted step-by-step until i is 0. In the loop, to count the difference of the new pixels and previous pixels applied curdiff in the coding which is an absolute number from the difference of both pixels. The number of curdiff would be compared with noise number, if curdiff has higher number than noise number, so it is assumed that there is a difference on the frames. A default noise number is 32, when it stated that the number has been changed, the value of “diffs” will be added as long as increasing of pixels and the number of “diffs” would be compared by number of “max_n_changes”. The number of “max_n_changes” is a threshold number that defined how many pixels which has been changed on those frames until it is resumed as motion. This threshold number is set as 1500. If the number of “diffs” is higher than the number of “max_n_changes”, it could be stated that there is a motion detection on those frames. In addition, all of pixels are not counted on the frames only, but the number of “max_n_changes” is also appropriated by dividing number of “max_n_changes” with step number as code of “max_n_changes /= step”. All of pixels on the frames aren‟t only processed, but it is also jumped onto next steps. It means that the step number is 10, and then after the first pixel has been processed, the next 10 pixels will be passed and continued within processing pixel of 12-th. This function is
When the captured images emerge changing in the frames, so the recording will detect motion as delay time of 5 seconds. Thus the captured image will be uploaded into Google drive automatically and emailed as notification to the user. In recorded video uploading, the function of “upload_video” must be invoked directory address and then invoked function of “_getfolder_id();” to check the existed folder in the Google drive as video storage space. When the folder has been found, the stored data will be uploaded, but when there isn‟t, it will notify that the directory doesn‟t exist. The next step is to upload video applying instruction code as “media=MediaFileUpload(video_fie_path,mimetype=‟video/a vi‟)”. After the video file has been uploaded, it will find link of video file which is just uploaded. If the link is found, it will be sent within the email. The command instruction to send email is _send_email. The message of email has same notification email, but without the image attachment. The function of notification email is sending notification that the video file has been uploaded as shown on script bellow, 1) if self.send_email: 2) msg = self.message 3) if video_link: 4) msg += „\n\n‟ + video_link 5) self._send_email(msg) Whether the notification sending or video uploading, both refers to a file configuration including information those are needed to send an email. The result of frame sizes which has been tested from the captured video shown on Table 1.
5422
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 8 (2016) pp 5419-5424 © Research India Publications. http://www.ripublication.com Table 1: The Result of Frame Sizes Testing.
Conclusions
1
320x240
Accepted frame size and run well
2
400x300
Error, frame height of 300 and it is not modulo 16
3
640x480
Accepted frame size and run well
The monitoring system using the Raspberry Pi and the webcam had been done and tested. The Raspberry Pi applied as a server and the webcam applied as an motion detection sensor. The capturing and sending notification would be done if there was a motion in such a room. The result of the testing shows that the monitoring system works well. To obtaining a good video quality in the monitoring system could employ video resolution which is 320x240 pixels. The bigger frame size, the more sensitive monitoring due to the motion because it must check each frame changing.
4
640x352
Accepted frame size and run well
Acknowledgments
No
Frame Size
Information
5
800x600
Error, frame height of 600 and it is not modulo 16
6
920x720
Resolution converted into 640x480
This work was supported by STMIK AMIKOM Yogyakarta.
References [1]
In the Table 1 shows that, not all of the frame sizes could be accepted by the systems. The accepted frame sizes are 320x240, 640x480 and 640x352. Meanwhile the frame sizes of 400x300 and 800x600 couldn‟t be accepted by system, because the frame components are not modulo 16. The recommendation due to the motion of frame width and height must be modulo 16 in its algorithm, in order to detect a motion. For frame size of 920x720 couldn‟t be accepted and it will be returned into the frame size of 640x480. The constraints are done by systems on the Raspberry Pi. The frame size of 640x480 is determined by the hardware driver that the system will command the driver to check the number of the frame size entered by user using code of “xioctl (s->fd, VIDIOC_TRY_FMT, &s->fmt)”. If the number of the frame size supported by the driver, then the number of frame size could be applied as output, unless it is appropriate, the driver will find number of correct frame size. In the testing step of the frame size is able to analyze affect of frame size on the systems such as frame rate, bit rate, lighting, and motion detection. The notification email will notify administrator that the video has been uploaded as shown on Figure 4.
[2]
[3]
[4]
[5]
[6]
[7]
Figure 4: Notification Email
5423
S. Aminu, I. M. Abba, B. I. Dodo, M. T. D. Cruz, and U. Eaganathan. Motion Detection Security System (MDSS) in Live Video Stream. Proceeding of The International Conference on Artificial Intelligence in Computer Science and ICT (AICS 2013), (2013) 188-197. C. F. Lin, S. M. Yuan, M. C. Leu, and C. T. Tsai. A Framework for Scalable Cloud Video Recorder System in Surveillance Environment. Proceedings of 2012 9th International Conference on Ubiquitous Intelligence & Computing and 9th International Conference on Autonomic & Trusted Computing (UIC/ATC), (2012) 655-660. J. E. Istiyanto, F. W. Wibowo. A DC Motor Control Based-On Cellular Phone. Proceedings of the 2nd Jogja International Physics Conference (JIPC), Yogyakarta, Indonesia: Universitas Gadjah Mada, (2007) EI072-EI075. Sudarmawan, F. W. Wibowo. Design of Gesture Technology Implementing Wireless Sensor Network and Short Message Service. Proceedings of the Third World Congress on Computing and Information Technology (WCIT 2014), Kuala Lumpur, Malaysia: The Society of Digital Information and Wireless Communications (SDIWC), (2014) 104-109. S. Kulkarni, A. Morye, P. Khedkar, P. Dhamane, D. B. Satre. Motion Object and Regional Detection Method Using Block-based Background Difference Video Frames. International Research Journal of Engineering and Technology (IRJET), (02) 07 (2015) 831-834. R. Rashmi and B. Latha. Video Surveillance System and Facility to Access PC From Remote Areas Using Smart Phone. Proceeding of 2013 International Conference on Information Communication and Embedded Systems (ICICES), (2013) 491-495. P. Jain and C. S. Satsangi. Object Tracking System Using Motion Detection and Sound Detection. International Journal of Innovative Research in Information Security (IJIRIS), (1) 2 (2014) 53-58.
International Journal of Applied Engineering Research ISSN 0973-4562 Volume 11, Number 8 (2016) pp 5419-5424 © Research India Publications. http://www.ripublication.com [8]
[9]
[10]
[11]
[12]
[13]
K. Lavrsen. Legacy Motion Guide for Motion Versions 3.1.18-3.1.20. http://www.lavrsen.dk/ foswiki/bin/view/Motion/Motion Guide 3x1x20, accessed on September 2015. K. Lavrsen. Motion – Download Files, http://www.lavrsen.dk/foswiki/bin/view/Motion/Dow nloadFiles, accessed on September 2015. F. W. Wibowo, P. P. Purwacandra. Object Tracking Using Initial Data To Count Object Image Based-on Wireless Sensor Network, Advanced Science Letters, 21 (2015) 112-116. DOI: http://dx.doi.org/10.1166/ asl.2015.5742 J. G. Apostolopoulos, W. T. Tan, and S. J. Wee. Video Streaming: Concepts, Algorithms, and Systems. Hewlett-Packard Company, (2002) 1-34. E. L. McHugh. Video Motion Detection For RealTime Hazard Warnings In Surface Mines, Transactions-Society For Mining Metallurgy And Exploration Incorporated, 318 (2006) 97. S. Pudaruth, F. Indiwarsingh, N. Bhugun. A unified Intrusion Alert System using Motion Detection and Face Recognition, Proceedings of 2nd International Conference on Machine Learning and Computer Science (IMLCS 2013), Kuala Lumpur, Malaysia, (2013) 17-20.
5424