資源簡介
目標跟蹤CSK算法python實現(xiàn),附帶中文注釋和兩個視頻數(shù)據(jù),可直接運行。
代碼片段和文件信息
#!/usr/bin/env?python
#?-*-?coding:?utf-8?-*-
“““
This?is?a?python?reimplementation?of?the?open?source?tracker?in
http://www2.isr.uc.pt/~henriques/circulant/index.html
Found?http://wiki.scipy.org/NumPy_for_Matlab_Users?very?useful
based?on?the?work?of?Jo?o?F.?Henriques?2012
http://www.isr.uc.pt/~henriques
Rodrigo?Benenson?MPI-Inf?2013
http://rodrigob.github.io
“““
from?__future__?import?print_function
import?os
import?os.path
import?sys
import?glob
import?time
from?optparse?import?OptionParser
import?scipy.misc
import?pylab
debug?=?False
class?CirculantMatrixTracker:
????def?__init__(self?object_example):
????????“““
???????object_example是顯示要跟蹤的對象的圖像
????????“““
????????return
????def?find(self?image):
????????“““
????????將返回找到對象的x/y坐標和分數(shù)
????????“““
????????return
????def?update_template(self?new_example?forget_factor=1):
????????“““
???????更新跟蹤模板,
????new_example應(yīng)該與大小相匹配
????提供給構(gòu)造函數(shù)的示例
????????“““
????????return
def?load_video_info(video_path):
????“““
????加載給定路徑中視頻的所有相關(guān)信息:
????圖像文件列表(字符串的單元格數(shù)組),
????初始位置(1x2),目標大小(1x2),是否將視頻大小調(diào)整為一半(boolean),
????以及用于精確計算的ground?truth信息(Nx2?for?N?frames)。
????坐標的排序始終是[y,x]。
????返回視頻的路徑,因為如果圖像位于子文件夾中,它可能會改變(這是MILTrack視頻的默認設(shè)置)。
????“““
????#?加載?ground?truth(MILTrack的格式)
????text_files?=?glob.glob(os.path.join(video_path?“*_gt.txt“))
????assert?text_files?\
????????“No?initial?position?and?ground?truth?(*_gt.txt)?to?load.“
????first_file_path?=?os.path.join(video_path?text_files[0])
????#f?=?open(first_file_path?“r“)
????#ground_truth?=?textscan(f?‘%f%f%f%f‘)?#?[x?y?width?height]
????#ground_truth?=?cat(2?ground_truth{:})
????ground_truth?=?pylab.loadtxt(first_file_path?delimiter=““)
????#f.close()
????#?設(shè)置初始位置和大小
????first_ground_truth?=?ground_truth[0?:]
????#?target_sz包含height?width
????target_sz?=?pylab.array([first_ground_truth[3]?first_ground_truth[2]])
????#?pos?包含?y?x?center
????pos?=?[first_ground_truth[1]?first_ground_truth[0]]?+?pylab.floor(target_sz?/?2)
????#try:
????if?True:
????????#?插入缺失的注釋
????????#?每5幀中有4幀用零填充
????????for?i?in?range(4):??#?x?y?width?height
????????????xp?=?range(0?ground_truth.shape[0]?5)
????????????fp?=?ground_truth[xp?i]
????????????x?=?range(ground_truth.shape[0])
????????????ground_truth[:?i]?=?pylab.interp(x?xp?fp)
????????#?store?positions?instead?of?boxes
????????ground_truth?=?ground_truth[:?[1?0]]?+?ground_truth[:?[3?2]]?/?2
????#except?Exception?as?e:
????else:
????????print(“Failed?to?gather?ground?truth?data“)
????????#print(“Error“?e)
????????#?ok?wrong?format?or?we?just?don‘t?have?ground?truth?data.
????????ground_truth?=?[]
????#列出所有幀。?首先,嘗試MILTrack的格式,其中的初始和最后幀號存儲在文本文件中。?如果它不起作用,
????#嘗試加載文件夾中的所有png/jpg文件。
????text_files?=?glob.glob(os.path.join(video_path?“*_frames.txt“))
????if?text_files:
????????first_file_path?=?os.path.join(video_path?text_files[0])
????????#f?=?open(first_file_path?“r“)
????????#frames?=?textscan(f?‘%f%f‘)
????????frames?=?pylab.loadtxt(first_file_path?delimiter=““?dtype=int
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????459??2018-11-12?20:18??CSK\.idea\CSK.iml
?????文件????????233??2018-11-12?20:17??CSK\.idea\misc.xm
?????文件????????258??2018-11-12?20:17??CSK\.idea\modules.xm
?????文件??????13315??2018-11-12?21:37??CSK\.idea\workspace.xm
?????文件????????319??2013-11-05?04:56??CSK\circulant_matrix_tracker-master\.gitignore
?????文件??????17626??2018-11-12?21:36??CSK\circulant_matrix_tracker-master\circulant_matrix_tracker.py
?????文件??????????7??2008-06-20?13:43??CSK\circulant_matrix_tracker-master\data\david\david_fr
?????文件???????4784??2008-06-20?13:43??CSK\circulant_matrix_tracker-master\data\david\david_gt.txt
?????文件??????12847??2009-10-27?12:04??CSK\circulant_matrix_tracker-master\data\david\david_MIL_scale_TR001.txt
?????文件??????12307??2009-10-27?12:05??CSK\circulant_matrix_tracker-master\data\david\david_MIL_scale_TR002.txt
?????文件??????12711??2009-10-27?12:05??CSK\circulant_matrix_tracker-master\data\david\david_MIL_scale_TR003.txt
?????文件??????13406??2009-10-27?12:05??CSK\circulant_matrix_tracker-master\data\david\david_MIL_scale_TR004.txt
?????文件??????12955??2009-10-27?12:06??CSK\circulant_matrix_tracker-master\data\david\david_MIL_scale_TR005.txt
?????文件???????6407??2009-03-24?00:08??CSK\circulant_matrix_tracker-master\data\david\david_MIL_TR001.txt
?????文件???????6383??2009-03-24?00:09??CSK\circulant_matrix_tracker-master\data\david\david_MIL_TR002.txt
?????文件???????6374??2009-03-24?00:10??CSK\circulant_matrix_tracker-master\data\david\david_MIL_TR003.txt
?????文件???????6446??2009-03-24?00:11??CSK\circulant_matrix_tracker-master\data\david\david_MIL_TR004.txt
?????文件???????6247??2009-03-24?00:12??CSK\circulant_matrix_tracker-master\data\david\david_MIL_TR005.txt
?????文件??????28043??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00001.png
?????文件??????28791??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00002.png
?????文件??????29125??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00003.png
?????文件??????28900??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00004.png
?????文件??????29726??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00005.png
?????文件??????30519??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00006.png
?????文件??????31183??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00007.png
?????文件??????30521??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00008.png
?????文件??????29941??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00009.png
?????文件??????29738??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00010.png
?????文件??????30519??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00011.png
?????文件??????30209??2008-03-13?14:25??CSK\circulant_matrix_tracker-master\data\david\imgs\img00012.png
............此處省略976個文件信息
評論
共有 條評論