使用iai_kinect2标定kinectV2相机
實(shí)驗(yàn)背景:因?yàn)樾枰谱鱞undlefusion需要的數(shù)據(jù)集,所以需要使用kinectV2相機(jī)獲取rgbd圖像,年前的時(shí)候在我的筆記本上安裝了libfreenect2庫(kù)和iai_kinect2,標(biāo)定過一次kinecv2相機(jī),然后使用kinectv2相機(jī)實(shí)時(shí)獲取的圖像實(shí)現(xiàn)elasticfusion稠密重建.但是由于當(dāng)時(shí)時(shí)間緊迫,很多東西都沒有搞明白,所以趁這次機(jī)會(huì)將一些問題整理一下,記錄一下.
環(huán)境搭建:
1. 安裝了ROS的kinetic版本
libfreenect2和iai_kinect2的安裝參考文章: https://www.cnblogs.com/li-yao7758258/p/7445429.html
2. 下載libfreenect2
$ cd Downloads $ git clone https://github.com/OpenKinect/libfreenect2.git3.安裝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_*.deb4.? 繼續(xù)安裝libfreenect2庫(kù)
$ cd libfreenect2 $ mkdir build $ cmake ../ $ make -j4 $ sudo make install5. 使用lsusb指令測(cè)試kinectv2相機(jī)有沒有鏈接成功.
6. 編譯iai_kinect2
$ cd ~/ROS #在/home/yunlei下創(chuàng)建了一個(gè)ROS文件夾,專門盛放ros的工程 $ mkdir -r ./iai_kinect2_ws/src/ $ cd ./iai_kinect2/src $ git clone https://github.com/code-iai/iai_kinect2.git $ cd iai_kinect2 $ rosdep install -r --from-paths . $ cd ~/ROS/iai_kinect2 $ catkin_make -DCMAKE_BUILD_TYPE="Release" $ rospack profile7. 測(cè)試kinectv2相機(jī)是否鏈接成功
$ cd Download $ cd libfreenect $ cd build/bin $ ./Protonect如果一切正常的話,相機(jī)拍攝的畫面將映入眼簾.?
?8. 測(cè)試kinectv2圖像數(shù)據(jù)
$ cd ~/ROS/iai_kinect2_ws $ source ./devel/setup.bash $ roslaunch kinect2_bridge kinect2_bridge.launch# open a new terminal $ rosrun kinect2_viewer kinect2_viewer(但是我這里執(zhí)行失敗)9. 查看此時(shí)發(fā)布的與kinect相關(guān)的topics
/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/points10. 打開/home/yunlei/ROS/iai_kinect2_ws/src/iai_kinect2/kinect2_bridge/launch/kinect2_bridge.launch查看kinect相機(jī)的分辨率
<!-- sd point cloud (512 x 424) --><node pkg="nodelet" type="nodelet" name="$(arg base_name)_points_xyzrgb_sd" machine="$(arg machine)"args="load depth_image_proc/point_cloud_xyzrgb $(arg nodelet_manager)" respawn="$(arg respawn)"><remap from="rgb/camera_info" to="$(arg base_name)/sd/camera_info"/><remap from="rgb/image_rect_color" to="$(arg base_name)/sd/image_color_rect"/><remap from="depth_registered/image_rect" to="$(arg base_name)/sd/image_depth_rect"/><remap from="depth_registered/points" to="$(arg base_name)/sd/points"/><param name="queue_size" type="int" value="$(arg queue_size)"/></node><!-- qhd point cloud (960 x 540) --><node pkg="nodelet" type="nodelet" name="$(arg base_name)_points_xyzrgb_qhd" machine="$(arg machine)"args="load depth_image_proc/point_cloud_xyzrgb $(arg nodelet_manager)" respawn="$(arg respawn)"><remap from="rgb/camera_info" to="$(arg base_name)/qhd/camera_info"/><remap from="rgb/image_rect_color" to="$(arg base_name)/qhd/image_color_rect"/><remap from="depth_registered/image_rect" to="$(arg base_name)/qhd/image_depth_rect"/><remap from="depth_registered/points" to="$(arg base_name)/qhd/points"/><param name="queue_size" type="int" value="$(arg queue_size)"/></node><!-- hd point cloud (1920 x 1080) --><node pkg="nodelet" type="nodelet" name="$(arg base_name)_points_xyzrgb_hd" machine="$(arg machine)"args="load depth_image_proc/point_cloud_xyzrgb $(arg nodelet_manager)" respawn="$(arg respawn)"><remap from="rgb/camera_info" to="$(arg base_name)/hd/camera_info"/><remap from="rgb/image_rect_color" to="$(arg base_name)/hd/image_color_rect"/><remap from="depth_registered/image_rect" to="$(arg base_name)/hd/image_depth_rect"/><remap from="depth_registered/points" to="$(arg base_name)/hd/points"/><param name="queue_size" type="int" value="$(arg queue_size)"/>可以發(fā)現(xiàn)kinecv2相機(jī)可以直接獲取的圖像的分辨率有三個(gè),分別是:hd(1920x1080), qhd(960x540), sd(512x424),每一種分辨率又對(duì)應(yīng)了彩色圖,灰度圖,深度圖,以及是否是經(jīng)過去畸變處理的,深度圖是否和彩色圖配準(zhǔn).
11. 如果你想獲取rect圖像,那么你需要給定相應(yīng)分辨率的相機(jī)內(nèi)參數(shù),而此時(shí)使用的是默認(rèn)/iai_kinect2/kinect2_bridge/data下的相機(jī)參數(shù),所以你需要標(biāo)定你需要的分辨率的相機(jī)參數(shù).
12.關(guān)于數(shù)據(jù)獲取,如果我標(biāo)定了960x540的相機(jī)內(nèi)參數(shù),獲取了去畸變后的而圖像,我直接使用rosbag record指令,錄制相應(yīng)的topic就可以了.所以現(xiàn)在最關(guān)鍵的是標(biāo)定相機(jī)
13. iai_kinect2中也提供了標(biāo)定工具,在/home/yunlei/ROS/iai_kinect2_ws/src/iai_kinect2/kinect2_calibration中,不過此時(shí)在/home/yunlei/ROS/iai_kinect2_ws/src/iai_kinect2/kinect2_calibration/src/kinect2_calibration.cpp文件中默認(rèn)是標(biāo)定1920x1080的圖像,如果想要標(biāo)定960x540的相機(jī)內(nèi)參數(shù),則需要將文件1349行中的HD改為QHD
將原來的
std::string topicColor = "/" + ns + K2_TOPIC_HD + K2_TOPIC_IMAGE_MONO; std::string topicIr = "/" + ns + K2_TOPIC_SD + K2_TOPIC_IMAGE_IR; std::string topicDepth = "/" + ns + K2_TOPIC_SD + K2_TOPIC_IMAGE_DEPTH;改為?
std::string topicColor = "/" + ns + K2_TOPIC_QHD + K2_TOPIC_IMAGE_MONO; std::string topicIr = "/" + ns + K2_TOPIC_SD + K2_TOPIC_IMAGE_IR; std::string topicDepth = "/" + ns + K2_TOPIC_SD + K2_TOPIC_IMAGE_DEPTH;我剛開始改成了SD但是這種情況下,當(dāng)你執(zhí)行rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record color指令時(shí),沒有彈出圖像窗口,無法保存圖像,并且提示
[ERROR] Tried to advertise a service that is already advertised in this node [/kinect2_calib_1591865100768222736/compressed/set_parameters] [ERROR] Tried to advertise a service that is already advertised in this node [/kinect2_calib_1591865100768222736/compressed/set_parameters]我剛開始根據(jù)這個(gè)錯(cuò)誤提示去搜索出了什么問題,但是有網(wǎng)友說這個(gè)不影響標(biāo)定,(https://blog.csdn.net/weixin_30536513/article/details/94969881)但是我這里確實(shí)影響了.我折騰了好久,但是還是沒有解決這個(gè)問題,當(dāng)我想放棄的時(shí)候,突然想起來,我可以把上面的SD改為QHD試試.果然,當(dāng)我改成了QHD后發(fā)現(xiàn),雖然還是會(huì)有上面的錯(cuò)誤的提示,但是此時(shí)彈出了圖像窗口,當(dāng)我拿著標(biāo)定板進(jìn)入相機(jī)的視野時(shí),他可以檢測(cè)到標(biāo)定板子上的特征點(diǎn),哇,我好開心.
總結(jié)
以上是生活随笔為你收集整理的使用iai_kinect2标定kinectV2相机的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在ASP.NET Core使用Middl
- 下一篇: 动感标题文字快闪(闪白特效)开场PR模板