Code Monkey home page Code Monkey logo

Comments (4)

 avatar commented on July 4, 2024

I solved the problem by extracting timestamp information, which are used as key frames! :D

from orb_slam2.

riematrix avatar riematrix commented on July 4, 2024

@dk683 hi, could you please make a brief instruction on how you did this? I mean what is the format of your data(tum or ros .bag)? How to extract timestamp of the video/images?

from orb_slam2.

 avatar commented on July 4, 2024

Hello @riematrix. My data format is .bag.
I added the following function to src.System.cc. The following function will save timestamp & pose of key-frames to .txt files.

P.S. Please don't forget to call the added function in a ros file, e.g., ROS/ORB_SLAM2/src/ros_mono.cc.

Cheers!

void System::keyFrameTimeStamp_sim3(const string &timestampFile, const string &sim3File) {
  cout << endl << "Saving keyFrameTimeStamp_sim3 to " << timestampFile << " & " << sim3File << " ..." << endl;

  vector<KeyFrame*> vpKFs = mpMap->GetAllKeyFrames();
  sort(vpKFs.begin(),vpKFs.end(),KeyFrame::lId);

  // Transform all keyframes so that the first keyframe is at the origin.
  // After a loop closure the first keyframe might not be at the origin.
  ofstream f1;
  f1.open(timestampFile.c_str());
  f1 << fixed;

  ofstream f2;
  f2.open(sim3File.c_str());
  f2 << fixed;

  // For all keyframes
  for(size_t i=0; i<vpKFs.size(); i++) {
      KeyFrame* pKF = vpKFs[i];

      if(pKF->isBad())
          continue;

      // timestamp
      f1 << setprecision(6) << pKF->mTimeStamp << endl;

      // sim3
      cv::Mat pose = pKF->GetPose();

      f2 << setprecision(8) << pose.at<float>(0,0) << " " << pose.at<float>(0,1)  << " " << pose.at<float>(0,2) << " "  << pose.at<float>(0,3) << endl <<
                               pose.at<float>(1,0) << " " << pose.at<float>(1,1)  << " " << pose.at<float>(1,2) << " "  << pose.at<float>(1,3) << endl <<
                               pose.at<float>(2,0) << " " << pose.at<float>(2,1)  << " " << pose.at<float>(2,2) << " "  << pose.at<float>(2,3) << endl <<
                               pose.at<float>(3,0) << " " << pose.at<float>(3,1)  << " " << pose.at<float>(3,2) << " "  << pose.at<float>(3,3) << endl;
  }

  f1.close();
  f2.close();
  cout << endl << "timestamp & sim3 saved!" << endl;
}

from orb_slam2.

riematrix avatar riematrix commented on July 4, 2024

@dk683 Thank you! I'd like to try this out.

from orb_slam2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.