Beispiel #1
0
 def perform_tracking(trackRun,
                      simParams,
                      trackParams,
                      returnResults=True,
                      path='.'):
     dirName = path
     cornerInfo = TrackFileUtils.ReadCorners(os.path.join(
         dirName, simParams['inputDataFile']),
                                             path=dirName)
Beispiel #2
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 #3
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
Beispiel #4
0
def main(args):
    dirName = os.path.join(args.path, args.scenario)

    paramFile = os.path.join(dirName, "simParams.conf")

    if os.path.exists(paramFile):
        sceneParams = ParamUtils.ReadSimulationParams(paramFile)
    else:
        sceneParams = dict()
        sceneParams.update(ParamUtils.simDefaults)
        sceneParams.update(ParamUtils.trackerDefaults)

        sceneParams.pop('seed')
        sceneParams.pop('totalTracks')
        sceneParams.pop('endTrackProb')
        sceneParams.pop('simConfFile')

        sceneParams['simName'] = args.scenario

    origTrackFile = os.path.join(dirName, sceneParams['simTrackFile'])
    filtTrackFile = os.path.join(dirName, sceneParams['noisyTrackFile'])
    volumeFile = os.path.join(dirName, sceneParams['inputDataFile'])
    volumeLoc = os.path.dirname(volumeFile)

    tracks, falarms = [], []

    if os.path.exists(origTrackFile):
        tracks, falarms = TrackFileUtils.ReadTracks(origTrackFile)

    volume = dict(frameCnt=0,
                  corner_filestem=sceneParams['corner_file'],
                  volume_data=[])
    if os.path.exists(volumeFile):
        # dictionary with "volume_data", "frameCnt", "corner_filestem"
        #    and "volume_data" contains a list of dictionaries with
        #    "volTime", "frameNum", "stormCells" where "stormCells" is
        #    a numpy array of dtype corner_dtype
        volume = TrackFileUtils.ReadCorners(volumeFile, volumeLoc)
        sceneParams['corner_file'] = volume['corner_filestem']

    # TODO: Temporary!
    # I would rather not do pickling, but I am pressed for time.
    # Plus, if I intend to make it a part of the ZigZag system,
    # then the name should be stored in the parameters file.
    polygonfile = os.path.join(dirName, "polygons.foo")
    polygons = {}

    if os.path.exists(polygonfile):
        polygons = load(open(polygonfile, 'rb'))

    do_save, state = AnalyzeRadar(volume, tracks, falarms, polygons,
                                  args.input_files)

    if do_save:
        # Create the directory if it doesn't exist already
        if not os.path.exists(dirName):
            makedirs(dirName)

        tracks, falarms, volume, polygons = state.save_features()
        volume['corner_filestem'] = sceneParams['corner_file']

        # Final save
        SaveState(paramFile, sceneParams, volumeFile, volume, origTrackFile,
                  filtTrackFile, tracks, falarms, polygonfile, polygons)