matlab中读取一个函数,也谈matlab中读取视频的一个重要函数mmreader

在matlab中输入help mmreader来查阅一下该函数,有如下信息:

MMREADER Create a multimedia reader object.

OBJ = MMREADER(FILENAME) constructs a multimedia reader object, OBJ, that

can read in video data from a multimedia file.  FILENAME is a string

specifying the name of a multimedia file.  There are no restrictions

on file extensions.  By default, MATLAB looks for the file FILENAME on

the MATLAB path.

If the object cannot be constructed for any reason (for example, if the

file cannot be opened or does not exist, or if the file format is not

recognized or supported), then MATLAB throws an error.

OBJ = MMREADER(FILENAME, ‘P1‘, V1, ‘P2‘, V2, ...)

constructs a multimedia reader object, assigning values V1, V2, etc. to the

specified properties P1, P2, etc.

If an invalid property name or property value is specified, MATLAB throws

an error and the object is not created.  Note that the property value pairs

can be in any format supported by the SET function, e.g. parameter-value

string pairs, structures, or parameter-value cell array pairs.

下面给出两个简单的应用:

clear

clc

cd(‘C:\Documents and Settings\Administrator\桌面\matlab‘);

% .avi必须是无损压缩的. matlab读取发现,视频尺寸为176*144

fileName = ‘ntia_wfall-qcif_original.avi‘;

% mm不表示美眉,而表示multimedia. obj是一个对象

obj = mmreader(fileName);

% 读取所有的帧数据

vidFrames = read(obj);

% 帧的总数

numFrames = obj.numberOfFrames;

% 读取数据

% mov(k)是一个结构体,mov(k).cdata实际上就是一个有RGB的帧

for k = 1 : numFrames

mov(k).cdata = vidFrames(:,:,:,k);

mov(k).colormap = [];

end

% 在matlab中播放视频

movie(mov);

clear

clc

cd(‘C:\Documents and Settings\Administrator\桌面\matlab‘);

% 有损压缩的.mpg视频. matlab读取后发现,视频大小为352*288

fileName = ‘功夫熊猫_盖世五侠的秘密.mpg‘;

% mm不表示美眉,而表示multimedia. obj是一个对象

obj = mmreader(fileName);

begin = 1001;

% 读取[begin begin + 99]中的100帧数据

vidFrames = read(obj, [begin begin + 99]);

% 读取数据

% mov(k)是一个结构体,mov(k).cdata实际上就是一个有RGB的帧

for k = 1 : 100

mov(k).cdata = vidFrames(:,:,:,k);

mov(k).colormap = [];

end

% 在matlab中播放视频

原文:http://www.cnblogs.com/yymn/p/4518093.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值