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.
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.
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).
- Double Click and select the “vipmem_Y.avi” input file(Please refer to Figure 2).
- In order to display the picture the "Video Viewer" from the "Sinks" group of the Video and Image Processing Blockset will be used.
- Connect the three blocks as shown in Figure 5.
- Run the model, you should see the video clip. A single frame is shown mage shown in Figure 6.
- Save your model (We used the name “Video_sim.mdl", that you may find it here).
The procedure for capture/display video using the DM6437 is shown in Figure 7.
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).
- 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 follows:
- Double-click the “Task” block and make the same changes as shown in Figure 34.
- 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.
- 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.
- Double-click the “Video Display” block and change the Video capture mode only if you are using the components in the PAL mode as shown in Figure 13.
- Connect the blocks as shown in Figure 14.
- 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.
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 protocol.
- 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.
- 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:
- 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).
- 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:
- Double-click the “Task” block and make the same changes as shown in Figure 20.
- Double-click the “IP Config” block and make the same changes as shown in Figure 21.
- 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.
- Connect the blocks as shown in Figure 23.
- Double-click the “TCP/IP Receive” block and make the same changes as shown in Figure 24.
.
- Double-click the “TCP/IP Send” block and configure it as shown in Figure 25:
- Double-click the “Byte Unpack” block and configure it as shown in Figure 26.
- Double-click the “Byte pack” block and configure it as shown in Figure 27.
- 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 :
- 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
- 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:
- 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.
- This model can be found here.