Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
BACHELOR OF TECHNOLOGY
By
DECLARATION
I PRIYANKA PAUL hereby declare that the Project Report entitled” AUTOMATIC
MOVING OBJECT DETECTION AND VIDEO SURVEILLANCE SYSTEM USING
BACK GROUND SUBTRACTION ALGORITHM” is done by me under the guidance of
Mr.S.RAMRAJ at BHARATH UNIVERSITY is submitted in partial fulfillment of the
requirements for the award of the degree in BACHELOR OF TECHNOLOGY.
DATE:
This is to certify that this Project Report is the bonafide work of Ms.PRIYANKA, Reg.
No U07IT083who carried out the project entitled “AUTOMATIC MOVING OBJECT
DETECTION AND VIDEO SURVEILLANCE SYSTEM USING BACK GROUND
SUBTRACTION ALGORITHM” under our supervision from December 2010 to March
2011.
i
LIST OF FIGURES
FIG NO. TITLE PAGE NO.
1 REQUEST FROM CLIENT TO SERVER 2
2 DATA FLOW DIAGRAM1 6
3 DATA FLOW DIAGRAM2 7
4 DATA FLOW DIAGRAM3 7
5 ACTIVITY DIAGRAM 8
6 ARCHITECTURE DIAGRAM 10
7 SEQUENCE DIAGRAM 11
8 COLABORATION DIAGRAM 12
9 ACTIVITY DIAGRAM 13
ii
ABSTRACT
According to the result of moving object detection research on video sequences, this
paper proposes a new method to detect moving object based on background
subtraction. First of all, we establish a reliable background updating model based on
statistical and use a dynamic optimization threshold method to obtain a more complete
moving object. And then, morphological filtering is introduced to eliminate the noise and
solve the background disturbance problem. At last, contour projection analysis is
combined with the shape analysis to remove the effect of shadow; the moving human
bodies are accurately and reliably detected. The experiment results show that the
proposed method runs quickly, accurately and fits for the real-time detection.
The movement of the people is tracked using video surveillance. The moving object is
identified using the image subtraction method. The background image is subtracted
from the foreground image. From that the moving object is derived. But in case of dark
area it is difficult to view the foreground image since it will show no difference. So the
frame algorithm and the threshold value is calculated to find the moving image. Using
frame algorithm the moving frame is identified. Then by the threshold value the
movement of the frame is identified and tracked. Hence the movement of the object is
identified accurately.
iii
CHAPTER-1
INTRODUCTION
1.1 OVERVIEW
According to the result of moving object detection research on video sequences, this
paper proposes a new method to detect moving object based on background
subtraction. First of all, we establish a reliable background updating model based on
statistical and use a dynamic optimization threshold method to obtain a more complete
moving object. And then, morphological filtering is introduced to eliminate the noise and
solve the background disturbance problem. At last, contour projection analysis is
combined with the shape analysis to remove the effect of shadow; the moving human
bodies are accurately and reliably detected. The experiment results show that the
proposed method runs quickly, accurately and fits for the real-time detection.
The movement of the people is tracked using video surveillance. The moving object is
identified using the image subtraction method. The background image is subtracted
from the foreground image. From that the moving object is derived. But in case of dark
area it is difficult to view the foreground image since it will show no difference. So the
frame algorithm and the threshold value is calculated to find the moving image. Using
frame algorithm the moving frame is identified. Then by the threshold value the
movement of the frame is identified and tracked. Hence the movement of the object is
identified accurately.
1.2 OBJECTIVE
The movement of the people is tracked using video surveillance. The moving
object is identified using the image subtraction method. The background image is
subtracted from the foreground image. From that the moving object is derived.
1
moving object
webcam
stores the image db
system
user mobile
2
CHAPTER-2
In the existing system, the moving object is identified using the some algorithms which
are not exactly doing that detection works. The image comparison is very difficult
process in many existing systems. And also there is no accuracy in the image
sequences.Moreover there is no alert system to inform the admin when unknown object
is detected.
In the existing system, the moving object is identified using the image subtraction
method. The background image is subtracted from the foreground image. From that the
moving object is identified. Here we can detect the exact image of the moving object.
Another advantage of this system is when an unknown image is captured by the system
it will alert the user automatically by sending a captured object details to user’s mobile.
Advantages
3
2.2 REQUIREMENT SPECIFICATION
RAM : 64 MB
HDD : 2.1 GB
Platform :Windows Xp
4
CHAPTER-3
4. Server
5. Alert SMS
communication & other personal information. User access the main server through
J2ME implementation to fetch out the image of the thief, Java 2 Micro Edition access
coding are installed in a Java enabled Mobile phone of the user. The J2ME coding is
converted into JAD file and then fused into a Java Enabled Mobile phone.
5
Send the alert
Send the
System
captured image
Admin mobile
Webcam
Fetch the adman’s View the
mobile number clips
from db
Web camera is connected with the place which is to be monitored. Once the admin
locks the door, he will be switching on the Web camera device for capturing the image.
The Web camera captures the first image which is kept as the Reference image for
further computational process. This reference image is always compared with the next
following images for the sake the intruder detection by applying Motion detection
algorithm.
6
Web cam on viewing
Pixel value
Constant
Value
Change
Start recording
image
Sending to admin
mobile
As image or video
7
Fig:3 DATA FLOW DIAGRAM3
Webcam
Fetch the adman’s View the
mobile number clips
from db
8
3.1.3 BACKGROUND SUBTRACTION ALGORITHM
server
9
3.1.4 SERVER
The main server will have the database of the admin’s mobile number and also the
server is connected with the mobile phone for sending Alert SMS to the admin’s
mobile. If there is any pixel change after applying Back Ground Subtraction
Algorithm, immediately system alerts main server to initiate JSMS package to send
SMS to the admins Mobile as well as start recording all the frames in the main
server.
10
3.1.5 IMAGE CAPTURING
Once after receiving the alert SMS to the admins mobile, admin will then login through
his mobile to access Main Server via J2ME package which is installed in his mobile.
Admin can see whether, the really thief has entered in or the Genuine people entry via
Image which is recorded by the web camera then after initiating Alert SMS. The admin
can decide then after either to neglect, if any genuine person has entered, ot take action
if thief has entered. To decide this admin not required to come directly, he can see
through his Mobile phone via J2ME & GPRS connection.
2: compare
11
4: if captured image is not match with db image
user
db
mobile
12
webcam captures the
moving object
match
13
CHAPTER-4
4.1 CODING
LOGIN.JAVA
import java.io.*;
importjava.sql.*;
importjavax.servlet.ServletException;
importjavax.servlet.http.*;
throwsIOException, ServletException
httpservletresponse.setContentType("text/html");
PrintWriterprintwriter = httpservletresponse.getWriter();
String s = httpservletrequest.getParameter("user");
String s1 = httpservletrequest.getParameter("pass");
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
14
ResultSetresultset = statement.executeQuery("select * from login where username='" +
s + "' and password='" + s1 + "'");
if(resultset.next())
printwriter.println("Logged In");
else
printwriter.println("Invalid user");
connection.close();
catch(Exception exception)
exception.printStackTrace();
}import java.io.*;
importjava.sql.*;
importjavax.servlet.ServletException;
importjavax.servlet.http.*;
15
throwsIOException, ServletException
httpservletresponse.setContentType("text/html");
PrintWriterprintwriter = httpservletresponse.getWriter();
String s = httpservletrequest.getParameter("user");
String s1 = httpservletrequest.getParameter("pass");
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
if(resultset.next())
printwriter.println("Logged In");
else
printwriter.println("Invalid user");
connection.close();
16
catch(Exception exception)
exception.printStackTrace();
MOTION.JAVA
importjavax.microedition.midlet.*;
importjavax.microedition.lcdui.*;
importjavax.microedition.lcdui.Form;
import javax.microedition.io.*;
import java.io.*;
importjava.lang.*;
HttpConnection con;
TextFieldtxtUser,txtPwd,txtIPAddress;
Display disp;
Command cmdOk,cmdBack,cmdView;
Menu m1;
String userpassword;
socketexamclsoc;
String str="";
Form status;
17
String url;
String fileContent="";
Static intfContentTemp = 0;
super(strTitle);
this.disp=disp1;
this.welScreen=welScreen;
url="http://"+ServerIPAddress.getServerIPAddress()+":8080/Motion/image/MotionMonito
r.dat";
while(true)
try
//
con=(HttpConnection)Connector.open(url);
InputStream in=con.openInputStream();
System.out.println("File Content:"+fContentTemp);
int c=0;
while((c=in.read())!=-1)
fileContent+=(char)c;
18
System.out.println("File Content:"+fileContent);
intfContent = Integer.parseInt(fileContent);
fileContent = "";
if(fContent>fContentTemp)
System.out.println("Motion is detected");
in.close();
else
fContentTemp = fContent;
Thread.sleep(30000);
catch(Exception e){}
publicDetectMotion(String msg,Stringst,Displaydisp)
super(st);
this.disp=disp;
19
cmdView = new Command("VIEW",Command.OK,1);
if(msg.startsWith("Motion is detected"))
System.out.println("Motion is detected");
status.addCommand(cmdView);
status.setCommandListener(this);
status.append("Motion is detected");
disp.setCurrent(status);
disp.setCurrent(status);
{}
20
public void pauseApp()
{}
if(com==cmdOk)
m1=new Menu("Menu",welScreen,disp);
disp.setCurrent(m1);
System.out.println("Menu is open");
if(com==cmdBack)
disp.setCurrent(welScreen);
if(com==cmdView)
m1=new Menu("Menu",welScreen,disp);
disp.setCurrent(m1);
21
SEND SMS.JAVA
package image;
import java.util.Date;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
class SendSMS
SendSMS()
String to = "info@priyanka.com";
try
props.put("mail.smtp.host", host);
session.setDebug(debug);
msg.setFrom(new InternetAddress(from));
InternetAddress address[] = {
22
new InternetAddress(to)
};
msg.setRecipients(javax.mail.Message.RecipientType.TO, address);
msg.setSubject(subject);
mbp1.setText(msgText);
mp.addBodyPart(mbp1);
msg.setContent(mp);
msg.setSentDate(new Date());
Transport.send(msg);
catch(MessagingExceptionmex)
mex.printStackTrace();
Exception ex = null;
ex.printStackTrace();
23
DATASOURCEREADER.JAVA
package image;
import java.awt.*;
import java.io.*;
import java.util.Enumeration;
import java.util.Vector;
import javax.media.*;
import javax.media.control.MonitorControl;
import javax.media.control.TrackControl;
import javax.media.datasink.*;
import javax.media.format.AudioFormat;
import javax.media.format.VideoFormat;
import javax.media.protocol.*;
class DataSourceHandler
DataSource source;
PullBufferStream pullStrms[];
PushBufferStream pushStrms[];
24
private Vector listeners;
SourceStream unfinishedStrms[];
Loop loops[];
Buffer readBuffer;
throws IncompatibleSourceException
pushStrms = ((PushBufferDataSource)source).getStreams();
pushStrms[i].setTransferHandler(this);
unfinishedStrms[i] = pushStrms[i];
} else
pullStrms = ((PullBufferDataSource)source).getStreams();
25
{
unfinishedStrms[i] = pullStrms[i];
} else
this.source = source;
return null;
return source.getContentType();
26
}
try
source.start();
catch(IOException e)
System.err.println(e);
if(loops != null)
loops[i].restart();
27
public void stop()
try
source.stop();
catch(IOException e)
System.err.println(e);
if(loops != null)
loops[i].pause();
stop();
if(loops != null)
28
{
loops[i].kill();
listeners.addElement(dsl);
if(dsl != null)
listeners.removeElement(dsl);
29
protected void sendEvent(DataSinkEvent event)
if(!listeners.isEmpty())
synchronized(listeners)
DataSinkListener listener;
listener = (DataSinkListener)list.nextElement();
try
stream.read(readBuffer);
catch(IOException e)
30
System.err.println(e);
return;
printDataInfo(readBuffer);
sendEvent(new EndOfStreamEvent(this));
try
stream.read(readBuffer);
catch(IOException e)
System.err.println(e);
return true;
printDataInfo(readBuffer);
if(readBuffer.isEOM())
31
if(checkDone(stream))
System.err.println("All done!");
close();
return true;
} else
return false;
if(strm == unfinishedStrms[i])
unfinishedStrms[i] = null;
} else
if(unfinishedStrms[i] != null)
done = false;
32
}
return done;
} else
if(buffer.isEOM())
try
Thread.sleep(1000L);
System.out.println("Motion Detected");
33
}
catch(Exception ex)
System.out.println(ex);
try
data = (byte[])buffer.getData();
raFile.write(data, 0, buffer.getLength());
System.out.println("Motion Detected");
raFile.close();
i++;
catch(Exception e)
e.printStackTrace();
34
}
return null;
DataSourceHandler()
pullStrms = null;
pushStrms = null;
unfinishedStrms = null;
loops = null;
DataSourceHandler handler;
PullBufferStream stream;
boolean paused;
boolean killed;
35
public synchronized void restart()
paused = false;
notify();
paused = true;
killed = true;
notify();
while(!killed)
try
36
wait();
catch(InterruptedException interruptedexception) { }
if(!killed)
if(done)
pause();
paused = true;
killed = false;
this.handler = handler;
this.stream = stream;
start();
37
Processor p;
Object waitSync;
boolean stateTransitionOK;
Player player;
public int i;
public DataSourceReader()
stateTransitionOK = true;
i = 0;
if(monitorOn)
enableSyncMux();
try
p = Manager.createProcessor(ds);
38
}
catch(Exception e)
return false;
p.addControllerListener(this);
p.configure();
Processor _tmp = p;
if(!waitForState(180))
return false;
p.setContentDescriptor(new ContentDescriptor("raw"));
if(tc == null)
return false;
39
if(!(tc[i].getFormat() instanceof VideoFormat))
continue;
videoTrack = tc[i];
break;
if(videoTrack == null)
return false;
videoTrack.setFormat(jpegFormat);
try
Codec codec[] = {
40
new MotionDetectionEffect()
};
videoTrack.setCodecChain(codec);
catch(UnsupportedPlugInException e)
p.prefetch();
Processor _tmp1 = p;
if(!waitForState(500))
return false;
p.realize();
Processor _tmp2 = p;
if(!waitForState(300))
return false;
try
41
{
handler.setSource(ods);
catch(IncompatibleSourceException e)
return false;
handler.addDataSinkListener(this);
handler.start();
p.prefetch();
Processor _tmp3 = p;
if(!waitForState(500))
return false;
if(monitorOn)
setLayout(new BorderLayout());
42
{
MonitorControl mc = (MonitorControl)controls[i];
monitorComp = mc.getControlComponent();
if(monitorPanel == null)
if(monitorComp != null)
monitorPanel.add(monitorComp);
mc.setEnabled(true);
if(monitorPanel != null)
add("Center", monitorPanel);
java.awt.Component cc;
43
add("South", cc);
p.start();
if(monitorOn)
setVisible(true);
return true;
super.addNotify();
pack();
void enableSyncMux()
if(!cname.equals("com.sun.media.multiplexer.RawBufferMux"))
44
continue;
muxes.removeElementAt(i);
break;
PlugInManager.setPlugInList(muxes, 5);
synchronized(waitSync)
try
catch(Exception exception) { }
return stateTransitionOK;
45
if((evt instanceof ConfigureCompleteEvent) || (evt instanceof
RealizeCompleteEvent) || (evt instanceof PrefetchCompleteEvent))
synchronized(waitSync)
stateTransitionOK = true;
waitSync.notifyAll();
} else
synchronized(waitSync)
stateTransitionOK = false;
waitSync.notifyAll();
} else
p.close();
} else
46
public void dataSinkUpdate(DataSinkEvent evt)
System.err.println("All done!");
evt.getSourceDataSink().close();
System.exit(0);
monitorOn = true;
if(inputURL == null)
prUsage();
MediaLocator ml;
prUsage();
47
System.exit(0);
DataSource ds = null;
try
ds = Manager.createDataSource(ml);
catch(Exception e)
System.exit(0);
if(!dsr.open(ds))
System.exit(0);
48
4.2 SCREENSHOTS
49
50
51
52
53
CHAPTER-5
5.1 SUMMARY
We proposed a new guidance method by that a user can easily detect motion without
maaning the control system. Video surveillance provides a cost-effective alternative for
public safety workers to monitor activities in almost any location, without adding more
feet on the street. Both fixed and mobile video services can be deployed to deliver a
Human body detection is to identify the corresponding part of human from the
moving region. But the extracted moving region may correspond to different moving
objects, such as pedestrians, vehicles and other such birds, floating clouds, the swaying
tree and other moving objects. Hence we use the shape features of motion regions to
further determine whether the moving object is a human being. Judging criteria are as
follows: The object area is larger than the set threshold. The aspect ratio of the object
region should conform to the set ratio. If these two conditions are met, the moving
54
REFERENCES
BASE PAPER
PAPERS REFERED
[31 Niu Lianqiang and Nan Jiang, "A moving objects detection algorithm based on
improved background subtraction," Intelligent Systems Design and Applications,
2008. ISDA '08. Eighth International Conference on Volume 3, 26-28 Nov. 2008
Page(s):604 – 607
[41 Du-Ming Tsai and Shia-Chih Lai, "Independent Component Analysis Based
Background Subtraction for Indoor Surveillance," Image Processing, IEEE
Transactions on Volume 18, Issue 1, Jan. 2009 Page(s):158 – 16
55
[61 N.J.Bauer and P.N.Pathirana, "Object focused simultaneous estimation of
optical flow and state dynamics," Intelligent Sensors, SensorNetworks and
Information Processing, 2008. ISSNIP 2008. International Conference on 15-18 Dec.
2008 Page(s):6l – 66
[71 Zhen Tang and Zhenjiang Miao, "Fast Background Subtraction and Shadow
Elimination Using hnproved Gaussian Mixture Model," Haptic, Audio and Visual
Environments and Garnes, 2007. HAVE 2007. IEEE International Workshop on 12-14
Oct. 2007 Page(s):38 – 41
WEBSITES REFFERED
[1] www.wseas.us
[2] www.ieeexplore.ieee.org
[3]www.wikipedia.org
BOOKS REFERED
[1] Motion based Background Modeling for Moving Object Detection on Moving
Platforms by Ming Yu Shish,Yao Jen Chang and Ching –Chun Huan
VIDEO LECTURES
[1] Lecture by Professor Mehran Sahami for the Stanford Computer Science
Department http://www.youtube.com/results?search_query=JAVA+PROGRAMMING+M
ETHODOLOGY&aq=o
56
[2] Joshua Bloch, Chief Java Architect at Google, presents his Effective
Java™ http://www.youtube.com/watch?v=ZOwHiGCzZjo
57
APPENDIX
SYSTEM TESTING
TYPES OF TESTS
UNIT TESTING
Unit testing involves the design of test cases that validate that the internal
program logic is functioning properly, and that program input produces valid outputs.
INTEGRATION TESTING
Integration tests are designed to test integrated software components to
determine if they actually run as one program. Testing is event driven and is more
concerned with the basic outcome of screens or fields. Integration tests demonstrate
that although the components were individually satisfaction, as shown by successfully
unit testing, the combination of components is correct and consistent. Integration testing
is specifically aimed at exposing the problems that arise from the combination of
components.
58
MOTION DETECTED
59
BACKGROUND SUBTRACTION ALGORITHM
FUNCTIONAL TEST
Functional tests provide a systematic demonstration that functions tested are
available as specified by the business and technical requirements, system
documentation, and user manuals.
60
SYSTEM TESTING
System testing ensures that the entire integrated software system meets
requirements. It tests a configuration to ensure known and predictable results.
61