Beispiel #1
0
def SaveState(paramFile, params, volumeFile, volume, origTrackFile,
              filtTrackFile, tracks, falarms, polygonfile, polygons):
    # Do I need to update the Params?
    volume['volume_data'] = SortVolume(volume['volume_data'])
    TrackFileUtils.SaveCorners(volumeFile,
                               volume['corner_filestem'],
                               volume['volume_data'],
                               path=os.path.dirname(volumeFile))
    ParamUtils.SaveConfigFile(paramFile, params)
    TrackFileUtils.SaveTracks(origTrackFile, tracks, falarms)
    TrackFileUtils.SaveTracks(filtTrackFile, tracks, falarms)

    # TODO: Save polygons in a better format
    dump(polygons, open(polygonfile, 'wb'))
Beispiel #2
0
def track_wrap(f):
    def perform_tracking(trackRun,
                         simParams,
                         trackParams,
                         returnResults=True,
                         path='.'):
        dirName = path
        cornerInfo = TrackFileUtils.ReadCorners(os.path.join(
            dirName, simParams['inputDataFile']),
                                                path=dirName)

    if len(cornerInfo['volume_data']) <= 1:
        raise Exception("Not enough frames for tracking: %d" %
                        len(cornerInfo['volume_data']))

    lasttime = _load_times(simParams, cornerInfo['volume_data'])

    tracks, falarms = f(trackParams, lasttime)

    TrackUtils.CleanupTracks(tracks, falarms)
    TrackFileUtils.SaveTracks(
        os.path.join(dirName, simParams['result_file'] + "_" + trackRun),
        tracks, falarms)

    if returnResults:
        return tracks, falarms
Beispiel #3
0
def SCIT_Track(trackRun, simParams, trackParams, returnResults=True, path='.'):

    dirName = path
    cornerInfo = TrackFileUtils.ReadCorners(os.path.join(
        dirName, simParams['inputDataFile']),
                                            path=dirName)
    if simParams['frameCnt'] <= 1:
        raise Exception("Not enough frames for tracking: %d" %
                        simParams['frameCnt'])

    lasttime = _load_times(simParams, cornerInfo['volume_data'])

    import scit

    speedThresh = float(trackParams['speedThresh'])
    framesBack = int(trackParams['framesBack'])
    default_dir = float(trackParams['default_dir'])
    default_spd = float(trackParams['default_spd'])

    stateHist = []
    strmTracks = []
    infoTracks = []

    strmAdap = {
        'spdThresh': speedThresh,
        'framesBack': framesBack,
        'default_dir': default_dir,
        'default_spd': default_spd,
        'max_timestep': 15.0
    }

    frameOffset = cornerInfo['volume_data'][0]['frameNum']

    for aVol in cornerInfo['volume_data']:
        currtime = aVol['volTime']
        tDelta = currtime - lasttime
        lasttime = currtime
        scit.TrackStep_SCIT(strmAdap, stateHist, strmTracks, infoTracks, aVol,
                            tDelta, frameOffset)

    scit.EndTracks(stateHist, strmTracks)

    falarms = []
    TrackUtils.CleanupTracks(strmTracks, falarms)
    TrackFileUtils.SaveTracks(
        os.path.join(dirName, simParams['result_file'] + "_" + trackRun),
        strmTracks, falarms)

    if returnResults:
        return strmTracks, falarms
Beispiel #4
0
def ASCIT_Track(trackRun,
                simParams,
                trackParams,
                returnResults=True,
                path='.'):
    import ascit
    dirName = path
    cornerInfo = TrackFileUtils.ReadCorners(os.path.join(
        dirName, simParams['inputDataFile']),
                                            path=dirName)
    speedThresh = float(trackParams['speedThresh'])
    default_spd = float(trackParams['default_spd'])

    if simParams['frameCnt'] <= 1:
        raise Exception("Not enough frames for tracking: %d" %
                        simParams['frameCnt'])

    lasttime = _load_times(simParams, cornerInfo['volume_data'])

    t = ascit.ASCIT(framesBack=int(trackParams['framesBack']),
                    default_dir=float(trackParams['default_dir']))
    for aVol in cornerInfo['volume_data']:
        currtime = aVol['volTime']
        tDelta = currtime - lasttime
        t.distThresh = speedThresh * tDelta
        t._default_spd = default_spd * tDelta
        t.TrackStep(aVol, tDelta)
        lasttime = currtime

    # Tidy up tracks because there won't be any more data
    t.finalize()

    tracks = t.tracks
    falarms = []
    TrackUtils.CleanupTracks(tracks, falarms)
    TrackFileUtils.SaveTracks(
        os.path.join(dirName, simParams['result_file'] + "_" + trackRun),
        tracks, falarms)

    if returnResults:
        return tracks, falarms