diff --git a/include/core/processor/processor_base.h b/include/core/processor/processor_base.h index 8d6e0894e320caa31882652a254bca8ad885745e..c5078c10fec051901557c67172598714e7e5fe0e 100644 --- a/include/core/processor/processor_base.h +++ b/include/core/processor/processor_base.h @@ -159,7 +159,7 @@ public: * Check if the time distance between two time stamps is smaller than * the time tolerance. */ - static bool simpleCheckTimeTolerance(const TimeStamp& _time_stamp1, const TimeStamp& _time_stamp2, const double& _time_tolerance); + static bool checkTimeTolerance(const TimeStamp& _time_stamp1, const TimeStamp& _time_stamp2, const double& _time_tolerance); /**\brief Check time tolerance * @@ -449,13 +449,13 @@ typename Buffer<T>::Iterator Buffer<T>::selectIterator(const TimeStamp& _time_st bool prev_exists = (post != container_.begin()); bool post_exists = (post != container_.end()); - bool post_ok = post_exists && simpleCheckTimeTolerance(post->first, _time_stamp, _time_tolerance); + bool post_ok = post_exists && checkTimeTolerance(post->first, _time_stamp, _time_tolerance); if (prev_exists) { Buffer<T>::Iterator prev = std::prev(post); - bool prev_ok = simpleCheckTimeTolerance(prev->first, _time_stamp, _time_tolerance); + bool prev_ok = checkTimeTolerance(prev->first, _time_stamp, _time_tolerance); if (prev_ok && !post_ok) return prev; @@ -507,7 +507,7 @@ T Buffer<T>::selectFirstBefore(const TimeStamp& _time_stamp, const double& _time return container_.begin()->second; // Return first element if despite being newer, it is within the time tolerance - if (simpleCheckTimeTolerance(container_.begin()->first, _time_stamp, _time_tolerance)) + if (checkTimeTolerance(container_.begin()->first, _time_stamp, _time_tolerance)) return container_.begin()->second; // otherwise return nullptr (no element before the provided ts or within the tolerance was found) @@ -528,7 +528,7 @@ T Buffer<T>::selectLastAfter(const TimeStamp& _time_stamp, const double& _time_t return container_.rbegin()->second; // Return last element if despite being older, it is within the time tolerance - if (simpleCheckTimeTolerance(container_.rbegin()->first, _time_stamp, _time_tolerance)) + if (checkTimeTolerance(container_.rbegin()->first, _time_stamp, _time_tolerance)) return container_.rbegin()->second; // otherwise return nullptr (no element after the provided ts or within the tolerance was found) @@ -614,7 +614,7 @@ inline bool Buffer<T>::doubleCheckTimeTolerance(const TimeStamp& _time_stamp1, } template <typename T> -inline bool Buffer<T>::simpleCheckTimeTolerance(const TimeStamp& _time_stamp1, +inline bool Buffer<T>::checkTimeTolerance(const TimeStamp& _time_stamp1, const TimeStamp& _time_stamp2, const double& _time_tolerance) { diff --git a/include/core/processor/processor_tracker.h b/include/core/processor/processor_tracker.h index 21560a5b2808d96a507faab816b9f35c87a30066..b12779a2e8190d7075fb12829248ecd7974edcde 100644 --- a/include/core/processor/processor_tracker.h +++ b/include/core/processor/processor_tracker.h @@ -308,7 +308,7 @@ inline FeatureBasePtrList& ProcessorTracker::getNewFeaturesListIncoming() inline bool ProcessorTracker::checkTimeTolerance(const TimeStamp& _ts1, const TimeStamp& _ts2) { - return (std::fabs(_ts2 - _ts2) < params_tracker_->time_tolerance); + return buffer_frame_.checkTimeTolerance(_ts1, _ts2, params_tracker_->time_tolerance); } inline bool ProcessorTracker::checkTimeTolerance(const CaptureBasePtr _cap, const TimeStamp& _ts) diff --git a/src/processor/processor_motion.cpp b/src/processor/processor_motion.cpp index 78d99903a18eeaa75fa81599c52aad95fbac66be..e25430f5fbc428029f54bd16f5d724414bd4de1a 100644 --- a/src/processor/processor_motion.cpp +++ b/src/processor/processor_motion.cpp @@ -930,7 +930,7 @@ FrameBasePtr ProcessorMotion::computeProcessingStep() if (keyframe_from_callback) { - if (buffer_frame_.simpleCheckTimeTolerance(keyframe_from_callback->getTimeStamp(), + if (buffer_frame_.checkTimeTolerance(keyframe_from_callback->getTimeStamp(), incoming_ptr_->getTimeStamp(), params_motion_->time_tolerance)) { @@ -966,7 +966,7 @@ FrameBasePtr ProcessorMotion::computeProcessingStep() if (keyframe_from_callback) { - if (buffer_frame_.simpleCheckTimeTolerance(keyframe_from_callback->getTimeStamp(), + if (buffer_frame_.checkTimeTolerance(keyframe_from_callback->getTimeStamp(), origin_ptr_->getTimeStamp(), params_motion_->time_tolerance))