kinect2的标定

我用的是ubuntu14.04LTS,ROS 版本是indigo,kinect v2,我是用双系统装的ubuntu,关于怎么使用安装kinect2的安装以及使用的都在github上有着详细的说明

Kinect2 开源驱动:libfreenect2

kinect2--> ros的bridge:iai_kinect2

安装
安装libfreenect2,这个libfreenect2据说是它的驱动包,希望是稳定的,放在home目录下;
安装好libfreenect2的依赖项

sudo apt-get install build-essential cmake pkg-config libturbojpeg libjpeg-turbo8-dev mesa-common-dev freeglut3-dev libxrandr-dev libxi-dev

安装libusb
sudo apt-add-repository ppa:floe/libusb
sudo apt-get update
sudo apt-get install libusb-1.0-0-dev
 
安装GLFW3
cd libfreenect2/depends
sh install_ubuntu.sh
sudo dpkg -i libglfw3*_3.0.4-1_*.deb
 
不要用sudo apt-get install安装glfw3,但可以用sudo apt-get remove libglfw3-dev卸载它。
所有以包形式安装的包都可以sudo apt-get remove来卸载它
接着编译库
cd ..
mkdir build && cd build
cmake ..
make
sudo make install

这时候插上kinect的数据线
运行lsusb,如果下面出现Bus 002 Device 003: ID 045e:02c4 Microsoft Corp.
Bus 002 Device 002: ID 045e:02d9 Microsoft Corp. 就说明连上了。
运行
  ./bin/Protonect
如果提示no device connected,是因为你的虚拟机默认设置是接usb2.0的口,而kinect v2要接usb3.0的口,所以要做出更改,但是用虚拟机装的ubuntu是连不上kinect的。

如果是要重装或是重新编译libfreenect2,则
cd
sudo rm -rf /usr/local/include/libfreenect2
cd /usr/local/lib
sudo rm -rf libfreenect2.so libfreenect2.so.0.2 libfreenect2.so.0.2.0
cd OpenNI2/Drivers
sudo rm -rf libfreenect2-openni2.so  libfreenect2-openni2.so.0
 
 
ROS接口安装
对于已经安装了Ros Indigo的Ubuntu14.04来说,使用下面的命令
cd ~/catkin_ws/src/
git clone https://github.com/code-iai/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .

cd ~/catkin_ws
catkin_make -DCMAKE_BUILD_TYPE="Release"
rospack profile
 

rosdep install -r --from-paths .这一步可能会报错,但这个报错是正常的,不用管,不会影响最终结果。

接下来可以测试了。

新打开一个终端,运行

cd ~/catkin_ws/
catkin_make
source ./devel/setup.bash
cd src
roslaunch kinect2_bridge kinect2_bridge.launch
获取Kinect数据

再新打开一个终端,运行

rosrun kinect2_viewer kinect2_viewer

就可以正常显示图像了

 

 

一般在使用前 ,我们都会矫正,就是所谓的计算相机的内外参数,一般使用的方法都是张正友标定法的理论,理论知识就不在赘述,其实当时看都是能看懂的一旦让自己完全从头推理就懵逼了

首先呢我们的矫正步骤就是,我们得有标定模板,这如果你之前下载了iai_kinect2在kinect2_calibration文件下是有标定模板的  你可以随意打印一个模板等着后期的标定使用

那么我就按照github的教程教你如果去矫正kinect2  以下 就是github给出的具体的步骤,对于其中的参数我们一般按照要求给就OK了,对于kienct 2的标定并不需要说把红外发射器给遮住  然后使用红外LED去矫正的,这是针对kinect1的,之前我矫正过kinect1  确实是需要把红外发射装置给遮住,然后才能矫正深度信息,

Detailed steps:

  1. If you haven't already, start the kinect2_bridge with a low number of frames per second (to make it easy on your CPU): rosrun kinect2_bridge kinect2_bridge _fps_limit:=2  (这一步就是要启动ROS的kienct 2的驱动货都kienct2的原始数据)
  2. create a directory for your calibration data files, for example: mkdir ~/kinect_cal_data; cd ~/kinect_cal_data(这是为了创建一个文件,存储我们用于矫正的照片)
  3. Record images for the color camera: rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record color   (这命令就是开始矫正深度相机的RGB相机,对于后面的参数我们可以知道chess5x7x0.03(是棋盘的大小  可以用尺子量一下的) record(记录保存下下) color
  4. Calibrate the intrinsics: rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate color
  5. Record images for the ir camera: rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record ir
  6. Calibrate the intrinsics of the ir camera: rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate ir
  7. Record images on both cameras synchronized: rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record sync
  8. Calibrate the extrinsics: rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate sync
  9. Calibrate the depth measurements: rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate depth
  10. Find out the serial number of your kinect2 by looking at the first lines printed out by the kinect2_bridge. The line looks like this: device serial: 012526541941
  11. Create the calibration results directory in kinect2_bridge/data/$serial: roscd kinect2_bridge/data; mkdir 012526541941
  12. Copy the following files from your calibration directory (~/kinect_cal_data) into the directory you just created: calib_color.yaml calib_depth.yaml calib_ir.yaml calib_pose.yaml
  13. Restart the kinect2_bridge and be amazed at the better data.

还要好多就不在写了

通常遇到最多的就是这种问题,但是这个问题并不影响我们的矫正

[ERROR] Tried to advertise a service that is already advertised in this node [/kinect2_calib_1458721837266890808/compressed/set_parameters]
[ERROR] Tried to advertise a service that is already advertised in this node [/kinect2_calib_1458721837266890808/compressed/set_parameters]

真正影响我们的是我们输入的参数  比如ROS的开发包给例子是使用棋盘格6*8的棋盘,正方形的边长为0.03米  但是我们的棋盘可能并并不是那么小的,这时候要使用我们的

棋盘的话就要注意给的参数了。比如用的是长有9个,款有7个正方形的标定棋盘,这时候我们的参数是6*8*0.05,参数一定要给准确,不然会出现错误的 啊、

而且就是在同一个文件下使用命令,

 

posted @ 2017-08-29 16:17  Being_young  阅读(13892)  评论(4编辑  收藏  举报