ros+iai_kinect2标定教程-失败-效果很差-更新和解决办法

17 篇文章 6 订阅
14 篇文章 0 订阅

更新内容:这垃圾,嗯,让我做不出来的都是垃圾~

利用ros自带的标定程序,我真的标定不好,最好的一次都没有原有的有用。

所以我只好寄希望于自带的参数,至少匹配的图片,在竖直方向几乎是没有偏差的。

只是水平方向,有一些畸变,并且深度图会向右偏移一定距离。

这个是一个复杂的问题,我好像并不能通过有效的计算,来将这些畸变补偿。

因此我们来进行一些简单的变换,将我们所需要的点,匹配即可。

这些只适合我的项目,可能大家需要的是下面的这些资料,都是我在github的issue上一个个搜集到的标定步骤:

标定小技巧:
1、校准位置和相机的处理
I usually used distances between 0.6 and 2.5 meters, near, middle and far. To go further away, you need a larger board, but then you can not be as close.
The individual calibrations are looking fine. For the extrinsics, it is important that the sensor and the board do not move at all, because the images are not taken at the same time. Holding on of them in a hand is not working well.
我通常使用0.6到2.5米之间的距离,近中远。要走得更远,你需要一个更大的棋盘,但是你不能离得更近。
单独的校准看起来很好。对于外部因素,传感器和电路板根本不移动是非常重要的,因为图像不是同时拍摄的。手中握着他们并不好

2、校准步骤和技巧
I think a malfunction that prevents a proper calibration is very unlikely. Most probably something in the calibration process went wrong. There are some very important things:

The pattern has to match exactly the dimensions that you set. Some printers are not as precise as others. Measure the printed pattern carefully. Length of each field, length over multiple fields, etc.
Placing of the pattern is very important, which less images, or many images of a similar view to the pattern you can get a good reprojection error, but a bad calibration. I normally capture around 100 - 200 images by following these steps:
place the pattern near to the camera
position the pattern in the top left corner of the image
move it along that row while taking pictures
go down one row and do step iii. again until you end up in the right bottom corner
rotate the pattern so that (1) the left border is further away from the camera than the right side, (2) the other way around, (3) the top border is further away than the bottom one, (4) the other way around, (5) left top corner is pointing up and the lower right corner is pointing down. For each of those rotations go back to step ii.
place the pattern further away from the camera and go to step ii. Do this for 3 different distances, near (<= 1m), middle range (> 1m, < 2.5m) and far (>= 2.5m). (The possible distances depend on the chess board size.)
Especially for the extrinsic calibration, it is important that the sensor and the pattern are not moving while taking the images.
我认为一个妨碍正确校准的故障是不太可能的。校准过程中很可能出错了。有一些非常重要的事情:

模式必须完全匹配您设置的尺寸。有些打印机不如其他打印机精确。仔细测量印刷图案。每个字段的长度,多个字段的长度等。
放置图案非常重要,这些图片较少,或者与图案类似的许多图像可以获得良好的重投影误差,但校准不好。我通常通过以下步骤捕获大约100 - 200张图像:
将图案放置在相机附近
将图案放置在图像的左上角
在拍照时沿着该行移动
往下走一排,然后进行第三步。直到你最终在右下角
(1)左边距离摄像机比右边距离更远,(2)反过来,(3)顶部边界比底部边界更远,(4)另一种方式(5)左上角朝上,右下角朝下。对于每一次轮换,回到步骤ii。
将图案放置在远离相机的位置,然后转到步骤ii。在距离(<= 1m),中距离(> 1m,<2.5m)和远(> = 2.5m)的3个不同距离进行。(可能的距离取决于棋盘尺寸。)
特别是对于外部校准,重要的是传感器和图案在拍摄图像时不会移动。

3、关于深度测量的问题:
https://github.com/code-iai/iai_kinect2/issues/271
https://github.com/code-iai/iai_kinect2/issues/311

4、激光打印机和墨水打印机的区别:
I just talked to a colleague. He said some inks might be transparent to IR. Are you using an ink printer? Could you try it on a laser printer? If that's true, what type of printer and ink are you using? (just out of curiosity)  

我刚刚跟一位同事谈过。他说一些墨水对IR可能是透明的。你在使用墨水打印机吗?你可以在激光打印机上试用吗?如果那是真的,你使用的是什么类型的打印机和墨水?(只是出于好奇)


5、自己标定的一些心得:

标定了快20次了,现在听到标定就想吐。。。反正没有标定成功过,所以说的这些心得,可能也没有什么用处。仅供参考吧。

标定的时候,看到那个彩色的线条和点,不要让这些点在抖动,尤其是偏的厉害,离得远的时候,这样的标定肯定不准的。

A4纸太小了,要是有机会尽量用大点的纸吧。

相机到底动不动,英语不好,没看懂,,,

拍照的时候,板尽量不要动。




下面是原博客——

参考链接:

主参考:https://github.com/code-iai/iai_kinect2/tree/master/kinect2_calibration

副参考:http://www.cnblogs.com/li-yao7758258/p/7445429.html

在项目之处,我使用的是国产奥比中光的Astra s款深度相机——

来个小广告,安利一下国货:



这款相机除了rgb分辨率低了一些之外。真的是特别好用,很精巧,不像kinect2那么庞大,线那么多。

我们当初没有买这家最高配置的100万像素的那款,这款只有30万像素,在最后的识别过程中,拍到的照片简直是瞎子一般。

恰好实验室的还有一款尘封已久的k2,于是没有买顶配的astra 了。

言归正题:

k2这款相机在安装好ros驱动之后,教程见上一篇文章

设置好路径,然后显示点云图的时候,就会发现一个很尴尬的问题,深度图和rgb图无法对应起来,在近处,大概1米以内,会有很大的偏移,具体的图,当时没有保存,只能描述一下了。

具体的原因应该是,这款相机的rgb原始像素是1920*1080,深度像素是512*424,但是在ros的程序包中,将深度图硬生生的投射到了1920*1080大小的画面,而且深度相机和rgb相机的位置有差距,一系列的变化,可是为啥程序没有自动校正?

在Astra的ros程序包里的话题就有一个校正话题——/camera/depth_registered/image_raw

这里的深度值图和rgb图大小一致,位置也经过内部校正,就可以很轻松的计算出xyz三维坐标。

但是这个就不行了,百度了一下,发现只能手动标定相机,真是不理解,为啥这种批量生产的相机会让客户手动标定!

教程:

https://github.com/code-iai/iai_kinect2/tree/master/kinect2_calibration


用谷歌浏览器打开,点击翻译,基本上就可以看懂了。文中提到的应该还是江湖常用的张正友标定算法,很明显比较复杂,还好iai_kinect2中有标定的程序,只需要复制粘贴命令就好。

下面提示一些小步骤:

1、打印棋盘。下载7*5*0.03这个版本的,这个恰好适合一张A4,打印的时候,尽量让黑色显示的黑一点,图片是PDF格式,选择实际大小,这个很重要,一定要保证每个黑色或者白色正方形的边长为3厘米。

2、贴纸和放置相机。这是一个细心的活儿,选一个平板,重点在于一定要将纸贴平,要是有三脚架最好,这样便于移动调整相机位置,没有那就随缘吧。


3、相机和棋盘以及光线。尽量不要将棋盘直接对着强光,比如太阳,我遇到的一个很无语的问题就是,使劲按住space或者s键,但是就是无法保存图片,还报错了一个这样的问题——

[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]

但是教程2在文末提示,这样的错误是不存在的,根本不影响标定,于是我就很乱动,后来才发现,原来是因为位置摆放的不好。

4、关于相机的移动。教程要求,每个数据集需要拍照100张照片,只有出现下面这样的连接线,才表示可以保存——



5、在看

Detailed steps:

输入命令之前,还需要 roslaunch kinect2_bridge kinect2_bridge.launch

然后就一步步的按照教程走就好了

问题应该就出在这儿,我已经前前后后,试过好几种方法,标记了6次,没有一次效果ok的,根本达不到源码作者那样的效果。

应该就是我不明白标定的技术细节。总会出现深度图和rgb的不匹配,深度图的膨胀和向右偏移



6、不要长时间的按住space空格键!这样会一直保存图片,在你毫不知情的情况下,拍上过多的照片,这将导致你接下来的校正无比长久,因此,尽量转动一个角度,偏移一个距离,拍一张,距离尽量在0.5米到1.5米,角度可以稍微放开一些。100张照片,以我i7的CPU,每个数据集将近处理12分钟。第一次手误拍了700张照片,上时间无法结束校正,只好删除重启重新来过。

7、后面的寻找设备号,这个就不太清楚了,还没有进行到那一步,等做好了,再更新。

先放一张拍的图片——



8、关于谷歌翻译的一些个人理解:

  1. Record images on both cameras synchronized: rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record sync
  2. 这个将红外和rgb都显示出来,都有彩色线连起来,然后保存,这个应该就是所谓的同步校正吧
  3. 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
  4. 通过kinect2_bridge,查看你的k2的序列号,这个我还无法理解,也不知道怎么获取,很明显device serial并不是command,需要查看kinect2_bridge运行的时候,显示的信息
  5. Create the calibration results directory in kinect2_bridge/data/$serial: roscd kinect2_bridge/data; mkdir 012526541941
  6. 利用roscd,快速进入kinect2_bridge/data目录,并且用你的序列号,创建一个目录,保存你的校正结果
  7. 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
  8. 将这几个文件复制到上面新建的目录中
  9. Restart the kinect2_bridge and be amazed at the better data.
  10. 重启你的设备,看看是不是真的有效果~





  • 6
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 14
    评论
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hehedadaq

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值