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中播放视频  
  • 相关阅读:
    Navigator对象关于语言的属性
    对ng-repeat的表格内容添加不同样式:ng-style
    ng-repeat
    ES 6 : 函数的扩展
    二维码下载,区分是 ios 和 android
    gulp配置备份
    [转]移动端web页面使用字体的思考
    移动开发总结
    前端优化:雅虎35条
    input填写银行卡号,每四位空一隔
  • 原文地址:https://www.cnblogs.com/yymn/p/4518093.html
Copyright © 2011-2022 走看看