Skip to content

Commit

Permalink
more estimation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelchang committed Sep 12, 2019
1 parent 23ee5ad commit 327f2bf
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
23 changes: 23 additions & 0 deletions src/data/feature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,33 @@ Vector3d Feature::GetWorldPoint()
return worldPoint_;
}

Vector3d Feature::GetEstimatedWorldPoint()
{
if (worldPointEstimateCached_)
{
return worldPointEstimate_;
}
Vector3d worldFramePt = GetBearing();
bool wasCompressed = frame_.IsCompressed();
worldFramePt *= frame_.GetDepthImage().at<double>((int)(kpt_.pt.y + 0.5), (int)(kpt_.pt.x + 0.5));
if (wasCompressed)
{
frame_.CompressImages();
}
worldPointEstimate_ = util::TFUtil::TransformPoint(frame_.GetEstimatedPose(), worldFramePt);
worldPointEstimateCached_ = true;
return worldPointEstimate_;
}

bool Feature::HasWorldPoint() const
{
return frame_.HasPose() && frame_.HasDepthImage();
}

bool Feature::HasEstimatedWorldPoint() const
{
return frame_.HasEstimatedPose() && frame_.HasDepthImage();
}

}
}
4 changes: 4 additions & 0 deletions src/data/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ class Feature

Vector3d GetBearing() const;
Vector3d GetWorldPoint();
Vector3d GetEstimatedWorldPoint();
bool HasWorldPoint() const;
bool HasEstimatedWorldPoint() const;

bool worldPointCached_{false};
bool worldPointEstimateCached_{false};
private:
Frame &frame_;
cv::KeyPoint kpt_;
cv::Mat descriptor_;
Vector3d worldPoint_;
Vector3d worldPointEstimate_;
};

}
Expand Down
6 changes: 6 additions & 0 deletions src/data/landmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ void Landmark::AddObservation(Feature obs, bool compute_gnd)
groundTruth_ = obs.GetWorldPoint();
hasGroundTruth_ = true;
}
if (obs.HasEstimatedWorldPoint())
{
posEstimate_ = obs.GetEstimatedWorldPoint();
obsForEst_.push_back(obs);
hasPosEstimate_ = true;
}
}
if (idToIndex_.find(obs.GetFrame().GetID()) != idToIndex_.end())
{
Expand Down
20 changes: 10 additions & 10 deletions src/reconstruction/triangulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ bool Triangulator::TriangulateNViews(const std::vector<data::Feature> &views, Ve
{
Matrix<double, 3, 4> pose;
Matrix<double, 3, 4> invpose;
if (view.GetFrame().HasPose())
{
pose = view.GetFrame().GetInversePose();
invpose = view.GetFrame().GetPose();
}
else if (view.GetFrame().HasEstimatedPose())
if (view.GetFrame().HasEstimatedPose())
{
pose = view.GetFrame().GetEstimatedInversePose();
invpose = view.GetFrame().GetEstimatedPose();
}
else if (view.GetFrame().HasPose())
{
pose = view.GetFrame().GetInversePose();
invpose = view.GetFrame().GetPose();
}
else
{
continue;
Expand All @@ -74,13 +74,13 @@ bool Triangulator::CheckReprojectionErrors(const std::vector<data::Feature> &vie
for (const data::Feature &view : views)
{
Matrix<double, 3, 4> pose;
if (view.GetFrame().HasPose())
if (view.GetFrame().HasEstimatedPose())
{
pose = view.GetFrame().GetInversePose();
pose = view.GetFrame().GetEstimatedInversePose();
}
else if (view.GetFrame().HasEstimatedPose())
else if (view.GetFrame().HasPose())
{
pose = view.GetFrame().GetEstimatedInversePose();
pose = view.GetFrame().GetInversePose();
}
else
{
Expand Down

0 comments on commit 327f2bf

Please sign in to comment.