Wednesday, November 4, 2015

取出 H.264 motion vector

2010 年 10 月 11 日
當時我研究擷取 Motion Vector 作為物件追蹤,發表在此作一記錄。

I’m modifying the JM14.2 to extract the motion vectors from the surveillance’s compressed H.264 stream.
The last mail I mentioned I could use FFMPEG to extract motion vectors. But I found it may not easy to do, due to the complexity of the code, the code is for decoding and fill the decoded raw to displaying device. I need to remove the irrelevant decoding code.
So, later I googled and found the JM14.2 (H.264/AVC Reference Software) for my further development, I think the license is under ISO/ITU related(it’s not important). Which has more clear code, I can simply comment out the decoding function (decode_one_macroblock()), then still preserving the parsing part of code - parsing a frame, slice and macro-block included parsing motion vectors of all macro-blocks. I’ve cross-compiled JM14.2 to my surveillance and run on it, but I find the JM14.2 is somehow slow, for a D1 resolution video which contains 17frames (1 I-frame and 16 P-frames) it costs about 5 seconds on the surveillance(ARM v4 about lower than 300Mhz). I think I need to tune it and remove the unused part of code. For now I’m using gprof to find the most consuming time part of code.
I expect I will have a motion-vector extraction code work on the surveillance.

The OpenCV I haven’t start.

For the surveying papers work, I recently collects three papers.
1.      Estimating Motion Reliability to Improve Moving Object Detection in The H264-AVC Domain (2009)
比利時的一篇論文
此論文的主要論點是 motion vectors 本身會有很多是 noise  motion vector這會讓以往在這個分割物件領域的演算法花費太多的時間在過濾這些 noise,所以他提出了一個方法可以很有效的過濾 noise,並且耗費很少的 CPU
其中描述很少有論文是 H264 的物件分割,除了 Zeng et.al 的那篇 MRF
此篇論文使用當前frame,前一個 frame與後一個 frame 在相同位置的 macro-blocks,來做相似度比較。
利用比出來的結果來判斷此 macro-block  motion vector 是否是 noise,必且分析是前景或是背景。

實驗:
它拿 MRF 來做比較,可以很明顯的看出來 MRF 有很多誤判的地方,從精準度的測驗數據上看起來比 MRF 好很多

疑問 :
A.它如何從 MRF 那篇論文拿到 Etri_od_A 的影像?
Ans:  google 上可以找到很多連結包含 Etri_od_A,以及PetsD2TeC2

B.它如何進行 MRF 的實驗(除非它有MRF程式碼)?

C.MRF 實驗的三個參數 (Alpha,Beta …) 它在比較實驗中如何決定因為原本MRF論文中沒有說明所定的參數是多少


2.      Moving object detection in the H.264 AVC compressed domain for video surveillance (2009)
此篇論文我很好奇他如何在 video surveillance 上做物件偵測,因為包含截取 MV 以及分割物件,此篇論文還沒有看。這篇論文與1.同一組作者。
本篇論文也是跟  MRF 那篇做比較

疑問:
A.我有可能跟這兩篇論文作者取得相關資源嗎 ? (最好有程式碼)。因為他拿 MRF 做比較,顯示他有拿到 MRF 的程式碼,不然不太可能依照 MRF 論文就寫出對應的程式。

3.      Moving Object Segmentation in H.264 AVC Compressed Domain Using Ant Colony Algorithm (2010)
此篇論文我列入不太重要的論文。
上海大學
使用螞蟻費洛蒙的概念來分割物件,將每一 MV 視為一隻螞蟻,透過在時域上的累計,將一群 MV 分類。
使用的數學式子很複雜但是表達方式過於簡單,無法看懂,實驗三言兩語帶過。
           文中也是利用 JM Reference 來擷取出 motion vector 

   5.所以我參考 Using libavformat and libavcodec 跟 ffplay 的 source code 寫了一個程式。這個程式可以把 video 每個 frame (除了沒有 motion vector 的 I-Frame)的 motion vector 取出來
http://victor.csie.org/2007/06/motion-vector-extraction.html
https://github.com/victorhsieh/motion-vector



No comments: