コード例 #1
0
FrameID MultipleAvroFileWriter::add_frame(std::string name, FrameType t) {
  unsigned int index = get_number_of_frames();
  RMF_TRACE("Adding frame " << index << " under " << get_loaded_frame());
  set_loaded_frame(FrameID(index));
  frame_.name = name;
  frame_.type = boost::lexical_cast<std::string>(FrameType(t));
  if (get_loaded_frame() != FrameID()) {
    unsigned int findex = get_loaded_frame().get_index();
    frame_.parents.push_back(findex);
  }
  frames_dirty_ = true;
  frame_.index = index;
  return FrameID(index);
}
コード例 #2
0
FrameID getEntryFrame(UniverseID const &universe, TimeDirection direction)
{
    assert(getTimelineLength(universe) >= 0);
    switch (direction) {
    case TimeDirection::FORWARDS:
        return FrameID(0, universe);
    case TimeDirection::REVERSE:
        return FrameID(getTimelineLength(universe) - 1, universe);
    default:
        assert(false);
    }
    //Never reached
    return FrameID();
}
コード例 #3
0
ObjectSampleDataset* RecallDatabase::makeObjectSampleDataset(AppState &state, const string &objectName)
{
    cout << "Making object sample dataset for " << objectName << endl;
    ObjectSampleDataset *result = new ObjectSampleDataset(objectName);

    HistorySlotInfo slotInfo;
    for (auto &it : state.model.stateSpec.objects)
        slotInfo.objectNames.push_back(it.name);
    slotInfo.lines = HistoryMetricWeights().lines;

    for (auto &replay : state.replayDatabase.replays)
    {
        for (int baseFrameIndex = learningParams().historyFrames + 30; baseFrameIndex < replay->states.size() - 30 - learningParams().historyFrames; baseFrameIndex++)
        {
            ObjectSample *newSample = new ObjectSample;
            newSample->frame = FrameID(replay->replay->index, baseFrameIndex);
            newSample->history = computeObjectHistorySingleton(state, replay->states, baseFrameIndex, objectName, slotInfo);
            newSample->transition = computeObjectTransitionSingleton(replay->states, baseFrameIndex, objectName);
            newSample->nextAction = replay->states[baseFrameIndex + 1].action;
            
            vector<ObjectSample*> &hashList = result->samplesByHash[newSample->history.hash];
            hashList.push_back(newSample);

            result->allSamples.push_back(newSample);
        }
    }

    return result;
}
コード例 #4
0
void ObjectAnalyzer::trackFrames(const ReplayFrame &frameA, const ReplayFrame &frameB)
{
    map<int, ObjectTrack*> newTracks;

    vector<int> processedObjectsB(frameB.objectAnnotations.size());
    for (int &x : processedObjectsB)
        x = 0;

    for (int objectIndexA = 0; objectIndexA < frameA.objectAnnotations.size(); objectIndexA++)
    {
        const ObjectAnnotation &annotationA = frameA.objectAnnotations[objectIndexA];
        
        int objectBMatch = -1;
        int bestDist = learningParams().objectMotionRadius + 1;
        for (int objectIndexB = 0; objectIndexB < frameB.objectAnnotations.size(); objectIndexB++)
        {
            const ObjectAnnotation &annotationB = frameB.objectAnnotations[objectIndexB];
            if (annotationA.objectID == annotationB.objectID && processedObjectsB[objectIndexB] == 0)
            {
                const int xDiff = abs(annotationA.origin.x - annotationB.origin.x);
                const int yDiff = abs(annotationA.origin.y - annotationB.origin.y);
                const int dist = max(xDiff, yDiff);
                if (dist < bestDist)
                {
                    bestDist = dist;
                    objectBMatch = objectIndexB;
                }
            }
        }

        if (objectBMatch != -1)
        {
            processedObjectsB[objectBMatch] = 1;
            ObjectTrack *liveTrack = liveTracks[objectIndexA];

            liveTrack->track.push_back(objectBMatch);

            newTracks[objectBMatch] = liveTrack;
        }
    }

    for (int objectIndexB = 0; objectIndexB < frameB.objectAnnotations.size(); objectIndexB++)
    {
        const ObjectAnnotation &annotationB = frameB.objectAnnotations[objectIndexB];
        if (processedObjectsB[objectIndexB] == 0)
        {
            ObjectTrack *newTrack = new ObjectTrack;
            newTrack->startFrame = FrameID(liveReplayIndex, frameB.index);
            newTrack->track.push_back(objectIndexB);
            
            objects[annotationB.objectID].tracks.push_back(newTrack);

            newTracks[objectIndexB] = newTrack;
        }
    }

    liveTracks = newTracks;
}
コード例 #5
0
void ObjectAnalyzer::startTracking(const ReplayFrame &firstFrame, int replayIndex)
{
    liveReplayIndex = replayIndex;
    liveTracks.clear();

    for (int objectIndex = 0; objectIndex < firstFrame.objectAnnotations.size(); objectIndex++)
    {
        const ObjectAnnotation &o = firstFrame.objectAnnotations[objectIndex];
        
        ObjectTrack *newTrack = new ObjectTrack;
        newTrack->startFrame = FrameID(replayIndex, firstFrame.index);
        newTrack->track.push_back(objectIndex);
        objects[o.objectID].tracks.push_back(newTrack);

        liveTracks[objectIndex] = newTrack;
    }
}
コード例 #6
0
ファイル: SetCurrentFrame.cpp プロジェクト: salilab/imp
SetCurrentFrame::~SetCurrentFrame() {
    if (old_frame_ != FrameID()) {
        file_.set_current_frame(old_frame_);
    }
}
コード例 #7
0
FrameID getArbitraryFrame(UniverseID const &universe, int frameNumber)
{
    assert(getTimelineLength(universe) >= 0);
    return frameNumber < getTimelineLength(universe) && frameNumber >= 0 ? FrameID(frameNumber, universe) : FrameID();
}