fix relocalization segfault

This commit is contained in:
Andre Phu-Van Nguyen
2015-02-03 20:14:17 -05:00
parent 1282a95dde
commit 30a43ccec6
2 changed files with 10 additions and 0 deletions
+5
View File
@@ -240,6 +240,11 @@ FrameHandlerMono::UpdateResult FrameHandlerMono::relocalizeFrame(
FramePtr ref_keyframe) FramePtr ref_keyframe)
{ {
SVO_WARN_STREAM_THROTTLE(1.0, "Relocalizing frame"); SVO_WARN_STREAM_THROTTLE(1.0, "Relocalizing frame");
if(ref_keyframe == nullptr)
{
SVO_INFO_STREAM("Relocalization successful.");
return RESULT_FAILURE;
}
SparseImgAlign img_align(Config::kltMaxLevel(), Config::kltMinLevel(), SparseImgAlign img_align(Config::kltMaxLevel(), Config::kltMinLevel(),
30, SparseImgAlign::GaussNewton, false, false); 30, SparseImgAlign::GaussNewton, false, false);
size_t img_align_n_tracked = img_align.run(ref_keyframe, new_frame_); size_t img_align_n_tracked = img_align.run(ref_keyframe, new_frame_);
+5
View File
@@ -130,6 +130,11 @@ FramePtr Map::getClosestKeyframe(const FramePtr& frame) const
{ {
list< pair<FramePtr,double> > close_kfs; list< pair<FramePtr,double> > close_kfs;
getCloseKeyframes(frame, close_kfs); getCloseKeyframes(frame, close_kfs);
if(close_kfs.empty())
{
return nullptr;
}
// Sort KFs with overlap according to their closeness // Sort KFs with overlap according to their closeness
close_kfs.sort(boost::bind(&std::pair<FramePtr, double>::second, _1) < close_kfs.sort(boost::bind(&std::pair<FramePtr, double>::second, _1) <