Skip to content
Snippets Groups Projects
Commit 2350ca94 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

Fix wrong incoming pointer and evaluation logic

parent 318003ab
No related branches found
No related tags found
1 merge request!157Kfpackmanager
This commit is part of merge request !157. Comments created here will be created in the context of that merge request.
......@@ -92,14 +92,25 @@ KFPackPtr KFPackBuffer::selectPack(const TimeStamp& _time_stamp, const Scalar& _
KFPackBuffer::Iterator post = container_.upper_bound(_time_stamp);
KFPackBuffer::Iterator prev = container_.end();
if (container_.empty())
return nullptr;
bool check_post = (post != container_.end());
if (post != container_.begin())
{
prev = std::prev(post);
if (!checkTimeTolerance(prev->first, prev->second->time_tolerance, _time_stamp, _time_tolerance) && checkTimeTolerance(post->first, post->second->time_tolerance, _time_stamp, _time_tolerance))
if (!checkTimeTolerance(prev->first, prev->second->time_tolerance, _time_stamp, _time_tolerance)
&& check_post
&& checkTimeTolerance(post->first, post->second->time_tolerance, _time_stamp, _time_tolerance))
return post->second;
else if (checkTimeTolerance(prev->first, prev->second->time_tolerance, _time_stamp, _time_tolerance) && !checkTimeTolerance(post->first, post->second->time_tolerance, _time_stamp, _time_tolerance))
else if (checkTimeTolerance(prev->first, prev->second->time_tolerance, _time_stamp, _time_tolerance)
&& check_post
&& !checkTimeTolerance(post->first, post->second->time_tolerance, _time_stamp, _time_tolerance))
return prev->second;
else if (checkTimeTolerance(prev->first, prev->second->time_tolerance, _time_stamp, _time_tolerance) && checkTimeTolerance(post->first, post->second->time_tolerance, _time_stamp, _time_tolerance))
else if (checkTimeTolerance(prev->first, prev->second->time_tolerance, _time_stamp, _time_tolerance)
&& check_post
&& checkTimeTolerance(post->first, post->second->time_tolerance, _time_stamp, _time_tolerance))
{
if (std::fabs((*post).first - _time_stamp) < std::fabs((*prev).first - _time_stamp))
return post->second;
......
......@@ -52,11 +52,11 @@ void ProcessorTracker::process(CaptureBasePtr const _incoming_ptr)
}
// Select using incoming_ptr
pack = kf_pack_buffer_.selectPack( incoming_ptr_->getTimeStamp(), time_tolerance_ );
pack = kf_pack_buffer_.selectPack( _incoming_ptr->getTimeStamp(), time_tolerance_ );
if (pack!=nullptr)
{
keyFrameCallback(pack->key_frame,pack->time_tolerance);
kf_pack_buffer_.removeUpTo( incoming_ptr_->getTimeStamp() );
kf_pack_buffer_.removeUpTo( _incoming_ptr->getTimeStamp() );
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment