From adcf41202603c96d3620eae8e64957f1aaf4d7d6 Mon Sep 17 00:00:00 2001 From: PierreGtch <pierre.guetschel@gmail.com> Date: Thu, 6 Jun 2019 17:50:16 +0200 Subject: [PATCH] Split decisions of searching for LC and creating features --- .../processor/processor_loopclosure_base2.h | 17 ++++------ src/processor/processor_loopclosure_base2.cpp | 32 ++++++++----------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/include/core/processor/processor_loopclosure_base2.h b/include/core/processor/processor_loopclosure_base2.h index 017420268..2a5f32347 100644 --- a/include/core/processor/processor_loopclosure_base2.h +++ b/include/core/processor/processor_loopclosure_base2.h @@ -21,6 +21,7 @@ struct ProcessorParamsLoopClosure2 : public ProcessorParamsBase * * This is an abstract class. * + You must define the following classes : + * - voteComputeFeatures() * - voteSearchLoopClosure() * - computeFeatures() * - findLoopCandidate() @@ -63,21 +64,15 @@ public: protected: - /** \brief Called by process(). Tells if processLoopClosure will be called + /** \brief Called by process(). Tells if computeFeatures() will be called */ - virtual bool voteSearchLoopClosure(CaptureBasePtr _incoming_ptr) = 0; + virtual bool voteComputeFeatures(CaptureBasePtr _incoming_ptr) = 0; - /** \brief Tries to close a loop + /** \brief Called by process(). Tells if findLoopCandidate() and createFactors() will be called * - * this method is called in process() if voteSearchLoopClosure retruns true - * this method uses : - * - selectPairKC() - * - computeFeatures() - * - findLoopCandidate() - * - validateLoop() - * - createFactors() + * WARNING : A LC can be searched only when voteComputeFeatures() return true */ - void processLoopClosure(void); + virtual bool voteSearchLoopClosure(CaptureBasePtr _incoming_ptr) = 0; /** \brief returns a KeyFrame-Capture pair compatible together (selected from the buffers) * diff --git a/src/processor/processor_loopclosure_base2.cpp b/src/processor/processor_loopclosure_base2.cpp index 7cc1483f8..e1360b49a 100644 --- a/src/processor/processor_loopclosure_base2.cpp +++ b/src/processor/processor_loopclosure_base2.cpp @@ -24,30 +24,26 @@ void ProcessorLoopClosureBase2::process(CaptureBasePtr _incoming_ptr) // the pre-process, if necessary, is implemented in the derived classes preProcess(); - if (voteSearchLoopClosure(_incoming_ptr)) + if (voteComputeFeatures(_incoming_ptr)) { - //CREAT_THREAD(function=processLoopClosure); - processLoopClosure(); + std::pair<FrameBasePtr,CaptureBasePtr> pairKC = selectPairKC(); + if (pairKC.first==nullptr || pairKC.second==nullptr) return; + computeFeatures(pairKC); + + if (voteSearchLoopClosure(_incoming_ptr)) + { + FrameBasePtr key_frame_1 = pairKC.first; + FrameBasePtr key_frame_2 = findLoopCandidate(key_frame_1); + if (key_frame_2==nullptr) return; + if (validateLoop(key_frame_1, key_frame_2)==false) return; + createFactors(key_frame_1, key_frame_2); + }; }; + // the post-process, if necessary, is implemented in the derived classes postProcess(); } -void ProcessorLoopClosureBase2::processLoopClosure() -{ - std::pair<FrameBasePtr,CaptureBasePtr> pairKC = selectPairKC(); - if (pairKC.first==nullptr || pairKC.second==nullptr) - return; - computeFeatures(pairKC); - FrameBasePtr key_frame_1 = pairKC.first; - FrameBasePtr key_frame_2 = findLoopCandidate(key_frame_1); - if (key_frame_2==nullptr) - return; - if (validateLoop(key_frame_1, key_frame_2)==false) - return; - createFactors(key_frame_1, key_frame_2); -} - /** * In the default implementation, we select the KF with the most recent TimeStamp * and that is compatible with at least a Capture -- GitLab