Play video or display image
Play a video or display image sequences.
If you own the MATLAB®
Coder™ product, you can generate C or C++ code from MATLAB code in which an instance of this system object is created. When you do so,
the scope system object is automatically declared as an extrinsic
variable. In this manner, you are able to see the scope display in the same way that you
would see a figure using the
plot function, without directly generating code
from it. For the full list of system objects supporting code generation, see .
Starting in R2016b, instead of using the
to perform the operation defined by the System
object™, you can call the object with arguments, as if it were a function. For
y = step(obj,x) and
y = obj(x) perform
videoPlayer = vision.VideoPlayer returns a video player object,
videoPlayer, for displaying video frames.
sets properties using one or more name-value pairs. Enclose each property name in
quotes. For example,
videoPlayer = vision.VideoPlayer(___,
videoPlayer = vision.VideoPlayer('Name','Caption
Name— Caption display on video player window
Video(default) | character vector
Caption display on video player window, specified as a character vector.
Position— Size and position of the video player window in pixels
Size and position of the video player window in pixels, specified as a four-element
[left bottom width height]. The default size depends on your
screen resolution. The window is positioned in the center of the screen, 400 pixels in
width by 300 pixels in height.
videoFrame— Video frame
Video frame, specified as a truecolor or 2-D grayscale image.
To use an object function, specify the
object as the first input argument. For
example, to release system resources of a System
Read video from a file and set up player object.
videoReader = VideoReader('viplanedeparture.mp4'); videoPlayer = vision.VideoPlayer;
Play video. Every call to the
step method reads another frame.
while hasFrame(videoReader) frame = readFrame(videoReader); step(videoPlayer,frame); end
Close the video player.