Real Time Motion Detection And Tracking System

Print   

02 Nov 2017

Disclaimer:
This essay has been written and submitted by students and is not an example of our work. Please click this link to view samples of our professional work witten by our professional essay writers. Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of EssayCompany.

Abstract- The reliable extraction of characteristic gait features from image sequences and their recognition are two important issues in gait recognition. In this paper, a novel 2-step, model- based approach is proposed to gait recognition by employing a 5- link biped locomotion human model. First the gait features are extracted from image sequences using the Metropolis-Hasting method. Hidden Markov Models (HMMs) are trained based on the frequencies of these feature trajectories, from which recognition is performed. In the next part of the project a methodology is developed to detect the motion in a video stream environment. This system is used to detect any motion in a live video streaming video and once motion has been detected in a live stream, the software will activate a warming system and capture the live streaming video.

Keywords- Motion, Detection, System, Tracking, Video, Matlab.

INTRODUCTION

Human gait recognition is an important task in a variety of applications, such as access control, surveillance, etc. To distinguish different persons by the manner they walk is a natural task to perform every day. Psychological studies have showed that gait signatures obtained from video can be used as a reliable cue to identify individuals. These findings inspired researches in computer vision to extract potential gait signatures from images to identify people. It is challenging, however, to find idiosyncratic gait features in marker-less motion sequences, where the use of markers is avoided because it is intrusive and not suitable in general gait recognition settings.

Ideally, the recognition features extracted from images should be invariant to factors other than gait, such as color, texture, or type of clothing. In most gait recognition approaches, recognition features are extracted from silhouette images. Although these features are invariant to texture and color, the static human shape, which is easy to be concealed, inevitably mingles with the movement features. In this paper, a 2-step, model-based approach is proposed, in which reliable gait features are extracted by fitting a five-link biped human model for each image to avoid shape information, followed by recognition using Hidden Markov Models (HMMs) based on frequency components of the trajectories of the relative joint positions.

In today’s competitive environment, the security concerns have grown tremendously. Therefore it is necessary for the surveillance techniques to improve with the challenging world. By using the video surveillance and monitoring technologies, it is possible to monitor and capture every inch and second the area of interest. When video- cassette recorders hit the market, video surveillance became popular.

II. MOTION DETECTION IN LIVE VIDEO STREAM

Metropolis Hasting Algorithm

In mathematics and physics, the Metropolis–Hastings algorithm [5, 6] is a Markov chain Monte Carlo method for obtaining a sequence of random samples from a probability distribution for which direct sampling is difficult. This sequence can be used to approximate the distribution (i.e., to generate a histogram), or to compute an integral (such as an expected value).

The Metropolis–Hastings algorithm can draw samples from any probability distribution, P(x) requiring only that a function dominating (being greater than or equal to) the density can be calculated at . In Bayesian applications, the normalization factor is often extremely difficult to compute, so the ability to generate a sample without knowing this constant of proportionality is a major virtue of the algorithm. The algorithm generates a Markov chain in which each state xt+1 depends only on the previous state xt .

Hidden Markov Model

A HMM is a kind of stochastic state machines. It allows a more sophisticated analysis of data with spatio-temporal variability. The use of HMM consist of two stages, the number of states of a HMM must be specified and the corresponding state transition and output probabilities are optimized in order that the generated symbols can correspond to observed image features of the examples within a specific movement class. In the matching stage, the probability with which a particular HMM generates the test symbol sequence corresponding to the observed image features is computed. HMMs generally outperform DTW for undivided time series data, and are therefore extensively applied to behavior understanding.

Tracking

After extracting the shape model and the initial configuration, the next step is to extract gait signatures over time based on the shape model. Current 2 D-based tracking methods use either image edges or dense optical flows and edges, are not totally reliable, especially when calculated from noisy images. To achieve robustness, we need to carry out computations within large regions, e.g., at the body part level. The image information we utilize is the color and inner silhouette region.

For an input frame It at the time instance t, the background model is used to obtain the silhouette image St . given the model (W) and human model parameters Mt = (Ct,θt), we can compose an image I(Mt; W). The best human model configuration should make this image as close to It as possible. In addition, the area of the human model should be equal to the area of the silhouette image, and the difference of the biped model configuration between time instance t-1 and t is small. Therefore, we want to estimate the best biped model Mt which minimizes the total energy of the following equation,

E = wc ∑ρ(It – I(Mt; W),σ)+ wA(A(St)-A(Mt))2 + wm|Mt – Mt-1|

Where wc, wA, and wm are three weight factors, ρ is the Geman- McClure function defined as:

Ρ(x, σ) = x2/(x2+σ2)

Which is robust error norm since it constrains the effect of large residue (x)value. The scale parameter σ is defined as:

σ = 1.4826 * median |It – I(Mt;W)|

The predicted orientation are given by:

Θt = 2 * θt-1 – θt-2

The minimization of the energy term is maximum the following probability,

P(Mt|It)

By employing the same Metropolis-Hasting method used in the initialization step.

Recognition

The sagittal elevation angles extracted from the above tracking procedure capture the temporal dynamics of the gait of the subject, whereas the trajectories of the corresponding joint position reveal the spatio-temporal history. In addition, the SEAs exhibit less inter-subject variation across humans. Therefore, our recognition method focuses on the joint position trajectories.

Based on the tracking results obtained with the biped model, the differences across people are largely temporal. It is, therefore necessary to choose a feature representation that makes the temporal characteristics of the data signal explicit. Because gait is cyclic, a frequency domain-based representation seems particularly suitable. To this end, first the following space domain features are computed: ankle elevation (s1), knee elevation (s2), ankle stride width (s3), and knee stride width (s4).

For each of these four features si, the Discrete Fourier Transform (DFT) is computed and denoted as Si over a fixed window size of 32 frames which slide over the feature signal sequences. The size of 32 frames was chosen to a typical human gait cycle. Future work should also investigate adaptive window size based on the actual period of the gait cycle of different person.

The DFTs reveal periodicities in the feature data as well as the relative strengths of any periodic components. Since that the lowest frequency component does not provide any information on the periodicity of the signal, while high frequency components mainly capture the noise, we sample the magnitude and phase of the second to fifth lowest frequency components. This leads to a feature vector containing 4 magnitude and 4 phase measures for each of the four space domain base features (S1,…..,S4), an overall dimension of 32.

Software Used

In this project, strong computing software called Matlab is used. Basically the advantage of using Matlab is that Matlab is an interpreted language for numerical computation. It allows one to perform numerical calculations, and visualize the results without the need for complicated and time consuming programming. Matlab allows its users to accurately solve problems, produce graphics easily and produce code efficiently.

III. SYSTEM ARCHITECTURE FUNCTIONING

Fig.1 Block Diagram for System Architecture

The system architecture is going to function in following way:

• Capturing the live video feed through a web cam

• Comparing the current frames captured with previous frames to detect motion

• Storing the frames on the memory if motion is detected

• Indicating through an alarm when the motion is detected

A. Motion Detection

1) Rationale: The detection of motion essentially requires the user to perform two major steps. They are: foremost step is to setup the hardware for acquiring the video data in which the motion is to be detected and the later step is to actually device an algorithm by which the motion will be detected. The AVI video format is actually an interleave of Audio and Video. The video stream is stored or acquired as a series of frames occurring in an ordered sequence one after the other [5].

2) Acquisition Step: The Matlab programming language is used to store data in the form of matrices. Therefore Matlab can provide quick interface with data matrices. The software provides for frame acquisition from hardware devices such as web cams or digital cameras as long as the devices are correctly initialized by the programmer. Therefore, in order to allow quick setup with the image acquisition devices, Matlab Function directory provides a host of predefined functions by which the user can inquire about the various different devices currently connected and then setup the required device with Matlab so that it can acquire and store data at run time.

B. Motion Detection Algorithm

The Matlab interface allows the user to define the commands to be performed at the run time. Once the user setup of the video source is complete the algorithm comes into play. The algorithm is built to take advantage of the strength of Matlab i.e. to store data as a form of matrices. The frames acquired are stored in the Matlab directory as matrix in which each element of the matrix contains information about the pixel value of the image at a particular location. Therefore, the pixel values are stored in the workspace as a grid where every element of the matrix corresponds to an individual pixel value [6].

Since Matlab considers each matrix as one large collection of values instead of a bunch of individual values it is significantly quicker in analyzing and processing the image data. The algorithm hence checks each frame being acquired by the device with the previously acquired frame and checks for the difference between the total values of each frame. A threshold level is set by the user with which the difference of values is compared. If the difference exceeds the threshold value the motion is said to be detected in the video stream.

Function Explaination:

a) Function Name: The Function name Mstart is executed as the Monitor button in the GUI is pressed by the user. It takes the value of the GUI from the user and updates it in the workspace.

b) Set: The set command is used to change the looks and controls available to the user in the GUI. It is used to change the value of the buttons and is also used to prevent the user from pressing buttons which cannot logically occur again. As the number of buttons that can be pressed by the user reduces, the amount of confusion in the users mind will also reduce as the process will be self guiding thereby reducing the number of errors or bugs and to ensure that user’s experience is hassle

free [7].

c) Video Input: The video input command is used to setup the video source for the rest of the program to be run.

d) Uiputfile: The Uiputfile function is used to allow the user to define the name and storage space of the output file of the video. This function is essential for two major reasons:

i) It allows the Matlab to save the file exactly where the user specifies thereby ensuring the user can easily find the storage location.

ii) It allows the user to name the file thereby allowing him to keep a record of each and every file without the chances of any previous record being overwritten.

e) Aviobj: The AVI object command is used to create an object file of the type AVI. The AVI file is a standard video format with a predefined method of encryption. Therefore, a class file is already present in Matlab and the AVI object file defines an instance to create the AVI file in which the motion is being stored. The object created is set to the filename specified by the user in the previous function.

f) Get: The get function is used to interface with the GUI file. It checks the status and returns the current value of the GUI

button as specified.

g) Start Vid: The Start function is used to start the video acquisition device to get the frame from the device object.

h) Stop Vid: The Stop function is very important in the video acquisition device. The Start function begins the video stream entering as input to Matlab. The stop function will stop this input. If the function is not used, the video stream continues in the path already started by Matlab. If the user will try to use it again, Matlab will not be able to start it again as the path will be busy. It will therefore stop the reusability of the program unless the whole of Matlab reinitializes.

i) Delete Vid: The delete function is used to delete the temporary frames stored by Matlab in the object file. This function will free up the workspace as well as enable the function to reuse the

pathname.

j) Imaqreset: The imaqreset function resets the acquisition device altogether. It ensures that the frame buffer in the object is free and completely new at the time the device restarts.

C. VIDEO, AUDIO, HELP AND GUI:

This section describes about the further development of the video and the audio units along with the help and the graphical user interfaces.

1) VIDEO: The software produces an AVI video file as it monitors the area in view. Irrespective of the fact that most modern operating systems would provide various different software’s to play video files in AVI format, the user should be able to view the file without having to switch programs and searching for it. Hence, it is of the utmost importance that there should be a video player that plays the video stream that has been produced.

2) AUDIO: In order for the software to act as a surveillance system it is important to provide a mechanism to raise an alarm in case motion is detected in the video stream. However, conversely, stealth may be required in a few cases where alarms may prove more harmful. Therefore, an alarm function is required which will allow the user to choose the audio function as per his requisites.

3) HELP: The help function is a prerequisite for any good software to ensure that the user can use each and every function of the program. The help file of any software should be detailed with examples or instructions about using the software to improve user’s interaction with the software.

4) GUI: The modern operating systems allow for almost every program to run using visual icons and Interfaces. Hence, most users would be put off from using software’s that are completely text based to run. Matlab provides the programmer with Matlab GUIDE which is a tool for generating user interfaces for the programs.

D. Developed Graphical User Interface

Fig. 2 GUI for Live Video Stream Function

The above figure shows the GUI created using GUIDE tool for detection and tracking of live video stream. Some important function as given for recorded video are same for GUI of live video stream also.

Fig. 3 GUI for Live Video Stream after Code is Initialized

As shown in the above Figure 3, the GUI consist of two axis and two buttons start and stop. Once the code is initialized, we get this GUI, and when we click on the start button, the webcam starts capturing video of the area to be monitored. In the next axis as shown in the GUI we get the detected output of the video. To detect the motion in the video, the current frames are compared with the previous frames. The difference of the frames is calculated and if the difference value exceeds certain threshold which is set by the user, the motion is said to be detected. The detection and tracking of the live video stream takes place simultaneously. when the motion is detected it is indicated in the command window as "Motion Detected". And that much part of the video gets stored in so that the user can view it in the future. This helps in providing a legal proof of some inappropriate activity since a video coverage can be used as a proof in the court of law.

This system also acquire the video sequence in the ".avi" format with the resolution of 640×480 pixels, frame rate of 15 frames/second and video sample size of 24 bit.

Fig.4 GUI for Tracked Output

The above Figure 4, shows the tracked output after detection of the live video stream. After pressing the stop button on the GUI as shown in Figure 4.4, the video display from the webcam is stopped and thus the detection and tracking gets stopped.

Explaination:

a) Initialization: The beginning lines are meant for initializing the program file before the function opens and runs. It sets the type of GUI by specifying if single or multiple instances can run at the same time.

b) Opening Function: The opening function is run just before the GUI is made visible to the user. It contains the various instructions to initialize the figure file so that it can run as a cohesive unit with the program.

c) Figure File: The figure file is a screenshot of the figure as created without the fringe icons and background.

d) Imread: The Imread function is the Matlab function, which can read image files and store their values in a variable. The variables created are matrices containing the RGB pixel value of images.

e) Axes: The axes function corresponds to the various axis figures present in the figure file. It sets up the axis with the corresponding output required.

f) Sub image: Matlab provides the sub image function to output images. This function returns the image instead of the mathematical equivalent of the pixel values.

g) Callback Function: The callback function is the auto-generated function that is called every time the user uses the corresponding interface.

IV. CONCLUSION

Thus a Motion Detection and tracking system was developed successfully in this paper. This system mainly provides an efficient method for surveillance purposes and is aimed to be highly beneficial for any person or organization. Thus, a motion based change detection in avi video format was completed and successfully implemented. The future scope of the work done could be as follows: the due course of time as we started to understand the minute details of our work, we significantly realized that our software would be tremendously important in the future world. Following changes or additions can be done on our work to include some new features:

• With the existing alarm system, advancement can be included and SMS can be sent to the user when motion is detected.

• The stored video can be automatically transferred to some email account so that an extra backup data can be used.

• A user id and password can be given to a user so that unauthorized people don’t have access to the software.

• A facility for the user can be given where he can mainly monitor only a small specific area in the range of the web cam.

• In the future, the user can be provided a remote access to this software from some remote PC through internet.

• Include an option to take snaps periodically, manually or automatically.



rev

Our Service Portfolio

jb

Want To Place An Order Quickly?

Then shoot us a message on Whatsapp, WeChat or Gmail. We are available 24/7 to assist you.

whatsapp

Do not panic, you are at the right place

jb

Visit Our essay writting help page to get all the details and guidence on availing our assiatance service.

Get 20% Discount, Now
£19 £14/ Per Page
14 days delivery time

Our writting assistance service is undoubtedly one of the most affordable writting assistance services and we have highly qualified professionls to help you with your work. So what are you waiting for, click below to order now.

Get An Instant Quote

ORDER TODAY!

Our experts are ready to assist you, call us to get a free quote or order now to get succeed in your academics writing.

Get a Free Quote Order Now