物体识别使用了tensorflow_object_detector的功能包,具体实现可以参考以下文章,在此不再赘述。
https://blog.csdn.net/qq_37464350/article/details/81009695
最近有在ros使用tensorflow以识别物体的需求,因此想要安装tensorflow并使用。在安装时出现了很多错误,研究了很久终于成功安装并使用,因此再此列出错误。以下解决办法出自互联网,由笔者整理,如有错误,欢迎指正。
错误1:无法使用PyInit_cv_bridge_boost模块
具体报错:
[ERROR] [1632402355.945936]: bad callback: <bound method Detector.image_cb of <__main__.Detector object at 0x7f29da6574e0>>
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback cb(msg) File "/home/huanyu-pc/my_ws/src/tensorflow_object_detector/scripts/detect_ros.py", line 80, in image_cb
cv_image = self.bridge.imgmsg_to_cv2(data, "bgr8")
File "/opt/ros/melodic/lib/python2.7/dist-packages/cv_bridge/core.py", line 163, in imgmsg_to_cv2
dtype, n_channels = self.encoding_to_dtype_with_channels(img_msg.encoding)
File "/opt/ros/melodic/lib/python2.7/dist-packages/cv_bridge/core.py", line 99, in encoding_to_dtype_with_channels
return self.cvtype2_to_dtype_with_channels(self.encoding_to_cvtype2(encoding))
File "/opt/ros/melodic/lib/python2.7/dist-packages/cv_bridge/core.py", line 91, in encoding_to_cvtype2
from cv_bridge.boost.cv_bridge_boost import getCvType
ImportError: dynamic module does not define module export function (PyInit_cv_bridge_boost)
解决办法:遇到这种问题是因为使用了python版本为3的opencv,具体原因我也拿不准,应该是不兼容了,解决办法找了很久都找不到,推荐删除这个环境,新建立一个python版本2.7的环境安装tensorflow并使用。
错误二:出现语法错误SyntaxError: invalid syntax
解决办法:pip install protobuf==3.17.3
缺少模块ImportError:No module named ‘PIL’
pip install -i https://pypi.douban.com/simple pillow