diff --git a/include/core/processor/processor_loopclosure_base2.h b/include/core/processor/processor_loopclosure_base2.h index 017420268d7372bea3fd9473445c35438fb63e5a..2a5f323475d9ce6032abe070589b5fde1c739cf4 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 7cc1483f8b2a8cffa22fcecbc6a35fffbda5e0cc..e1360b49a7957703139cfd0c68d8059b157e275e 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