laurentkneip / opengv

OpenGV is a collection of computer vision methods for solving geometric vision problems. It is hosted and maintained by the Mobile Perception Lab of ShanghaiTech.
Other
1.01k stars 354 forks source link

double free or corruption (out) while using fivept_kneip #88

Open rakshith95 opened 5 years ago

rakshith95 commented 5 years ago

opengv::relative_pose::CentralRelativeAdapter adapter(bearing_vectors1, bearing_vectors2); vector< int > indices; for(int i=10;i<100;i+=20) indices.push_back(i); opengv::rotations_t R; R = opengv::relative_pose::fivept_kneip(adapter, indices); cout<<R.size()<<"\n";

Running this gives the following error: double free or corruption (out) Aborted (core dumped

Any idea why this happens?

samontab commented 5 years ago

Your compiler settings are not setup correctly.

If you look at the OpenGV CMakeLists.txt file you'll see that they add a few different definitions to compile the code correctly. Try compiling the tests by setting BUILD_TESTS=ON. You'll see that test_relative_pose uses fivept_kneip without any issues.

Add those definitions to your compilation and your code should run fine.

For example, if you're using cmake on a laptop, you just need to add this line to your CMakeLists.txt:

add_definitions(-march=native)

chutsu commented 4 years ago

IMO having -march=native is probably not a sensible default. Most people who use Eigen in their projects will probably not have that on by default, causing compilation to go through but Eigen to conk out during runtime when using OpenGV due to Eigen mismatch. (OpenGV compiled with optimized Eigen, against non-optimized user code).

I certainly got caught out and had spent some time on this issue. It would probably be best to either: