ubuntu16.04安装kinect V2驱动及相机标定

kinect V2相机驱动官方地址:https://github.com/OpenKinect/libfreenect2

下载libfreenect2

git clone https://github.com/OpenKinect/libfreenect2.git
cd libfreenect2

安装编译环境

安装必备环境

编译工具

sudo apt-get install build-essential cmake pkg-config

libusb

sudo apt-get install libusb-1.0-0-dev

TurboJPEG

sudo apt-get install libturbojpeg libjpeg-turbo8-dev

OpenGL

sudo apt-get install libglfw3-dev

所需要的依赖统一安装:

sudo apt-get install build-essential cmake pkg-config libusb-1.0-0-dev libturbojpeg libjpeg-turbo8-dev libglfw3-dev

#安装可选依赖
OpenCL

sudo apt-get install beignet-dev

CUDA

VAAPI

sudo apt-get install libva-dev libjpeg-dev

OpenNI2

sudo apt-get install libopenni2-dev

编译配置

编译

mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
make
make install
# -DCMAKE_INSTALL_PREFIX指定安装的路径

设置设备访问规则

sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/

调试

./bin/Protonect

调试过程中,检查相机usb是否是连接的是3.0

标定

1. Ros工作空间搭建

新建workspace

2. 下载编译kinect2驱动节点

cd src
下载源码

git clone https://github.com/code-iai/iai_kinect2.git

安装kinect2 所需要的依赖

cd iai_kinect2
rosdep install -r --from-paths

编译节点

catkin_make

测试连接

#1. 开启kinect2_bridge

roslaunch kinect2_bridge kinect2_bridge.launch

#2. 启动kinect2_viewer

rosrun kinect2_viewer kinect2_viewer

可以通过rosrun kinect2_viewer kinect2_viewer --help进行查看可配置的参数。

#Kinect2驱动通讯
#查看kinect2驱动发布的数据
rostopic list
输出结果如下:

/kinect2/bond
/kinect2/hd/camera_info
/kinect2/hd/image_color
/kinect2/hd/image_color/compressed
/kinect2/hd/image_color_rect
/kinect2/hd/image_color_rect/compressed
/kinect2/hd/image_depth_rect
/kinect2/hd/image_depth_rect/compressed
/kinect2/hd/image_mono
/kinect2/hd/image_mono/compressed
/kinect2/hd/image_mono_rect
/kinect2/hd/image_mono_rect/compressed
/kinect2/hd/points
/kinect2/qhd/camera_info
/kinect2/qhd/image_color
/kinect2/qhd/image_color/compressed
/kinect2/qhd/image_color_rect
/kinect2/qhd/image_color_rect/compressed
/kinect2/qhd/image_depth_rect
/kinect2/qhd/image_depth_rect/compressed
/kinect2/qhd/image_mono
/kinect2/qhd/image_mono/compressed
/kinect2/qhd/image_mono_rect
/kinect2/qhd/image_mono_rect/compressed
/kinect2/qhd/points
/kinect2/sd/camera_info
/kinect2/sd/image_color_rect
/kinect2/sd/image_color_rect/compressed
/kinect2/sd/image_depth
/kinect2/sd/image_depth/compressed
/kinect2/sd/image_depth_rect
/kinect2/sd/image_depth_rect/compressed
/kinect2/sd/image_ir
/kinect2/sd/image_ir/compressed
/kinect2/sd/image_ir_rect
/kinect2/sd/image_ir_rect/compressed
/kinect2/sd/points

kinect2 相机是通过topic来传递数据的。在topic中会发现大量的topic信息。
hd,qhd,sd分别代表分辨率。

#调试显示相机图像

rosrun image_view image_view image:=/kinect2/hd/image_color

#相机标定
启动kinect2_brige

rosrun kinect2_bridge kinect2_bridge _fps_limit:=2

_fps_limit:=2设置相机每秒2帧进行采样。

启动时查看启动日志得到设备序列.

创建采样的文件夹

mkdir ~/kinect_cal_data
cd ~/kinect_cal_data

彩图采样

rosrun kinect2_calibration kinect2_calibration chess6x9x0.02 record color
chess6x9x0.02: chess为标定板,格式为widthxheightxsize.

width为标定板宽度方向的标定点个数。

height为标定板高度方向的标定点个数。

size为标定方格的宽度,单位为米。

彩图标定

rosrun kinect2_calibration kinect2_calibration chess6x9x0.02 calibrate color
红外图采样

rosrun kinect2_calibration kinect2_calibration chess6x9x0.02 record ir
红外图标定

rosrun kinect2_calibration kinect2_calibration chess6x9x0.02 calibrate ir
同步采样

rosrun kinect2_calibration kinect2_calibration chess6x9x0.02 record sync
同步标定

rosrun kinect2_calibration kinect2_calibration chess6x9x0.02 calibrate sync
深度标定

rosrun kinect2_calibration kinect2_calibration chess6x9x0.02 calibrate depth

将标定结果存储到指定目录

来到kinect2_bridge/data目录下

roscd kinect2_bridge/data
mkdir 设备串口名称

设备串口名称是在 kinect2_bridge启动时日志中会打印出来的

拷贝标定的结果配置文件

cp ~/kinect_cal_data/calib_color.yaml .
cp ~/kinect_cal_data/calib_depth.yaml .
cp ~/kinect_cal_data/calib_ir.yaml .
cp ~/kinect_cal_data/calib_pose.yaml .

你可能感兴趣的:(相机及标定)