From 210490177dc29ad1f85d8ae7f7bb11e6c55abb56 Mon Sep 17 00:00:00 2001
From: PierreGtch <pierre.guetschel@gmail.com>
Date: Wed, 19 Jun 2019 11:25:59 +0200
Subject: [PATCH] ProcessorLoopClosureBase test if the two captures are linked
 to kf of come from the same kf

---
 src/processor/processor_loopclosure_base.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/processor/processor_loopclosure_base.cpp b/src/processor/processor_loopclosure_base.cpp
index 04408df13..242f2b445 100644
--- a/src/processor/processor_loopclosure_base.cpp
+++ b/src/processor/processor_loopclosure_base.cpp
@@ -34,8 +34,16 @@ void ProcessorLoopClosureBase::process(CaptureBasePtr _incoming_ptr)
         {
             CaptureBasePtr capture_1 = pairKC.second;
             CaptureBasePtr capture_2 = findLoopCandidate(capture_1);
-            if (capture_2==nullptr) return;
-            if (validateLoop(capture_1, capture_2)==false) return;
+            if (validateLoop(capture_1, capture_2)==false)  return;
+            if (capture_2==nullptr)                         return;
+            if (capture_1->getFrame() == nullptr || capture_2->getFrame() == nullptr) {
+                WOLF_WARN("ProcessorLoopClosureBase : tried to close a loop with captures linked to no KF");
+                return;
+            };
+            if (capture_1->getFrame() == capture_2->getFrame()) {
+                WOLF_WARN("ProcessorLoopClosureBase : findLoopCandidate() returned two captures of the same frame");
+                return;
+            };
             createFactors(capture_1, capture_2);
         };
     };
-- 
GitLab