Anda di halaman 1dari 71

AUTOMATIC MOVING OBJECT DETECTION AND VIDEO

SURVEILLANCE SYSTEM USING BACK GROUND SUBTRACTION


ALGORITHM

Submitted in the partial fulfillment of the requirements


for the award of the degree in

BACHELOR OF TECHNOLOGY

By

PRIYANKA PAUL (U07IT083)

DEPARTMENT OF INFORMATION TECHNOLOGY


BHARATH INSTITUTE OF SCIENCE AND TECHNOLOGY
BHARATH UNIVERSITY
(Established under Section 3 of UGC Act 1956)
CHENNAI 600 073
MARCH 2011

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:

PLACE:CHENNAI SIGNATURE OF THE CANDIDATES


BHARATH UNIVERSITY
(Established under Section 3 of UGC Act 1956)
BHARATH INSTITUTE OF SCIENCE AND TECHNOLOGY

DEPARTMENT OF INFORMATION TECHNOLOGY


BONAFIDE CERTIFICATE

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.

Internal Guide Head of the Department

S RAMRAJ K ALICE SURESH

Submitted for Viva Voce Examination held on________________________

Internal Examiner External Examiner


CONTENTS
CHAPTER PAGE
NO. TITLE NO.
LIST OF ABBREVATIONS i
LIST OF FIGURES ii
ABSTRACT iii
1 INTRODUCTION
1.1 OVERVIEW 1
1.2 OBJECTIVE 1

2 AIM AND SCOPE OF PRESENT INVESTIGATION 3


2.1 SYSTEM ANALYSIS 3
2.1.1 EXISTING SYSTEM 3
2.1.2 PROPOSED SYSTEM 3
2.2 REQUIREMENT SPECIFICATION 4
2.2.1 HARDWARE REQUIREMENT 4
2.2.2 SOFTWARE REQUIREMENT 4

3 EXPERIMENTAL OR MATERIAL AND METHOD 5


3.1 MODULE DESCRIPTION 5
3.1.1 ADMIN 5
3.1.2 REFERENCE IMAGE CAPTURING 6
3.1.3 BACKROUND SUBTRACTION ALGORITHM 9
3.1.4 SERVER 10
3.1.5 ALERT SMS 10
3.1.6 IMAGE CAPTURING BY J2ME 11

4 RESULT AND DISCUSSION,PERFORMANCE ANALYSIS 14


4.1 CODING 14
4.2 SCREENSHOTS 49
5 SUMMARY AND CONCLUSION 69
5.1 SUMMARY 54
5.2 CONCLUSION AND FUTURE ENHANCEMENT 54
REFERENCES 55
APPENDIX 57
ACKNOWLEDGEMENT

We are indebted to our Chancellor THIRU. ER.LAKSHMI NARAYANAN,


Bharath University, for him excellent guidance and constructive, concrete suggestion
throughout our work in this project. His constant encouragement, help and review of the
entire work during the course of the work is invaluable.
Our sincere thanks to the Vice Chancellor Dr.K.P.Thooyamani, Bharath
University for his excellent guidance and support.
We are grateful to DR. KARI THANAGARATNAM, Principal, Bharath Institute of
Science And Technology, for providing the suggestion to carry out this innovative
project.
We are indebted to Mrs. .K ALICE SURESH, Head of the Department and
project coordinator, Information Technology, for his excellent guidance and her ideas for
the project the
My sincere thanks toMR. S RAMRAJ,project guide, andall the members of our
faculty, Department of Information Technology, for their suggestion and encouragement
to do our project work.
LIST OF ABBREVATIONS

IPTraceback - Internet Protocol Traceback

ITM System -Internet Threat MonitoringSystem

TCP - Transmission Control Protocol

ODBC - Open Database Connectivity

JDBC - JAVA Database Connectivity

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

captures the image

compare the image with existing


image

webcam
stores the image db
system

fetches the mobile number


sends the captured image

view the details

alert the user by sending SMS

user mobile

Fig:1 ARCHITECTURAL DIAGRAM

2
CHAPTER-2

AIM AND SCOPE OF PRESENT INVESTIGATION

2.1 SYSTEM ANALYSIS


System Analysis is a combined process dissecting the system responsibilities that are
based on the problem domain characteristics and users requirements.

2.1.1 EXISTING SYSTEM

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.

2.1.2 PROPOSED SYSTEM

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

 High accuracy in image capturing


 Send an alert to user’s mobile whenever a new object is detected
 User can view the image, or video clips via his mobile itself
 Efficient use of background subtraction algorithm

3
2.2 REQUIREMENT SPECIFICATION

2.2.1 HARDWARE REQUIREMENTS

 Processor : Pentium II 266 MHz

 RAM : 64 MB

 HDD : 2.1 GB

2.2.2 SOFTWARE REQUIREMENTS

 Platform :Windows Xp

 Front End : Java JDK1.5/1.6, java swing

 Back End :MS SQL server

4
CHAPTER-3

EXPERIMENTAL OR MATERIAL AND METHOD

3.1 MODULE DESCRIPTION


1. User Registration

2. Reference Image Capturing

3. Back Ground Subtraction Algorithm

4. Server

5. Alert SMS

6. Image Capturing by J2ME

3.1.1 USER REGISTRATION

This process is registered by providing Name, Mobile number, Address for

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

FIG:1 REQUEST FROM CLIENT TO SERVER

3.1.2 Reference Image Capturing

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

Admin can view

As image or video

Fig:2 DATA FLOW DIAGRAM1

7
Fig:3 DATA FLOW DIAGRAM3

Send the alert


Send the
System
captured image
Admin mobile

Webcam
Fetch the adman’s View the
mobile number clips
from db

Fig:4 DATA FLOW DIAGRAM4

8
3.1.3 BACKGROUND SUBTRACTION ALGORITHM

Back Ground Subtraction Algorithm is applied to find out the Motion in a


particular room. The web camera is kept for further process. The reference image which
is taken by the camera is compared with the further images taken by the camera. If
same image persist, the no alert is initiated, if some movement or the motion is detected
by the web camera, immediately, the triggers Back Ground Subtraction Algorithm, for
further process. This Back Ground Subtraction Algorithm is effective in processing the
subtraction the present suspected image with the previous Reference image. If there is
any pixel change with respect to the reference image, immediately it alerts the

give the request


server

search the best book for given


request

guide the user by displaying the


location find out the current location of the
librarian book

give commands to the robot

can view the location


receiving the command
robot

points the exact position of the


book using laser light

server

Fig:5 ACTIVITY DIAGRAM

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.

Fig:6 ARCHITECTURE DIAGRAM

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.

webcam system db user mobile

1: sends the captured image of a object

2: compare

3: stores the caputured image

4: if captured image is not match with db image

5: fetch the mobile number of the admin

6: send the alert message

7: view the details

Fig:7 SEQUENCE DIAGRAM

11
4: if captured image is not match with db image

1: sends the captured image of a object


system
webcam

7: view the details


6: send the alert message
2: compare
3: stores the caputured image
5: fetch the mobile number of the admin

user
db
mobile

Fig:7 COLABORATION DIAGRAM

12
webcam captures the
moving object

send the captured


image to system

system compares the


image with existing image

match

send the alert send the normal


message message

user can view the image

Fig:9 ACTIVITY DIAGRAM

13
CHAPTER-4

RESULTS AND DISCUSSION, PERFORMANCE ANALYSIS

4.1 CODING

LOGIN.JAVA

import java.io.*;

importjava.sql.*;

importjavax.servlet.ServletException;

importjavax.servlet.http.*;

public class LoginServlet extends HttpServlet

public void doGet(HttpServletRequesthttpservletrequest,


HttpServletResponsehttpservletresponse)

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");

Connection connection = DriverManager.getConnection("jdbc:odbc:Login");

Statement statement = connection.createStatement();

System.out.println("username" + s + "password" + s1);

14
ResultSetresultset = statement.executeQuery("select * from login where username='" +
s + "' and password='" + s1 + "'");

if(resultset.next())

printwriter.println("Logged In");

MotionDetection mm=new MotionDetection();

else

printwriter.println("Invalid user");

connection.close();

catch(Exception exception)

exception.printStackTrace();

}import java.io.*;

importjava.sql.*;

importjavax.servlet.ServletException;

importjavax.servlet.http.*;

public class LoginServlet extends HttpServlet

public void doGet(HttpServletRequesthttpservletrequest,


HttpServletResponsehttpservletresponse)

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");

Connection connection = DriverManager.getConnection("jdbc:odbc:Login");

Statement statement = connection.createStatement();

System.out.println("username" + s + "password" + s1);

ResultSetresultset = statement.executeQuery("select * from login where username='" +


s + "' and password='" + s1 + "'");

if(resultset.next())

printwriter.println("Logged In");

MotionDetection mm=new MotionDetection();

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.*;

public class DetectMotion extends Form implements CommandListener

HttpConnection con;

TextFieldtxtUser,txtPwd,txtIPAddress;

Display disp;

Command cmdOk,cmdBack,cmdView;

static Form welScreen;

Menu m1;

String userpassword;

socketexamclsoc;

String str="";

Form status;

17
String url;

String fileContent="";

Static intfContentTemp = 0;

publicDetectMotion(String strTitle,FormwelScreen,Display disp1)

super(strTitle);

this.disp=disp1;

this.welScreen=welScreen;

url="http://"+ServerIPAddress.getServerIPAddress()+":8080/Motion/image/MotionMonito
r.dat";

while(true)

try

//

clsoc = new socketexam(disp);

con=(HttpConnection)Connector.open(url);

InputStream in=con.openInputStream();

System.out.println("Before reading MotionMonitor.dat");

System.out.println("File Content:"+fContentTemp);

int c=0;

while((c=in.read())!=-1)

fileContent+=(char)c;

System.out.println("After reading MotionMonitor.dat");

18
System.out.println("File Content:"+fileContent);

intfContent = Integer.parseInt(fileContent);

fileContent = "";

if(fContent>fContentTemp)

System.out.println("Motion is detected");

in.close();

newDetectMotion("Motion is detected","Motion is detected",disp);

else

newDetectMotion("No Motion is detected","Motion is detected",disp);

fContentTemp = fContent;

Thread.sleep(30000);

catch(Exception e){}

publicDetectMotion(String msg,Stringst,Displaydisp)

super(st);

this.disp=disp;

status = new Form("MOTION MONITOR");

19
cmdView = new Command("VIEW",Command.OK,1);

status.append(new Gauge("", false, Gauge.INDEFINITE,


Gauge.CONTINUOUS_RUNNING));

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);

if(msg.startsWith("No Motion is detected"))

// status.append("No Motion is detected");

disp.setCurrent(status);

public void startApp()

public void destroyApp(boolean f)

{}

20
public void pauseApp()

{}

public void commandAction(Command com,Displayable d1)

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";

String from = "info@priyanka.com";

String host = "216.237.118.18";

boolean debug = true;

String subject = "Alert";

String msgText ="Motion Detected";

try

Properties props = System.getProperties();

props.put("mail.smtp.host", host);

Session session = Session.getDefaultInstance(props, null);

session.setDebug(debug);

MimeMessagemsg = new MimeMessage(session);

msg.setFrom(new InternetAddress(from));

InternetAddress address[] = {

22
new InternetAddress(to)

};

msg.setRecipients(javax.mail.Message.RecipientType.TO, address);

msg.setSubject(subject);

MimeBodyPartmbp1 = new MimeBodyPart();

mbp1.setText(msgText);

Multipart mp = new MimeMultipart();

mp.addBodyPart(mbp1);

msg.setContent(mp);

msg.setSentDate(new Date());

Transport.send(msg);

catch(MessagingExceptionmex)

mex.printStackTrace();

Exception ex = null;

if((ex = mex.getNextException()) != 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.*;

public class DataSourceReader extends Frame

implements ControllerListener, DataSinkListener

class DataSourceHandler

implements DataSink, BufferTransferHandler

DataSource source;

PullBufferStream pullStrms[];

PushBufferStream pushStrms[];

24
private Vector listeners;

SourceStream unfinishedStrms[];

Loop loops[];

Buffer readBuffer;

public void setSource(DataSource source)

throws IncompatibleSourceException

if(source instanceof PushBufferDataSource)

pushStrms = ((PushBufferDataSource)source).getStreams();

unfinishedStrms = new SourceStream[pushStrms.length];

for(int i = 0; i < pushStrms.length; i++)

pushStrms[i].setTransferHandler(this);

unfinishedStrms[i] = pushStrms[i];

} else

if(source instanceof PullBufferDataSource)

pullStrms = ((PullBufferDataSource)source).getStreams();

unfinishedStrms = new SourceStream[pullStrms.length];

loops = new Loop[pullStrms.length];

for(int i = 0; i < pullStrms.length; i++)

25
{

loops[i] = new Loop(this, pullStrms[i]);

unfinishedStrms[i] = pullStrms[i];

} else

throw new IncompatibleSourceException();

this.source = source;

readBuffer = new Buffer();

public void setOutputLocator(MediaLocator medialocator)

public MediaLocator getOutputLocator()

return null;

public String getContentType()

return source.getContentType();

26
}

public void open()

public void start()

try

source.start();

catch(IOException e)

System.err.println(e);

if(loops != null)

for(int i = 0; i < loops.length; i++)

loops[i].restart();

27
public void stop()

try

source.stop();

catch(IOException e)

System.err.println(e);

if(loops != null)

for(int i = 0; i < loops.length; i++)

loops[i].pause();

public void close()

stop();

if(loops != null)

28
{

for(int i = 0; i < loops.length; i++)

loops[i].kill();

public void addDataSinkListener(DataSinkListener dsl)

if(dsl != null && !listeners.contains(dsl))

listeners.addElement(dsl);

public void removeDataSinkListener(DataSinkListener dsl)

if(dsl != null)

listeners.removeElement(dsl);

29
protected void sendEvent(DataSinkEvent event)

if(!listeners.isEmpty())

synchronized(listeners)

DataSinkListener listener;

for(Enumeration list = listeners.elements(); list.hasMoreElements();


listener.dataSinkUpdate(event))

listener = (DataSinkListener)list.nextElement();

public void transferData(PushBufferStream stream)

try

stream.read(readBuffer);

catch(IOException e)

30
System.err.println(e);

sendEvent(new DataSinkErrorEvent(this, e.getMessage()));

return;

printDataInfo(readBuffer);

if(readBuffer.isEOM() && checkDone(stream))

sendEvent(new EndOfStreamEvent(this));

public boolean readPullData(PullBufferStream stream)

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;

public boolean checkDone(SourceStream strm)

boolean done = true;

for(int i = 0; i < unfinishedStrms.length; i++)

if(strm == unfinishedStrms[i])

unfinishedStrms[i] = null;

} else

if(unfinishedStrms[i] != null)

done = false;

32
}

return done;

void printDataInfo(Buffer buffer)

if(buffer.getFormat() instanceof AudioFormat)

System.err.println("Read audio data:");

} else

System.err.println("Read video data:");

System.err.println(" Time stamp: " + buffer.getTimeStamp());

System.err.println(" Sequence #: " + buffer.getSequenceNumber());

System.err.println(" Data length: " + buffer.getLength());

if(buffer.isEOM())

System.err.println(" Got EOM!");

try

Thread.sleep(1000L);

System.out.println("Motion Detected");

33
}

catch(Exception ex)

System.out.println(ex);

try

String imageFile = "image" + i + ".jpg";

RandomAccessFile raFile = new RandomAccessFile(imageFile, "rw");

byte data[] = (byte[])null;

data = (byte[])buffer.getData();

raFile.write(data, 0, buffer.getLength());

System.out.println("Motion Detected");

raFile.close();

i++;

catch(Exception e)

e.printStackTrace();

public Object[] getControls()

return new Object[0];

34
}

public Object getControl(String name)

return null;

DataSourceHandler()

pullStrms = null;

pushStrms = null;

listeners = new Vector(1);

unfinishedStrms = null;

loops = null;

class Loop extends Thread

DataSourceHandler handler;

PullBufferStream stream;

boolean paused;

boolean killed;

35
public synchronized void restart()

paused = false;

notify();

public synchronized void pause()

paused = true;

public synchronized void kill()

killed = true;

notify();

public void run()

while(!killed)

try

while(paused && !killed)

36
wait();

catch(InterruptedException interruptedexception) { }

if(!killed)

boolean done = handler.readPullData(stream);

if(done)

pause();

public Loop(DataSourceHandler handler, PullBufferStream stream)

paused = true;

killed = false;

this.handler = handler;

this.stream = stream;

start();

37
Processor p;

Object waitSync;

boolean stateTransitionOK;

static boolean monitorOn = false;

Player player;

public int i;

public DataSourceReader()

waitSync = new Object();

stateTransitionOK = true;

i = 0;

public boolean open(DataSource ds)

System.err.println("create processor for: " + ds.getContentType());

if(monitorOn)

enableSyncMux();

try

p = Manager.createProcessor(ds);

38
}

catch(Exception e)

System.err.println("Failed to create a processor from the given DataSource: " +


e);

return false;

p.addControllerListener(this);

p.configure();

Processor _tmp = p;

if(!waitForState(180))

System.err.println("Failed to configure the processor.");

return false;

p.setContentDescriptor(new ContentDescriptor("raw"));

TrackControl tc[] = p.getTrackControls();

if(tc == null)

System.err.println("Failed to obtain track controls from the processor.");

return false;

TrackControl videoTrack = null;

for(int i = 0; i < tc.length; i++)

39
if(!(tc[i].getFormat() instanceof VideoFormat))

continue;

videoTrack = tc[i];

break;

if(videoTrack == null)

System.err.println("The input media does not contain a video track.");

return false;

float frameRate = ((VideoFormat)videoTrack.getFormat()).getFrameRate();

Dimension size = ((VideoFormat)videoTrack.getFormat()).getSize();

int w = size.width % 8 != 0 ? (size.width / 8) * 8 : size.width;

int h = size.height % 8 != 0 ? (size.height / 8) * 8 : size.height;

VideoFormat jpegFormat = new VideoFormat("jpeg", new Dimension(w, h), -1,


Format.byteArray, frameRate);

videoTrack.setFormat(jpegFormat);

System.err.println("Video transmitted as:");

System.err.println(" " + jpegFormat);

try

Codec codec[] = {

40
new MotionDetectionEffect()

};

videoTrack.setCodecChain(codec);

catch(UnsupportedPlugInException e)

System.err.println("The processor does not support effects.");

p.prefetch();

Processor _tmp1 = p;

if(!waitForState(500))

System.err.println("Failed to realize the processor.");

return false;

p.realize();

Processor _tmp2 = p;

if(!waitForState(300))

System.err.println("Failed to realize the processor.");

return false;

DataSource ods = p.getDataOutput();

DataSourceHandler handler = new DataSourceHandler();

try

41
{

handler.setSource(ods);

catch(IncompatibleSourceException e)

System.err.println("Cannot handle the output DataSource from the processor: "


+ ods);

return false;

handler.addDataSinkListener(this);

handler.start();

p.prefetch();

Processor _tmp3 = p;

if(!waitForState(500))

System.err.println("Failed to prefetch the processor.");

return false;

if(monitorOn)

setLayout(new BorderLayout());

javax.media.Control controls[] = p.getControls();

Panel monitorPanel = null;

java.awt.Component monitorComp = null;

for(int i = 0; i < controls.length; i++)

42
{

if(controls[i] instanceof MonitorControl)

MonitorControl mc = (MonitorControl)controls[i];

monitorComp = mc.getControlComponent();

if(monitorPanel == null)

monitorPanel = new Panel();

monitorPanel.setLayout(new GridLayout(0, 1));

if(monitorComp != null)

monitorPanel.add(monitorComp);

mc.setEnabled(true);

if(monitorPanel != null)

add("Center", monitorPanel);

java.awt.Component cc;

if((cc = p.getControlPanelComponent()) != null)

43
add("South", cc);

p.start();

if(monitorOn)

setVisible(true);

return true;

public void addNotify()

super.addNotify();

pack();

void enableSyncMux()

Vector muxes = PlugInManager.getPlugInList(null, null, 5);

for(int i = 0; i < muxes.size(); i++)

String cname = (String)muxes.elementAt(i);

if(!cname.equals("com.sun.media.multiplexer.RawBufferMux"))

44
continue;

muxes.removeElementAt(i);

break;

PlugInManager.setPlugInList(muxes, 5);

boolean waitForState(int state)

synchronized(waitSync)

try

for(; p.getState() < state && stateTransitionOK; waitSync.wait()) { }

catch(Exception exception) { }

return stateTransitionOK;

public void controllerUpdate(ControllerEvent evt)

45
if((evt instanceof ConfigureCompleteEvent) || (evt instanceof
RealizeCompleteEvent) || (evt instanceof PrefetchCompleteEvent))

synchronized(waitSync)

stateTransitionOK = true;

waitSync.notifyAll();

} else

if(evt instanceof ResourceUnavailableEvent)

synchronized(waitSync)

stateTransitionOK = false;

waitSync.notifyAll();

} else

if(evt instanceof EndOfMediaEvent)

p.close();

} else

boolean _tmp = evt instanceof SizeChangeEvent;

46
public void dataSinkUpdate(DataSinkEvent evt)

if(evt instanceof EndOfStreamEvent)

System.err.println("All done!");

evt.getSourceDataSink().close();

System.exit(0);

public static void main(String args[])

monitorOn = true;

String inputURL = "vfw://o";

if(inputURL == null)

System.err.println("No input url is specified");

prUsage();

MediaLocator ml;

if((ml = new MediaLocator(inputURL)) == null)

System.err.println("Cannot build media locator from: " + inputURL);

prUsage();

47
System.exit(0);

DataSource ds = null;

try

ds = Manager.createDataSource(ml);

catch(Exception e)

System.err.println("Cannot create DataSource from: " + ml);

System.exit(0);

DataSourceReader dsr = new DataSourceReader();

if(!dsr.open(ds))

System.exit(0);

static void prUsage()

System.err.println("Usage: java DataSourceReader [-monitor] <url>");

48
4.2 SCREENSHOTS

49
50
51
52
53
CHAPTER-5

SUMMARY AND CONCLUSION

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

range of benefits to communities while increasing the efficiency and effectiveness of

public safety workers.

5.2 CONCLUSION AND FUTURE ENHANCEMENT

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

object is the moving human body, or is not a human body.

54
REFERENCES

BASE PAPER

Tao Jianguo, Yu Changhong, "Real-Time Detection and Tracking of Moving


Object," Intelligent Information Technology Application, 2008. UTA '08. Second
International Symposium on Volume 2, 20-22 Dec. 2008 Page(s):860 – 863

PAPERS REFERED

[1] M.Dimitrijevic, "Human body pose detection using Bayesian spatiotemporal


templates," 2007 International Conference on Intelligent and Advanced Systems,
2008, pp.764-9.

[21 Tao Jianguo, Yu Changhong, "Real-Time Detection and Tracking of Moving


Object," Intelligent Information Technology Application, 2008. UTA '08. Second
International Symposium on Volume 2, 20-22 Dec. 2008 Page(s):860 – 863

[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

[51 K.Kinoshita, M.Enokidani, M. Izumida and K.Murakami, "Tracking of a Moving


Object Using One-Dimensional Optical Flow with a Rotating Observer," Control,
Automation, Robotics and Vision, 2006. ICARCV '06. 9th International Conference on 5-
8 Dec. 2006 Page(s): 1 – 6

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

[2]Adaptive Background Estimation and object detection applying in Automated visual


surveillance by M.Sankari and S.Meena

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

The purpose of testing is to discover errors. Testing is the process of trying to


discover every conceivable fault or weakness in a work product.

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.

WHITE BOX TESTING


White Box Testing is a testing in which in which the software tester has knowledge
of the inner workings, structure and language of the software, or at least its purpose
BLACK BOX TESTING
Black Box Testing is testing the software without any knowledge of the inner
workings, structure or language of the module being tested.

61

Anda mungkin juga menyukai