A Framework for Video Processing with the DM6437 DVDP
Introduction
This chapter describes general procedures for reading and writing video streamss. The scripts and models created in this chapter will be the basis for the other video processing chapters.
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 Digital Video Development Platform (DVDP) .
- Video camera and screen.
Related Files
- Simulink Model for Simulation - Video_sim.mdl
- Input Video File - vipmem_Y.avi
- Simulink Model for Real-Time Video Processing with a Camera- Video_R_W.mdl
- MATLAB script for Real-Time TCP/IP Interface - RW_tcpip_script.m
- Simulink Model for Real-Time Video Processing through the TCP/IP Interface - RW_dm6437_tcpip.mdl
- Simulink Model for PC Control of Real-Time Video Processing through the TCP/IP Interface - RW_pcl_tcpip.mdl
Simulation
Start by creating a new model in Simulink®.
- Open the Simulink library browser and add the "From Multimedia File" from the "Sources" group of the Video and Image Processing Blockset (Please refer to Figure 1).
Figure 1: The "From Multimedia File" Simulink Block - Double Click and select the “vipmem_Y.avi” input file(Please refer to Figure 2).
Figure 2: Source Block Configuration - In order to display the picture the "Video Viewer" from the "Sinks" group of the Video and Image Processing Blockset will be used.
Figure 3: The "To Video Display" Block Figure 4: Configuring the Video Viewer - Connect the three blocks as shown in Figure 5.
Figure 5: Displaying a Video-Clip - Run the model, you should see the video clip. A single frame is shown mage shown in Figure 6.
Figure 6: The Video Display - Save your model (We used the name “Video_sim.mdl", that you may find it here).
Real-Time Processing with the DM6437 DVDP
Using a Camera and a Display
The procedure for capture/display video using the DM6437 is shown in Figure 7.
CCS Code Generation
This procedure is similar to the one developed for stills pictures. Video will be capture/display using a camera and a monitor. Image acquisition and Processing will run in a DSP/BIOS task.
- Open the “stills_R_W.mdl”
- Delete the “From RTDX” and “To RTDX” blocks
- Add the "Task" block from the "DSP/BIOS library" group of the "Target Support Package TC6" Blockset.
- Add the “Function- Call Subsystem” from the “Ports & Subsystems" group of the "Simulink" Blockset (Please refer to Figure 8).
Figure 8: The "Function-Call Subsystem" Block - Rename “Function- Call Subsystem” to “Video Processing” and connect it to the “Task” block.
- Save the model as “Video_R_W.mdl”. Your model should look as follows1:
Figure 9: The Video Processing Model Template - Double-click the “Task” block and make the same changes as shown in Figure 34.
Figure 10: Configuring a "Task" - Double-click the “Video Processing” block. A new window will be opened.
- In the new window, add the "Video Capture" and "Video Display" from the "DM6437 EVM Board Support" group of the ""Target Support Package TC6" Blockset as shown in Figure 11.
Figure 11: The "Video Capture" block - Double-click the “Video Capture” block and change the Sample Time (and the Video capture mode only if you are using the components in the PAL mode) as shown in Figure 12.
Figure 12: Video Capture Configuration - Double-click the “Video Display” block and change the Video capture mode only if you are using the components in the PAL2 mode as shown in Figure 13.
Figure 13: Video Display Configuration - Connect the blocks as shown in Figure 14.
Figure 14: Capturing and Displaying Video - Generate code & create project. Double-click the " Generate code &.." block.
- Build the project. Double-click the “Build Project” block.
- Load the project. Double-click the “Load Project” block.
- Run the target. Double-click the “Run” block. This model can be found here.
Using the TCP/IP Interface
This section will describe a Simulink model used to generate code for capturing and displaying video frames from/to the PC target using the TCP/IP protocol3.
- Create a new Simulink model
- Open the Simulink library browser and add the "C6437EVM" from the "Target Support Package TC6" group of the " C6000 Target Preferences" Blockset (Please refer to Figure 16).We now need to create Simulink dedicated block to execute CCS commands.
Figure 16: The "C6437EVM" Block - Drag in an empty subsystem into the model (Simulink->Ports & Subsystem-> Subsystem).
- Delete its contents
- Format it: Give it a name. In our example we use “Bulid / Reload & Run".
- Right click on the Subsystem, choose “Block Properties”. Go to the Callbacks tab, and under OpenFcn* enter: “RW_tcpip_script('RW_pcl_tcpip');”, as shown in the following picture:
Figure 17: Creating the “Bulid / Reload & Run” Simulink block - Add the "Task" block from the "DSP/BIOS library" group of the "Target Support Package TC6" Blockset.
- Add the “Function- Call Subsystem” from the “Ports & Subsystems" group of the "Simulink" Blockset (Please refer to Figure 18).
Figure 18: The "Function-Call Subsystem" Block - Rename “Function- Call Subsystem” to “R_W Algorithm” and connect it to the “Task” block.
- Add the "IP Config" block from "Target Support Package™ TC6->DM6437 EVM Board Support"
- Save the model as “RW_dm6437_tcpip.mdl”. Your model should look as follows:
Figure 19: The " RW_dm6437_tcpip.mdl " Model - Double-click the “Task” block and make the same changes as shown in Figure 20.
Figure 20: "Task" Configuration - Double-click the “IP Config” block and make the same changes as shown in Figure 21.
Figure 21: “IP Config” Configuration - Double-click the “R_W Algorithm” block. A new window will be opened.
- In the new window, add the "TCP/IP Recive", "TCP/IP Send", "Byte Unpack" and "Byte Pack" from the "C6000 DSP Communication Libary" group of the ""Target Support Package TC6" Blockset as shown in Figure 22.
Figure 22: The "TCP/IP Receive" and "TCP/IP Send" blocks - Connect the blocks as shown in Figure 23.
Figure 23: The “R_W Algorithm” block - Double-click the “TCP/IP Receive” block and make the same changes as shown in Figure 24..
Figure 24: "TCP/IP Receive" Configuration (a) Main Screen (b) Data Types - Double-click the “TCP/IP Send” block and configure it as shown in Figure 25:
Figure 25: "TCP/IP Send" Configuration - Double-click the “Byte Unpack” block and configure it as shown in Figure 26.
Figure 26: " Byte Unpack " Configuration - Double-click the “Byte pack” block and configure it as shown in Figure 27.
Figure 27: " Byte Pack " Configuration - Open a new m-file, copy the following code and save it as "RW_tcpip_script.m" at the same directory as the model.
- Create another new Simulink model. Add the "Byte Pack" from the "C6000 DSP Communication Libary" group of the ""Target Support Package TC6" Blockset as shown before and the "TCP/IP Receive", "TCP/IP Send" from the "Instrument Control Toolbox" blockset.
- Configure the " TCP/IP Receive " and " TCP/IP Send " blocks :
Figure 28: "TCP/IP Receive" "TCP/IP Send" Blocks Configuration (a) "TCP/IP Receive" (b) TCP/IP Send - Add the "To Video Display" from the "DM6437 EVM Board Support" group of the ""Target Support Package TC6" Blockset , also add the "From Multimedia File" from " Signal Processing Sources" group of the "Signal Processing blockset".
- Configure the " From Multimedia File " block
Figure 29: "From Multimedia File" Configuration (a) "TCP/IP Receive" (b) TCP/IP Send - Add the “Subsystem” from the “Ports & Subsystems" group of the "Simulink" Blockset as shown before.
- Rename “Function- Call Subsystem” to “Display”.Double-click the “Display” block. A new window will be opened. In the new window, add the "Byte Unpack" and " To Video Display " as shown before, add the "Reshape" from the "Math Operations" grope of the "Simulink" blockset. (Configurations are the same as before).
- Connect the blocks as follows:
Figure 30: The "Display" block - Your model should look as follows:
- Save it as “RW_pcl_tcpip.mdl”.
- Build load and run the project. Double-click the "Build / Reload & Run" block.
- Running the script, you will see the video captured and displayed. A single frame is shown in Figure 32.
Figure 31: Capturing and Displaying Video Using TCP/IP (a) The Captured Video (b) The Displayed Video - This model can be found here.
0 comments:
Post a Comment