You are on page 1of 7

RESEARCH ARTICLE

Low Cost Real Time Monitoring System and Storing


Image Data Using Motion Detection
Ferry Wahyu Wibowo1, Muhammad Andari Ardiansyah2
1,2
Department of Informatics Engineering, STMIK AMIKOM Yogyakarta, Yogyakarta 55283, Indonesia

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.

1. INTRODUCTION been entered by someone. The notification of this could


be sent as an email, short message service (SMS), or
A closed circuit television (CCTV) is usually used in missed-call3,4,5. The email may be a solution that is easier
the offices, banks, industries, public facilities, and appropriate as a warning system in case of monitoring
supermarkets, homes, etc. For small sizes of the CCTV because it is available to be accessed using smartphone
are deployed in the homes. The utilization of the CCTV nowadays6. The email could be completed with
has a good feature because the CCTV uses a web camera attachment and text including warning of intruder who is
and streaming video technology to monitor such captured as such motion activities in the room 7. So the
monitored places which can be monitored every where monitoring system is quite well to be implemented and
and every time when it is connected to internet 1. The connected to the server. The server could process a digital
operational of the CCTV is used in recording an activities video data and send the warning text to the email.
in real-time. The monitoring systems are more proper The requirement to make a server can be implemented
applied in the areas of high activities such as a single board computer (SBC) as a server alternative of
supermarkets, industries, and traffic light. But for low the monitoring system. The SBC could be a mini and tiny
activities such as warehouses, schools, rooms, or homes, computer e.g. Raspberry Pi, Banana Pi, etc. In this paper
the monitoring systems are lack of utilizations caused by employs Raspberry Pi as a server because the Raspberry
consuming many resources in the recording storage. A Pi features have capability as a personal computer (PC),
real-time monitoring will effect burdening on the although it isnt so very complex as PC. Beside that the
recording storage in the server because the recorded video price of the Raspberry Pi is cheaper than closed circuit
files size will be large and consuming much spaces 2. television digital video recorder (CCTV-DVR) and
These activities will make un-efficient works of the internet protocol (IP) camera which has a millions prices.
server. A webcam attached to the Raspberry Pi is applied to
A solution to prevent burdening of the server works is detect a motion in the room. Capturing motion image is
making an image recording devices that would record using a webcam in real-time, thus the image data will be
such image when it is needed. The webcam will record processed and computed by the Raspberry Pi. As long as
image when someone is entering a room, in this case the
webcam will detect and capture the motion. It can be

*
Email Address: ferrywahyu, arik.maldini@gmail.com
utilized to alert the owner which shows that the room has
1
there is no motion detected in the room, the Raspberry Pi of labeled area sizes above the default constraints.
will never process the image data and send the text with The streaming is such technology to play video file
captured image and video to the email. 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.
2. RELATED WORKS When the video and audio files are streamed, it will make
a buffer and those files will be downloaded into buffer in
In this section contains of the related works which the client machine. In a seconds or it depends on the
are utilized in this paper. Some used applications and internet access acceleration, the buffer will be filled those
terms related to this works are Raspbian, motion files and playable.
application, email, webcam, and Google drive application
programming interface (API). 2.3. Email

2.1. Raspbian An electronic mail or known as email is an electronic


mail delivering services protocol sent via internet. A
A Raspbian is an open-source operating system protocol used in the process of delivering email known as
which is derivative of Debian based-on ARM (armhf)- simple mail transfer protocol (SMTP). This protocol has
Debian architecture, but it has been optimized for ARMv6 been basic rules to delivering email and applied in the
utilized in the hardware of Raspberry Pi. The Raspbian is transmission control protocol/internet protocol (TCP/IP)
the result of collaboration of both Raspberry Pi and network arbitrating how the email moved from a host to
Debian. This operating system has provided more than other destined host(s). The email is utilized to send
35,000 packages of available deb software and pre- notification and attachment of recorded files from the
compiled for easily installation on Raspberry Pi and monitoring system.
specified for ARM hardware of Raspberry Pi.
2.4. Webcam
2.2. Motion Application
A web camera or also known as webcam is a mini
A motion is an application that is able to monitor video camera functioned as picture taking or monitoring
video signal from a camera and detecting a change of the device. In this paper, a webcam employed as image or
video slices. The motion application is firstly developed video input device and a motion detection sensor. The
by Jeroen Vreeken and enhanced by Folkert van Heusden webcam used for this monitoring system is the webcam
and Kenneth Lavrsen. The application itself is written Logitech C170. The webcam has resolution of 320x460
using C-language and its output as jpg image or mpg up-to 768x1024 pixels with frame-rate up-to 30 frames
video8. The motion application is a text mode and could per second (fps). This frame rate effects on the resulted
be downloaded as free of charge on the site of video, the higher frame rate, the finer resulted video
http://www.lavrsen.dk/foswiki/bin/view/Motion/Downloa motion. Some kinds of webcam i.e.
dFiles9. The work principle of the motion in this paper is a. A serial/parallel port webcam, which uses serial or
comparing pixel intensity from the new image and the parallel port. This webcam model is not produced
reference image (previous image). When there is no a anymore
changing of the pixel intensity, the reference image is b. A universal serial bus (USB) webcam, which is
zero (0), but when there is changing structure, so the generally found and using USB port for its connection.
reference image is change and detected as a motion. In This kind of webcam also supports plug and play
order to prevent uncorrected image data from capturing feature
image, it needs to set an image motion in the pixel c. A firewire webcam, which utilizes firewire port and
changing constraints for initial image data 10. In this case, has capability to result a high frame rate, so the
comparison on coloring and imaging just take black and resulted video has a fine motion. But this kind of
white imaging. A motion application has utilization webcam is still expensive.
feature as motion detection, live streaming webcam, d. A network/wireless webcam, which has
motion tracking, threshold controlling, and screenshot network/wireless facilities. This webcam doesnt need
feature in such intervals. Video streaming is an important a computer to run on. This webcam can be connected
media applied on the internet and contains of frames 11. directly to the internet network.
The referenced frame is renewed recursively with
new image frame, so after renewing within frame of N it 2.5. Google Drive API
will consist of * (frame of N) + * (frame of N-1) +
1/8 * (frame of N-2) and so on. From all pixels has been A Google drive application programming interface
changed between both referenced frames and new frames, (API) has been released by Google, in which the software
the average number of x and y will be counted. After it is developer can implement the service due to this drive
activated, the pixel location will be counted based-on all easily. Google drive is cloud storage utilized to store such
files. Google released API for Google drive in the form of Google drive has duration time of 5 seconds started when
library for several kinds of programming language. With the camera has caught the motion from the difference of
this Google drive API, some software or system previous and new images. The duration time could be set
developers can upload, download, reload, and delete some as long as needed. Then the video files are uploaded and
file(s) in the Google drive. In this paper, the Google drive stored to the Google drive. The storage process in the
functioned as a video files storage which the video files cloud drive aims to reduce the Raspberry Pi storage
has been captured by the webcam, so it can minimalize capacity usage, because the video files have a big
the usage space of the storage device attached on the capacity.
Raspberry Pi.

3. 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 Fig.1. Flowchart of The Notification Principle
streaming input/output (I/O), so the system could monitor
in real-time within accessing of internet protocol (IP) 4 EXPERIMENTAL RESULT
from Raspberry Pi and webcam port.
The notification is given by the system to the The monitoring system consists of the hardware and
administrator or user through email. The sent notification software implementations. The hardware implementation
is a text of detected motion with the attachment of the carried out the laptop and Raspberry Pi, and the software
image and video which is stored in the Google drive. implementation carried out the software program that is
Before sending the email, the notification must be programmed in the Raspberry Pi and the client computer,
converted into format of base64. A libraries which needed in order the devices were able to communicate each other
by this program are smtplib and base64. The notification it needs some configurations in the applications and
system was designed as apart of interactive functions network testing which has been done. The Raspberry Pi
between both system and administrator. It is done was employed as a server in the capturing the image data
automatically when there is a detected motion by the using webcam (see Figure 2), thus the image data as an
camera. Flowchart of the notification principle of the image or video sent via wireless local area network
detected motion is resumed on the Figure 1. The principle (WLAN) to the client computer. Raspberry Pi and
of video uploading aims to secure and backup data due to computer connected using integrated network of 802.11n.
the monitoring system12,13. The video files sent to the
3
In this paper, the monitoring systems are not only Fig.3. PuTTY Configuration
implemented on the wireless local area network (WLAN),
but the monitoring systems are also implemented on the In the detection of motion, the motion application
internet access. So it can be accessed and monitored using program was installed on the Raspberry Pi device to
gadgets at anytime and anywhere as long as connected to handle detection motion in such rooms and live
the internet. 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
Fig.2. Connection Between Raspberry Pi and Webcam
there is a difference on the frames. A default noise
number is 32, when it stated that the number has been
Connection between both client and server to obtain
a good data communication in the WLAN must be tested changed, the value of diffs will be added as long as
increasing of pixels and the number of diffs would be
to know the performance. The testing step in this case
employed a secure shell (SSH). The SSH is a protocol to compared by number of max_n_changes. The number
of max_n_changes is a threshold number that defined
secure accessing to the computers. The application to test
the SSH can utilized a PuTTY application which has how many pixels which has been changed on those
frames until it is resumed as motion. This threshold
capability to connect devices wirelessly in the WLAN.
PuTTY is an open-source program to do SSH network number is set as 1500. If the number of diffs is higher
than the number of max_n_changes, it could be stated
protocol, Rlogin and Telnet. This program is used to
connect, simulate, and test something due to the network. that there is a motion detection on those frames. In
addition, all of pixels are not counted on the frames only,
In this paper, The PuTTY application configured by
entering address of Raspberry Pi internet protocol (IP) as but the number of max_n_changes is also appropriated
by dividing number of max_n_changes with step
shown on figure 3. The Raspberry Pi IP address obtained
from dynamic host configuration protocol (DHCP) router number as code of max_n_changes /= step. All of pixels
on the frames arent only processed, but it is also jumped
was 192.168.1.11 and using port of 22 as shown. It shows
that the network was accessible and could be utilized in onto next steps. It means that the step number is 10, and
then after the first pixel has been processed, the next 10
the network connection.
pixels will be passed and continued within processing
pixel of 12-th. This function is 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 5 800x600 Error, frame height of 600
frame size video was using resolution of 320x240 to and it is not modulo 16
maximize quality of the streaming image. A script for this 6 920x720 Resolution converted into
configuration written as memset(u, 320, width); and 640x480
memset(v, 240, height);}. When there is a motion it will
In the Table 1 shows that, not all of the frame sizes
use gap delay time for 5 seconds, in order not to long to
could be accepted by the systems. The accepted frame
be tested. Beside that, the benefit of the small gap delay
sizes are 320x240, 640x480 and 640x352. Meanwhile the
time in capturing frame could be sent and uploaded as
frame sizes of 400x300 and 800x600 couldnt be accepted
soon as possible without waiting too long in its process.
by system, because the frame components are not modulo
Meanwhile the small captured video gap must be encoded
16. The recommendation due to the motion of frame
rapidly, so the motion feature configuration for encoding
width and height must be modulo 16 in its algorithm, in
real-time video could be ran.
order to detect a motion. For frame size of 920x720
When the captured images emerge changing in the
couldnt be accepted and it will be returned into the frame
frames, so the recording will detect motion as delay time
size of 640x480. The constraints are done by systems on
of 5 seconds. Thus the captured image will be uploaded
the Raspberry Pi. The frame size of 640x480 is
into Google drive automatically and emailed as
determined by the hardware driver that the system will
notification to the user. In recorded video uploading, the
command the driver to check the number of the frame
function of upload_video must be invoked directory
size entered by user using code of xioctl (s->fd,
address and then invoked function of _getfolder_id(); to
VIDIOC_TRY_FMT, &s->fmt). If the number of the
check the existed folder in the Google drive as video
frame size supported by the driver, then the number of
storage space. When the folder has been found, the stored
frame size could be applied as output, unless it is
data will be uploaded, but when there isnt, it will notify
appropriate, the driver will find number of correct frame
that the directory doesnt exist. The next step is to upload
size. In the testing step of the frame size is able to analyze
video applying instruction code as
affect of frame size on the systems such as frame rate, bit
media=MediaFileUpload(video_fie_path,mimetype=vid
rate, lighting, and motion detection. The notification
eo/avi). After the video file has been uploaded, it will
email will notify administrator that the video has been
find link of video file which is just uploaded. If the link is
uploaded as shown on Figure 4.
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 Fig.4. Notification Email
shown on Table 1.

Table.1. The Result of Frame Sizes Testing. 5. CONCLUSIONS


No Frame Size Information
The monitoring system using the Raspberry Pi and
1 320x240 Accepted frame size and the webcam had been done and tested. The Raspberry Pi
run well applied as a server and the webcam applied as an motion
2 400x300 Error, frame height of 300 detection sensor. The capturing and sending notification
and it is not modulo 16 would be done if there was a motion in such a room. The
3 640x480 Accepted frame size and result of the testing shows that the monitoring system
run well works well. To obtaining a good video quality in the
monitoring system could employ video resolution which
4 640x352 Accepted frame size and
is 320x240 pixels. The bigger frame size, the more
run well sensitive monitoring due to the motion because it must
check each frame changing.
5
ACKNOWLEDGMENTS Research Journal of Engineering and Technology (IRJET), (02)
07 (2015) 831-834.
[6] R. Rashmi and B. Latha. Video Surveillance System and Facility
This work was supported by STMIK AMIKOM to Access PC From Remote Areas Using Smart Phone.
Yogyakarta. Proceeding of 2013 International Conference on Information
Communication and Embedded Systems (ICICES), (2013) 491-
REFERENCES 495.
[7] P. Jain and C. S. Satsangi. Object Tracking System Using Motion
Detection and Sound Detection. International Journal of
[1] S. Aminu, I. M. Abba, B. I. Dodo, M. T. D. Cruz, and U.
Innovative Research in Information Security (IJIRIS), (1) 2
Eaganathan. Motion Detection Security System (MDSS) in Live
(2014) 53-58.
Video Stream. Proceeding of The International Conference on
[8] K. Lavrsen. Legacy Motion Guide for Motion Versions 3.1.18-
Artificial Intelligence in Computer Science and ICT (AICS
3.1.20. http://www.lavrsen.dk/foswiki/bin/view/Motion/Motion
2013), (2013) 188-197.
Guide 3x1x20, accessed on September 2015.
[2] C. F. Lin, S. M. Yuan, M. C. Leu, and C. T. Tsai. A Framework
[9] K. Lavrsen. Motion Download Files,
for Scalable Cloud Video Recorder System in Surveillance
http://www.lavrsen.dk/foswiki/bin/view/Motion/DownloadFiles,
Environment. Proceedings of 2012 9th International Conference
accessed on September 2015.
on Ubiquitous Intelligence & Computing and 9 th International
[10] F. W. Wibowo, P. P. Purwacandra. Object Tracking Using Initial
Conference on Autonomic & Trusted Computing (UIC/ATC),
Data To Count Object Image Based-on Wireless Sensor Network,
(2012) 655-660.
Advanced Science Letters, 21 (2015) 112-116. DOI:
[3] J. E. Istiyanto, F. W. Wibowo. A DC Motor Control Based-On
http://dx.doi.org/10.1166/asl.2015.5742
Cellular Phone. Proceedings of the 2nd Jogja International
[11] J. G. Apostolopoulos, W. T. Tan, and S. J. Wee. Video Streaming:
Physics Conference (JIPC), Yogyakarta, Indonesia: Universitas
Concepts, Algorithms, and Systems. Hewlett-Packard Company,
Gadjah Mada, (2007) EI072-EI075.
(2002) 1-34.
[4] Sudarmawan, F. W. Wibowo. Design of Gesture Technology
[12] E. L. McHugh. Video Motion Detection For Real-Time Hazard
Implementing Wireless Sensor Network and Short Message
Warnings In Surface Mines, Transactions-Society For Mining
Service. Proceedings of the Third World Congress on Computing
Metallurgy And Exploration Incorporated, 318 (2006) 97.
and Information Technology (WCIT 2014), Kuala Lumpur,
[13] S. Pudaruth, F. Indiwarsingh, N. Bhugun. A unified Intrusion
Malaysia: The Society of Digital Information and Wireless
Alert System using Motion Detection and Face Recognition,
Communications (SDIWC), (2014) 104-109.
Proceedings of 2nd International Conference on Machine
[5] S. Kulkarni, A. Morye, P. Khedkar, P. Dhamane, D. B. Satre.
Learning and Computer Science (IMLCS 2013), Kuala Lumpur,
Motion Object and Regional Detection Method Using Block-
Malaysia, (2013) 17-20.
based Background Difference Video Frames. International

You might also like