Skip to content

Commit

Permalink
Load the visible landmarks the first time each camera get active.
Browse files Browse the repository at this point in the history
  • Loading branch information
ALouis38 committed Jul 26, 2016
1 parent cd3f2f7 commit 8ece367
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions gui/MainWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class MainWindowPrivate
QString imagePath; // Full path to camera image data
QString depthMapPath; // Full path to depth map data
kwiver::vital::landmark_map::map_landmark_t *visibleLandmarks;
bool areVisibleLandmarksLoaded = false;
};

// Methods
Expand Down Expand Up @@ -427,6 +428,30 @@ void MainWindowPrivate::setActiveCamera(int id)
this->activeCameraIndex = id;
this->UI.worldView->setActiveCamera(this->cameras[id].camera);

//Load visible landmarks for the active camera once
if(!this->cameras[id].areVisibleLandmarksLoaded)
{

auto const& tracks = this->tracks->tracks();
foreach (auto const& track, tracks)
{
auto const& all_frame_ids = track->all_frame_ids();
if (all_frame_ids.count(id))
{
auto const& landmarkId = track->id();
auto const& landmark = this->landmarks->landmarks()[landmarkId];

if (landmark)
{
this->cameras[id].visibleLandmarks->insert(
std::make_pair(landmarkId, landmark));
}
}
}

this->cameras[id].areVisibleLandmarksLoaded = true;
}

this->updateCameraView();

this->UI.worldView->setVisibleLandmarks(kwiver::vital::simple_landmark_map(
Expand Down Expand Up @@ -835,27 +860,6 @@ void MainWindow::loadProject(QString const& path)
}
}

// Set visible landmarks for each cameras all at once
if (d->tracks)
{
auto const& tracks = d->tracks->tracks();
foreach (auto const& track, tracks)
{
auto const& all_frame_ids = track->all_frame_ids();
foreach (auto frame_id, all_frame_ids)
{
auto const& id = track->id();
auto const& landmark = d->landmarks->landmarks()[id];

if (landmark)
{
d->cameras[frame_id].visibleLandmarks->insert(
std::make_pair(id, landmark));
}
}
}
}

#ifdef VTKWEBGLEXPORTER
d->UI.actionWebGLScene->setEnabled(true);
#endif
Expand Down

0 comments on commit 8ece367

Please sign in to comment.