Portable Surveillance Camera With Motion Capture Using Raspberry Pi
Portable Surveillance Camera With Motion Capture Using Raspberry Pi
Introduction
Surveillance Cameras play an important role in our day to day lives, they help
us verify evidence and catch criminals. Although only a handful of people use a
surveillance or security cameras inside their homes. Such cameras have become
increasingly popular to be used in public spaces and in some cases, they are also
used inside building societies. However, getting a traditional camera with
proprietary hardware and software can be quite expensive and there is not a lot
of changes you can make to the camera’s software to fine tune it’s
functionalities. Moreover, the security cameras these days have to be connected
to a power outlet or a computer for it to function properly, thus, making them
not so portable and while there are portable security cameras, they are pretty
expensive. This is where the use of IoT in the form of Raspberry Pi comes in.
The Internet of Things (IoT) is the network of physical devices, vehicles, home
appliances and other items embedded with electronics, software, sensors,
actuators, and connectivity which enables these objects to connect and exchange
data. Each thing is uniquely identifiable through its embedded computing
system but is able to inter-operate within the existing Internet infrastructure.
The Raspberry Pi is a small single board computer which can be loaded with a
Linux based OS for the Raspberry Pi and different modules and sensors can be
connected to it and programmed, in order to make the device IoT ready,
including cameras. The IoT is expanding at a rapid rate and is expected to grow
over the coming years at a pace which makes previous technology adoptions
look insignificant. The IoT promises to connect everything from CCTV
cameras, medical devices, smart home products to smart enabled vehicles and
many more devices. Raspberry Pi makes it possible to make simple systems all
by ourselves and provide cheaper alternatives to existing systems as they use
open source softwares rather than that of the proprietary kind.
1
Chapter – 2
Literature Review
1)Kokkonis, George, et al. "Real-time wireless multisensory smart
surveillance with 3D-HEVC streams for internet-of-things (IoT)." The
Journal of Supercomputing 73.3 (2017): 1044-1062.
The last few years, significant advances which improve healthcare have been
done in Internet of Things, in cloud computing, in video coding, and in mobile
devices. This paper provides an overview of these advances. Also, we propose
an IoT-based surveillance system for ubiquitous healthcare monitoring. The
system consists of sensors, actuators, and cameras. Mesh topology was decided
to be used as it provides important advantages. Moreover, the Constrained
Application Protocol (CoAP) is used for the data compression and transferring,
and the Scalable High-Efficiency Video Coding (SHVC) is used for the video
compression and transferring. The SHVC can deliver the same video quality in
half of the bit rate than the High-Efficiency Video Coding (HEVC).
Furthermore, cloud services are provided, such as storage and real-time
monitoring. Finally, we made a comparative analysis between our proposed
system architecture and two other approaches. From this analysis, we can say
that our system architecture has some benefits instead of other similar
architectures. Also, we made an analysis of the bandwidth and the network
throughput. The results are significant since the bandwidth required for the
transmission of data and video is reduced.
3
4) Alsmirat, Mohammad A., et al. "Internet of surveillance: a cloud
supported large-scale wireless surveillance system." The Journal of
Supercomputing 73.3 (2017): 973-992.
Large-scale video surveillance systems are among the necessities for securing
our life these days. The high bandwidth demand and the large storage
requirements are the main challenges in such systems. To face these challenges,
the system can be deployed as a multi-tier framework that utilizes different
technologies. In such a framework, technologies proposed under the umbrella of
the Internet of Things (IoT) can play a significant rule in facing the challenges.
In video surveillance, the cameras can be considered as “the things” that are
streaming videos to a central processing and storage server (the cloud) through
the Internet. Wireless technologies can be used to connect wireless cameras to
the surveillance system more conveniently than wired cameras. Unfortunately,
wireless communication in general tend to have limited bandwidth that needs
careful management to achieve scalability. In this paper, we design and evaluate
a reliable IoT-based wireless video surveillance system that provides an optimal
bandwidth distribution and allocation to minimize the overall surveillance video
distortion. We evaluate our system using NS-3 simulation. The results show that
the proposed framework fully utilizes the available cloud bandwidth budget and
achieves high scalability.
4
integrates multiple information and communication technology (ICT) and
Internet of Things (IoT) solutions, so as to improve the quality life of its
citizens. However, there are many security and privacy issues which must be
taken into account before the official launching of this new technological
concept. Many methods which focus on media security of wireless sensor
networks have been proposed and can be adopted in the new expandable
network of IoT. In this paper, we describe the upcoming IoT network
architecture and its security challenges and analyze the most important
researches on media security and privacy in wireless sensor networks (WSNs).
Subsequently, we propose an Efficient Algorithm for Media-based Surveillance
System (EAMSuS) in IoT network for Smart City Framework, which merges
two algorithms introduced by other researchers for WSN packet routing and
security, while it reclaims the new media compression standard, High
Efficiency Video Coding (HEVC). Experimental analysis shows the efficacy of
our proposed scheme in terms of users’ privacy, media security, and sensor
node memory requirements. This scheme can be successfully integrated into the
IoT network of the upcoming Smart City concept.
5
technologies such as RFID tags and embedded sensor and actuator nodes, the
IoT has stepped out of its infancy and is the next revolutionary technology in
transforming the Internet into a fully integrated Future Internet. As we move
from www (static pages web) to web2 (social networking web) to web3
(ubiquitous computing web), the need for data-on-demand using sophisticated
intuitive queries increases significantly. This paper presents a Cloud centric
vision for worldwide implementation of Internet of Things. The key enabling
technologies and application domains that are likely to drive IoT research in the
near future are discussed. A Cloud implementation using Aneka, which is based
on interaction of private and public Clouds is presented. We conclude our IoT
vision by expanding on the need for convergence of WSN, the Internet and
distributed computing directed at technological research community.
6
locally on raspberry pi and sent when the connection resumes. The camera is
mounted on the motor and its movement (Left/Right) is controlled through IoT
webpage by the user, thus providing user with enhanced view of the
surroundings.
8) Ali, Afiq Muzakkir Mat, Nazrul Muhaimin Ahmad, and Anang Hudaya
Muhamad Amin. "Cloudlet-based cyber foraging framework for
distributed video surveillance provisioning." Information and
Communication Technologies (WICT), 2014 Fourth World Congress on.
IEEE, 2014.
7
Chapter – 3
System Analysis
3.1 Existing System
Most security cameras on the market today are standard analog security cameras
connected directly to a digital video recorder. The cameras is this type of system
consist of a lens, DSP chip (digital signal processing chip) and a housing. The
cameras are simply the window used by the DVR (digital video recorder) to see.
The cameras are connected to the DVR using transmission cables. There are
many types of cables, but they will all have a connection directly to the DVR.
The DVR is the heart of this system. The security digital video recorder receives
the video from the camera, compresses it and stores it on a hard drive to be
retrieved later. Most DVRs also convert the analog video to digital format and
are able to stream that video over the internet using a built in webserver. In this
scenario, the DVR is responsible for compression, conversion, storage and
streaming of all the video that comes from each camera. addittionaly, the DVR
is the inteligence behind the cameras and is responsible for all the motion
detection, schedules, notifications, alarm inputs and more.In the end, this type
of surveillance system is usually less expensive because the cameras are simply
cameras and there is only one unit that does all the grunt work, the DVR.
IP Surveillance systems:
IP or network security camera systems are very different from analog systems
because each camera does the job of the DVR. Essentially, an IP camera is a
standard security camera that can also compress video, convert the video to
digital format and stream it over ethernet. So each camera is esentially its own
8
DVR. Some IP cameras also have SD card slots so that they can store video
directly onto an SD card. IP cameras are sometimes connected to an NVR
(network video recorder) instead of a DVR. Since the video is compressed and
converted to digital at the camera, the camera can stream the video over a
network to a PC or NVR that will record the compressed video. The benefit of
IP cameras is that it is easy to add additional cameras to the network and there
are higher resolutions available than in standard analog surveillance systems.
Disadvantages:-
2)The few portable cameras that are out there are pretty expensive
3)The configurations that are setup for the camera are pretty much fixed and not
a whole lot of changes can be made as the software used in proprietary.
The proposed system uses a Raspberry Pi for the computations and open source
software to gather data, which helps us drive down the costs.The open source
software that will be used for motion detection, live stream and the mail alert
trigger will be ‘Motion’ and the mail client used is SSMTP along with mailutils.
A usb webcam will be attached to the Raspberry Pi.The Pi will power up the
camera while the software that will make this camera IoT ready will be the
Motion software.When motion is detected, the motion software commands the
camera to start clicking pictures as well as record short videos.All of these
media files will be locally stored in the Pi.Whenever motion is started up, the
camera immediately starts livestreaming the footage it captures over a
9
network.This livestream can be viewed by typing in the IP address of the Pi in
the browser while the device you are trying to view the livestream on is
connected to the same network the Pi is connected to.Along with clicking
pictures and recording videos when motion is detected, the motion software is
configured to send an email with the latest picture it clicked as an attachment to
your mail.In order for this to work, the SSMTP mail client as well as mailutils
needs to be installed and setup by providing your mail details in the
configuration files.Motion then works with SSMTP in order to send the
email.Each picture it clicks will have a timestamp on it.The motion software is
configured to run in the background as soon as the Raspberry Pi boots up
removing the need to start the motion software manually.In order to make the
whole system truly portable and independent of other systems, the Pi is
connected to a dongle at all times in order for the Pi to get constant internet
connection for the livestream to function.As for power, a power bank is
connected to the Pi using a micro usb cable which powers the Pi and the Pi will
provide power to the usb camera connected to it.Keep in mind that this system
is not supposed to completely replace your home surveillance system but rather
be a temporary and portable solution to fulfil your security needs and can be
setup anywhere you want.Given below is the architecture of the system:-
10
3.2.1 Advantages of Proposed System:-
The system is portable and can be used without the need for any kind of
setup.
It is a cheaper alternative to the more expensive cameras out there.
Since the software used is open source, it is possible to fine tune the
configurations to your liking.
A feasibility study aims to objectively and rationally uncover the strengths and
weaknesses of an existing business or proposed venture, opportunities and
threats present in the natural environment, the resources required to carry
through, and ultimately the prospects for success.In its simplest terms, the two
criteria to judge feasibility are cost required and value to be attained.A well-
designed feasibility study should provide a historical background of the
business or project, a description of the product or service, accounting
statements, details of the operations and management, marketing research and
policies, financial data, legal requirements and tax obligations.[1] Generally,
feasibility studies precede technical development and project implementation.A
feasibility study evaluates the project's potential for success; therefore,
perceived objectivity is an important factor in the credibility of the study for
potential investors and lending institutions.It must therefore be conducted with
an objective, unbiased approach to provide information upon which decisions
can be based.
This study is carried out to check the economic impact of the proposed system
on the organization.The amount of money that a company can invest in an idea
is limited and thus, the expenditures must be justified. Thus it was possible to
develop the system well within a budget because most of the technologies used
11
is freely available( Eg:Motion software is an open source). By analyzing the
parameters such as Hardware cost since all the software used is free, Total
estimated cost of the project, Financing of the project by equal sharing between
our team members, Cost-benefit analysis. Projected cash flow and profitability,
we conclude that our project is economically feasible.
Technical feasibility study is carried out to check the technical feasibility, that
is, the technical requirements of the system. Any system developed must not
have a high demand on the available technical resources. This will lead to high
demands being placed on the client. The developed system must have a modest
requirement, as only minimal or null changes are required for implementing this
system.With respect to technical feasibility, we analyzed various technical
considerations that include Software available, Platforms available, Protocols
available for network communication, Interoperability factors and also our
knowledge level and expertization with the tools available to implement our
project and thus, we have concluded that out project is technically feasible.
Operational feasibility is the measure of how well a proposed system solves the
problems, and takes advantage of the opportunities identified during scope
definition and how it satisfies the requirements identified in the requirements
analysis phase of system development.The operational feasibility assessment
focuses on the degree to which the proposed development project fits in with
the existing business environment and objectives with regard to development
schedule, delivery date, corporate culture and existing business processes.To
ensure success, desired operational outcomes must be imparted during design
and development. These include such design-dependent parameters as
reliability, maintainability, supportability, usability, producibility, disposability,
12
sustainability, affordability and others. These parameters are required to be
considered at the early stages of design if desired operational behaviours are to
be realised. A system design and development requires appropriate and timely
application of engineering and management efforts to meet the previously
mentioned parameters. A system may serve its intended purpose most
effectively when its technical and operating characteristics are engineered into
the design. Therefore, operational feasibility is a critical aspect of systems
engineering that needs to be an integral part of the early design phases.Thus, all
the parameters of reliability, maintainability, supportability, usuability,
producibility and disposability have been analysed for our system and we have
concluded that our project is operationally feasible.
13
Chapter – 4
System Requirements
14
Chapter – 5
Software Description
5.1 Raspian OS
5.2 Motion
5.3 SSMTP
5.4 Mailtutils
5.5 mpack
The mpack program encodes the the named file in one or more MIME
messages. The resulting messages are mailed to one or more recipients, written
to a named file or set of files, or posted to a set of newsgroups.
16
Chapter – 6
Project Description
6.1 Problem Definition
The surveillance and security cameras used these days are fixed to a ceratin
point and the system cannot be moved around easily once it is set up.There may
arise certain situations where one might want to have some security at hand so
that they can setup a security camera even though it is to be used for only a few
hours or so.Like in a hotel room or in an exhibition where an already setup
security camera might come in handy.While there are a few portable
surveillance cameras out there, they are quite expensive and cannot be
customised beyond a certain limit.The main aim of our project is to provide a
portable surveillance system that is independent of any other system, is
affordable and can be customised to your needs.
The ultimate aim of the project is to make the surveillance system as portable as
possible and also encourage the use of IoT for personal use.The portability of
the system comes with the use of Power bank and operating the Raspberry Pi in
headless mode.Motion taking place in front of the connected camera is detected
by the Motion software and the pictures clicked and videos recorded are saved
locally.Livestream is also enabled when the camera is turned on.The installed
mail client will be used to send an email of the latest picture clicked as an
attachment using SSMTP,Mailutils and mpack.
17
Prerequisites:-
Motion needs to be installed in the Pi in order to configure its config file and
enable the livestream, local storage of media files and motion detection features
with the help of the connected camera.Motion can be installed and configured in
the following way in order to get the mentioned features up and running.
Step 1: First run the below command to update the Raspbian OS on Raspberry
Pi:
Step 3: Now set Motion daemon to yes by editing the file: /etc/default/motion so
that it will be always running. Edit this file using ‘nano’ editor with ‘sudo’ like
given below:
Step 4: Now we need to set the permission for the Target Directory
(/var/lib/motion/), in which Motion saves all the Video recordings and picture
files. We need to set ‘Motion’ as owner of this directory by issuing below
command:
18
sudo chown motion:motion /var/lib/motion/
Step 5: Now we are almost done, only we need to change one config option in
Motion configuration file (/etc/motion/motion.conf) which is stream_localhost
off. We have to turn off this local host streaming, otherwise we will not be able
to access the Video feed on our network and it will be only accessible from the
Raspberry Pi itself. To doing so, edit the Motion Configuration file with ‘nano’
editor and turn it off, like shown in screenshot 1
Now we are done and ready to get our live feed from the USB web
camera connected to Pi. Just start the Motion service using below
command and open your Raspberry Pi’s IP, with port 8081, in your
browser (like 192.168.1.103:8081):
You can always start, stop, restart and get status of Motion service using
below four commands:
sudo reboot
19
6.4.2 Power Module
This module will send an email of the latest snap captured to the mail
account mentioned whenever motion is detected by the system.
A mail client needs to be installed in order for this to work.
A number of tools are to be installed to install a mail client.
Once this is done,Motion needs to be configured to send an email with
the picture recently saved in the local storage as an attachment.
Installation of tools and the configuration of Motion can be done in the
following way:-
For this solution you'll need a throwaway Gmail account, as you are going to
specify your Gmail password in a configuration file.
Next, run:
and ensure that file contains the following configuration parameters, making
sure that your Gmail account credentials are in place:
root=postmaster
mailhub=smtp.gmail.com:587
hostname=raspberrypi
AuthPass=yourgmailpassword
FromLineOverride=YES
UseSTARTTLS=YES
Finally send a test email with an attachment from the target_dir directory:
Here you'll need to make a small change to your Motion configuration file.
21
What happens here is that Motion will call this command each time a new
image snapshot is saved to the target_dir directory. The %f variable contains the
full path to the file.Save the configuration file, restart Motion and voila! You
should now be receiving email notifications each time Motion detects a motion
event.
Note:Ctrl+W can be used in order to search for terms in the conf file.
22
Chapter – 7
System Testing
7.1 Introduction
This is the first level of testing. The different modules are tested against the
specifications produced during the integration. This is done to test the internal
logic of each module. Those resulting from the interaction between modules are
initially avoided. The input received and output generated is also tested to see
23
whether it falls in the expected range of values. Unit testing is performed from
the bottom up, starting with the smallest and lowest modules and proceeding
one at a time.
In integration testing, the tested modules are combined into sub-systems, which
are then tested. The goal of integration testing to check whether the modules can
be integrated properly emphasizing on the interfaces between modules. The
different modules were linked together and integration testing done on them.
The objective of the validation test is to tell the user about the validity and
reliability of the system. It verifies whether the system operates as specified
and the integrity of important data is maintained. User motivation is very
important for the successful performance of the system.
The integration of each module in the system is checked during this level of
testing. The objective of system testing is to check if the software meets its
requirements. System testing is done to uncover errors that were not found in
earlier tests. This includes forced system failures and validation of total system
as the user in the operational environment implements it.
A test case is a set of conditions under which the tester will determine whether
the system is working or not.
TC 1:The mail will not be sent if the filename is not written properly in the
on_picture save parameter
24
TC 2:Checking the status of the battery of the power bank leads to rebooting of
the motion software
TC 3:The battery has not dropped from 75% even after over 2 hours of usage
implying that the system can last for a long time
TC 4:The mail alert system does not affect the performance of the security
camera module
TC 5:There is a small amount of delay on receiving the mail after the picture is
clicked.
25
Chapter – 8
Implementation
8.1 Introduction
The power bank is powers up the Pi which in turn powers the camera.After the
installation of motion, motion is configured by making changes to various
parameters such as stream_localhost, image width, image height, stream quality,
etc. in order to get the livestream up and running as well as make the camera
capture images and record videos at regular intervals when motion is
detected.SSMTP,Mailutils and mpack are the tools that are installed which
install the mail client needed for the email alert system.The ssmtp is configured
with the user details entered in the AuthEmail and AuthPassword.This is
necessary in order to set the mail account throught which the mail will be
sent.The receipient email is also supposed to be entered in the config file.After
this is done,motion is configured to send the email by uncommenting the
on_picture_save parameter and using mpack –s “Subject” %f [recipient_email]
where %f is the full path along with the filename.Once this is done, the mail
alert system is ready to use.
26
Chapter – 9
The novelty and significance of this work is that by introducing the idea of an
affordable portable surveillance system using open source software is that a
portable and ready to use security camera system will be available for the
general public to use which can come in handy quite often.This surveillance
system is not supposed to replace the stationary security camera systems but
rather provide a temporary solutions for your quick home security needs and
provide a cheaper alternative to the expensive options out there.The success of
this project wil encourage the general public to dabble in IoT and create IoT
systems for their personal use by themselves making the private companies to
work harder to deliver more quality products and thereby increasing healthy
competition between brands that compete in the same market, thereby
increasing the no. of quality products in the market which are more affordable.
The whole system can be fixed in a case so that the whole system can be carried
around as 1 component rather than carrying around 3 components all the
time.As of now, the livestream that is broadcasted over the network has no
sound so the inclusion of a microphone module to the Pi and integrating it with
the system could broadcast the livestream with sound as well.
27
Appendix - 1
SCREEN SHOTS
Configuration of Motion
28
29
30
31
32
33
Livestream
Email Alert
34
Storage of Photos and Videos
35
Appendix – 2
References
1)
https://circuitdigest.com/microcontroller-projects/raspberry-pi-surveillance-
camera
2)
https://www.bouvet.no/bouvet-deler/utbrudd/building-a-motion-activated-
security-camera-with-the-raspberry-pi-zero
3)
https://wiki.archlinux.org/index.php/SSMTP
4)
https://directory.fsf.org/wiki/Mailutils
5)
https://linux.die.net/man/1/mpack
6)
https://en.wikipedia.org/wiki/MIME
36
7)
https://en.wikipedia.org/wiki/Motion_(surveillance_software)
8)
https://en.wikipedia.org/wiki/Raspbian
37