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中播放视频  
  • 相关阅读:
    rest_framework viewsets.ViewSet 的简单使用
    rest_framework django 简单使用(数据库创建数据, 覆盖数据, 其他的大同小异)
    mysql 初始 密码
    centos python No module named '_bz2'
    shell 中的 if-elif-else 注意点
    CENTOS7下安装REDIS
    centos python安装 No module named '_ctypes'
    编译nginx时struct crypt_data’没有名为‘current_salt’的成员:cd.current_salt[0] = ~salt[0];的解决方案
    centos opencv-python libSM.so.6: cannot open shared object file: No such file or directory
    mysql_config not found
  • 原文地址:https://www.cnblogs.com/yymn/p/4518093.html
Copyright © 2011-2022 走看看