前言
笔者因为需要使用g2o的python版本解决优化问题,所以就要安装g2opy。但由于安装过程中的一些细节和依赖版本出现偏差,容易导致安装失败。这里,笔者就将这几天调试成功的过程进行总结q(≧▽≦q)
参考链接
uoip/g2opy
Sologala/g2opy
调试环境
Google colab(自己电脑内存不足QAQ)
整体代码
git clone https://github.com/uoip/g2opy.git
cd g2opy
mkdir build
cd build
cmake ..
make -j8
cd ..
python setup.py install
下载源码
!git clone https://github.com/uoip/g2opy.git
下载相关依赖
cmake和Eigin下载
!apt-get install cmake libeigen3-dev
!apt-get install libsuitesparse-dev
!apt-get install qtdeclarative5-dev qt5-qmake
!apt-get install qtdeclarative5-dev qt5-qmake libqglviewer-headers
几个依赖的版本总结
pybind11 v2.9.1
Python v3.7
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
Eigin v3.3.4-4
Cmake v3.22.5
Make
cd g2opy
!mkdir build
cd build
!cmake -DPYBIND11_PYTHON_VERSION=3.7 ..
注意:为了防止出现以下的Bug,所以需要指定上-DPYBIND11_PYTHON_VERSION
Cmake结果
!make -j8
在make到96%和99%的时候会出现一些提示,如果是如下的提示可以完全忽略。
make到【99%】到【100%】时编译比较慢,同时会占用较大的内存。
因此,需要注意内存开销以及耐心等待
[ 92%] Built target types_slam3d_addons
In file included from /usr/include/eigen3/Eigen/Core:473:0,
from /content/g2opy/g2o/core/eigen_types.h:30,
from /content/g2opy/build/g2o/config.h:26,
from /content/g2opy/g2o/core/openmp_mutex.h:30,
from /content/g2opy/g2o/core/optimizable_graph.h:37,
from /content/g2opy/g2o/core/base_vertex.h:30,
from /content/g2opy/g2o/types/sba/types_sba.h:30,
from /content/g2opy/g2o/types/sba/types_sba.cpp:27:
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h: In member function ‘virtual void g2o::VertexCam::setToOriginImpl()’:
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:649:82: warning: ‘*((void*)&<anonymous> +160)’ is used uninitialized in this function [-Wuninitialized]
res = pmul(lhs.template packet<LoadMode,Packet>(row, Index(0)), pset1<Packet>(rhs.coeff(Index(0), col)));
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:99: warning: ‘*((void*)&<anonymous> +168)’ is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:99: warning: ‘*((void*)&<anonymous> +176)’ is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:649:82: warning: ‘*((void*)&<anonymous> +184)’ is used uninitialized in this function [-Wuninitialized]
res = pmul(lhs.template packet<LoadMode,Packet>(row, Index(0)), pset1<Packet>(rhs.coeff(Index(0), col)));
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:99: warning: ‘*((void*)&<anonymous> +192)’ is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:99: warning: ‘*((void*)&<anonymous> +200)’ is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:649:82: warning: ‘*((void*)&<anonymous> +208)’ is used uninitialized in this function [-Wuninitialized]
res = pmul(lhs.template packet<LoadMode,Packet>(row, Index(0)), pset1<Packet>(rhs.coeff(Index(0), col)));
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:99: warning: ‘*((void*)&<anonymous> +216)’ is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:99: warning: ‘*((void*)&<anonymous> +224)’ is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:649:82: warning: ‘*((void*)&<anonymous> +232)’ is used uninitialized in this function [-Wuninitialized]
res = pmul(lhs.template packet<LoadMode,Packet>(row, Index(0)), pset1<Packet>(rhs.coeff(Index(0), col)));
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:99: warning: ‘*((void*)&<anonymous> +240)’ is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:99: warning: ‘*((void*)&<anonymous> +248)’ is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
[ 99%] Building CXX object python/CMakeFiles/g2o.dir/g2o.cpp.o
In file included from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:16:0,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/internals.h:82:34: warning: ‘int PyThread_create_key()’ is deprecated [-Wdeprecated-declarations]
decltype(PyThread_create_key()) tstate = 0; // Usually an int but a long on Cygwin64 with Python 3.x
^
In file included from /usr/include/python3.7m/pystate.h:11:0,
from /usr/include/python3.7m/traceback.h:8,
from /usr/include/python3.7m/Python.h:119,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/common.h:111,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pytypes.h:12,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/usr/include/python3.7m/pythread.h:95:17: note: declared here
PyAPI_FUNC(int) PyThread_create_key(void) Py_DEPRECATED(3.7);
^~~~~~~~~~~~~~~~~~~
In file included from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:16:0,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/internals.h:82:34: warning: ‘int PyThread_create_key()’ is deprecated [-Wdeprecated-declarations]
decltype(PyThread_create_key()) tstate = 0; // Usually an int but a long on Cygwin64 with Python 3.x
^
In file included from /usr/include/python3.7m/pystate.h:11:0,
from /usr/include/python3.7m/traceback.h:8,
from /usr/include/python3.7m/Python.h:119,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/common.h:111,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pytypes.h:12,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/usr/include/python3.7m/pythread.h:95:17: note: declared here
PyAPI_FUNC(int) PyThread_create_key(void) Py_DEPRECATED(3.7);
^~~~~~~~~~~~~~~~~~~
In file included from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:16:0,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/internals.h: In function ‘pybind11::detail::internals& pybind11::detail::get_internals()’:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/internals.h:167:53: warning: ‘int PyThread_create_key()’ is deprecated [-Wdeprecated-declarations]
internals_ptr->tstate = PyThread_create_key();
^
In file included from /usr/include/python3.7m/pystate.h:11:0,
from /usr/include/python3.7m/traceback.h:8,
from /usr/include/python3.7m/Python.h:119,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/common.h:111,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pytypes.h:12,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/usr/include/python3.7m/pythread.h:95:17: note: declared here
PyAPI_FUNC(int) PyThread_create_key(void) Py_DEPRECATED(3.7);
^~~~~~~~~~~~~~~~~~~
In file included from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:16:0,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/internals.h:168:61: warning: ‘int PyThread_set_key_value(int, void*)’ is deprecated [-Wdeprecated-declarations]
PyThread_set_key_value(internals_ptr->tstate, tstate);
^
In file included from /usr/include/python3.7m/pystate.h:11:0,
from /usr/include/python3.7m/traceback.h:8,
from /usr/include/python3.7m/Python.h:119,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/common.h:111,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pytypes.h:12,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/usr/include/python3.7m/pythread.h:97:17: note: declared here
PyAPI_FUNC(int) PyThread_set_key_value(int key, void *value) Py_DEPRECATED(3.7);
^~~~~~~~~~~~~~~~~~~~~~
In file included from /content/g2opy/python/g2o.cpp:1:0:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h: In constructor ‘pybind11::gil_scoped_acquire::gil_scoped_acquire()’:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:1741:75: warning: ‘void* PyThread_get_key_value(int)’ is deprecated [-Wdeprecated-declarations]
tstate = (PyThreadState *) PyThread_get_key_value(internals.tstate);
^
In file included from /usr/include/python3.7m/pystate.h:11:0,
from /usr/include/python3.7m/traceback.h:8,
from /usr/include/python3.7m/Python.h:119,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/common.h:111,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pytypes.h:12,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/usr/include/python3.7m/pythread.h:98:20: note: declared here
PyAPI_FUNC(void *) PyThread_get_key_value(int key) Py_DEPRECATED(3.7);
^~~~~~~~~~~~~~~~~~~~~~
In file included from /content/g2opy/python/g2o.cpp:1:0:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:1753:60: warning: ‘int PyThread_set_key_value(int, void*)’ is deprecated [-Wdeprecated-declarations]
PyThread_set_key_value(internals.tstate, tstate);
^
In file included from /usr/include/python3.7m/pystate.h:11:0,
from /usr/include/python3.7m/traceback.h:8,
from /usr/include/python3.7m/Python.h:119,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/common.h:111,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pytypes.h:12,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/usr/include/python3.7m/pythread.h:97:17: note: declared here
PyAPI_FUNC(int) PyThread_set_key_value(int key, void *value) Py_DEPRECATED(3.7);
^~~~~~~~~~~~~~~~~~~~~~
In file included from /content/g2opy/python/g2o.cpp:1:0:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h: In member function ‘void pybind11::gil_scoped_acquire::dec_ref()’:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:1792:69: warning: ‘void PyThread_delete_key_value(int)’ is deprecated [-Wdeprecated-declarations]
PyThread_delete_key_value(detail::get_internals().tstate);
^
In file included from /usr/include/python3.7m/pystate.h:11:0,
from /usr/include/python3.7m/traceback.h:8,
from /usr/include/python3.7m/Python.h:119,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/common.h:111,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pytypes.h:12,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/usr/include/python3.7m/pythread.h:99:18: note: declared here
PyAPI_FUNC(void) PyThread_delete_key_value(int key) Py_DEPRECATED(3.7);
^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /content/g2opy/python/g2o.cpp:1:0:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h: In constructor ‘pybind11::gil_scoped_release::gil_scoped_release(bool)’:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:1820:52: warning: ‘int PyThread_set_key_value(int, void*)’ is deprecated [-Wdeprecated-declarations]
PyThread_set_key_value(key, nullptr);
^
In file included from /usr/include/python3.7m/pystate.h:11:0,
from /usr/include/python3.7m/traceback.h:8,
from /usr/include/python3.7m/Python.h:119,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/common.h:111,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pytypes.h:12,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/usr/include/python3.7m/pythread.h:97:17: note: declared here
PyAPI_FUNC(int) PyThread_set_key_value(int key, void *value) Py_DEPRECATED(3.7);
^~~~~~~~~~~~~~~~~~~~~~
In file included from /content/g2opy/python/g2o.cpp:1:0:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h: In destructor ‘pybind11::gil_scoped_release::~gil_scoped_release()’:
/content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:1833:47: warning: ‘int PyThread_set_key_value(int, void*)’ is deprecated [-Wdeprecated-declarations]
PyThread_set_key_value(key, tstate);
^
In file included from /usr/include/python3.7m/pystate.h:11:0,
from /usr/include/python3.7m/traceback.h:8,
from /usr/include/python3.7m/Python.h:119,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/detail/common.h:111,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pytypes.h:12,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/cast.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/attr.h:13,
from /content/g2opy/EXTERNAL/pybind11/include/pybind11/pybind11.h:43,
from /content/g2opy/python/g2o.cpp:1:
/usr/include/python3.7m/pythread.h:97:17: note: declared here
PyAPI_FUNC(int) PyThread_set_key_value(int key, void *value) Py_DEPRECATED(3.7);
^~~~~~~~~~~~~~~~~~~~~~
In file included from /content/g2opy/python/g2o.cpp:19:0:
/content/g2opy/python/core/base_unary_edge.h: In function ‘void g2o::declareBaseUnaryEdge(pybind11::module&)’:
/content/g2opy/python/core/base_unary_edge.h:33:40: warning: unused parameter ‘m’ [-Wunused-parameter]
void declareBaseUnaryEdge(py::module & m) {
^
In file included from /content/g2opy/python/g2o.cpp:20:0:
/content/g2opy/python/core/base_binary_edge.h: In function ‘void g2o::declareBaseBinaryEdge(pybind11::module&)’:
/content/g2opy/python/core/base_binary_edge.h:40:41: warning: unused parameter ‘m’ [-Wunused-parameter]
void declareBaseBinaryEdge(py::module & m) {
^
In file included from /content/g2opy/python/g2o.cpp:25:0:
/content/g2opy/python/core/linear_solver.h: In function ‘void g2o::declareLinearSolver(pybind11::module&)’:
/content/g2opy/python/core/linear_solver.h:38:39: warning: unused parameter ‘m’ [-Wunused-parameter]
void declareLinearSolver(py::module & m) {
^
[100%] Linking CXX shared module ../../lib/g2o.cpython-37m-x86_64-linux-gnu.so
D.22163 + 160]’/content/g2opy/g2o/types/sba/types_sba.h: In member function ‘setToOriginImpl’:
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:649:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmul(lhs.template packet<LoadMode,Packet>(row, Index(0)), pset1<Packet>(rhs.coeff(Index(0), col)));
^
D.22163 + 168]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
^
D.22163 + 176]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
^
D.22163 + 184]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:649:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmul(lhs.template packet<LoadMode,Packet>(row, Index(0)), pset1<Packet>(rhs.coeff(Index(0), col)));
^
D.22163 + 192]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
^
D.22163 + 200]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
^
D.22163 + 208]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:649:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmul(lhs.template packet<LoadMode,Packet>(row, Index(0)), pset1<Packet>(rhs.coeff(Index(0), col)));
^
D.22163 + 216]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
^
D.22163 + 224]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
^
D.22163 + 232]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:649:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmul(lhs.template packet<LoadMode,Packet>(row, Index(0)), pset1<Packet>(rhs.coeff(Index(0), col)));
^
D.22163 + 240]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
^
D.22163 + 248]’/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:631:3: warning: is used uninitialized in this function [-Wuninitialized]
res = pmadd(lhs.template packet<LoadMode,Packet>(row, Index(UnrollingIndex-1)), pset1<Packet>(rhs.coeff(Index(UnrollingIndex-1), col)), res);
^
[100%] Built target g2o
安装到python
cd ..
!python setup.py install
简单测试一下:
测试Example:
import numpy as np
import g2o
class BundleAdjustment(g2o.SparseOptimizer):
def __init__(self, ):
super().__init__()
solver = g2o.BlockSolverSE3(g2o.LinearSolverCSparseSE3())
solver = g2o.OptimizationAlgorithmLevenberg(solver)
super().set_algorithm(solver)
def optimize(self, max_iterations=10):
super().initialize_optimization()
super().optimize(max_iterations)
def add_pose(self, pose_id, pose, cam, fixed=False):
sbacam = g2o.SBACam(pose.orientation(), pose.position())
sbacam.set_cam(cam.fx, cam.fy, cam.cx, cam.cy, cam.baseline)
v_se3 = g2o.VertexCam()
v_se3.set_id(pose_id * 2) # internal id
v_se3.set_estimate(sbacam)
v_se3.set_fixed(fixed)
super().add_vertex(v_se3)
def add_point(self, point_id, point, fixed=False, marginalized=True):
v_p = g2o.VertexSBAPointXYZ()
v_p.set_id(point_id * 2 + 1)
v_p.set_estimate(point)
v_p.set_marginalized(marginalized)
v_p.set_fixed(fixed)
super().add_vertex(v_p)
def add_edge(self, point_id, pose_id,
measurement,
information=np.identity(2),
robust_kernel=g2o.RobustKernelHuber(np.sqrt(5.991))): # 95% CI
edge = g2o.EdgeProjectP2MC()
edge.set_vertex(0, self.vertex(point_id * 2 + 1))
edge.set_vertex(1, self.vertex(pose_id * 2))
edge.set_measurement(measurement) # projection
edge.set_information(information)
if robust_kernel is not None:
edge.set_robust_kernel(robust_kernel)
super().add_edge(edge)
def get_pose(self, pose_id):
return self.vertex(pose_id * 2).estimate()
def get_point(self, point_id):
return self.vertex(point_id * 2 + 1).estimate()
.so文件处理
将生成的.so文件所在文件夹lib进行压缩处理,
!tar -cvf FileName.tar lib
接着进入g2opy目录下
python setup.py install
就可以使用啦!!!