import pfpy def pfNodeName(): return 'Filter tracks' def main(): # how many trackers? num= pfpy.getNumTrackers() # loop over every tracker idx= 0 while (idx < num): # fetch a reference to this tracker t= pfpy.getTrackerRef(idx) # copy tracker so that we can read from it without the data being affected by writing to it as well t2= t.copy() # loop over every frame inp= t.getInPoint(); outp= t.getOutPoint(); f= inp; while (f <= outp): # is the tracker visible in these 3 adjacent frames? if t.getHidden(f-1) == False and \ t.getHidden(f) == False and \ t.getHidden(f+1) == False : # fetch tracker positions in each frame (read from the copy) lp= t2.getTrackPosition(f-1) cp= t2.getTrackPosition(f) np= t2.getTrackPosition(f+1) # store averaged tracker position t.setTrackPosition(f, (lp[0]+cp[0]+np[0])/3.0, (lp[1]+cp[1]+np[1])/3.0) f += 1 # free the copied tracker data t2.freeCopy() idx += 1 print("filtered ", num, " trackers")