Giter Site home page Giter Site logo

g2o_ba_example's Introduction

g2o_ba_example

An easy example of doing bundle adjustment within two images using g2o.

Require: g2o, OpenCV 2.4.x

The program reads two images from the data/1.png and data/2.png, then finds and matches orb key-points between them. After these, it uses g2o to estimate the relative motion between frames and the 3d positions (under a unknown scale).

This is an example written for the beginners of g2o and SLAM.

For more details please see the corresponding blog: http://www.cnblogs.com/gaoxiang12/p/5304272.html (in Chinese only).

g2o_ba_example's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

g2o_ba_example's Issues

编译错误

error: no match for call to ‘(cv::ORB) (const cv::Mat&, cv::Mat, std::vectorcv::KeyPoint&, cv::Mat&)’
orb( img1, cv::Mat(), kp1, desp1 );
error: no match for call to ‘(cv::ORB) (const cv::Mat&, cv::Mat, std::vectorcv::KeyPoint&, cv::Mat&)’
orb( img2, cv::Mat(), kp2, desp2 );
请求帮帮我。

About v->setMarginalized(true);

Hi,
Why here need set it as true? I am not familiar with marginalized out stuff. Will some one give me some advice to understand marginal covariance? Some materials? Thanks very much.

malloc(): memory corruption

~/Projects/g2o_ba_example/build$ ./ba_example 1.png 2.png
分别找到了500和500个特征点
找到了326组对应特征点。
*** Error in `./ba_example': malloc(): memory corruption: 0x000000000079f820 ***
Aborted (core dumped)

*** Error in `./ba_example': double free or corruption (out): 0x00000000014abcc0 ***

Strange problem, just those lines cause error:

  LOG(INFO) << "g2o optimizer done.";

  // 添加节点
  // 两个位姿节点
  for (int i = 0; i < 2; i++) {
    g2o::VertexSE3Expmap *v = new g2o::VertexSE3Expmap();
    v->setId(i);
    if (i == 0)
      v->setFixed(true); // 第一个点固定为零
    // 预设值为单位Pose,因为我们不知道任何信息
    v->setEstimate(g2o::SE3Quat());
    optimizer.addVertex(v);
  }
  // 很多个特征点的节点
  // 以第一帧为准
//  for (size_t i = 0; i < pts1.size(); i++) {
//    g2o::VertexSBAPointXYZ *v = new g2o::VertexSBAPointXYZ();
//    v->setId(2 + i);
//    // 由于深度不知道,只能把深度设置为1了
//    double z = 1;
//    double x = (pts1[i].x - cx) * z / fx;
//    double y = (pts1[i].y - cy) * z / fy;
//    v->setMarginalized(true);
//    v->setEstimate(Eigen::Vector3d(x, y, z));
//    optimizer.addVertex(v);
//  }

  LOG(INFO) << "vertex added.";

When I comment all rest codes, debug one by one, find that , only those lines codes cause error like this:

*** Error in `./ba_example': double free or corruption (out): 0x00000000014abcc0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fc8d66e07e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fc8d66e937a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fc8d66ed53c]
/usr/local/lib/libg2o_types_sba.so(_ZN3g2o26EdgeProjectP2MC_IntrinsicsD0Ev+0x2d)[0x7fc8d8cf6b0d]
/usr/local/lib/libg2o_core.so(_ZN3g2o7Factory12registerTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_32AbstractHyperGraphElementCreatorE+0x497)[0x7fc8d9188fd7]
/usr/local/lib/libg2o_types_sba.so(+0x20a3d)[0x7fc8d8ceea3d]
/lib64/ld-linux-x86-64.so.2(+0x106ca)[0x7fc8d93b96ca]
/lib64/ld-linux-x86-64.so.2(+0x107db)[0x7fc8d93b97db]
/lib64/ld-linux-x86-64.so.2(+0xc6a)[0x7fc8d93a9c6a]
======= Memory map: ========

Anybody knows why?

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.