Skip to content Skip to navigation

Connexions

You are here: Home » Content » Video Surveillance

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • TI DSP display tagshide tags

    This module is included inLens: Texas Instruments DSP Lens
    By: Texas InstrumentsAs a part of collection: "From MATLAB and Simulink to Real-Time with TI DSP's"

    Click the "TI DSP" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Also in these lenses

  • Lens for Engineering

    This module is included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Video Surveillance

Module by: Jacob Fainguelernt. E-mail the author

Summary: This module describes the design flow of a motion detection system based video surveillance system based on the DM6437 Digital Video Development Platform (DVDP). The system will be able to identify and record only “interesting” video frames containing motion.

Introduction

Continuous-scene monitoring applications, such as ATM booths, parking lots or traffic monitoring systems, generate large volumes of data. Recording and archiving such volumes of data is a real problem, and one way to solve this is to reduce the size of the data stream right at the source.

In addition to traditional methods for compressing individual video images, we could identify and record only “interesting” video images, such as those images with significant amounts of motion in the field of view. That could significantly help reduce the data rates for surveillance-specific applications.

In this section, we’ll illustrate the design flow of a motion detection system based video surveillance system. The system will be able to identify and record only “interesting” video frames containing motion.

The development process will follow the following three steps:

  1. Functional Requirements
  2. System modeling and simulation
  3. Code generation and implementation

Hardware and Software Requirements

This laboratory was originally developed using the following hardware and software:

  • MATLAB® R2008a
  • Code Composer Studio (CCS) v3.3
  • Texas Instruments DM6437 hardware.

Related Files

Video Surveillance

In this session we will show how to create the line detection model, and how it can be integrated in Simulation and Real-Time Implementations.

Figure 1
Figure 1 (figure__1.png)

Figure 1: The Motion Detection Process

The Motion Energy Estimation

The Motion Energy estimation is based on the calculation of the Sum of Absolute Differences (SAD)” according to the following equation:

Table 1
SAD = i j I k i , j I k 1 i , j SAD = i j I k i , j I k 1 i , j size 12{ ital "SAD"= Sum cSub { size 8{i} } { Sum cSub { size 8{j} } { lline I rSub { size 8{k} } left (i,j right ) - I rSub { size 8{k - 1} } left (i,j right ) rline } } } {}
where:  
I k i , j I k i , j size 12{I rSub { size 8{k} } left (i,j right )} {} - Current Frame
I k 1 i , j I k 1 i , j size 12{I rSub { size 8{k - 1} } left (i,j right )} {} - Previous Frame

Functional Description

The Video Surveillance system block diagram is shown in Figure 2. The source video is displayed and played back through the system. This incoming video stream is processed by a subsystem that estimates the motion within the scene and captures the interesting video frames. The system can display either the recorded video frame or the Absolute Differences (AD) image.

The user can configure the motion energy threshold value and select which image will be displayed (Display Control). The system outputs include, besides the displayed image, the following features:

  • A graph of the motion energy as a function of time. This graph displays the threshold value as well.
  • The Frame count of the recorded image
  • An output signal triggered by motion detection (Trigger)

While the generated code is running on the target, a host side Simulink® model simultaneously sends video frames to the target via TCP/IP protocol using TCP/IP Blocks from Instrument Control Toolbox™. The target receives video frames sent by the host side Simulink model, computes the sum of the absolute value of differences (SAD) between successive video frames, and returns an estimate of motion. When the motion estimate value exceeds a threshold, the target increments a counter and sends the corresponding frame back to the host.

Figure 2: Video Surveillance Block Diagram
Figure 2 (fig2.JPG)

Simulation

  1. Open a new Simulink model
  2. Add the blocks shown in the following table (Please refer also to Figure 3):
Table 2: Video Surveillance Simulink Blocks
Functionality Block Blockset Quant.
SAD Subsystem Simulink / Ports & Subsystems 1
Delay Signal Processing Blockset / Signal Operations 1
Abs Simulink / Math Operations 1
Matrix Sum Signal Processing Blockset / Math Functions / Matrices and Linear Algebra / Matrix Operations 2
Data Type Conversion Simulink / Signal Attributes 1
Add Sum, Simulink / Math Operations 1
Recording Enabled Subsystem Simulink / Ports & Subsystems 1
Add Sum, Simulink / Math Operations 1
Delay Signal Processing Blockset / Signal Operations 1
counter Subsystem Simulink / Ports & Subsystems 1
Add Sum, Simulink / Math Operations 1
Delay Signal Processing Blockset / Signal Operations 1
Generate data for motion energy and threshold display Matrix Concatenate Simulink / Math Operations 2
Compare Motion Energy against Threshold Relational Operator Simulink / Logic and Bit Operations 1
Input Video From Multimedia File Signal Processing Blockset / Signal Processing Sources 1
Display Control Constant Signal Processing Blockset / Signal Processing Sources 1
Display Motion Energy and Threshold Floating Scope Simulink/Sinks 1
Draws formatted text on an image or video stream Insert Text Video and Image Processing Blockset / Text & figure__ 1
Connected to the trigger (not used for simulation) Terminator Simulink/Sinks 1
Images’ Display To Video Display Video and Image Processing Blockset / Sinks 2

Figure 3: Simulink Blocks for Video Surveillance
Figure 3 (figure__2.png)

Configuring the SAD blocks

  1. Configure one of the “Add” block for subtraction, you may also change its icon shape to a circular form as follows1:
    Figure 4
    Figure 4 (figure__3.png)
  2. Configure its fixed point mode of operation Configure one of the “Matrix Sum” blocks for adding rows:
    Figure 5
    Figure 5 (figure__4.png)
  3. Configure its fixed point mode of operation
    Figure 6
    Figure 6 (figure__5.png)
  4. Configure the fixed point mode of operation for the second Matrix “Column Add” block:
    Figure 7
    Figure 7 (figure__6.png)

Configuring the Input blocks

  1. Configure on of the “Video Source” "From Multimedia File" block for reading frames from the "vipmen.avi" file.
    Table 3
    figure__7.png figure__8.png
  2. Set the initial value of the "Constant" to 1e5.
    Figure 8
    Figure 8 (figure__9.png)
    Figure 9
    Figure 9 (figure__10.png)
  3. Configure "Data Type Conversion" block :
    Figure 10
    Figure 10 (figure__11.png)
  4. Configure " Relational Operator " block :
    Figure 11
    Figure 11 (figure__12.png)
  5. Configure one of the " Matrix Concatenate " block :
    Figure 12
    Figure 12 (figure__13.png)
  6. The “Floating Scope” will be used to display the motion energy and the threshold2 as a function of time. Double-Click the block. A cope screen will appear, you should then click the icon as shown in the following picture:
    Figure 13
    Figure 13 (figure__14.png)
    You may keep the default configuration for "Data history".
  7. Configure the " Insert Text " block :
    Figure 14
    Figure 14 (figure__15.png)
  8. Double-click on the "Enabled Subsystem" block, and build it as shown below:
    Figure 15
    Figure 15 (figure__16.png)
  9. Double-click on one of the "Subsystem" block and build it as shown below:
    Figure 16
    Figure 16 (figure__17.png)
    Save the subsystem as: "Motion Energy"
  10. Double-click on one the remaining "Subsystem" block,build it as shown below and name it "Frame Counter":
    Figure 17
    Figure 17 (figure__18.png)

Connecting the blocks:

  1. Connect the blocks as shown in the following figure:
    Figure 18: Video Surveillance model
    Figure 18 (figure__19.png)
  2. Save the model as "surveillance_sim.mdl".

Running the model

  1. Run the model. You should observe the following images:
    Table 4
    Current Frame Recorded Frame
    figure__20.png figure__21.png
  2. Double click the scope and you will see:
    Figure 19
    Figure 19 (fig22.JPG)
    In this scope display, yellow represents the motion estimate from each video frame, and magenta is the threshold level. In the Motion Threshold scope here, we see that we identified five frames with motion above the threshold that were captured and recorded.

Real Time Implementation

Video Surveillance using TCP/IP

  1. Open the “video_sim.mdl” Simulink model (generated in the "A Framework for Video Processing with the DM6437 DVDP" module).
  2. Rename the model "my_dm6437evmsurveil_tcpip.mdl".
  3. Rename the “R_W Algorithm” subsystem to “Surveillance Algorithm”.
  4. Double-click the “Surveillance Algorithm” block.
  5. In this block, add a Add the “Function- Call Subsystem” from the “Ports & Subsystems" group of the "Simulink" Blockset.
  6. Rename “Function- Call Subsystem” to “Video Frame Capture Motion Threshold” and Double-click it.
  7. Open the model "surveillance_sim.mdl", created in section and copy it into “Video Frame Capture Motion Threshold ”.
  8. Add three input ports "In1" from the "Sources" group of the "Simulink" blockset and three output ports "Out1" from the "Sinks" group of the "Simulink" blockset.
  9. Add a "Switch" from the "Signal Routing" group of the "Simulink" blockset and a "Gain" from the "Math Operation" group of the "Simulink" blockset.
  10. Double-click the “Motion Energy” block and add him another output port as shown:
    Figure 20
    Figure 20 (figure__23.png)
  11. Connect the blocks as shown:
    Figure 21
    Figure 21 (figure__24.png)
  12. Configure the "Gain" block :
    Figure 22
    Figure 22 (figure__25.png)
  13. Configure the "Switch" block :
    Figure 23
    Figure 23 (figure__26.png)
  14. Double-click the “Surveillance Algorithm” subsystem.
  15. Configure the "Byte Unpack" block :
    Figure 24
    Figure 24 (figure__27.png)
  16. Configure the "Byte Pack" block :
    Figure 25
    Figure 25 (figure__28.png)
  17. Configure the " TCP/IP Receive " block :
    Figure 26
    Figure 26 (figure__29.png)
    Figure 27
    Figure 27 (figure__30.png)
  18. Configure the " TCP/IP Send " block :
    Figure 28
    Figure 28 (figure__31.png)
  19. Connect the “Video Frame Capture Motion Threshold ” block as shown:
    Figure 29
    Figure 29 (figure__32.png)
  20. Open the “RW_pcl_tcpip.mdl” model, created in the "Video R_W" file
  21. Rename the model "my_pc_surveil_tcpip.mdl".
  22. Add the "Manual Switch" from the "Signal Routing" group of the "Simulink" blockset and three "Constant" blocks from the "Signal Processing" group of the "Signal Processing" blockset.
  23. Configure the " Constant " blocks:
    Table 5
    figure__33.png figure__34.png
    fig33.JPG fig34.JPG
  24. Configure the "Byte Unpack" block :
    Figure 30
    Figure 30 (figure__35.png)
  25. Connect the block as shown:
    Figure 31
    Figure 31 (figure__36.png)
  26. Configure the " TCP/IP Receive " block :
    Figure 32
    Figure 32 (figure__37.png)
  27. Double-click the “Display” subsystem.
  28. Double-click the “Data Unpack” subsystem.
  29. Configure the "Byte Unpack" block :
    Figure 33
    Figure 33 (figure__38.png)
  30. Connect the block as shown:
    Figure 34
    Figure 34 (figure__39.png)
  31. Add to the "Display" subsystem the "Insert Text" from the " Text & figure__" group of the " Video and Image Processing " blockset, " Floating Scope" from the "Sinks" group of the "Simulink" blockset.
  32. Configure the " Insert Text " block :
    Figure 35
    Figure 35 (figure__40.png)
  33. Add the “Subsystem” from the “Ports & Subsystems" group of the "Simulink" Blockset
  34. Rename it "Combine Count"
  35. Add a "Frame Counter" subsystem as we did in paragraph 14 at the first section.
    Figure 36
    Figure 36 (figure__41.png)
  36. Add a "Matrix Concatenate" from the "Math Operations" group of the "Simulink" blockset.
  37. Connect the block as shown:
    Figure 37
    Figure 37 (figure__42.png)
  38. Configure the " Matrix Concatenate" block :
    Figure 38
    Figure 38 (figure__43.png)
  39. Connect the "Display" subsystem as shown:
    Figure 39
    Figure 39 (figure__44.png)
  40. Open a new m-file, copy the following code and save it as "my_tcpip_surveil_script.m" at the same directory as the model.
    
    function my_tcpip_surveil_script(hostModelName)
    %my_tcpip_surveil_script controls host-side TCP/IP processing for 
    %  Video Surveillance demo:
    %  1) Builds and runs the target application
    %********** Initialization ********************
    % Get model name
    modelName = gcs;
     
    % Connect to CCS
    CCS_Obj = connectToCCS(modelName);
    saved_visibility = CCS_Obj.isvisible;
    CCS_Obj.visible(1);
     
    % Load application
    loadApp(modelName, CCS_Obj);
     
    % Run application
    fprintf('Running application: %s\n', modelName);
    CCS_Obj.run;     
     
    % Allow some time for DHCP address acquisition
    pause(3);
     
    % Retrieve target's host name 
    boardType = get_param([modelName '/IP Config'], 'boardType');
    userPrompt = sprintf('Enter the IP address or the host name of the %s board: ', boardType);
    hostName = inputdlg(userPrompt, 'Target IP address');
    if isempty(hostName)
        errordlg('You have to provide a valid IP address or host name to run the demo.', ...
            'TCP/IP Surveillance Recording', 'modal');
        return;
    end
    hostName = strtrim(hostName{1});
     
     
    % Launch host side UDP receive / Video display model
    fprintf('Launching host side application: %s\n', hostModelName);
    open_system(hostModelName);
     
    % Update host side TCP/IP blocks with target's IP address
    set_param([hostModelName '/TCP//IP Send'], 'Host', hostName);
    set_param([hostModelName '/TCP//IP Receive'], 'Host', hostName);
    fprintf('Click on play button to start running the host side application!\n\n')
     
    %[EOF] tcpip_surveil_script.m
    
  41. Open a new m-file, copy the following code and save it as "my_tcpip_surveil_script.m" at the same directory as the model.
  42. now we have two models ("my_pc_surveil_tcpip.mdl" and "my_dm6437evmsurveil_tcpip.mdl") and one MATLAB file ("my_tcpip_surveil_script.m")

Running the Real-time Model

  1. Build load and run the project from the "my_dm6437evmsurveil_tcpip.mdl" model. Double-click the " Build / Reload & Run" block.
  2. Running the script, you will see:
    Figure 40
    Figure 40 (figure__45.png)
    Figure 41
    Figure 41 (figure__46.png)
    If you want to display the Absolute Differences Image, change the state of the switch from 0 to 1. You will then see:
    Figure 42
    Figure 42 (figure__47.png)

Footnotes

  1. The symbol “|” is used to place the “+” and “-“ perpendicular to each other
  2. The threshold is changed upon a user command. The simultaneous display of the threshold and motion energy will enable the user to follow-up the process of recording frames.

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks