From 5a920ce96bcebb9ee7cf2007ec2680b6320b6178 Mon Sep 17 00:00:00 2001 From: veerkumar Date: Fri, 10 Apr 2020 00:29:22 -0400 Subject: [PATCH 1/2] updated code for python3 --- config.py | 2 +- draw_bbox.py | 30 +++++++++---------- draw_graph.py | 4 +-- run_trackers.py | 50 +++++++++++++++---------------- scripts/__init__.py | 6 ++-- scripts/bscripts/__init__.py | 46 ++++++++++++++-------------- scripts/bscripts/run_ASLA.py | 2 +- scripts/bscripts/run_BSBT.py | 4 +-- scripts/bscripts/run_CPF.py | 4 +-- scripts/bscripts/run_CT.py | 2 +- scripts/bscripts/run_CXT.py | 4 +-- scripts/bscripts/run_DFT.py | 2 +- scripts/bscripts/run_Frag.py | 4 +-- scripts/bscripts/run_IVT.py | 2 +- scripts/bscripts/run_KMS.py | 4 +-- scripts/bscripts/run_L1APG.py | 2 +- scripts/bscripts/run_LOT.py | 2 +- scripts/bscripts/run_MEEM.py | 2 +- scripts/bscripts/run_MIL.py | 4 +-- scripts/bscripts/run_MTT.py | 2 +- scripts/bscripts/run_MUSTer.py | 2 +- scripts/bscripts/run_ORIA.py | 2 +- scripts/bscripts/run_SBT.py | 4 +-- scripts/bscripts/run_SCM.py | 2 +- scripts/bscripts/run_SMS.py | 4 +-- scripts/bscripts/run_Struck.py | 4 +-- scripts/bscripts/run_TLD.py | 2 +- scripts/butil/__init__.py | 18 +++++------ scripts/butil/calc_rect_center.py | 4 +-- scripts/butil/eval_results.py | 2 +- scripts/butil/load_results.py | 18 +++++------ scripts/butil/seq_config.py | 35 +++++++++++----------- scripts/butil/shift_bbox.py | 12 ++++---- scripts/butil/split_seq.py | 4 +-- scripts/model/__init__.py | 6 ++-- 35 files changed, 149 insertions(+), 148 deletions(-) diff --git a/config.py b/config.py index 43590313..7e884ad4 100644 --- a/config.py +++ b/config.py @@ -48,7 +48,7 @@ # for evaluating results thresholdSetOverlap = [x/float(20) for x in range(21)] -thresholdSetError = range(0, 51) +thresholdSetError = list(range(0, 51)) # for drawing plot MAXIMUM_LINES = 10 diff --git a/draw_bbox.py b/draw_bbox.py index ca4b4739..57153fe3 100644 --- a/draw_bbox.py +++ b/draw_bbox.py @@ -8,54 +8,54 @@ def main(): evalTypes = ['OPE', 'SRE', 'TRE'] - print "Eval types" + print("Eval types") for i in range(len(evalTypes)): evalType = evalTypes[i] - print "{0:2d}. {1}".format(i+1, evalType) + print("{0:2d}. {1}".format(i+1, evalType)) while True: - n = int(raw_input("\nInput evalType number (-1 to exit) : ")) + n = int(input("\nInput evalType number (-1 to exit) : ")) if n == -1: sys.exit() try: evalType = evalTypes[n-1] break except: - print "invalid number" + print("invalid number") src = RESULT_SRC.format(evalType) trackers = os.listdir(src) - print "\nTrackers" + print("\nTrackers") for i in range(len(trackers)): t = trackers[i] - print "{0:2d}. {1}".format(i+1, t) + print("{0:2d}. {1}".format(i+1, t)) while True: - n = int(raw_input("\nInput tracker number (-1 to exit) : ")) + n = int(input("\nInput tracker number (-1 to exit) : ")) if n == -1: sys.exit() try: tracker = trackers[n-1] break except: - print "invalid number" + print("invalid number") src = src + '/' + tracker + '/' seqs = [x for x in os.listdir(src) if x.endswith('.json')] while True: - print "\nSequences" + print("\nSequences") for i in range(len(seqs)): s = seqs[i] - print "{0:2d}. {1}".format(i+1, s) + print("{0:2d}. {1}".format(i+1, s)) results = [] - n = int(raw_input("\nInput sequence number (-1 to exit) : ")) + n = int(input("\nInput sequence number (-1 to exit) : ")) if n == -1: sys.exit() try: resultFile = open(os.path.join(src, seqs[n-1])) except: - print "invalid number" + print("invalid number") string = resultFile.read() jsonList = json.loads(string) @@ -65,15 +65,15 @@ def main(): for i in range(len(results)): result = results[i] - print "{0:2d}. startFrame : {1},\tshiftType : {2}".format(i+1, result.startFrame, result.shiftType) + print("{0:2d}. startFrame : {1},\tshiftType : {2}".format(i+1, result.startFrame, result.shiftType)) - n = int(raw_input("\nInput result number (-1 to exit) : ")) + n = int(input("\nInput result number (-1 to exit) : ")) if n == -1: sys.exit() try: result = results[n-1] except: - print "invalid number" + print("invalid number") continue seq = butil.load_seq_config(result.seqName) diff --git a/draw_graph.py b/draw_graph.py index 6e9e8395..9a8cf291 100644 --- a/draw_graph.py +++ b/draw_graph.py @@ -6,7 +6,7 @@ def main(): evalTypes = ['OPE'] - testname = 'tb50' + testname = 'tb100' for i in range(len(evalTypes)): evalType = evalTypes[i] result_src = RESULT_SRC.format(evalType) @@ -41,7 +41,7 @@ def get_graph(scoreList, fignum, evalType, testname): plt.plot(thresholdSetOverlap, attr.successRateList, label='', alpha=0.5, c='#202020', ls='--') else: - print 'err' + print('err') plt.title('{0}_{1} (sequence average)'.format(evalType, testname.upper())) plt.rcParams.update({'axes.titlesize': 'medium'}) plt.xlabel('thresholds') diff --git a/run_trackers.py b/run_trackers.py index 31e48677..dbeb433a 100644 --- a/run_trackers.py +++ b/run_trackers.py @@ -15,14 +15,14 @@ def main(argv): opts, args = getopt.getopt(argv, "ht:e:s:",["tracker=","evaltype=" ,"sequence="]) except getopt.GetoptError: - print 'usage : run_trackers.py -t -s ' \ - + '-e ' + print('usage : run_trackers.py -t -s ' \ + + '-e ') sys.exit(1) for opt, arg in opts: if opt == '-h': - print 'usage : run_trackers.py -t -s ' \ - + '-e ' + print('usage : run_trackers.py -t -s ' \ + + '-e ') sys.exit(0) elif opt in ("-t", "--tracker"): trackers = [x.strip() for x in arg.split(',')] @@ -38,11 +38,11 @@ def main(argv): # evalTypes = [arg] if SETUP_SEQ: - print 'Setup sequences ...' + print('Setup sequences ...') butil.setup_seqs(loadSeqs) - testname = raw_input("Input Test name : ") - print 'Starting benchmark for {0} trackers, evalTypes : {1}'.format( - len(trackers), evalTypes) + testname = input("Input Test name : ") + print('Starting benchmark for {0} trackers, evalTypes : {1}'.format( + len(trackers), evalTypes)) for evalType in evalTypes: seqNames = butil.get_seq_names(loadSeqs) seqs = butil.load_seq_configs(seqNames) @@ -53,23 +53,23 @@ def main(argv): if len(results) > 0: evalResults, attrList = butil.calc_result(tracker, seqs, results, evalType) - print "Result of Sequences\t -- '{0}'".format(tracker) + print("Result of Sequences\t -- '{0}'".format(tracker)) for seq in seqs: try: - print '\t\'{0}\'{1}'.format( - seq.name, " "*(12 - len(seq.name))), - print "\taveCoverage : {0:.3f}%".format( - sum(seq.aveCoverage)/len(seq.aveCoverage) * 100), - print "\taveErrCenter : {0:.3f}".format( - sum(seq.aveErrCenter)/len(seq.aveErrCenter)) + print('\t\'{0}\'{1}'.format( + seq.name, " "*(12 - len(seq.name))), end=' ') + print("\taveCoverage : {0:.3f}%".format( + sum(seq.aveCoverage)/len(seq.aveCoverage) * 100), end=' ') + print("\taveErrCenter : {0:.3f}".format( + sum(seq.aveErrCenter)/len(seq.aveErrCenter))) except: - print '\t\'{0}\' ERROR!!'.format(seq.name) + print('\t\'{0}\' ERROR!!'.format(seq.name)) - print "Result of attributes\t -- '{0}'".format(tracker) + print("Result of attributes\t -- '{0}'".format(tracker)) for attr in attrList: - print "\t\'{0}\'".format(attr.name), - print "\toverlap : {0:02.1f}%".format(attr.overlap), - print "\tfailures : {0:.1f}".format(attr.error) + print("\t\'{0}\'".format(attr.name), end=' ') + print("\toverlap : {0:02.1f}%".format(attr.overlap), end=' ') + print("\tfailures : {0:.1f}".format(attr.error)) if SAVE_RESULT : butil.save_scores(attrList, testname) @@ -91,7 +91,7 @@ def run_trackers(trackers, seqs, evalType, shiftTypeSet): for idxTrk in range(len(trackers)): t = trackers[idxTrk] if not os.path.exists(TRACKER_SRC + t): - print '{0} does not exists'.format(t) + print('{0} does not exists'.format(t)) sys.exit(1) if not OVERWRITE_RESULT: trk_src = os.path.join(RESULT_SRC.format(evalType), t) @@ -103,9 +103,9 @@ def run_trackers(trackers, seqs, evalType, shiftTypeSet): seqResults = [] seqLen = len(subSeqs) for idx in range(seqLen): - print '{0}_{1}, {2}_{3}:{4}/{5} - {6}'.format( + print('{0}_{1}, {2}_{3}:{4}/{5} - {6}'.format( idxTrk + 1, t, idxSeq + 1, s.name, idx + 1, seqLen, \ - evalType) + evalType)) rp = tmpRes_path + '_' + t + '_' + str(idx+1) + '/' if SAVE_IMAGE and not os.path.exists(rp): os.makedirs(rp) @@ -117,8 +117,8 @@ def run_trackers(trackers, seqs, evalType, shiftTypeSet): try: res = eval(funcName) except: - print 'failed to execute {0} : {1}'.format( - t, sys.exc_info()) + print('failed to execute {0} : {1}'.format( + t, sys.exc_info())) os.chdir(WORKDIR) break os.chdir(WORKDIR) diff --git a/scripts/__init__.py b/scripts/__init__.py index 1d115c92..37a75cbb 100644 --- a/scripts/__init__.py +++ b/scripts/__init__.py @@ -1,3 +1,3 @@ -from model import * -from bscripts import * -import butil \ No newline at end of file +from .model import * +from .bscripts import * +from . import butil diff --git a/scripts/bscripts/__init__.py b/scripts/bscripts/__init__.py index 6c04cfcb..2a5650b0 100644 --- a/scripts/bscripts/__init__.py +++ b/scripts/bscripts/__init__.py @@ -1,23 +1,23 @@ -from run_ASLA import * -from run_BSBT import * -from run_CPF import * -from run_CT import * -from run_CXT import * -from run_DFT import * -from run_Frag import * -from run_IVT import * -from run_KMS import * -from run_L1APG import * -from run_LOT import * -from run_LSK import * -from run_MIL import * -from run_MTT import * -from run_OAB import * -from run_ORIA import * -from run_SBT import * -from run_SCM import * -from run_SMS import * -from run_Struck import * -from run_TLD import * -from run_MUSTer import * -from run_MEEM import * \ No newline at end of file +from .run_ASLA import * +from .run_BSBT import * +from .run_CPF import * +from .run_CT import * +from .run_CXT import * +from .run_DFT import * +from .run_Frag import * +from .run_IVT import * +from .run_KMS import * +from .run_L1APG import * +from .run_LOT import * +from .run_LSK import * +from .run_MIL import * +from .run_MTT import * +from .run_OAB import * +from .run_ORIA import * +from .run_SBT import * +from .run_SCM import * +from .run_SMS import * +from .run_Struck import * +from .run_TLD import * +from .run_MUSTer import * +from .run_MEEM import * diff --git a/scripts/bscripts/run_ASLA.py b/scripts/bscripts/run_ASLA.py index f7034680..2c945522 100644 --- a/scripts/bscripts/run_ASLA.py +++ b/scripts/bscripts/run_ASLA.py @@ -3,7 +3,7 @@ def run_ASLA(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/bscripts/run_BSBT.py b/scripts/bscripts/run_BSBT.py index 95f56f9c..d4749123 100644 --- a/scripts/bscripts/run_BSBT.py +++ b/scripts/bscripts/run_BSBT.py @@ -14,9 +14,9 @@ def run_BSBT(seq, rp, bSaveImage): if not os.path.exists(path): os.makedirs(path) - command = map(str,['BeyondSemiBoostingTracker.exe', '100', '0.99', '2', + command = list(map(str,['BeyondSemiBoostingTracker.exe', '100', '0.99', '2', '0', '0', '0', seq.name, seq.path, seq.startFrame, seq.endFrame, - seq.nz, seq.ext, x, y, w, h]) + seq.nz, seq.ext, x, y, w, h])) tic = time.clock() subprocess.call(command) diff --git a/scripts/bscripts/run_CPF.py b/scripts/bscripts/run_CPF.py index 493e01e9..45af8e40 100644 --- a/scripts/bscripts/run_CPF.py +++ b/scripts/bscripts/run_CPF.py @@ -14,8 +14,8 @@ def run_CPF(seq, rp, bSaveImage): if not os.path.exists(path): os.makedirs(path) - command = map(str,['ObjTrk.exe', '1', path , seq.name, seq.path, - seq.startFrame, seq.endFrame, seq.nz, seq.ext, x, y, w, h]) + command = list(map(str,['ObjTrk.exe', '1', path , seq.name, seq.path, + seq.startFrame, seq.endFrame, seq.nz, seq.ext, x, y, w, h])) tic = time.clock() subprocess.call(command) diff --git a/scripts/bscripts/run_CT.py b/scripts/bscripts/run_CT.py index 826375f3..8f9c5c11 100644 --- a/scripts/bscripts/run_CT.py +++ b/scripts/bscripts/run_CT.py @@ -3,7 +3,7 @@ def run_CT(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/bscripts/run_CXT.py b/scripts/bscripts/run_CXT.py index 3680f1f4..e4c23181 100644 --- a/scripts/bscripts/run_CXT.py +++ b/scripts/bscripts/run_CXT.py @@ -14,8 +14,8 @@ def run_CXT(seq, rp, bSaveImage): if not os.path.exists(path): os.makedirs(path) - command = map(str,['CXT.exe', '1', '0', '0', '1', seq.name, seq.path, path, - seq.startFrame, seq.endFrame, seq.nz, seq.ext, x, y, w, h]) + command = list(map(str,['CXT.exe', '1', '0', '0', '1', seq.name, seq.path, path, + seq.startFrame, seq.endFrame, seq.nz, seq.ext, x, y, w, h])) tic = time.clock() subprocess.call(command) diff --git a/scripts/bscripts/run_DFT.py b/scripts/bscripts/run_DFT.py index 066c480e..76d27e8c 100644 --- a/scripts/bscripts/run_DFT.py +++ b/scripts/bscripts/run_DFT.py @@ -4,7 +4,7 @@ def run_DFT(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/bscripts/run_Frag.py b/scripts/bscripts/run_Frag.py index 06ff7d52..44f859ad 100644 --- a/scripts/bscripts/run_Frag.py +++ b/scripts/bscripts/run_Frag.py @@ -9,9 +9,9 @@ def run_Frag(seq, rp, bSaveImage): w = seq.init_rect[2] h = seq.init_rect[3] - command = map(str,['fragtrack.exe', '25', '16', '3', '0', '0', + command = list(map(str,['fragtrack.exe', '25', '16', '3', '0', '0', seq.name, seq.path, seq.startFrame, seq.endFrame, \ - seq.nz, seq.ext, x, y, w, h]) + seq.nz, seq.ext, x, y, w, h])) tic = time.clock() subprocess.call(command) diff --git a/scripts/bscripts/run_IVT.py b/scripts/bscripts/run_IVT.py index eb94011d..565f9ef3 100644 --- a/scripts/bscripts/run_IVT.py +++ b/scripts/bscripts/run_IVT.py @@ -4,7 +4,7 @@ def run_IVT(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/bscripts/run_KMS.py b/scripts/bscripts/run_KMS.py index 84950bd2..1401b667 100644 --- a/scripts/bscripts/run_KMS.py +++ b/scripts/bscripts/run_KMS.py @@ -14,8 +14,8 @@ def run_KMS(seq, rp, bSaveImage): if not os.path.exists(path): os.makedirs(path) - command = map(str,['ObjTrk.exe', '0', path , seq.name, seq.path, - seq.startFrame, seq.endFrame, seq.nz, seq.ext, x, y, w, h]) + command = list(map(str,['ObjTrk.exe', '0', path , seq.name, seq.path, + seq.startFrame, seq.endFrame, seq.nz, seq.ext, x, y, w, h])) tic = time.clock() subprocess.call(command) diff --git a/scripts/bscripts/run_L1APG.py b/scripts/bscripts/run_L1APG.py index 5f4f33b1..491da3c5 100644 --- a/scripts/bscripts/run_L1APG.py +++ b/scripts/bscripts/run_L1APG.py @@ -3,7 +3,7 @@ def run_L1APG(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/bscripts/run_LOT.py b/scripts/bscripts/run_LOT.py index 45e924ed..ce048ac6 100644 --- a/scripts/bscripts/run_LOT.py +++ b/scripts/bscripts/run_LOT.py @@ -3,7 +3,7 @@ def run_LOT(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/bscripts/run_MEEM.py b/scripts/bscripts/run_MEEM.py index ad43a8d5..342c3bb6 100644 --- a/scripts/bscripts/run_MEEM.py +++ b/scripts/bscripts/run_MEEM.py @@ -6,7 +6,7 @@ def run_MEEM(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) diff --git a/scripts/bscripts/run_MIL.py b/scripts/bscripts/run_MIL.py index 9e1602ff..0171b7bd 100644 --- a/scripts/bscripts/run_MIL.py +++ b/scripts/bscripts/run_MIL.py @@ -14,8 +14,8 @@ def run_MIL(seq, rp, bSaveImage): if not os.path.exists(path): os.makedirs(path) - command = map(str,['MIL.exe', '1', '4', '30', '0', '0', path , seq.name, - seq.path, seq.startFrame, seq.endFrame, seq.nz, seq.ext, x, y, w, h]) + command = list(map(str,['MIL.exe', '1', '4', '30', '0', '0', path , seq.name, + seq.path, seq.startFrame, seq.endFrame, seq.nz, seq.ext, x, y, w, h])) tic = time.clock() subprocess.call(command) diff --git a/scripts/bscripts/run_MTT.py b/scripts/bscripts/run_MTT.py index 9696f76f..02163486 100644 --- a/scripts/bscripts/run_MTT.py +++ b/scripts/bscripts/run_MTT.py @@ -3,7 +3,7 @@ def run_MTT(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/bscripts/run_MUSTer.py b/scripts/bscripts/run_MUSTer.py index d06f32f8..5defbea2 100644 --- a/scripts/bscripts/run_MUSTer.py +++ b/scripts/bscripts/run_MUSTer.py @@ -10,7 +10,7 @@ def run_MUSTer(seq, rp, bSaveImage): img_files = sorted([x for x in os.listdir(seq.path) if x.endswith(seq.ext)]) source['img_files'] = img_files[seq.startFrame-1:seq.endFrame] if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/bscripts/run_ORIA.py b/scripts/bscripts/run_ORIA.py index a1959ebe..e45a7ac8 100644 --- a/scripts/bscripts/run_ORIA.py +++ b/scripts/bscripts/run_ORIA.py @@ -4,7 +4,7 @@ def run_ORIA(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/bscripts/run_SBT.py b/scripts/bscripts/run_SBT.py index 8c413818..5d8d4f9c 100644 --- a/scripts/bscripts/run_SBT.py +++ b/scripts/bscripts/run_SBT.py @@ -38,9 +38,9 @@ def run_SBT(seq, rp, bSaveImage): if not os.path.exists(path): os.makedirs(path) - command = map(str,['SemiBoostingTracker_b.exe', '100', '0.99', '2', + command = list(map(str,['SemiBoostingTracker_b.exe', '100', '0.99', '2', '0', '0', '0', seq.name, seq.path, seq.startFrame, seq.endFrame, - seq.nz, seq.ext, x, y, w, h]) + seq.nz, seq.ext, x, y, w, h])) # command = ['SemiBoostingTracker1.exe'] diff --git a/scripts/bscripts/run_SCM.py b/scripts/bscripts/run_SCM.py index 4f76eb87..6e826c41 100644 --- a/scripts/bscripts/run_SCM.py +++ b/scripts/bscripts/run_SCM.py @@ -4,7 +4,7 @@ def run_SCM(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/bscripts/run_SMS.py b/scripts/bscripts/run_SMS.py index 8a2725c4..345268fc 100644 --- a/scripts/bscripts/run_SMS.py +++ b/scripts/bscripts/run_SMS.py @@ -14,8 +14,8 @@ def run_SMS(seq, rp, bSaveImage): if not os.path.exists(path): os.makedirs(path) - command = map(str,['ObjTrk.exe', '2', path , seq.name, seq.path, - seq.startFrame, seq.endFrame, seq.nz, seq.ext, x, y, w, h]) + command = list(map(str,['ObjTrk.exe', '2', path , seq.name, seq.path, + seq.startFrame, seq.endFrame, seq.nz, seq.ext, x, y, w, h])) tic = time.clock() subprocess.call(command) diff --git a/scripts/bscripts/run_Struck.py b/scripts/bscripts/run_Struck.py index 8aece257..ee72cbfd 100644 --- a/scripts/bscripts/run_Struck.py +++ b/scripts/bscripts/run_Struck.py @@ -14,9 +14,9 @@ def run_Struck(seq, rp, bSaveImage): if not os.path.exists(path): os.makedirs(path) - command = map(str,['struck.exe', 'haar', 'gaussian', '0.2', '100', '100', + command = list(map(str,['struck.exe', 'haar', 'gaussian', '0.2', '100', '100', '30', '10', bSaveImage, bSaveImage, seq.name, seq.path, seq.startFrame, - seq.endFrame, seq.nz, seq.ext, x, y, w, h]) + seq.endFrame, seq.nz, seq.ext, x, y, w, h])) tic = time.clock() subprocess.call(command) diff --git a/scripts/bscripts/run_TLD.py b/scripts/bscripts/run_TLD.py index 27c5f598..d86847cd 100644 --- a/scripts/bscripts/run_TLD.py +++ b/scripts/bscripts/run_TLD.py @@ -4,7 +4,7 @@ def run_TLD(seq, rp, bSaveImage): global m if m == None: - print 'Starting matlab engine...' + print('Starting matlab engine...') m = matlab.engine.start_matlab() m.addpath(m.genpath('.', nargout=1), nargout=0) seq.init_rect = matlab.double(seq.init_rect) diff --git a/scripts/butil/__init__.py b/scripts/butil/__init__.py index dc551a28..eebc1846 100644 --- a/scripts/butil/__init__.py +++ b/scripts/butil/__init__.py @@ -1,19 +1,19 @@ import math from config import * -from seq_config import * -from eval_results import * -from load_results import * -from shift_bbox import * -from split_seq import * -from calc_seq_err_robust import * -from calc_rect_center import * +from .seq_config import * +from .eval_results import * +from .load_results import * +from .shift_bbox import * +from .split_seq import * +from .calc_seq_err_robust import * +from .calc_rect_center import * def d_to_f(x): - return map(lambda o:round(float(o),4), x) + return [round(float(o),4) for o in x] def matlab_double_to_py_float(double): - return map(d_to_f, double) + return list(map(d_to_f, double)) def ssd(x, y): if len(x) != len(y): diff --git a/scripts/butil/calc_rect_center.py b/scripts/butil/calc_rect_center.py index 71dde4e7..ed826cc4 100644 --- a/scripts/butil/calc_rect_center.py +++ b/scripts/butil/calc_rect_center.py @@ -7,7 +7,7 @@ def corners2rect(corners): y = result_corners[1,0] w = result_corners[0,2] - x h = result_corners[1,2] - y - rect = map(int, [x, y, w, h]) + rect = list(map(int, [x, y, w, h])) return rect def rect_affine_IVT(tmplsize, res): @@ -102,7 +102,7 @@ def calc_rect_center(*params): y = result_corners[1,0] w = result_corners[0,2] - x h = result_corners[1,2] - y - rect = map(int, [x, y, w, h]) + rect = list(map(int, [x, y, w, h])) center = np.mean(corners[:,0:4],1) return rect, center, corners diff --git a/scripts/butil/eval_results.py b/scripts/butil/eval_results.py index ba57d2f0..9aeb90ee 100644 --- a/scripts/butil/eval_results.py +++ b/scripts/butil/eval_results.py @@ -30,7 +30,7 @@ def calc_result(tracker, seqs, results, evalType): anno = seq.gtRect[result.startFrame-1: result.endFrame] - print '{0} : eval {1}'.format(tracker, seq.name) + print('{0} : eval {1}'.format(tracker, seq.name)) aveCoverage, aveErrCenter, errCoverage, errCenter = \ scripts.butil.calc_seq_err_robust(result, anno) seq.aveCoverage.append(aveCoverage) diff --git a/scripts/butil/load_results.py b/scripts/butil/load_results.py index f024cc0e..8f140333 100644 --- a/scripts/butil/load_results.py +++ b/scripts/butil/load_results.py @@ -15,11 +15,11 @@ def save_seq_result(result): try: string = json.dumps(result, default=lambda o : o.__dict__) except: - print map(type, result[0].__dict__.values()) + print(list(map(type, list(result[0].__dict__.values())))) sys.exit() fileName = src + '/{0}.json'.format(seqName) resultFile = open(fileName, 'wb') - resultFile.write(string) + resultFile.write(string.encode()) resultFile.close() def save_scores(scoreList, testname=None): @@ -36,7 +36,7 @@ def save_scores(scoreList, testname=None): string = json.dumps(score, default=lambda o : o.__dict__) fileName = scoreSrc + '/{0}.json'.format(score.name) scoreFile = open(fileName, 'wb') - scoreFile.write(string) + scoreFile.write(string.encode()) scoreFile.close() def load_all_results(evalType): @@ -51,7 +51,7 @@ def load_all_results(evalType): def load_result(evalType, tracker): resultSRC = RESULT_SRC.format(evalType) - print 'Loading \'{0}\'...'.format(tracker), + print('Loading \'{0}\'...'.format(tracker), end=' ') src = os.path.join(resultSRC, tracker) resultNames = os.listdir(src) attrs = [] @@ -65,7 +65,7 @@ def load_result(evalType, tracker): string = attrFile.read() j = json.loads(string) attr = Attribute(**j) - attr.successRateList = map(lambda o:o*100, attr.successRateList) + attr.successRateList = [o*100 for o in attr.successRateList] attrs.append(attr) attrs.sort() elif name.endswith('.json'): @@ -76,12 +76,12 @@ def load_result(evalType, tracker): results.append([Result(**j) for j in jsonList]) elif type(jsonList) is dict: results.append([Result(**jsonList)]) - print '({0} seqs)'.format(len(resultNames) - 1) + print('({0} seqs)'.format(len(resultNames) - 1)) return results, attrs def load_seq_result(evalType, tracker, sequence): resultSRC = RESULT_SRC.format(evalType) - print 'Loading {0}/{1}...'.format(tracker, sequence) + print('Loading {0}/{1}...'.format(tracker, sequence)) src = os.path.join(resultSRC, tracker) result_src = os.path.join(src, sequence+'.json') resultFile = open(result_src) @@ -101,7 +101,7 @@ def load_all_scores(evalType, testname): def load_scores(evalType, tracker, testname): resultSRC = RESULT_SRC.format(evalType) - print 'Loading \'{0}\'...'.format(tracker) + print('Loading \'{0}\'...'.format(tracker)) src = os.path.join(resultSRC, tracker+'/scores_{0}'.format(testname)) attrNames = os.listdir(src) attrs = [] @@ -110,7 +110,7 @@ def load_scores(evalType, tracker, testname): string = attrFile.read() j = json.loads(string) attr = Score(**j) - attr.successRateList = map(lambda o:o*100, attr.successRateList) + attr.successRateList = [o*100 for o in attr.successRateList] attrs.append(attr) attrs.sort() return attrs diff --git a/scripts/butil/seq_config.py b/scripts/butil/seq_config.py index c6bb693f..f2863b26 100644 --- a/scripts/butil/seq_config.py +++ b/scripts/butil/seq_config.py @@ -1,4 +1,4 @@ -import urllib2 +import urllib.request, urllib.error, urllib.parse import zipfile import shutil import copy @@ -53,14 +53,14 @@ def get_sub_seqs(s, numSeg, evalType): def setup_seqs(loadSeqs): seqs = make_seq_configs(loadSeqs) for seq in seqs: - print "\t" + seq.name + "\t" + seq.path + print("\t" + seq.name + "\t" + seq.path) save_seq_config(seq) def save_seq_config(seq): string = json.dumps(seq.__dict__, indent=2) src = os.path.join(SEQ_SRC, seq.name) configFile = open(src+'/cfg.json', 'wb') - configFile.write(string) + configFile.write(string.encode()) configFile.close() def load_seq_config(seqName): @@ -119,12 +119,12 @@ def make_seq_configs(loadSeqs): if not os.path.exists(src): os.makedirs(src) if not os.path.exists(imgSrc): - print name + ' does not have img directory' + print(name + ' does not have img directory') if DOWNLOAD_SEQS: download_sequence(name) else: - print 'If you want to download sequences,\n' \ - + 'check if config.py\'s DOWNLOAD_SEQS is True' + print('If you want to download sequences,\n' \ + + 'check if config.py\'s DOWNLOAD_SEQS is True') sys.exit(1) imgfiles = sorted(os.listdir(imgSrc)) @@ -158,11 +158,11 @@ def make_seq_configs(loadSeqs): gtRect = [] for line in gtLines: if '\t' in line: - gtRect.append(map(int,line.strip().split('\t'))) + gtRect.append(list(map(int,line.strip().split('\t')))) elif ',' in line: - gtRect.append(map(int,line.strip().split(','))) + gtRect.append(list(map(int,line.strip().split(',')))) elif ' ' in line: - gtRect.append(map(int,line.strip().split(' '))) + gtRect.append(list(map(int,line.strip().split(' ')))) init_rect = [0,0,0,0] seq = Sequence(name, path, startFrame, endFrame, @@ -245,17 +245,18 @@ def download_sequence(seqName): def download_and_extract_file(url, dst, ext_dst): - print 'Connecting to {0} ...'.format(url) + print('Connecting to {0} ...'.format(url)) try: - u = urllib2.urlopen(url) + u = urllib.request.urlopen(url) except: - print 'Cannot download {0} : {1}'.format( - url.split('/')[-1], sys.exc_info()[1]) + print('Cannot download {0} : {1}'.format( + url.split('/')[-1], sys.exc_info()[1])) sys.exit(1) f = open(dst, 'wb') meta = u.info() - file_size = int(meta.getheaders("Content-Length")[0]) - print "Downloading {0} ({1} Bytes)..".format(url.split('/')[-1], file_size) + #file_size = int(meta.getheaders("Content-Length")[0]) + file_size = int(u.headers['content-length']) + print("Downloading {0} ({1} Bytes)..".format(url.split('/')[-1], file_size)) file_size_dl = 0 block_sz = 8192 while True: @@ -268,12 +269,12 @@ def download_and_extract_file(url, dst, ext_dst): status = r"{0:d} ({1:3.2f}%)".format( file_size_dl, file_size_dl * 100. / file_size) status = status + chr(8)*(len(status)+1) - print status, + print(status, end=' ') f.close() f = open(dst, 'rb') z = zipfile.ZipFile(f) - print '\nExtracting {0}...'.format(url.split('/')[-1]) + print('\nExtracting {0}...'.format(url.split('/')[-1])) z.extractall(ext_dst) f.close() os.remove(dst) diff --git a/scripts/butil/shift_bbox.py b/scripts/butil/shift_bbox.py index 9eccc79a..129c406f 100644 --- a/scripts/butil/shift_bbox.py +++ b/scripts/butil/shift_bbox.py @@ -10,37 +10,37 @@ def shift_init_BB(r, shiftType, imgH, imgW): ratio = 0.7 w = ratio * r[2] h = ratio * r[3] - r = map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h]) + r = list(map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h])) elif shiftType == 'scale_8': ratio = 0.8 w = ratio * r[2] h = ratio * r[3] - r = map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h]) + r = list(map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h])) elif shiftType == 'scale_9': ratio = 0.9 w = ratio * r[2] h = ratio * r[3] - r = map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h]) + r = list(map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h])) elif shiftType == 'scale_11': ratio = 1.1 w = ratio * r[2] h = ratio * r[3] - r = map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h]) + r = list(map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h])) elif shiftType == 'scale_12': ratio = 1.2 w = ratio * r[2] # 104.4 h = ratio * r[3] # 382.8 - r = map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h]) + r = list(map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h])) elif shiftType == 'scale_13': ratio = 1.3 w = ratio * r[2] h = ratio * r[3] - r = map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h]) + r = list(map(round, [center[0]-w/2.0, center[1]-h/2.0, w, h])) elif shiftType == 'left': r[0] -= round(0.1 * r[2] + 0.5) diff --git a/scripts/butil/split_seq.py b/scripts/butil/split_seq.py index b8cec9db..8d733c96 100644 --- a/scripts/butil/split_seq.py +++ b/scripts/butil/split_seq.py @@ -12,7 +12,7 @@ def split_seq_TRE(seq, segNum, rect_anno): if not isinstance(idxExclude[0], np.ndarray): idxExclude = [idxExclude] - idx = range(1, seq.len + 1) + idx = list(range(1, seq.len + 1)) for j in range(len(idxExclude)): begin = idxExclude[j][0] - 1 @@ -25,7 +25,7 @@ def split_seq_TRE(seq, segNum, rect_anno): if r[0]<=0 or r[1]<=0 or r[2]<=0 or r[3]<=0: idx[i] = 0 idx = [x for x in idx if x > 0] - for i in reversed(range(len(idx))): + for i in reversed(list(range(len(idx)))): if seq.len - idx[i] + 1 >= minNum: endSeg = idx[i] endSegIdx = i + 1 diff --git a/scripts/model/__init__.py b/scripts/model/__init__.py index 8028f909..f75bbdf8 100644 --- a/scripts/model/__init__.py +++ b/scripts/model/__init__.py @@ -1,3 +1,3 @@ -from score import * -from result import * -from sequence import * \ No newline at end of file +from .score import * +from .result import * +from .sequence import * From 413f73547cfca4253ccea59501562fd23c4dfa5d Mon Sep 17 00:00:00 2001 From: "Pramod Kumar (Veer)" Date: Fri, 10 Apr 2020 00:32:00 -0400 Subject: [PATCH 2/2] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 00b7feb6..8a9223cc 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -Trakcer Benchmark (Tested on python 2.7.10) +Trakcer Benchmark (Tested on python 3.6) Usage - Default (for all trackers, all sequences, all evaltypes(OPE, SRE, TRE))