hengli / camodocal

CamOdoCal: Automatic Intrinsic and Extrinsic Calibration of a Rig with Multiple Generic Cameras and Odometry
Other
1.18k stars 390 forks source link

bin/intrinsic_calib (core dumped) #65

Open dkoguciuk opened 7 years ago

dkoguciuk commented 7 years ago

Hello,

I wanted to use camodocal and I've started with examples provided with your package. Something went wrong on my PC so I've set up a clean virtual machine with Ubuntu 16.04 and also faced the problem below. I know it's something with EIGEN alignment, but before I'll dive into the code I thought maybe someone is already aware of it?

intrinsic_calib: /usr/include/eigen3/Eigen/src/Core/DenseStorage.h:128: Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 32>::plain_array() [with T = double; int Size = 4; int MatrixOrArrayOptions = 0]: Assertion `(reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & (31)) == 0 && "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !!! ****"' failed.
Aborted (core dumped)

For sake of completeness the whole verbose output of the program:

ubuntu@ubuntu-VirtualBox:~/camodocal/build$ bin/intrinsic_calib -i ../data/images/ -p img --camera-model mei --verbose
# INFO: Camera model: Mei
# INFO: Adding ../data/images/img117.bmp
# INFO: Adding ../data/images/img108.bmp
# INFO: Adding ../data/images/img84.bmp
# INFO: Adding ../data/images/img22.bmp
# INFO: Adding ../data/images/img115.bmp
# INFO: Adding ../data/images/img19.bmp
# INFO: Adding ../data/images/img110.bmp
# INFO: Adding ../data/images/img17.bmp
# INFO: Adding ../data/images/img52.bmp
# INFO: Adding ../data/images/img4.bmp
# INFO: Adding ../data/images/img42.bmp
# INFO: Adding ../data/images/img26.bmp
# INFO: Adding ../data/images/img53.bmp
# INFO: Adding ../data/images/img160.bmp
# INFO: Adding ../data/images/img77.bmp
# INFO: Adding ../data/images/img60.bmp
# INFO: Adding ../data/images/img111.bmp
# INFO: Adding ../data/images/img20.bmp
# INFO: Adding ../data/images/img55.bmp
# INFO: Adding ../data/images/img30.bmp
# INFO: Adding ../data/images/img5.bmp
# INFO: Adding ../data/images/img54.bmp
# INFO: Adding ../data/images/img56.bmp
# INFO: Adding ../data/images/img39.bmp
# INFO: Adding ../data/images/img113.bmp
# INFO: Adding ../data/images/img87.bmp
# INFO: Adding ../data/images/img61.bmp
# INFO: Adding ../data/images/img25.bmp
# INFO: Adding ../data/images/img148.bmp
# INFO: Adding ../data/images/img158.bmp
# INFO: Adding ../data/images/img139.bmp
# INFO: Adding ../data/images/img129.bmp
# INFO: Adding ../data/images/img131.bmp
# INFO: Adding ../data/images/img137.bmp
# INFO: Adding ../data/images/img69.bmp
# INFO: Adding ../data/images/img47.bmp
# INFO: Adding ../data/images/img159.bmp
# INFO: Adding ../data/images/img1.bmp
# INFO: Adding ../data/images/img82.bmp
# INFO: Adding ../data/images/img112.bmp
# INFO: Adding ../data/images/img136.bmp
# INFO: Adding ../data/images/img116.bmp
# INFO: Adding ../data/images/img79.bmp
# INFO: Adding ../data/images/img48.bmp
# INFO: Adding ../data/images/img32.bmp
# INFO: Adding ../data/images/img58.bmp
# INFO: Adding ../data/images/img23.bmp
# INFO: Adding ../data/images/img80.bmp
# INFO: Adding ../data/images/img83.bmp
# INFO: Adding ../data/images/img34.bmp
# INFO: Adding ../data/images/img18.bmp
# INFO: Adding ../data/images/img140.bmp
# INFO: Adding ../data/images/img149.bmp
# INFO: Adding ../data/images/img76.bmp
# INFO: Adding ../data/images/img2.bmp
# INFO: Adding ../data/images/img44.bmp
# INFO: Adding ../data/images/img45.bmp
# INFO: Adding ../data/images/img70.bmp
# INFO: Adding ../data/images/img0.bmp
# INFO: Adding ../data/images/img40.bmp
# INFO: Adding ../data/images/img78.bmp
# INFO: Adding ../data/images/img81.bmp
# INFO: Adding ../data/images/img85.bmp
# INFO: # images: 63
# INFO: Detected chessboard in image 1
# INFO: Detected chessboard in image 2
# INFO: Detected chessboard in image 3
# INFO: Detected chessboard in image 4
# INFO: Detected chessboard in image 5
# INFO: Did not detect chessboard in image 6
# INFO: Detected chessboard in image 7
# INFO: Did not detect chessboard in image 8
# INFO: Detected chessboard in image 9
# INFO: Detected chessboard in image 10
# INFO: Detected chessboard in image 11
# INFO: Detected chessboard in image 12
# INFO: Detected chessboard in image 13
# INFO: Detected chessboard in image 14
# INFO: Detected chessboard in image 15
# INFO: Detected chessboard in image 16
# INFO: Detected chessboard in image 17
# INFO: Detected chessboard in image 18
# INFO: Detected chessboard in image 19
# INFO: Did not detect chessboard in image 20
# INFO: Detected chessboard in image 21
# INFO: Detected chessboard in image 22
# INFO: Detected chessboard in image 23
# INFO: Detected chessboard in image 24
# INFO: Detected chessboard in image 25
# INFO: Detected chessboard in image 26
# INFO: Detected chessboard in image 27
# INFO: Detected chessboard in image 28
# INFO: Detected chessboard in image 29
# INFO: Detected chessboard in image 30
# INFO: Detected chessboard in image 31
# INFO: Detected chessboard in image 32
# INFO: Detected chessboard in image 33
# INFO: Detected chessboard in image 34
# INFO: Detected chessboard in image 35
# INFO: Detected chessboard in image 36
# INFO: Detected chessboard in image 37
# INFO: Did not detect chessboard in image 38
# INFO: Detected chessboard in image 39
# INFO: Detected chessboard in image 40
# INFO: Detected chessboard in image 41
# INFO: Detected chessboard in image 42
# INFO: Detected chessboard in image 43
# INFO: Detected chessboard in image 44
# INFO: Detected chessboard in image 45
# INFO: Detected chessboard in image 46
# INFO: Detected chessboard in image 47
# INFO: Detected chessboard in image 48
# INFO: Detected chessboard in image 49
# INFO: Detected chessboard in image 50
# INFO: Did not detect chessboard in image 51
# INFO: Detected chessboard in image 52
# INFO: Detected chessboard in image 53
# INFO: Detected chessboard in image 54
# INFO: Detected chessboard in image 55
# INFO: Detected chessboard in image 56
# INFO: Detected chessboard in image 57
# INFO: Detected chessboard in image 58
# INFO: Did not detect chessboard in image 59
# INFO: Detected chessboard in image 60
# INFO: Detected chessboard in image 61
# INFO: Detected chessboard in image 62
# INFO: Detected chessboard in image 63
# INFO: Calibrating...
[camera] # INFO: Initial reprojection error: 3.655 pixels
intrinsic_calib: /usr/include/eigen3/Eigen/src/Core/DenseStorage.h:128: Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 32>::plain_array() [with T = double; int Size = 4; int MatrixOrArrayOptions = 0]: Assertion `(reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & (31)) == 0 && "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !!! ****"' failed.
Aborted (core dumped)

And gdb backtrace:

Thread 1 "intrinsic_calib" received signal SIGABRT, Aborted.
0x00007fffee97a428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007fffee97a428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007fffee97c02a in __GI_abort () at abort.c:89
#2  0x00007fffee972bd7 in __assert_fail_base (fmt=<optimized out>, 
    assertion=assertion@entry=0x7ffff72d1318 "(reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & (31)) == 0 && \"this assertion is explained here: \" \"http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAss"..., file=file@entry=0x7ffff72d12e0 "/usr/include/eigen3/Eigen/src/Core/DenseStorage.h", line=line@entry=128, 
    function=function@entry=0x7ffff72d3420 <Eigen::internal::plain_array<double, 4, 0, 32>::plain_array()::__PRETTY_FUNCTION__> "Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 32>::plain_array() [with T = double; int Size = 4; int MatrixOrArrayOptions = 0]") at assert.c:92
#3  0x00007fffee972c82 in __GI___assert_fail (
    assertion=0x7ffff72d1318 "(reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & (31)) == 0 && \"this assertion is explained here: \" \"http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAss"..., file=0x7ffff72d12e0 "/usr/include/eigen3/Eigen/src/Core/DenseStorage.h", line=128, 
    function=0x7ffff72d3420 <Eigen::internal::plain_array<double, 4, 0, 32>::plain_array()::__PRETTY_FUNCTION__> "Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 32>::plain_array() [with T = double; int Size = 4; int MatrixOrArrayOptions = 0]") at assert.c:101
#4  0x00007ffff70d7fe3 in Eigen::internal::plain_array<double, 4, 0, 32>::plain_array (this=0x1fe2bf0) at /usr/include/eigen3/Eigen/src/Core/DenseStorage.h:128
#5  0x00007ffff70d22aa in Eigen::DenseStorage<double, 4, 4, 1, 0>::DenseStorage (this=0x1fe2bf0) at /usr/include/eigen3/Eigen/src/Core/DenseStorage.h:187
#6  0x00007ffff70d2b94 in Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 1, 0, 4, 1> >::PlainObjectBase (this=0x1fe2bf0) at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:457
#7  0x00007ffff70d06fe in Eigen::Matrix<double, 4, 1, 0, 4, 1>::Matrix (this=0x1fe2bf0) at /usr/include/eigen3/Eigen/src/Core/Matrix.h:259
#8  0x00007ffff70ce158 in Eigen::Quaternion<double, 0>::Quaternion (this=0x1fe2bf0) at /usr/include/eigen3/Eigen/src/Geometry/Quaternion.h:242
#9  0x00007fffec4bf9ec in camodocal::Transform::Transform (this=0x1fe2bf0) at /home/ubuntu/camodocal/src/sparse_graph/Transform.cc:6
#10 0x00007ffff71a402c in __gnu_cxx::new_allocator<camodocal::Transform>::construct<camodocal::Transform> (this=0x7fffffffcc90, __p=0x1fe2bf0) at /usr/include/c++/5/ext/new_allocator.h:120
#11 0x00007ffff71a2acc in std::allocator_traits<Eigen::aligned_allocator<camodocal::Transform> >::_S_construct<camodocal::Transform> (__a=..., __p=0x1fe2bf0) at /usr/include/c++/5/bits/alloc_traits.h:256
#12 0x00007ffff71a10aa in std::allocator_traits<Eigen::aligned_allocator<camodocal::Transform> >::construct<camodocal::Transform> (__a=..., __p=0x1fe2bf0) at /usr/include/c++/5/bits/alloc_traits.h:402
#13 0x00007ffff719f981 in std::__uninitialized_default_n_a<camodocal::Transform*, unsigned long, Eigen::aligned_allocator<camodocal::Transform> > (__first=0x1fe2bf0, __n=57, __alloc=...)
    at /usr/include/c++/5/bits/stl_uninitialized.h:623
#14 0x00007ffff719d975 in std::vector<camodocal::Transform, Eigen::aligned_allocator<camodocal::Transform> >::_M_default_initialize (this=0x7fffffffcc90, __n=57)
    at /usr/include/c++/5/bits/stl_vector.h:1311
#15 0x00007ffff719b235 in std::vector<camodocal::Transform, Eigen::aligned_allocator<camodocal::Transform> >::vector (this=0x7fffffffcc90, __n=57, __a=...) at /usr/include/c++/5/bits/stl_vector.h:279
#16 0x00007ffff7196bae in camodocal::CameraCalibration::optimize (this=0x7fffffffdb60, camera=..., rvecs=std::vector of length 57, capacity 57 = {...}, 
    tvecs=std::vector of length 57, capacity 57 = {...}) at /home/ubuntu/camodocal/src/calib/CameraCalibration.cc:471
#17 0x00007ffff71968cb in camodocal::CameraCalibration::calibrateHelper (this=0x7fffffffdb60, camera=..., rvecs=std::vector of length 57, capacity 57 = {...}, 
    tvecs=std::vector of length 57, capacity 57 = {...}) at /home/ubuntu/camodocal/src/calib/CameraCalibration.cc:450
#18 0x00007ffff719425c in camodocal::CameraCalibration::calibrate (this=0x7fffffffdb60) at /home/ubuntu/camodocal/src/calib/CameraCalibration.cc:75
#19 0x0000000000489879 in main (argc=8, argv=0x7fffffffddb8) at /home/ubuntu/camodocal/src/examples/intrinsic_calib.cc:198

The instructions I've used to set up the virtual machine:

sudo add-apt-repository ppa:bzindovic/suitesparse-bugfix-1319687
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install cmake cmake-curses-gui git libboost-all-dev python-pip virtualbox-guest-utils libyaml-cpp-dev qtcreator libopenblas-dev libeigen3-dev libgoogle-glog-dev libatlas-base-dev libsuitesparse-dev libsuitesparse-dev libblas-dev liblapack-dev liblapacke-dev

cd
git clone https://github.com/opencv/opencv_contrib.git
git clone http://github.com/opencv/opencv.git
cd opencv && mkdir build && cd build
cmake -DOPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -DBUILD_opencv_legacy=OFF ../
make
sudo make install

cd 
git clone https://github.com/ceres-solver/ceres-solver.git
cd ceres-solver && mkdir build && cd build
cmake ../
make
sudo make install
dkoguciuk commented 7 years ago

It seems like to be an Eigen bug (?). After installation of Eigen 3.2.10 there is no core dumped anymore, but for every version above (I've checked 3.3.0, 3.3.1, 3.3.2 and most recent 3.3.3) the error is present. I am not patient enough to track the problem, just switching to 3.2.10.

russelldj commented 5 years ago

Installing eigen 3.2.10 from here and pointing cmake at it worked for me as well.

HViktorTsoi commented 3 years ago

I'm using Eigen 3.3.4, Ubuntu 18.04, and run into the same issue.

Modify camodocal/cmake/BuildConfigGCC.cmake
https://github.com/hengli/camodocal/blob/b399fa9ee81b5182e59f717e67a8ddd6503cdcb4/cmake/BuildConfigGCC.cmake#L45

else(APPLE)
add_compiler_flags("    -g -ggdb -D_DEBUG -march=native" Debug          CACHE)
add_compiler_flags("             -DNDEBUG -march=native" ReleaseAll     CACHE)
add_compiler_flags("-O2                   -march=native" Release        CACHE)
add_compiler_flags("-O2 -g -ggdb          -march=native" RelWithDebInfo CACHE)
add_compiler_flags("-Os                   -march=native" MinSizeRel     CACHE)

to

else(APPLE)
add_compiler_flags("    -g -ggdb -D_DEBUG" Debug          CACHE)
add_compiler_flags("             -DNDEBUG" ReleaseAll     CACHE)
add_compiler_flags("-O2                  " Release        CACHE)
add_compiler_flags("-O2 -g -ggdb         " RelWithDebInfo CACHE)
add_compiler_flags("-Os                  " MinSizeRel     CACHE)

Remove the -march=native flag, solved this problem.