Ubuntu 20.04 + ROS Noetic + OpenCV 4.10编译kalibr相机标定功能包

环境:Ubuntu 20.04 + ROS Noetic + OpenCV:4.2.0

1、创建工作空间

mkdir -p kalibr_ws/src
cd kalibr_ws/ 
source /opt/ros/noetic/setup.bash 
cd src/ 
catkin_init_workspace 

2、下载kalibr源码并编译

git clone https://github.com/ethz-asl/kalibr.git 
cd .. 
catkin_make -DCMAKE_BUILD_TYPE=Release -j4

编译过程中遇到相关问题:

  • Could not find a package configuration file provided by "boost_python3"

Ubuntu 20.04 + ROS Noetic + OpenCV 4.10编译kalibr相机标定功能包_第1张图片

解决方法:

https://github.com/ethz-asl/kalibr/issues/368

/kalibr/Schweizer-Messer/numpy_eigen/cmake/add_python_export_library.cmake:89 
change 
	list(APPEND BOOST_COMPONENTS python3) 
to 
	list(APPEND BOOST_COMPONENTS python)
  • /usr/include/python3.8/numpy/__multiarray_api.h:1541:35: error: return-statement with a value, in function returning ‘void’ [-fpermissive]

1541 | #define NUMPY_IMPORT_ARRAY_RETVAL NULL

Ubuntu 20.04 + ROS Noetic + OpenCV 4.10编译kalibr相机标定功能包_第2张图片

解决方法:

https://blog.csdn.net/zhaodeming000/article/details/119859124

在文件中kalibr/Schweizer-Messer/numpy_eigen/src/autogen_module/numpy_eigen_export_module.cpp添加

BOOST_PYTHON_MODULE(libnumpy_eigen) 
{ 
	using namespace boost::python;
    // Without this import, the converter will segfault 
    #undef NUMPY_IMPORT_ARRAY_RETVAL 
    #define NUMPY_IMPORT_ARRAY_RETVAL
    
    import_array();
  • /home/ubuntu/kalibr_ws/src/kalibr/aslam_offline_calibration/ethz_apriltag2/src/example/apriltags_demo.cpp:53:10: fatal error: libv4l2.h: No such file or directory

    53 | #include

Ubuntu 20.04 + ROS Noetic + OpenCV 4.10编译kalibr相机标定功能包_第3张图片

解决方法:

sudo apt-get install libv4l-dev
  • error: ‘CV_CAP_PROP_FRAME_WIDTH’ was not declared in this scope 305 | m_cap.set(CV_CAP_PROP_FRAME_WIDTH, m_width);

Ubuntu 20.04 + ROS Noetic + OpenCV 4.10编译kalibr相机标定功能包_第4张图片

解决方法:

https://blog.csdn.net/CGJustDoIT/article/details/108150459

在kalibr_ws/src/kalibr/aslam_offline_calibration/ethz_apriltag2/src/example/apriltags_demo.cpp中添加:

#include
#include

using namespace std; 
#include  
#include  
#include  
#include  
#include  
#include  


const string usage = "\n"     
    m_cap.set(cv::CAP_PROP_FRAME_WIDTH, m_width);    
	m_cap.set(cv::CAP_PROP_FRAME_HEIGHT, m_height);    
	cout << "Camera successfully opened (ignore error messages above...)" << endl;   
	cout << "Actual resolution: "         
        << m_cap.get(cv::CAP_PROP_FRAME_WIDTH) << "x"         
        << m_cap.get(cv::CAP_PROP_FRAME_HEIGHT) << endl;
  • error: ‘pid_t gettid()’ was declared ‘extern’ and later ‘static’ [-fpermissive]

Ubuntu 20.04 + ROS Noetic + OpenCV 4.10编译kalibr相机标定功能包_第5张图片

解决方法:

  • error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope

    22 | _mask = cv::imread(maskFile, CV_LOAD_IMAGE_GRAYSCALE);

Ubuntu 20.04 + ROS Noetic + OpenCV 4.10编译kalibr相机标定功能包_第6张图片

  • /usr/include/boost/python/detail/destroy.hpp:20:9: error: ‘Eigen::MatrixBase<Derived>::~MatrixBase()

Ubuntu 20.04 + ROS Noetic + OpenCV 4.10编译kalibr相机标定功能包_第7张图片

解决方法:

https://blog.csdn.net/weixin_48135525/article/details/117999358

change line 466 protected intopublic in /usr/include/eigen3/Eigen/src/Core/MatrixBase.h or /usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h.

3、编译成功

Ubuntu 20.04 + ROS Noetic + OpenCV 4.10编译kalibr相机标定功能包_第8张图片

你可能感兴趣的:(SLAM,opencv,ubuntu,slam)