read
Read one or more video frames
Description
returns data in the format specified by the video
= read(___,'native'
)VideoFormat
property
and can include any of the input arguments in the previous syntaxes.
Examples
Read Video Frames Using Frame Index
Create a VideoReader
object for the sample video file xylophone_video.mp4
.
v = VideoReader("xylophone_video.mp4");
Read only the first video frame.
firstFrame = read(v,1);
Read only the last video frame.
lastFrame = read(v,Inf);
Read frames 5 through 10.
earlyFrames = read(v,[5 10]);
Read from the 50th frame to the end of the video file.
lateFrames = read(v,[50 Inf]);
Display the size and type information of the video frame variables.
whos *Frame*
Name Size Bytes Class Attributes earlyFrames 240x320x3x6 1382400 uint8 firstFrame 240x320x3 230400 uint8 lastFrame 240x320x3 230400 uint8 lateFrames 240x320x3x92 21196800 uint8
Clear the VideoReader
object.
clear v
Input Arguments
v
— Input VideoReader
object
VideoReader
object
Input VideoReader
object. Use the VideoReader
function to
create a VideoReader
object from your video file.
index
— Frames to read
[1 Inf]
(default) | numeric scalar | two-element array
Frames to read, specified as a numeric scalar or a two-element array.
To read a single frame, specify a numeric scalar.
To read a range of frames, specify a two-element array.
The first frame number is 1, and Inf
represents the
last frame of the file.
Example: 10
Example: Inf
Example: [1 20]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
video
— Video frame data
numeric array | structure array
Video frame data, returned as a numeric or structure array. The size and
format of video
depends on the
VideoFormat
property of v
. When
the VideoFormat
property of v
is
'Indexed'
or 'Grayscale'
, the data
type and dimensions of video
depend on whether you call
read
with the 'native'
argument.
For most files, the data type and dimensions of video
are
as follows.
H
is the image frame height, W
is
the image frame width, and F
is the number of frames
read.
Value of
obj.VideoFormat | Data Type of
video | Dimensions of
video | Description |
---|---|---|---|
'RGB24' , with or without specifying
'native' | uint8 |
| RGB24 image |
'Grayscale' , without specifying
'native' | uint8 |
| Grayscale image |
'Indexed' , without specifying
'native' | uint8 |
| RGB24 image |
'Grayscale' or
'Indexed' , specifying
'native' | struct | 1-by- | MATLAB® movie, which is an array of frame
structure arrays, each containing the fields
|
For Motion JPEG 2000 files, the data type and dimensions of
video
are as follows.
Value of
obj.VideoFormat | Data Type of
video | Dimensions of
video | Description |
---|---|---|---|
'Mono8' | uint8 |
| Mono image |
'Mono8 Signed' | int8 |
| Mono signed image |
'Mono16' | uint16 |
| Mono image |
'Mono16 Signed' | int16 |
| Mono signed image |
'RGB24' | uint8 |
| RGB24 image |
'RGB24 Signed' | int8 |
| RGB24 signed image |
'RGB48' | uint16 |
| RGB48 image |
'RGB48 Signed' | int16 |
| RGB48 signed image |
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Code generation for
read
does not support the optional positional argumentnative
.
Generate Code That Uses Row-Major Layout — Generate Code That Uses Row-Major Array Layout (MATLAB Coder).
Version History
Introduced in R2010b
See Also
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)