You are on page 1of 6

2015 IEEE International Conference on Control System, Computing and Engineering, 27 - 29 November 2015, Penang, Malaysia

A Real-time Surveillance Mini-rover Based on


OpenCV-Python-JAVA Using Raspberry Pi 2
Nazmul Hossain, Mohammad Tanzir Kabir, Tarif Riyad Rahman, Mohamed Sajjad Hossen, Fahim Salauddin
Department of Electrical and Computer Engineering
North South University
Dhaka, Bangladesh.
nazmul.hossain@northsouth.edu, tanzir.kabir@northsouth.edu, trahman@northsouth.edu, hmohamedsajjad43@gmail.com,
fahim.salauddin.bd@ieee.org

Abstract-- Real-time surveillance is a vital component in any II. RELATED WORK


situation or environment where there is a high need of security
Raspberry Pi series computers are relatively new in the
for both personal and commercial property and assets.
Technology today is used in many different ways in order to
market. The first Raspberry Pi 1 Model B+ was introduced
provide us such surveillance. An ideal solution for surveillance
commercially only 3 years ago on February, 2012. On the
involves not only the assortment of necessary sensors and devices official Raspberry Pi site (www.raspberrypi.org), there are lots
using appropriate tools, but also should be provided in the most of helpful resources for one to start using Raspberry Pi in
optimized way for obtaining feed and data while keeping the relevant projects. Even though the Raspberry Pi has been in
expenditure minimized. In our project, we aimed at developing a the technological arena for relatively shorter period of time,
low-cost, real-time video surveillance mini-rover which will be people had already been using it to make various interesting
capable of providing real-time video footage and roam around in and marvelous projects in their own ways. Some of those
the area which we want to observe. Our target was to use projects demonstration videos which are similar to our
hardware which is very low of cost and easily available. project, can be watched on the YouTube.
One such interesting project introduced a fuzzy based smart
KeywordsMini-rover, Video Surveillance, Real-time, monitoring system using Raspberry Pi, Python & JAVA in [2].
Networking, OpenCV, Python, JAVA, Raspberry Pi 2.
Loscri, Mitton & Compagnone applied OpenCV Object
Detection and Face Recognition to implement the
behavioral algorithm described in their paper for Arduino
I. INTRODUCTION based platform [3].
In our modern day to day life, security and surveillance
In [4], line tracking algorithm was implemented using
plays a very pivotal role. An effective security and Raspberry Pi in marine environment for detecting fault in
surveillance system can provide crucial early warnings in case underwater communication/ oil pipelines.
of any kind of emergency. However, if the surveillance system
is capable of roaming inside the area of surveillance, more In [5], a rocker-bogie suspension rover with scooping arm
area of interest can be observed with optimum number of was controlled using cellphone technology (DTMF) where the
surveillance equipment under constrained budget. main component was an Atmega32 board. However, its video
streaming range was only limited to 100 feet.
Moreover, if the surveillance system is easily modifiable However, the project implemented and described in [6] is
with various sensors (digital temperature/ humidity/ flame/ very similar to ours compared to other projects from [2], [3],
sonic/ air quality/ gas sensors, etc.), obtaining necessary data [4] and [5]. In [6], a Raspberry Pi based rover was controlled
becomes much easier. This availability of various kinds of from smart devices using web browser via WLAN/ Internet.
necessary data in turn helps us in decision making process But, according to the system overview given in [6], the user
while managing various kinds of situations. can access the rover control & video feed webpage running on
the webserver hosted on the Raspberry Pi but the user agent
According to Kevin Ashton in [1], loss, waste and cost (smart devices) has to be connected to the same Wi-Fi
management would be a lot easier if we had computers with network where the Raspberry Pi is connected or has to connect
information on everything that we use were in charge of to the internet through the same subnet used by the Raspberry
Pi. In contrast to [6], our Mini-rover can be controlled either
counting and tracking items without any intervention from any
from a Laptop/ Desktop/ Android devices using our JAVA or
human. RFID technology would enable computers with those Android-JAVA application either via a Wi-Fi LAN in local
kinds of powers without the limitations of human-entered data areas or, when using the cloud server & Internet, the mini-
so replacing, repairing or recalling faulty items would be a lot rover can be placed anywhere in the world with Internet
more convenient. connectivity and controlled from the remote control platform
(Laptop/ Desktop/ Android devices) connected to the Internet.
In the latter case (with cloud server and Internet) , both the
mini-rover and the Remote Control platform neednt to be

978-1-4799-8252-3/15/$31.00 2015 IEEE 476


2015 IEEE International Conference on Control System, Computing and Engineering, 27 - 29 November 2015, Penang, Malaysia

connected to the Internet via the same subnnet, only the cloud
server will need to have a Public/ Global IP
P Address.

III. MOTIVATION & BACKGROU UND


Its needless to say that security plays a pivotal
p role in our
modern life. Whether its for business purrposes or personal
reason, the need of surveillance and securityy has always been
much talked about. On top of that, remotee surveillance can
play a very effective role in providing securrity in our modern
ways of life.
Most of the present day surveillance systtems provide with
fixed-point CCTV view of certain area. To T record/ obtain
surveillance footage from various viewing anngle, one must use
PTZ (Point-Tilt-Zoom) CCTV cameras whicch are quite costly Fig. 1. Diagrammatic Overview of
o the Project
and moreover, they remain fixed at one siingle point they
cant roam around and provide coverage of a larger area.
Besides, once installed, modification/ uppgrading of those
systems are quite costly and time-consumingg. V. HARDWARE USEED IN THE PROJECT
So, we wanted to develop a simple video surveillance mini- For implementing our projject, we used various hardware
rover system which can be remotely controlled to move which are low of cost, reliabble and readily available in the
around and provide the user with real-time video
v footage of an local market. We also wanted to recycle any old parts if
area of interest. possible. Below here is givenn a list and short descriptions of
various principal hardware useed in our project:

IV. SALIENT FEATURES OF THE PROJECTR A. Raspberry Pi 2 Model B Veersion 1.1:


Followings are the salient features of our project:
p
To be able to handle all the process and computations
It should be inexpensive in comparisson to present day
needed for the mini-rover suurveillance system, we chose to
surveillance equipment. For example, only a single
PTZ CCTV camera will cost arouund $100 - $450 use a Raspberry Pi 2 (Model B,
B Version 1.1) for our project.
depending on the manufacturing company (as of
August 30, 2015).
The mini-rovers chassis should be b able to move
forward, backward, leftward & righhtward on its four
wheels with all the equipment on boarrd.
The USB Webcam should be able to t provide with a
clear, real-time view of the area at its front.
Video stream data from the webcam should
s be sent to a
remote controlling platform over the Internet/ Wireless
network for being displayed to the useers screen.
The mini-rover should be able to receive commands
from the remote controlling platform
m (i.e.: Desktop or
Fig. 2. A Raspberry Pi 2 Model B Version 1.1
Laptop) over the Internet/ Wireless network
n and move
around according to the given commaand.
We chose Raspberry Pi 2 ass the Brain of our mini-rover
The system should be easily moddifiable for future because of the following reasonns:
integration of various types of sensoors with the video Raspberry Pi 2 doesnt require
r much power to operate.
surveillance module on board the minni-rover. It is very low-cost (USD D $35 only).
The next image shows a diagrammatic overview of our It runs on Raspbian OS, an optimized version of
project: Debian Linux (which is Open-source).
It has in total 40 GPIO O pins to interact with various
sensors & modules. Soo, even after connecting all the
hardware of our projecct, there are enough GPIO pins
left to connect variouss types of sensors in future if
modification becomes necessary.
n

477
2015 IEEE International Conference on Control System, Computing and Engineering, 27 - 29 November 2015, Penang, Malaysia

Its a full-fledged CPU capable of connecting to a


Local Network / Internet via its Ethernet port or using a
Raspberry Pi 2 compatible USB modem or USB Wi-Fi
adapter which is ideal for implementing our project.

B. L298N H-Bridge Dual Motor Controller:

To control all the dc motors onboard the mini-rovers


chassis, we used a L298N H-Bridge Dual Motor Controller.

Fig. 5. Apacer 4400mAh mobile power bank used in our project

E. Power Supply for Mini-Rovers Driving Motors:

To provide external power to the two DC motors driving the


mini-rover, we used a small plastic battery pack capable of
holding 5(five) AA batteries (1.5V each, total 7.5V).

F. Four-wheeled RC Toy-car Chassis:


Fig. 3. A L298N H-Bridge dual motor controller
As for constructing the mini-rovers body, we salvaged a
thrown-out four-wheeled RC Toy-car chassis, replaced its
Bluetooth RC Module with our L298N H-Bridge Dual Motor
C. A4Tech USB Mini Webcam: Controller and assembled all other components on top of that
chassis.
To obtain video footage, we used a standard, plug-n-play
A4Tech USB Webcam.

Fig. 6. Vertical (left) & lateral (right) view of the mini-rover

Fig. 4. A4Tech USB webcam used in our project VI. MAJOR SOFTWARE & LANGUAGES USED
The deliverance of smooth movement control and good
quality video capture was a priority in choosing the proper
D. Apacer 4400mAh Mobile Power Bank: software for our project. The list of all the software used in our
project is given below:
To supply power to the Raspberry Pi 2 on-board the mini-
rover, we used a 4400mAh Apacer Mobile Power Bank. A. Raspbian OS:

There are several different operating systems for the


Raspberry Pi. Among these, Raspbian stands out to be the
most popular Debian Linux based operating system for the
Raspberry Pi [7].

478
2015 IEEE International Conference on Control System, Computing and Engineering, 27 - 29 November 2015, Penang, Malaysia

Cardboard and paper for making the rover body

A. Hardware Setup Sequence::

After obtaining all the necesssary hardware and accessories,


we began to setup and connecct the hardware together for the
mini-rover as follows:
After enclosing the R-Pi 2 innside a protective plastic casing,
we established required connnections between the R-Pi 2s
GPIO pins and L298Ns inputt pins as shown in the Figure 8
below:

Fig. 7. A typical Raspbian desktop

B. Python:

In the context of our project, Pythhon is the best


programming language that can be useed to allow the
Raspberry Pi to interact (in our case alloowing control for
movement and video capture) with the user or
o client.

C. OpenCV:

For the purposes of our project, OpenC CV library was an


essential tool for the video capturing aspect of the mini-rover.
Due to the librarys flexible compatibiliity and hardware Fig. 8. Connections between Raspberrry Pi 2s GPIO & L298Ns pins
acceleration standards, OpenCV was easily integrated
i into our
Raspberry Pi 2. After connecting the two DC C motors of the chassis with the
motor controller & then the motor
m controller with Raspberry
D. JAVA: Pi 2, we connected the USB Webcam and a Wi-Fi pocket
router (which will provide network connectivity to the
All the programs running on the central server
s and also on Raspberry Pi 2) to the Raspbeerry Pi 2s USB ports. One can
the remote control laptop for this project were written and use a USB Wi-Fi adapter com mpatible with the Raspberry Pi 2
implemented using JAVA. Data transmissioon (both video and instead of a Wi-Fi pocket routeer for network connectivity.
rover movement commands) was achieved usingu JAVA socket We then put all the connected hardware so far on the
programming both on the central server and the control salvaged toy-car chassis as shoown in Figure 6. We connected
laptop. the power bank with Raspbeerry Pi 2 at the last stage of
hardware assembly to switch-oon the Raspberry Pi 2.
E. SSH, Putty and Xming:
B. Software Setup Sequence:
SSH stands for Secure Shell. SSH is used to establish
cryptographic network-protocol based shell sessions from a After powering up the R-Pii 2, we establish a SSH session
remote platform on a Linux-based machinee. Putty & Xming from a remote laptop using an Ethernet cable, Putty & Xming
are two third party software used in our prroject to establish server program.
SSH sessions between our Windows-baseed laptop and the After that, we opened up tw
wo separate consoles on the R-Pi
Linux-based R-Pi 2 for remotely accesssing the desktop/ 2 using the SSH session and obtained root privileges (using
command line of the R-Pi 2 on board the minni-rover. the command sudo su).
Then, we ran the central serrver program (written in JAVA)
on a separate laptop which iss connected to the same Wi-Fi
VII. SETUP & IMPLEMENTATIO
ON
network provided by the Wi-Fii pocket router connected to the
Alongside the major hardware mentioneed previously, we Raspberry Pi 2.
used the following miscellaneous items too to implement our From the previously openedd up consoles on the Raspberry
project: Pi 2, we accessed two python scripts
s (stored on the Raspberry
A robust encasing for protecting the Raaspberry Pi Pi 2) for controlling the mini--rovers movement & obtaining
5 AA size batteries for the motor control battery pack video footage from the USB webcam and by running them, we
Jumper cables (male-to-female, femalee-to-female) connect the Raspberry Pi 2 onn-board the mini-rover with the
Ethernet cable central server.
Utility tape for attaching components of
o the rover Then, we connected the reemote control laptop with the
same Wi-Fi network where thee central server & the R-Pi 2 are

479
2015 IEEE International Conference on Control System, Computing and Engineering, 27 - 29 November 2015, Penang, Malaysia

connected and ran the two JAVA programs IX. ACHIEVEMENT


RoverControl.java & VideoFrame.java to access the The main objective of our project was to provide a real-time
webcam feed and the mini-rovers movement control panel as surveillance mini-rover that can be remotely controlled and at
shown in Figure 9:
the same time obtain video feed of the desired area. In our
project, we used the Raspberry Pi 2 as the main processing
unit for overall mini-rover control and functions.
We successfully achieved using the internet as the medium
of connection required for transferring control signals and
obtaining video feed. If we had used standard radio signals or
Bluetooth connectivity instead of Internet or Wi-Fi as medium
of connectivity that would not have enabled the mini-rover to
achieve its virtually global operating range.
X. LIMITATIONS
However, as most of real-world things, our mini-rover has
some limitations, too. For example:

When using a local Wi-Fi network, mini-rovers


Fig. 9. Mini-rovers movement control panel (on the left) & Video feed from response time is almost instantaneous. However, when
the Mini-rovers webcam (on the right) as displayed on the remote control using the Internet to remotely control and obtain
laptops screen
footage from the mini-rover (while using a cloud server
with public IP address), the response time will vary
VIII. RESULTS & ANALYSIS (might be few milliseconds in case of movement
control and a few seconds in case of video-streaming if
After assembling all the hardware correctly and installing & Internet bandwidth being used is low). It can be
running all the software, we successfully demonstrated that the overcome if high-speed Internet connectivity through
mini-rover can: cellular data network is ensured.

Provide us with a Black and White video footage of As a RC toy car chassis was used for the mini-rovers
the area at its front. body, in case of muddy or sandy surface, our mini-
It can receive commands from the remote control rover in its current design isnt suitable. However, if a
laptop/pc/android device and move Left/ Right/ Up/ stronger, robust chassis with greater mobility is
Down according to the given commands. designed and used with our mini-rovers concept, then
When connected with the central server via Internet it will be able to handle almost all kinds of terrain quite
(using a USB Wi-Fi dongle connected to the Raspberry well.
Pi 2s USB port and available Wi-Fi network), the
mini-rover can be placed anywhere in the world where Due to its current RC toy car chassis, the mini-rover
Wi-Fi Internet connectivity is available & send/ cant take any extra payload. It can be overcome by
receive data to/ from the remote control platform using the solution described in the previous point.
(which is also connected to the central server via
Internet) . The viewing angle of the USB webcam is fixed. This
can be overcome by mounting the USB webcam on a
The gray-scale image format was chosen because video- tilt and rotation enabled platform (this platform can be
frames in gray-scale format is much faster to stream and constructed using servo motors and other necessary
consumes one-third of the bandwidth required for streaming things).
same video-frames in RGB or any other color format similar
to RGB format. As we used cellular/ mobile network for As there was no Raspberry Pi 2 compatible USB Wi-Fi
connecting our mini-rover to the Internet while connecting to dongle available in the local (Bangladeshi) market (its
the cloud-server, a good amount of bandwidth was saved as a available in the international market), we were
result of using gray-scale image format. compelled to use a 3G Mobile Pocket Router for
providing Wi-Fi connectivity to the Raspberry Pi 2.
And as a direct result of using Internet via cellular data This only limits the Raspberry Pi 2 to connect to the
network, we were able to achieve virtually global operating Internet. The 3G Mobile connection had bandwidth
range for our mini-rover. limitations and at times was intermittent, causing a
problem for continuous motor control and video feed
capturing of our mini-rover. In order to overcome this

480
2015 IEEE International Conference on Control System, Computing and Engineering, 27 - 29 November 2015, Penang, Malaysia

problem, we need to use a Raspberry Pi 2 compatible XII. CONCLUSION


USB Wi-Fi dongle. This project provided an inexpensive solution for mobile
surveillance in any necessary environment. Total cost of our
project was estimated to be around $90 which is much cheaper
XI. FUTURE WORKS compared to presently available mobile surveillance solutions.
Our mini-rover can indeed be controlled fully to move in all
In future, our project can be expanded in a number of ways.
Below here is some of the possible future works suggestion directions. By using the USB webcam, we can also obtain
for our project: video-footage in real time while the mini-rover is on the move.
And above all, the mini-rover is fully controlled through
We can modify the mini-rover chassis to be able to internet connection, whether it is through a local network, Wi-
handle all kinds of terrain and all kinds of inclement Fi, 3G or a cloud server, which makes our mini-rover the best
weather. option for integrating an IoT application into the issue of
Any necessary sensor can be installed on the mini-rover security and surveillance services. By adding necessary
(i.e.: Digital temperature & humidity sensor, Gas modifications as mentioned before, our project can be
sensor, Air quality sensor, Sonic sensor, etc.) to obtain delivered as a full-fledged device which can be used for home
necessary information on the surveillance area. or corporate surveillance purposes.

Solar panel and compatible battery modules can be


installed on the modified chassis to make the mini-
rover to be solar-powered. REFERENCES
[1] The Internet of Things Thing by Kevin Ashton Retrieved from
We may devise and add a module involving a laser http://www.rfidjournal.com/articles/view?4986
sensor for measuring distance so that the mini-rover
[2] Fahim Slauddin and Tarif Riyad Rahman . A Fuzzy based low-cost
can scan and generate a 3D map representation of the monitoring module built with raspberry pi python java architecture.
surroundings, hence providing the person controlling International Conference on Smart Sensors and Application (ICSSA) ,
the rover a 3D map representation of the surrounding 2015.
area. [3] Valeria Loscri, Nathalie Mitton, and Emilio Compagnone. OpenCV
WebCam applications in an arduino-based rover. International
Artificial Intelligence (i.e.: Machine-Learning, Pattern/ Workshop on Wireless Sensor, Actuator and Robot Networks
Object Recognition, etc.) can be added to enable the (WiSARN), Jun 2014, Benidorm, Spain. 2014.
mini-rover identify obstacles/ hazardous environment [4] S. Amir, A.A. Siddiqui, N. Ahmed, and B.S. Chowdhury.
and notify & suggest alternatives to the operator/ Implementation of line tracking algorithm using raspberry pi in
control station while making the mini-rover fully maritime environment. IEEE International Conference on Industrial
automated for roaming around. Engineering and Engineering Management (IEEM), 2014.
[5] S. Divakar. Cell phone controlled rocker-bogie suspension type rover
With necessary sensors and modules installed and any with a scooping arm. 8th International Conference on Ubiquitous
other modifications, the mini-rover can be used to Robots and Ambient Intelligence (URAI), 2011.
monitor various high-risk large areas like various [6] Dadi Anil Kumar and Mrs.Dr.M.Sangeetha. Controlling raspberry pi
industrial plants, factories or can be used to constantly rover through any smart device using web browser via WLAN/
internet. International Journal of Science, Engineering and Technology
monitor vast areas like various agricultural fields/ farms Reasearch (IJSETR), Vol. 4, Isuue 4, April 2015.
where constant human monitoring can be too costly. [7] Harrington, N. Learning Raspbian. Packt Publishing ebooks
Account.2015.

481

You might also like