The following figure shows the algorithm which runs on the host side machine and communicates with the target using the TCP/IP Send and Receive blocks. The model communicates with the target at port number 49000. The TCP/IP blocks are configured to send and receive data in blocking mode.

Target Model

The following figure shows the target side example model.

The following figure shows the Surveillance Algorithm which is executued on the target C6416. The algorithm is implemented using blocks from Simulink, DSP System Toolbox™ and Embedded Coder and is converted to C using Simulink® Coder™.

Analysis

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. 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 using the TCP/IP block. You can also adjust the motion threshold using the host side Simulink model.

Running the Example

Open the target model and double click "Build Reload & Run" to build, load and run the DSP code. Once the code is generated, it will bring up the host side model. Run the host side model to watch the video surveillance algorithm using motion detection.