也谈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. “我爱淘”第二冲刺阶段Scrum站立会议8

    完成任务: 完成学院分类的点击查看书籍功能,可以点击书的条目查看书的详细信息.完善界面显示,实现购买功能,优化提示,购买后就将该书从数据库中删去. 计划任务: 将书的详细信息进行完善,并且可以点击收藏 ...

  2. php addslashes和stripslashes函数

    addslashes — 使用反斜线引用字符串 stripslashes — 反引用一个引用字符串   Example #1 一个 addslashes() 例子 <?php$str = &qu ...

  3. C#高级编程 (第六版) 学习 第五章:数组

    第五章 数组 1,简单数组 声明:int[] myArray; 初始化:myArray = new int[4]; 为数组分配内存. 还可以用如下的方法: int[] myArray = new in ...

  4. C++ Primer Plus学习:第十一章

    运算符重载 使用方法: 在类的声明中定义重载运算符 datatype operator操作符(datatype); 定义:datatype classname:: operator操作符(dataty ...

  5. zabbix简介

    (一)监控系统 初探 前言: 对于监控系统而言,首先必须搞清楚需要监控什么? (1)硬件设备和软件设备:服务器,路由器,交换机,I/O存储系统,操作系统,网络,各种应用程序 (2)各种指标:数据库宕机 ...

  6. PAT 甲级 1127 ZigZagging on a Tree

    https://pintia.cn/problem-sets/994805342720868352/problems/994805349394006016 Suppose that all the k ...

  7. CodeForces Round #527 (Div3) C. Prefixes and Suffixes

    http://codeforces.com/contest/1092/problem/C Ivan wants to play a game with you. He picked some stri ...

  8. 遍历frame中的表单:

    遍历frame中的表单: public void table1() { // 查找frame List<WebElement> iframes = driver.findElements( ...

  9. 判断一个变量是不是json,以及如何将变量转换成json

    https://blog.csdn.net/A123638/article/details/52486975这里看到一个很好的方法 // 判断变量是不是jsonisJson(variable: any ...

  10. webgl glsl

    GLSL是什么? GLSL是运行在GPU上的着色器语言 GLSL有自己的语法,跟js有些不同. GLSL是一个强类型的语言,所以在写着器语言时,必须要用强类型,强类型,强类型,强类型 GLSL是着色器 ...