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

Fix upvote in voteForKeyframe

parent b8cabada
No related branches found
No related tags found
1 merge request!208Vision utils
...@@ -150,6 +150,13 @@ void ProcessorTracker::process(CaptureBasePtr const _incoming_ptr) ...@@ -150,6 +150,13 @@ void ProcessorTracker::process(CaptureBasePtr const _incoming_ptr)
{ {
processKnown(); processKnown();
// eventually add more features
if (last_ptr_->getFeatureList().size() < params_tracker_->min_features_for_keyframe)
{
WOLF_TRACE("Adding more features...");
processNew(params_tracker_->max_new_features);
  • Why are we doing processNew() if we haven't decided yet if a new KF is made?

  • Author Owner

    This is here to add more features in case there are less than required.

    We made it so that we can ramp up the number of features across several captures. It's like a workaround. I would like to not have to resort to these kind of things, but it may happen that we are low on features for a while, and a condition featureList()->size() < min_ftr_for_kf in voteForKf() would fire one new keyframe per capture while the scene is not showing enough features.

  • But it has no impact if a KF is not created since no factors are added and these tracks are starting in a non-key frame...

  • Author Owner

    Maybe...

    So how to tacke this situation where there are insufficient features, less than the necessary for a KF? The think is that we need to avoid the processor creating KFs stupidly

  • Auxiliary frames are the solution (temporary KF), but you need to add the frame to the solver in order to make these features work.

    Here, everything is based on the assumption of deciding KF (or auxiliary) in last. Maybe, this assumption is not fully applicable to the trifocal approach..

    Edited by Joan Vallvé Navarro
  • Author Owner

    No no, these frames do not go into solving... if there's no features the only thing is wait, but we need to keep detecting things to see if there are indeed features!!!

  • Author Owner

    Otherwise a processor that runs out of features is dead forever ! ??

  • If you run out of features, your problem gets disconnected. Apart from this drawback, the processor is not dead, whenever you (or other processor) create a KF, processNew() is called (and so detectNewFeatures()).

    I think that to handle the case in which no new features were detected in processNew(), we should add a check after calling it inside the if(voteForKeyFrame()...). Then, abort the KF creation if no new features were detected.

    But, now, this call to processNew() is dangerous because is not following the assumptions made in this function: (see comment from processor_tracker_feature.cpp)

    /* Rationale: A keyFrame will be created using the last Capture.
         * First, we work on the last Capture to detect new Features,
         * When done, we need to track these new Features to the incoming Capture.
         * At the end, all new Features are appended to the lists of known Features in
         * the last and incoming Captures.
         */
    Edited by Joan Vallvé Navarro
  • Author Owner

    Yes I agree it's not so good...

    The check inside voteForKf() is insufficient, since it is only done once. If not passed, next time you dont vote and you never test again.

    Unless you always vote when there are not enough features, but this destroys the logic of voting.

    And waiting for external KFs is not good either because there might not be any other sensor.

    Maybe this can be left to any one of the individual processors? I dont know how to tackle everything in the general case.

  • I do not understand why "If not passed, next time you dont vote and you never test again.", it depends on how the voteForKeyFrame() is implemented.. why "always vote when there are not enough features" destroys the logic of voting?

  • Please register or sign in to reply
}
if (voteForKeyFrame() && permittedKeyFrame()) if (voteForKeyFrame() && permittedKeyFrame())
{ {
// We create a KF // We create a KF
...@@ -164,9 +171,9 @@ void ProcessorTracker::process(CaptureBasePtr const _incoming_ptr) ...@@ -164,9 +171,9 @@ void ProcessorTracker::process(CaptureBasePtr const _incoming_ptr)
// process // process
processNew(params_tracker_->max_new_features); processNew(params_tracker_->max_new_features);
// Set key // // Set key
last_ptr_->getFramePtr()->setKey(); // last_ptr_->getFramePtr()->setKey();
//
// Set state to the keyframe // Set state to the keyframe
last_ptr_->getFramePtr()->setState(getProblem()->getState(last_ptr_->getTimeStamp())); last_ptr_->getFramePtr()->setState(getProblem()->getState(last_ptr_->getTimeStamp()));
...@@ -187,10 +194,6 @@ void ProcessorTracker::process(CaptureBasePtr const _incoming_ptr) ...@@ -187,10 +194,6 @@ void ProcessorTracker::process(CaptureBasePtr const _incoming_ptr)
{ {
// We do not create a KF // We do not create a KF
// eventually add more features
if (last_ptr_->getFeatureList().size() < params_tracker_->min_features_for_keyframe)
processNew(params_tracker_->max_new_features);
// Advance this // Advance this
last_ptr_->getFramePtr()->addCapture(incoming_ptr_); // Add incoming Capture to the tracker's last Frame last_ptr_->getFramePtr()->addCapture(incoming_ptr_); // Add incoming Capture to the tracker's last Frame
last_ptr_->remove(); last_ptr_->remove();
...@@ -207,6 +210,7 @@ void ProcessorTracker::process(CaptureBasePtr const _incoming_ptr) ...@@ -207,6 +210,7 @@ void ProcessorTracker::process(CaptureBasePtr const _incoming_ptr)
break; break;
} }
number_of_tracks_ = last_ptr_->getFeatureList().size();
postProcess(); postProcess();
} }
......
...@@ -89,6 +89,8 @@ class ProcessorTracker : public ProcessorBase ...@@ -89,6 +89,8 @@ class ProcessorTracker : public ProcessorBase
FeatureBaseList new_features_last_; ///< List of new features in \b last for landmark initialization and new key-frame creation. FeatureBaseList new_features_last_; ///< List of new features in \b last for landmark initialization and new key-frame creation.
FeatureBaseList new_features_incoming_; ///< list of the new features of \b last successfully tracked in \b incoming FeatureBaseList new_features_incoming_; ///< list of the new features of \b last successfully tracked in \b incoming
size_t number_of_tracks_;
public: public:
ProcessorTracker(const std::string& _type, ProcessorTracker(const std::string& _type,
ProcessorParamsTrackerPtr _params_tracker); ProcessorParamsTrackerPtr _params_tracker);
...@@ -194,6 +196,16 @@ class ProcessorTracker : public ProcessorBase ...@@ -194,6 +196,16 @@ class ProcessorTracker : public ProcessorBase
FeatureBaseList& getNewFeaturesListLast(); FeatureBaseList& getNewFeaturesListLast();
const size_t& previousNumberOfTracks() const
{
return number_of_tracks_;
}
size_t& previousNumberOfTracks()
{
return number_of_tracks_;
}
protected: protected:
void computeProcessingStep(); void computeProcessingStep();
......
...@@ -266,41 +266,24 @@ bool ProcessorTrackerFeatureTrifocal::correctFeatureDrift(const FeatureBasePtr _ ...@@ -266,41 +266,24 @@ bool ProcessorTrackerFeatureTrifocal::correctFeatureDrift(const FeatureBasePtr _
bool ProcessorTrackerFeatureTrifocal::voteForKeyFrame() bool ProcessorTrackerFeatureTrifocal::voteForKeyFrame()
{ {
// List of conditions
// // A. crossing voting threshold with ascending number of features
// bool vote_up = true;
// // 1. vote if we did not have enough features before
// vote_up = vote_up && (last_ptr_->getFeatureList().size() < params_tracker_feature_trifocal_->min_features_for_keyframe);
// // 2. vote if we have enough features now
// vote_up = vote_up && (incoming_ptr_->getFeatureList().size() >= params_tracker_feature_trifocal_->min_features_for_keyframe);
//
// // B. crossing voting threshold with descending number of features
// bool vote_down = true;
// // 1. vote if we had enough features before
// vote_down = vote_down && (last_ptr_->getFeatureList().size() >= params_tracker_feature_trifocal_->min_features_for_keyframe);
// // 2. vote if we have not enough features now
// vote_down = vote_down && (incoming_ptr_->getFeatureList().size() < params_tracker_feature_trifocal_->min_features_for_keyframe);
//
// FIX: This LIST are ALWAYS empty.
// WOLF_TRACE("getNewFeaturesListLast().size() ", getNewFeaturesListLast().size());
// WOLF_TRACE("getNewFeaturesListIncoming().size() ", getNewFeaturesListIncoming().size());
// A. crossing voting threshold with ascending number of features // A. crossing voting threshold with ascending number of features
bool vote_up = true; bool vote_up = true;
// 1. vote if we did not have enough features before // 1. vote if we did not have enough features before
vote_up = vote_up && (getNewFeaturesListLast().size() < params_tracker_feature_trifocal_->min_features_for_keyframe); vote_up = vote_up && (previousNumberOfTracks() < params_tracker_feature_trifocal_->min_features_for_keyframe);
// 2. vote if we have enough features now // 2. vote if we have enough features now
vote_up = vote_up && (getNewFeaturesListIncoming().size() >= params_tracker_feature_trifocal_->min_features_for_keyframe); vote_up = vote_up && (incoming_ptr_->getFeatureList().size() >= params_tracker_feature_trifocal_->min_features_for_keyframe);
// B. crossing voting threshold with descending number of features // B. crossing voting threshold with descending number of features
bool vote_down = true; bool vote_down = true;
// 1. vote if we had enough features before // 1. vote if we had enough features before
vote_down = vote_down && (getNewFeaturesListLast().size() >= params_tracker_feature_trifocal_->min_features_for_keyframe); vote_down = vote_down && (last_ptr_->getFeatureList().size() >= params_tracker_feature_trifocal_->min_features_for_keyframe);
// 2. vote if we have not enough features now // 2. vote if we have not enough features now
vote_down = vote_down && (getNewFeaturesListIncoming().size() < params_tracker_feature_trifocal_->min_features_for_keyframe); vote_down = vote_down && (incoming_ptr_->getFeatureList().size() < params_tracker_feature_trifocal_->min_features_for_keyframe);
if (vote_up)
WOLF_TRACE("VOTE UP");
if (vote_down)
WOLF_TRACE("VOTE DOWN");
return vote_up || vote_down; return vote_up || vote_down;
} }
......
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