内参标定及livox_camera_calib使用

内参标定

1.获取图片:

a.相机连接matlab(没试过)

b.运行ros节点进行截图

#usb cam  获取话题:/UAV2_usbcam/image_raw
cd px4_dep
 
//启动launch文件获取相机画面
roslaunch usb_cam usb_cam_uav2.launch 
//开窗口获取实时相机数据
rqt_image_view
//截取标定板图片(截取时可以稍微移动)
rosrun image_view extract_images _sec_per_frame:=0.5 image:=/UAV2_usbcam/image_raw

参考:内参标定以及基于livox-camera-calib的相机雷达外参标定-CSDN博客

2.matlab标定:

参考:用matlab对相机进行标定获取相机内参_matlab 相机内参 fc-CSDN博客

livox_camera_calib使用

编译过程参考官方文档

github:GitHub - hku-mars/livox_camera_calib: This repository is used for automatic calibration between high resolution LiDAR and camera in targetless scenes.This repository is used for automatic calibration between high resolution LiDAR and camera in targetless scenes. - GitHub - hku-mars/livox_camera_calib: This repository is used for automatic calibration between high resolution LiDAR and camera in targetless scenes.icon-default.png?t=N7T8https://github.com/hku-mars/livox_camera_calib

1. Prerequisites

1.1 Ubuntu and ROS

Ubuntu 64-bit 16.04 or 18.04. ROS Kinetic or Melodic. ROS Installation and its additional ROS pacakge:

    sudo apt-get install ros-XXX-cv-bridge ros-xxx-pcl-conversions

1.2 Eigen
Eigen Installationicon-default.png?t=N7T8http://eigen.tuxfamily.org/index.php?title=Main_Page

使用下面命令查看版本,一般不用自己装(装了可能会导致版本过高导致opencv编译报错)

pkg-config --modversion eigen3

1.3 Ceres Solver

ubuntu 20.04 安装 ceres库_ubuntu20.04安装ceres-CSDN博客

1.4 PCL

Ubuntu 20.04安装PCL_ubuntu20.04安装pcl-CSDN博客

查看版本:

pkg-config --modversion pcl_common

2. Build

cd ~/catkin_ws/src
git clone https://github.com/hku-mars/livox_camera_calib.git
cd ../
catkin_make
source ~/catkin_ws/devel/setup.bash

遇到的问题:catkin_make报错:

/home/chen/calib_ws/src/livox_camera_calib/src/lidar_camera_calib.cpp: In function ‘int main(int, char**)’:
/home/chen/calib_ws/src/livox_camera_calib/src/lidar_camera_calib.cpp:311:14: error: ‘LocalParameterization’ is not a member of ‘ceres’
  311 |       ceres::LocalParameterization *q_parameterization =
      |              ^~~~~~~~~~~~~~~~~~~~~
/home/chen/calib_ws/src/livox_camera_calib/src/lidar_camera_multi_calib.cpp: In function ‘int main(int, char**)’:
/home/chen/calib_ws/src/livox_camera_calib/src/lidar_camera_multi_calib.cpp:312:14: error: ‘LocalParameterization’ is not a member of ‘ceres’
  312 |       ceres::LocalParameterization *q_parameterization =
      |              ^~~~~~~~~~~~~~~~~~~~~
/home/chen/calib_ws/src/livox_camera_calib/src/lidar_camera_calib.cpp:311:37: error: ‘q_parameterization’ was not declared in this scope
  311 |       ceres::LocalParameterization *q_parameterization =
      |                                     ^~~~~~~~~~~~~~~~~~
/home/chen/calib_ws/src/livox_camera_calib/src/lidar_camera_calib.cpp:312:15: error: expected type-specifier
  312 |           new ceres::EigenQuaternionParameterization();
      |               ^~~~~
/home/chen/calib_ws/src/livox_camera_calib/src/lidar_camera_multi_calib.cpp:312:37: error: ‘q_parameterization’ was not declared in this scope
  312 |       ceres::LocalParameterization *q_parameterization =
      |                                     ^~~~~~~~~~~~~~~~~~
/home/chen/calib_ws/src/livox_camera_calib/src/lidar_camera_multi_calib.cpp:313:15: error: expected type-specifier
  313 |           new ceres::EigenQuaternionParameterization();
 

解决方法:

ceres::LocalParameterization 报错对应信息均改为:

      ceres::Manifold *q_parameterization =
          new ceres::EigenQuaternionParameterization();

new ceres::EigenQuaternionParameterization()报错改为:

ceres::Manifold *q_parameterization =
          new ceres::EigenQuaternionManifold();

运行官方示例,下载官方提供的png和pcd文件

修改yaml文件为自己的存放地址

# Data path. adjust them!
common:
    image_file: "/home/chen/calib_ws/data/calib/image/1.png"
    pcd_file: "/home/chen/calib_ws/data/calib/pcd/1.pcd"
    result_file: "/home/chen/calib_ws/data/calib/result/extrinsic.txt"

以及:

# Calibration Parameters.!
calib:
    calib_config_file: "/home/chen/calib_ws/src/livox_camera_calib/config/config_outdoor.yaml"
    use_rough_calib: true # set true if your initial_extrinsic is bad

运行:

roslaunch livox_camera_calib multi_calib.launch

结果:

cd_file path:/home/chen/calib_ws/data/calib/pcd/1.pcd
[ INFO] [1721564548.598898967]: Sucessfully load calib config file
[ INFO] [1721564548.650429739]: Sucessfully load image!
[ INFO] [1721564548.690314707]: Sucessfully extract edge from image, edge size:51218
[ INFO] [1721564548.690357808]: Loading point cloud from pcd file.
[ INFO] [1721564569.095121346]: Sucessfully load pcd, pointcloud size: 6254400
[ INFO] [1721564569.095160709]: Building Voxel
[ INFO] [1721564595.057002796]: Extracting Lidar Edge
[ INFO] [1721564618.601478219]: Finish prepare!
Initial rotation matrix:
 0 -1  0
 0  0 -1
 1  0  0
Initial translation:0 0 0
Rough calibration min cost:0.831699
Rough calibration min cost:0.831699
Rough calibration min cost:0.830428
Rough calibration min cost:0.830428
Rough calibration min cost:0.830272
Rough calibration min cost:0.829893
Rough calibration min cost:0.82938
Rough calibration min cost:0.82938
Rough calibration min cost:0.829224
Rough calibration min cost:0.829224
Rough calibration min cost:0.829224
Iteration:0 Dis:30 pnp size:7772
iter      cost      cost_change  |gradient|   |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time
   0  2.525481e+05    0.00e+00    2.06e+06   0.00e+00   0.00e+00  1.00e+04        0    1.64e+00    1.65e+00
   1  2.124843e+05    4.01e+04    7.29e+03   0.00e+00   1.00e+00  3.00e+04        1    1.71e+00    3.36e+00
   2  2.124840e+05    3.15e-01    1.84e+00   5.48e-05   1.00e+00  9.00e+04        1    1.72e+00    5.07e+00
Ceres Solver Report: Iterations: 3, Initial cost: 2.525481e+05, Final cost: 2.124840e+05, Termination: CONVERGENCE
q_dis:0.307869 ,t_dis:0.0133007
Iteration:1 Dis:30 pnp size:7634
iter      cost      cost_change  |gradient|   |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time
   0  2.098803e+05    0.00e+00    2.92e+05   0.00e+00   0.00e+00  1.00e+04        0    1.60e+00    1.60e+00
   1  2.074380e+05    2.44e+03    8.89e+02   0.00e+00   9.99e-01  3.00e+04        1    1.67e+00    3.27e+00
Ceres Solver Report: Iterations: 2, Initial cost: 2.098803e+05, Final cost: 2.074380e+05, Termination: CONVERGENCE
q_dis:0.115785 ,t_dis:0.00455216
 

3.实际使用

参考:内参标定以及基于livox-camera-calib的相机雷达外参标定-CSDN博客

.按照单目内参标定打开相机

2.打开雷达

cd mid360_ws
//运行launch文件获取雷达数据
roslaunch livox_ros_driver2 msg_MID3602.launch


 
3.截图和获取pcd文件

截图按照内参标定所用方法即可

获取pcd和截图需要同时运行和终止进程,获取到的是消息包,通过下面方法获取pcd文件

//截取消息
rosbag record /nav2/livox/lidar

通过上方命令可以获取bag文件,在bag_to_pcd.launch(livox-camera-clib-master文件下)中改动参数,通过该文件实现bag转pcd文件

然后参考官方示例进行标定

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值