zoukankan      html  css  js  c++  java
  • 视频运动motion vector获取。

    http://victor.csie.org/blog/archives/362
    ----------------------------------------------------------------------
    Motion Vector Extraction June 10

    Filed under Uncategorized by victor | 1 comment

    為了做 MULTIMEDIA ANALYSIS AND INDEXING 這門課的 project,我們這組需要從 MPEG video 裡面取出 motion vector(它在 MPEG video 裡的用途是用來做壓縮。一個物體在畫面裡面移動時,其實只需要描述它的位移,而不需整個重新 encode)。

    不知道是不是因為大部分的人需要的都是 video 的 frame,而不是 motion vector(其實在解壓縮時只差一步),我 google 了好久都找不到工具可以用。後來發現 ffmpeg 的 ffplay 可以直接把 motion vector 邊撥邊畫出來,但是還是沒辦法 dump 出來。

    $ ffplay -vismv 3 xxx.mpg

    vismv 那個參數其實是三個 bit,第一個 bit 代表 P-Frame,第二個代表 B-Frame 的 forward motion vector,第三個 bit 則是 B-Frame 的 backward vector。

    不過,這只能看。所以我參考 Using libavformat and libavcodec 跟 ffplay 的 source code 寫了一個程式。這個程式可以把 video 每個 frame (除了沒有 motion vector 的 I-Frame)的 motion vector 取出來。如果要改成取第幾個 frame、或是某個 range 之類的,也很好改。

    g++ compile 時需要加上 -lavcodec -lavformat 兩個參數,當然也要先裝上 libavcodec 跟 libavformat 兩個 library。有裝 ffmpeg 就會有。

    http://victor.csie.org/archive/motion_vector.cpp


    ------------------------------------------------------------------------
    /usr/local/include/libavutil/common.h: In function 'int32_t av_clipl_int32_c(int64_t)':
    /usr/local/include/libavutil/common.h:168: error: 'UINT64_C' was not declared in this scope
    ----------------
    vi /usr/local/include/libavutil/common.h

    #ifdef __cplusplus
     #define __STDC_CONSTANT_MACROS
     #ifdef _STDINT_H
      #undef _STDINT_H
     #endif
     # include <stdint.h>
    #endif

    ----------------------
    在包含 ffmpeg 的相关头文件
    extern "C"
    {
    #include"filename.h"
    }

    转自:http://blog.chinaunix.net/uid-14779297-id-1988335.html

  • 相关阅读:
    SCILAB简介[z]
    UG OPEN API编程基础 2约定及编程初步
    Office 2003与Office 2010不能共存的解决方案
    UG OPEN API 编程基础 3用户界面接口
    NewtonRaphson method
    UG OPEN API编程基础 13MenuScript应用
    UG OPEN API编程基础 14API、UIStyler及MenuScript联合开发
    UG OPEN API编程基础 4部件文件的相关操作
    UG OPEN API编程基础 1概述
    16 UG Open的MFC应用
  • 原文地址:https://www.cnblogs.com/retrieval/p/3180436.html
Copyright © 2011-2022 走看看