1. 程式人生 > >Ubuntu16.04+Kinect2攝像頭進行物體識別

Ubuntu16.04+Kinect2攝像頭進行物體識別

ork功能包

首先安裝依賴庫:

sudo apt-get install meshlab

sudo apt-get install libosmesa6-dev

sudo apt-get install python-pyside.qtcore

sudo apt-get install python-pyside.qtgui

下載原始碼編譯:
mkdir ork_ws
cd ork_ws
wstool init src https://raw.github.com/wg-perception/object_recognition_core/master/doc/source/ork.rosinstall.kinetic.plus


cd src
wstool update -j8
cd ..
rosdep install --from-paths src -i -y

catkin_make

echo "source ~/ork_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

ORK 是一套以 template matching 方法為主的辨識工具,也就是說,他會把感測器看到的物體跟資料庫中的物體比對,夠相似的就算是辨識成功,所以我們接著要來處理資料庫。首先要安裝 CouchDB 這個工具
sudo apt-get install couchdb
接下來檢查一下是否有安裝成功
用 curl -X GET http://localhost:5984


rosrun object_recognition_core object_add.py -n "coke " -d "A universal can of coke" --commit
執行上面這個指令之後,你可以去 http://localhost:5984/_utils/database.html?object_recognition/_design/objects/_view/by_object_name 看看自己的資料庫裡是否已經新增了這個物體:


git clone https://github.com/wg-perception/ork_tutorials
cd .. && catkin_make


rosrun object_recognition_core mesh_add.py <YOUR_OBJECT_ID> <path to ork_tutorials/data/coke.stl> --commit

[    9085f3469dffde7c1ae78413d900079d
rosrun object_recognition_core mesh_add.py 9085f3469dffde7c1ae78413d900079d /home/zx/ork_ws/src/ork_tutorials/data/coke.stl --commit
]


檢視模型:
sudo pip install git+https://github.com/couchapp/couchapp.git
rosrun object_recognition_core push.sh

{安裝pip:  sudo apt install python-pip}

訓練模型:
rosrun object_recognition_core training -c `rospack find object_recognition_linemod`/conf/training.ork


識別:
cd kinect_ws
source devel/setup.bash
roslaunch kinect2_bridge kinect2_bridge.launch publish_tf:=true
 
rviz
 
cd ork_ws
source devel/setup.bash
rosrun topic_tools relay /kinect2/qhd/image_depth_rect /camera/depth_registered/image_raw
 
rosrun topic_tools relay /kinect2/qhd/image_color_rect /camera/rgb/image_rect_color
 
rosrun topic_tools relay /kinect2/qhd/camera_info /camera/rgb/camera_info
 
rosrun topic_tools relay /kinect2/qhd/camera_info /camera/depth_registered/camera_info
 
rosrun topic_tools relay /kinect2/qhd/points /camera/depth_registered/points
 
rosrun tf static_transform_publisher 0 0 0 0 0 0 kinect2_ir_opticalrame camera_depth_optical_frame 40
 
rosrun object_recognition_core detection -c  `rospack find object_recognition_linemod`/conf/detection.ros.ork