資源簡介
matlab實現視頻中動態目標跟蹤程序及注釋-trackingzhushi.m
本人是新手,在網上下了基于matlab的視頻動態跟蹤程序,現把程序分享下。希望高手指教下該程序用到了什么算法,如何實現視頻跟蹤的,謝謝了。。。
本人是新手,在網上下了基于matlab的視頻動態跟蹤程序,現把程序分享下。希望高手指教下該程序用到了什么算法,如何實現視頻跟蹤的,謝謝了。。。
代碼片段和文件信息
?????????????????%%%%%%%%%%???Directions:??%?表示對程序語句的注釋;?%%???表示對程序注釋語句的注釋的注釋.?%%%%%%%%%%
????????????????????????????????????????
function?d?=?tracking(video)????????????????????????%?tracking函數定義.
if?ischar(video)????????????????????????????????????%?Determine?whether?item?is?character?array,tf?=?ischar(A)?returns?logical?1?(true).
????????????????????????????????????????????????????%?if?A?is?a?character?array?and?logical?0?(false)?otherwise.
????????????????????????????????????????????????????%?判斷判斷video是否為一個字符數組。是返回1,否則返回0.
????????????????????????????????????????????????????
????????????????????????????????????????????????????
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%??讀取所需視頻信息??%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
????%?Load?the?video?from?an?avi?file.
????%%從一個avi文件中讀取視頻文件獲取相關視頻文件信息.
????
????avi?=?aviread(video);???????????????????????????%?mov?=?aviread(filename)??reads?the?AVI?movie?filename?into?the?MATLAB?movie?structure?mov。
????????????????????????????????????????????????????%?該函數將avi中的視頻信息讀入到MATLAB電影緩存中。
????pixels?=?double(cat(4avi(1:2:end).cdata))/255;?%?double(x)?returns?the?double-precision?value?for?X.?If?X?is?already?a?double-precision
????????????????????????????????????????????????????%?array?double?has?no?effect.如果X是一個非雙精度數值則該函數返回一個雙精度值,否則該函數無任何作用.
????????????????????????????????????????????????????%?cat:Concatenate?arrays?along?specified?dimension沿具體指定維將avi視頻數據分塊為由4個矩陣元素組成的矩陣
????????????????????????????????????????????????????
????????????????????????????????????????????????????
????????????????????????????????????????????????????
????clear?avi???????????????????????????????????????%?clear?name?:removes?just?the?M-file?or?MEX-file?function?or?variable?name?from?the?workspace.
????????????????????????????????????????????????????%?清除工作空間緩存。
else
????
????%?Compile?the?pixel?data?into?a?single?array
????%%?把像素數據編譯成為一個單獨的4維數組
????
????pixels?=?double(cat(4video{1:2:end}))/255;?????%?像素值pixels定義為矩陣。
????clear?video?????????????????????????????????????%?clear?keyword:?clears?the?items?indicated?by?keyword.按關鍵字video清除各項目
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%???圖像轉化???%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?Convert?to?RGB?to?GRAY?SCALE?image.
%?%?把RGB轉換為灰度圖像
nframes?=?size(pixels4);???????????????????????????%?m?=?size(Xdim)?:returns?the?size?of?the?dimension?of?X?specified?by?scalar?dim.
????????????????????????????????????????????????????%?下標dim指示pixdls數組的維數值dim大小,即將dim賦值給nframes。?
????????????????????????????????????????????????????
for?f?=?1:nframes???????????????????????????????????%?視頻圖像幀循環變量f
%?????F?=?getframe(gcf);????????????????????????????%%??F?=?getframe(gcf):gets?a?frame?from?the?figure?or?axes?identified?by?handle?h.
????????????????????????????????????????????????????%%?從由h確定的圖片或者軸線獲得一幀。
%?????[xmap]=frame2im(F);??????????????????????????%%?[XMap]?=
評論
共有 條評論