Viewing Video Signals in Simulink
Using the Video Viewer Block
Use the Video Viewer block when you require a
wired-in video display with simulation controls in your Simulink model.
The Video Viewer block provides simulation control
buttons directly from the GUI. The block integrates play, pause, and
step features while running the model and also provides video analysis
tools such as pixel region viewer.
For more information about the Video Viewer block, see the Video Viewer block reference page in the Video and Image Processing Blockset Reference.
Back to Top
Using the To Video Display Block
Use the To Video Display block in your Simulink model
as a simple display viewer designed for optimal performance. This
block supports code generation for the Windows platform.
For more information about the To Video Display block, see the To Video Display block reference page in
the Video and Image Processing Blockset Reference.
Back to Top
Using the MPlay GUI
The MPlay GUI enables you to view video signals in Simulink models
without adding blocks to your model. You can also view videos represented
as variables in the MATLAB workspace.
You can open several instances of the MPlay GUI simultaneously
to view multiple video data sources at once. You can also dock these
MPlay GUIs in the MATLAB desktop. Use the figure arrangement buttons
in the upper-right corner of the Sinks window to control the placement
of the docked GUIs.
For further information on using the MPlay GUI, see the following
topics:
For more information about the MPlay GUI, see the mplay function reference page.
Connecting MPlay to Your Simulink Model
Set Simulink simulation mode to Normal to
use mplay . MPlay does not work when you use Acceleration Modes.
The following procedure shows you how to use the MPlay GUI to
view a Simulink signal:
Open a Simulink model. At the MATLAB command
prompt, type
vipmplaytut

Open an MPlay GUI by typing mplay on
the MATLAB command line.
Run the model.
Select the signal line you want to view. For example,
select the bus signal coming out of the Rotate block.
On the MPlay GUI, click Connect to Simulink
Signal GUI element,

The video appears in the MPlay window.

Change to floating-scope mode by clicking the persistent
connect GUI element,
button.
Experiment with selecting different signals and viewing
them in the MPlay window. You can also use multiple MPlay GUIs to
display different Simulink signals.
Note
During code generation, Real-Time Workshop does not generate
code for the MPlay GUI. |
MPlay GUI Interface
The following figure shows the MPlay GUI containing an image
sequence.

The following sections provide descriptions of the MPlay GUI
toolbar buttons and equivalent menu options.
Toolbar Buttons
Playback Toolbar — Workspace and File Sources
Playback Toolbar — Simulink Sources
Configuration
The MPlay Configuration dialog box enables you to change the
behavior and appearance of the GUI as well as the behavior of the
playback shortcut keys.
To open the Configuration dialog box, select File > Configuration Set > Edit.
To save the configuration settings for future use,
select File > Configuration
Set > Save as.
Note
By default, the MPlay GUI uses the configuration settings from
the file mplay.cfg. Create a backup copy of the
file to store your configuration settings. |
To load a preexisting configuration set, select File > Configuration Set > Load.
Configuration Core Pane
The Core pane controls the graphic user interface (GUI) general
and source settings.

General UI
Click General
UI, and then select the Options button
to open the General UI Options dialog box.

If you select the Display
the full source path in the title bar check box, the full Simulink path
appears in the title bar. Otherwise, the title bar displays a shortened
name.
Use the Message log opens when parameter
to control when the Message log window opens. You can use this window
to debug issues with video playback. Your choices are for
any new messages, for warn/fail messages, only
for fail messages, or manually.
Source UI
Click
Source UI, and then click the Options button
to open the Source UI Options dialog box.

If you select the Keyboard commands respect playback
modes check box, the keyboard shortcut keys behave in response
to the playback mode you selected.
Using the Keyboard commands respect playback modes
Open and play a video using MPlay.
Select the Keyboard commands respect playback
modes check box.
Select the Backward playback button.
Using the right keyboard arrow key moves the video
backward, and using the left keyboard arrow key moves the video forward.
With MPlay set to play backwards, the keyboard "forward"
performs "forward with the direction the video is playing".
To disconnect the keyboard behavior from the MPlay playback
settings, clear the check box.
Use the Recently used sources list parameter
to control the number of sources you see in the
Configuration Sources Pane
The Sources pane contains the GUI options that relate to connecting
to different sources. Select the Enabled check
box next to each source type to specify to which type of source you
want to connect the GUI.

Click File, and then click the Options button
to open the Sources:File Options dialog box.

Use the Default open file path parameter
to control the folder that is displayed in the Connect to
File dialog box. The Connect to File dialog
box becomes available when you select File > Open.
Click Simulink, and then click the Options button
to open the Sources:Simulink Options dialog box.

You can have the Simulink model associated with an MPlay
GUI to open with MPlay. To do so, select the Load Simulink
model if not open check box.
Configuration Visuals Pane
The Visuals pane contains the name of the visual type and its
description.

Configuration Tools Pane
The Tools pane contains the tools that are available on the
MPlay GUI. Select the Enabled check box next
to the tool name to specify which tools to include on the GUI.

Click Image Tool, and then
click the Options button to open the Image
Tool Options dialog box.

Select the Open new Image Tool window for
export check box if you want to send each video frame to
a different session of Image Tool.
Pixel Region
Select
the Pixel Region check box to display and enable
the pixel region GUI button. For more information on working with
pixel regions, see Getting Information
about the Pixels in an Image.
Image Navigation Tools
Select
the Image Navigation Tools check box to enable
the pan-and-zoom GUI button.
Instrumentation Set
Select
the Instrumentation Set check box to enable the
option to load and save viewer settings. The option appears in the File menu.
Video Information
The Video Information dialog box lets you view basic information
about the video. To open this dialog box, select Tools
> Video Information or click the information button
.

Color Map for Intensity Video
The Colormap dialog box lets you change the colormap of an intensity
video. You cannot access the parameters on this dialog box when the
GUI displays an RGB video signal. To open this dialog box for an intensity
signal, select Tools > Colormap or press C.

Use the Colormap parameter to specify the
colormap to apply to the intensity video.
Sometimes, the pixel values do not use the entire data type
range. In such cases, you can select the Specify range of
displayed pixel values check box. You can then enter the
range for your data. The dialog box automatically displays the range
based on the data type of the pixel values.
Frame Rate
The Frame Rate dialog box displays the frame rate of the source.
It also lets you change the rate at which the MPlay GUI plays the
video and displays the actual playback rate.
Note
This dialog box becomes available when you use the MPlay GUI
to view a video signal in a Simulink model. |
The playback rate is the number of frames
the GUI processes per second. You can use the Desired playback
rate parameter to decrease or increase the playback rate.
To open this dialog box, select Playback > Frame Rate or press T.

To increase the playback rate when system hardware cannot keep
pace with the desired rate, select the Allow frame drop
to achieve desired playback rate check box. This parameter
enables the MPlay GUI to achieve the playback rate by dropping video
frames. Dropped video frames sometimes cause lower quality playback.

You can refine further both the quality of playback versus the
hardware burden, by controlling the number of frames to drop per frame
or frames displayed. For example, suppose you set the Desired
playback rate to 80 frames/sec. One way to achieve the
desired playback rate is to set the Playback schedule to Show
1 frame, Drop 3 frames. Change this playback schedule, by
setting both of the refresh rates (which is how often the GUI updates
the screen), to 20 frames/sec. MPlay can achieve
the desired playback rate (in this case, 80 frames/sec) by using these
parameter settings.
In general, the relationship between the Frame Drop parameters
is:

In this case, the refresh_rate includes a more accurate calculation
based on both the minimum and maximum refresh rates.
Use the Minimum refresh rate and Maximum
refresh rate parameters to adjust the playback schedule
of video display. Use these parameters in the following way:
Saving the Settings of Multiple MPlay GUIs
The MPlay GUI enables you to save and load the settings of multiple
GUI instances. You only have to configure the MPlay GUIs associated
with your model once.
To save the GUI settings:
To open the preconfigured MPlay GUIs:
You can save instrument sets for instances of MPlay connected
to a source. If you attempt to save an instrument set for an MPlay
instance that is not connected to a source, the Message Log displays
a warning.
Message Log
The Message Log dialog box provides a system level record of
configurations and extensions used. You can filter what messages to
display by Type and Category,
view the records, and display record details.
The Type parameter allows you
to select either All, Info, Warn, or Fail message
logs.
The Category parameter allows
you to select either Configuration or Extension message
summaries.
The Configuration message indicates
a new configuration file loaded.
The Extension message indicates
a registered component. For example, a Simulink message,
indicating a registered component, available for configuration.
Status Bar
Along the bottom of the MPlay viewer is the status bar. It displays
information, such as video status, Type of video playing (I or RGB),
Frame size, Percentage of frame rate, Frame rate, and Current
frame: Total frames.
Note
A minus sign (-) for Current frame indicates
reverse video playback. |
Back to Top
 | Viewing Video Files | | Viewing Video File Frames |  |
Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
Get this Simulink Kit