也谈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.

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

  1. clear
  2. clc
  3. cd('C:\Documents and Settings\Administrator\桌面\matlab');
  4. % .avi必须是无损压缩的. matlab读取发现,视频尺寸为176*144
  5. fileName = 'ntia_wfall-qcif_original.avi';
  6. % mm不表示美眉,而表示multimedia. obj是一个对象
  7. obj = mmreader(fileName);
  8. % 读取所有的帧数据
  9. vidFrames = read(obj);
  10. % 帧的总数
  11. numFrames = obj.numberOfFrames;
  12. % 读取数据
  13. % mov(k)是一个结构体,mov(k).cdata实际上就是一个有RGB的帧
  14. for k = 1 : numFrames
  15. mov(k).cdata = vidFrames(:,:,:,k);
  16. mov(k).colormap = [];
  17. end
  18. % 在matlab中播放视频
  19. movie(mov);
    1. clear
    2. clc
    3. cd('C:\Documents and Settings\Administrator\桌面\matlab');
    4. % 有损压缩的.mpg视频. matlab读取后发现,视频大小为352*288
    5. fileName = '功夫熊猫_盖世五侠的秘密.mpg';
    6. % mm不表示美眉,而表示multimedia. obj是一个对象
    7. obj = mmreader(fileName);
    8. begin = 1001;
    9. % 读取[begin begin + 99]中的100帧数据
    10. vidFrames = read(obj, [begin begin + 99]);
    11. % 读取数据
    12. % mov(k)是一个结构体,mov(k).cdata实际上就是一个有RGB的帧
    13. for k = 1 : 100
    14. mov(k).cdata = vidFrames(:,:,:,k);
    15. mov(k).colormap = [];
    16. end
    17. % 在matlab中播放视频

也谈matlab中读取视频的一个重要函数mmreader的更多相关文章

  1. matlab中读取txt数据文件(txt文本文档)

    matlab中读取txt数据文件(txt文本文档) 根据txt文档不同种类介绍不同的读取数据方法 一.纯数据文件(没有字母和中文,纯数字) 对于这种txt文档,从matalb中读取就简单多了 例如te ...

  2. Matlab中如何将(自定义)函数作为参数传递给另一个函数

    假如我们编写了一个积分通用程序,想使它更具有通用性,那么可以把被积函数也作为一个参数.在c/c++中,可以使用函数指针来实现上边的功能,在matlab中如何实现呢?使用函数句柄--这时类似于函数指针的 ...

  3. 【机器学习】Matlab中实现QQ-plot的一个好工具gqqplot

    Matlab中实现QQ-plot的一个好工具gqqplot 26JUN June 26, 2013 这几天看了一下QQ-plot以及在Matlab中的实现,可是Matlab自带的qqplot函数不能满 ...

  4. MATLAB中白噪声的WGN和AWGN函数的使用

    MATLAB中白噪声的WGN和AWGN函数的使用如下: MATLAB中产生高斯白噪声非常方便,可以直接应用两个函数,一个是WGN,另一个是AWGN.WGN用于产生高斯白噪声,AWGN则用于在某一 信号 ...

  5. php字符串查找函数 php查找字符串中出现的次数函数substr_count,判断字符串中是否包含另一个字符串函数strpos

    php字符串查找函数 php查找字符串中出现的次数函数substr_count,判断字符串中是否包含另一个字符串函数strpossubstr_count($haystack, $needle [,$o ...

  6. opencv 从摄像头中读取视频并保存(c++版)

    原文:http://blog.csdn.net/zhongshijunacm/article/details/68947890 OpenCV中的视频操作函数如下表所列: VideoCapture Vi ...

  7. matlab中读取txt数据文件(转)

    根据txt文档不同种类介绍不同的读取数据方法 一.纯数据文件(没有字母和中文,纯数字) 对于这种txt文档,从matalb中读取就简单多了 例如test.txt文件,内容为“17.901 -1.111 ...

  8. Matlab中image、imagesc和imshow函数用法解析

    来源:https://blog.csdn.net/zhuiyuanzhongjia/article/details/79621813 1.显示RGB图像 相同点:这三个函数都是把m*n*3的矩阵中的数 ...

  9. 把一个文件中所有文件名或者文件路径读取到一个txt文件,然后在matlab中读取

    链接: http://blog.csdn.net/dreamgchuan/article/details/51113295 dir /on/b/s  这个读取的是这样的格式:

随机推荐

  1. 解决Ubuntu16.04 fatal error: json/json.h: No such file or directory

    参考博客 错误产生 安装json-c库之后,根据GitHub上面的readme文件链接到json-c库时出现以下错误: SDMBNJson.h:9:23: fatal error: json/json ...

  2. Qt多线程-QThread

    版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:Qt多线程-QThread     本文地址:http://techieliang.com/2 ...

  3. Mac 常用快捷键整理

    Mac下常用的快捷键: Command+W 将当前窗口关闭(可以关闭Safari标签栏,很实用) Command+Option+M 将所有窗口最小化 Command+Q 关闭当前应用程序(相当于Doc ...

  4. (转)Linux 命令--查看物理CPU个数、核数、逻辑CPU个数

    # 总核数 = 物理CPU个数 X 每颗物理CPU的核数 # 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数 # 查看物理CPU个数 cat /proc/cpuinfo| ...

  5. c 用指针操作结构体数组

    重点:指针自加,指向下一个结构体数组单元 #include <stdio.h> #include <stdlib.h> #include <string.h> #d ...

  6. 控件属性和InitializeComponent()关系:

    namespace Test22 { partial class Form1 { /// <summary> /// 必需的设计器变量. /// </summary> priv ...

  7. [讲解]sql except和intersect运算符(比拟两个或多个select语句的结果并前去非重复值)

    图 1 UNION 中若有重复的行,会被移除,只留下一个 1.简介 EXCEPT和INTERSECT运算符使您可以比较两个或多个SELECT语句的结果并返回非重复值. 2.区别 EXCEPT运算符返回 ...

  8. MVC与MVP简单对比

    在Java平台,基于Spring等技术的MVC框架已经走向成熟:在.NET平台,微软也推出了MVC.MVP Framework,MVP不同于MVC的地方,关键在于,View不再显示的依赖于Busine ...

  9. 【Linux笔记】GRUB配置与应用,启动故障分析解决。

    一.GRUB启动位置 GRUB是现今大多数Linux系统采用的自举程序,这里先来看一下Linux的程序顺序: 执行顺序    动作 固件Firmware(CMOS/BIOS) →  POST(Pwer ...

  10. namesapce的作用 增加访问路径 目的:区分不同包的相同action的访问路径