From 3992e4f70fd24c501cfb437a1713b701efe6322f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joan=20Vallv=C3=A9=20Navarro?= <jvallve@iri.upc.edu>
Date: Mon, 17 Jun 2019 15:13:40 +0200
Subject: [PATCH] bug fix described in the corresponding issue

---
 src/processor/processor_motion.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp
index 02b975499..a33fcde2c 100644
--- a/src/processor/processor_motion.cpp
+++ b/src/processor/processor_motion.cpp
@@ -96,7 +96,6 @@ void ProcessorMotion::process(CaptureBasePtr _incoming_ptr)
 
     switch(processing_step_)
     {
-
         case RUNNING_WITHOUT_PACK :
         case RUNNING_WITH_PACK_ON_ORIGIN :
             break;
@@ -658,6 +657,10 @@ PackKeyFramePtr ProcessorMotion::computeProcessingStep()
 
     PackKeyFramePtr pack = buffer_pack_kf_.selectFirstPackBefore(last_ptr_, params_motion_->time_tolerance);
 
+    // ignore "future" KF to avoid MotionBuffer::split() error
+    if (pack && pack->key_frame->getTimeStamp() > last_ptr_->getBuffer().get().back().ts_)
+        pack = nullptr;
+
     if (pack)
     {
         if (buffer_pack_kf_.checkTimeTolerance(pack->key_frame->getTimeStamp(), pack->time_tolerance, origin_ptr_->getTimeStamp(), params_motion_->time_tolerance))
-- 
GitLab