Skip to content

Problem with training new vectors for FAST features. #8

Description

@thesidjway

Hello @dorian3d,
First of all thank you for this great library.
I modified the demo.cpp in DBoW2 that works on Orb to train feature vectors in order to generate a vocabulary similar to the one used in DLoopDetector.

Here are the two functions I'm using:

void loadFeatures(vector<vector<BRIEF::bitset > > &features)
{
  features.clear();
  features.reserve(NIMAGES);

  cout << "Extracting BRIEF features..." << endl;
  for(int i = 1; i < 25; ++i)
  {
    stringstream ss;
    ss << "/home/thesidjway/train2/DBoW2/build/brief_train/frame" <<  setfill('0') << setw(4) << i << ".jpg";
    cout << ss.str() << endl;
    cv::Mat image = cv::imread(ss.str(), 0);
    cv::Mat mask;
    vector<cv::KeyPoint> keypoints, kpt;
    cv::Mat descriptors;
    vector<BRIEF::bitset> descriptors_1;
    DVision::BRIEF m_brief;
    cv::FAST(image, kpt, 20, true);
    m_brief.compute(image, kpt, descriptors_1);
    features.push_back(descriptors_1);
  }
}
void testVocCreation(const vector<vector<BRIEF::bitset > > &features)
{
  // branching factor and depth levels 
  const int k = 10;
  const int L = 6;
  const WeightingType weight = TF_IDF;
  const ScoringType score = L1_NORM;

  BriefVocabulary voc(k, L, weight, score);

  cout << "Creating a small " << k << "^" << L << " vocabulary..." << endl;
  voc.create(features);
  cout << "... done!" << endl;


  cout << "Vocabulary information: " << endl
  << voc << endl << endl;
  
  // save the vocabulary to disk
  cout << endl << "Saving vocabulary..." << endl;
  voc.save("/home/thesidjway/brief_k10L6_edited.voc.gz");
  cout << "Done" << endl;
}

The functions compile and run just fine and I am able to output a voc.gz file but when I import the file into the DLoopDetector, it just crashes.

Could you please help me in this regard?
Also can existing vocabularies be appended with new BoWvectors in any way?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions