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,參數一定要給准確,不然會出現錯誤的 啊、

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM