本文基于古月居《ROS机器人开发与实践》一书而来,应用robot_vision与tensorflow_object_detection功能包
1)连接摄像头到PC端,可以通过
roslaunch usb_cam usb_cam-test.launch
测试摄像头
如果有问题可以参考https://blog.csdn.net/felaim/article/details/60146455
解决
2)安装Opencv
sudo apt-get update
sudo apt-get install ros-kinectic-vision-opencv libopencv-dev python-opencv
测试一下
rosrun robot_vision cv_bridge_test.py
rqt_image_view
3)安装Tensorflow
sudo apt-get install python-pip python-dev
sudo -H pip install --upgrade pip
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.0-cp27-none-linux_x86_64.whl
pip --default-timeout=1000 install -U pip
sudo pip install --upgrade $TF_BINARY_URL
测试一下
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
4)安装Tensorflow Object Detection API
sudo apt-get install protobuf-compiler python-pil python-lxml
sudo pip install jupyter
sudo pip install matplotlib
然后下载模型库
git clone https://github.com/tensorflow/models
可以先用迅雷下好再转到home目录下
编译库
(在research下编译)
注:安装jupyter时可能遇到错误,更新一下pip再安装,sudo -H pip install –upgrade pip
如果失败点击打开链接
需要重新更新jupyter
protoc object_detection/protos/*.proto --python_out=.
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
python object_detection/builders/model_builder_test.py
5)运行识别
roslaunch usb_cam usb_cam-test.launch
roslaunch tensorflow_object_detection ros_tensorflow_object_detection.launch
rqt_image_view
后续学习
https://blog.csdn.net/wizardforcel/article/details/79293944
参考博客
https://blog.csdn.net/mwlwlm/article/details/75126670
https://blog.csdn.net/weixin_35654926/article/details/75452450