1: Kinect内参标定
1.1 注意事项:
1. Print your calibration pattern (for the examples, we used chess5x7x0.03) and glue it to a flat object
2. Get two tripods, one for holding the calibration pattern, and another one for holding the kinect2 sensor
3. When recording images for all the steps indicated below (RGB, IR, SYNC), start the recording program, then press spacebar to record each image
4. It is recommended to take images that show the calibration pattern in all areas of the image, and with different orientations of the pattern (tilting the pattern relative to the plane of the image), and at least two distances. So you can easily reach 100 images per calibration set
5. We normally start at a short distance, where the calibration pattern covers most of the image, there we take several pictures tilting the calibration pattern vertically, then horizontally
6. Then we move the calibration pattern further away, and for different orientations (tilting) of the pattern, we take many images so that we calibration pattern is present around most of the camera image. For example, at first the calibration pattern is on the left upper corner. Then on the next image on the upper middle, then on the upper right corner. Then some images where the calibration pattern is in the middle vertically, etc...
1.2操作步骤:
1. 设定视频帧: rosrun kinect2_bridge kinect2_bridge _fps_limit:=2 (电脑配置高可不加限制)
即: rosrun kinect2_bridge kinect2_bribge
2. create a directory for your calibration data files, for example:
mkdir ${DIR_FOR_KINECT}/iai_kinect2/kinect2_cal_data
3. rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record color
and use the spacebar in the picture to recore the picture
4. rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate color
5. rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record ir
and use the spacebar in the picture to recore the picture
6. rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate ir
7. rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record sync
and use the spacebar in the picture to recore the picture
8. rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate sync
9. 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: 015643252847
11. Create the calibration results directory in kinect2_bridge/data/$serial:
roscd kinect2_bridge/data; mkdir 015643252847
12. Copy the following files from your calibration directory ( ${DIR_FOR_KINECT}/iai_kinect2/kinect2_cal_data ) into the directory you just created: calib_color.yaml calib_depth.yaml calib_ir.yaml calib_pose.yaml
13. 到此kinect内参已经标定完成,对应device serial的文件夹。当计算机连接kinect时,自动会去读取对应设备号文件夹的参数文件,因此对于新的一款kinect接入时,需要重新标定得到配置文件保存在对应的设备序列号文件夹下。
2: Kinect外参标定
对于需要将kinect坐标系下采集到的三维坐标信息映射到机器人坐标系下的场景,必须知道Kinect基坐标原点在robot坐标系下的三维坐标或者robot基坐标系原点在Kinect坐标系下的三维坐标。对于我所涉及的场景,我更加关心将Kinect采集的深度图上关于物体的三维坐标转换到robot坐标系下,方便robot去到达或者计算等后续工作。
本kinect标定场景图( kinect视角,kinect在robot正前方 )
首先解析一下在 https://github.com/code-iai/iai_kinect2/blob/master/kinect2_viewer/src/viewer.cpp
中 官方提供的viewer的功能:
1: 通过订阅ros下kinect发布的话题,实时更新imageColor and imageDepth
2: imageViewer() 完成彩色图像的显示,保存当前图片和退出
3: cloudViewer() 完成点云图像的显示,保存当前图片和退出
4: 显示质量选择:qhd,hd,ir,sd
(具体实现参考源代码)
作为本次标定工作,需要在此基础上增加功能–捕获鼠标坐标点和其对应的三维点.
首先构造体Receiver() 创建一个publisher 的室友成员:
ros::Publisher mouseEventPosePub = nh.advertise<geometry_msgs::PoseStamped>("/mouse_event_pose", 10);
然后在imageViewer或者cloudViewer中注册回调映射
visualizer->registerMouseCallback(&Receiver::mouseEventOccurred, *this);
与本身自带的键盘回调映射非常相似:
visualizer->registerKeyboardCallback(&Receiver::keyboardEvent, *this);
最后,需要回调函数的封装(与键盘回调函数(keyboardEvent)相似):
void mouseEventOccurred (const pcl::visualization::MouseEvent &event, void* )
{
if (event.getButton () == pcl::visualization::MouseEvent::LeftButton &