import pfpy from pfpy import Tracker def pfNodeName(): return 'Import 2dt' def pfAutoRun(): # by default, this script does not run automatically return False def stripQuotes(s) : return s[1:len(s)-2] def readLine(f) : l= f.readline() while len(l) > 0 and l[0] == '#' : l= f.readline() return l def main() : # ask for a filename filename= input("") # open the file f= open(filename, 'r') # read contents l= readLine(f) while len(l) > 0 : if l[0] == '\"' : # create a new tracker t= Tracker.new(stripQuotes(l)) # how many frames? n= int(readLine(f)) print("Creating tracker", t.getName(), n, "frames") for idx in range(0, n, 1) : d= readLine(f).split() if len(d) == 4 : # fetch the frame number frame= int(d[0]) # first or last frame? if idx == 0 : t.setInPoint(frame) elif idx == n-1 : t.setOutPoint(frame) # store position t.setTrackPosition(frame, float(d[1]), float(d[2])) # store matching score t.setTrackScore(frame, 1.0-float(d[3])) l= readLine(f) print("")