def createProposals(mergedTracks, featSpat, cutOffLevel, xmax=np.inf, ymax=np.inf, regionSize=15): """create SingleTube proposals from the 'mergedTracks' clusters in trajectory clusters format""" # how many proposals nrProposals = mergedTracks.shape[0] # how many trajectory tracks nrTracks = featSpat.shape[0] zeroFound = True while zeroFound: # the list of tubes that will be created tubeLst = TubeList() # the list of tubes that will be sub-sampled selectedTubes = TubeList() # keep track of the nr of trajectories per merge nrTraj = np.zeros(nrProposals) nrTrajT1 = np.zeros(nrProposals) nrTrajT2 = np.zeros(nrProposals) for p in xrange(nrProposals): # clusterformat: a merged ID, and trackIDs t1 and t2 [mergedID, t1, t2] = mergedTracks[p][0:3] if t1 < nrTracks: # if a trackID is lower than nrTracks it is a trajectory tube1 = traj2tube(featSpat[t1,0], featSpat[t1,1:], xmax, ymax, regionSize) nrT1 = 1 else: # otherwise it is a previously merged proposal idx = int(t1) - nrTracks tube1 = tubeLst[idx] nrT1 = nrTraj[idx] if t2 < nrTracks: # if a trackID is lower than nrTracks it is a trajectory tube2 = traj2tube(featSpat[t2,0], featSpat[t2,1:], xmax, ymax, regionSize) nrT2 = 1 else: # otherwise it is a previously merged proposal idx = int(t2) - nrTracks tube2 = tubeLst[idx] nrT2 = nrTraj[idx] # the nr of trajectories of this merge nrTraj[p] = nrT1 + nrT2 nrTrajT1[p] = nrT1 nrTrajT2[p] = nrT2 # make a copy of t1 and merge it with t2 newTube = tube1.copy() newTube.merge(tube2) tubeLst.append(newTube) # if to subsample, add to the selected list if nrT1 >= cutOffLevel and nrT2 >= cutOffLevel: selectedTubes.append(newTube) if len(selectedTubes) == 0: cutOffLevel = cutOffLevel/2 if cutOffLevel <= 0: return selectedTubes else: return selectedTubes
def createProposals(mergedTracks, featSpat, cutOffLevel, xmax=np.inf, ymax=np.inf, regionSize=15): """create SingleTube proposals from the 'mergedTracks' clusters in trajectory clusters format""" # how many proposals nrProposals = mergedTracks.shape[0] # how many trajectory tracks nrTracks = featSpat.shape[0] zeroFound = True while zeroFound: # the list of tubes that will be created tubeLst = TubeList() # the list of tubes that will be sub-sampled selectedTubes = TubeList() # keep track of the nr of trajectories per merge nrTraj = np.zeros(nrProposals) nrTrajT1 = np.zeros(nrProposals) nrTrajT2 = np.zeros(nrProposals) for p in xrange(nrProposals): # clusterformat: a merged ID, and trackIDs t1 and t2 [mergedID, t1, t2] = mergedTracks[p][0:3] if t1 < nrTracks: # if a trackID is lower than nrTracks it is a trajectory tube1 = traj2tube(featSpat[t1, 0], featSpat[t1, 1:], xmax, ymax, regionSize) nrT1 = 1 else: # otherwise it is a previously merged proposal idx = int(t1) - nrTracks tube1 = tubeLst[idx] nrT1 = nrTraj[idx] if t2 < nrTracks: # if a trackID is lower than nrTracks it is a trajectory tube2 = traj2tube(featSpat[t2, 0], featSpat[t2, 1:], xmax, ymax, regionSize) nrT2 = 1 else: # otherwise it is a previously merged proposal idx = int(t2) - nrTracks tube2 = tubeLst[idx] nrT2 = nrTraj[idx] # the nr of trajectories of this merge nrTraj[p] = nrT1 + nrT2 nrTrajT1[p] = nrT1 nrTrajT2[p] = nrT2 # make a copy of t1 and merge it with t2 newTube = tube1.copy() newTube.merge(tube2) tubeLst.append(newTube) # if to subsample, add to the selected list if nrT1 >= cutOffLevel and nrT2 >= cutOffLevel: selectedTubes.append(newTube) if len(selectedTubes) == 0: cutOffLevel = cutOffLevel / 2 if cutOffLevel <= 0: return selectedTubes else: return selectedTubes