zoukankan      html  css  js  c++  java
  • 也谈matlab中读取视频的一个重要函数mmreader

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

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

    [plain] view plaincopy
     
    1. clear  
    2. clc  
    3. cd('C:Documents and SettingsAdministrator桌面matlab');  
    4.   
    5. % .avi必须是无损压缩的. matlab读取发现,视频尺寸为176*144  
    6. fileName = 'ntia_wfall-qcif_original.avi';   
    7.   
    8. % mm不表示美眉,而表示multimedia. obj是一个对象  
    9. obj = mmreader(fileName);  
    10.    
    11. % 读取所有的帧数据  
    12. vidFrames = read(obj);  
    13.    
    14. % 帧的总数  
    15. numFrames = obj.numberOfFrames;  
    16.   
    17. % 读取数据  
    18. % mov(k)是一个结构体,mov(k).cdata实际上就是一个有RGB的帧  
    19.  for k = 1 : numFrames  
    20.      mov(k).cdata = vidFrames(:,:,:,k);  
    21.      mov(k).colormap = [];  
    22. end  
    23.    
    24. % 在matlab中播放视频  
    25. movie(mov);  
    [plain] view plaincopy
     
      1. clear  
      2. clc  
      3. cd('C:Documents and SettingsAdministrator桌面matlab');  
      4.   
      5. % 有损压缩的.mpg视频. matlab读取后发现,视频大小为352*288  
      6. fileName = '功夫熊猫_盖世五侠的秘密.mpg';   
      7.   
      8. % mm不表示美眉,而表示multimedia. obj是一个对象  
      9. obj = mmreader(fileName);  
      10.    
      11. begin = 1001;  
      12. % 读取[begin begin + 99]中的100帧数据  
      13. vidFrames = read(obj, [begin begin + 99]);  
      14.   
      15. % 读取数据  
      16. % mov(k)是一个结构体,mov(k).cdata实际上就是一个有RGB的帧  
      17.  for k = 1 : 100  
      18.      mov(k).cdata = vidFrames(:,:,:,k);  
      19.      mov(k).colormap = [];  
      20. end  
      21.    
      22. % 在matlab中播放视频  
  • 相关阅读:
    AJax封装避免页面重复代码
    word 2010 建立多级结构和目录
    (转)C# 选择正确的集合
    IIS7如何部署asp.net网站 (asp.net mvc 5 , asp.net 4.5 , asp.net 4.0 都可以 )
    (转)程序集清单定义与程序集引用不匹配- 分析及解决
    CentOS 6.5 安装 MySQL5.6 并用Navicat for MySQL 连接
    用EF访问Centos下的MySQL
    SQLServer中的页如何影响数据库性能 (转)
    .NET Framework各版本比较
    EntityFramework简介
  • 原文地址:https://www.cnblogs.com/yymn/p/4518093.html
Copyright © 2011-2022 走看看