小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
在使用小鱼的yolov5_ros2功能包时,编译环节出现问题
-
-
此回复已被删除! -
此回复已被删除! -
@小鱼
TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'Failed <<< iocpsupport [2.04s, exited with code 1]
Aborted <<< matrixlib [2.30s]
Aborted <<< ma [2.43s]Summary: 0 packages finished [14.3s]
1 package failed: iocpsupport
2 packages aborted: ma matrixlib
2 packages had stderr output: iocpsupport ma -
@LeeSonFirm https://fishros.org.cn/forum/topic/151/提问前必看-不符合要求的问题拒绝回答
每看出和yolo相关的日志,请提供完整的上下文和操作流程和日志
-
@小鱼
请问下好的安装包在哪个目录里面啊,好像关于yolo的包没下载下来 -
@小鱼
找不到yolov5的包 -
@LeeSonFirm 下载到哪个目录是你自己决定的
-
@小鱼
当时没设置位置,直接粘贴代码了,现在不知道在哪,还有办法找出来吗 -
@小鱼
lizijian@lizijian-virtual-machine:~$ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple yolov5
/usr/bin/pip3:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import load_entry_point
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: yolov5 in ./.local/lib/python3.8/site-packages (7.0.13)
Requirement already satisfied: gitpython>=3.1.30 in ./.local/lib/python3.8/site-packages (from yolov5) (3.1.43)
Requirement already satisfied: matplotlib>=3.3 in ./.local/lib/python3.8/site-packages (from yolov5) (3.7.5)
Requirement already satisfied: numpy>=1.18.5 in ./.local/lib/python3.8/site-packages (from yolov5) (1.24.4)
Requirement already satisfied: opencv-python>=4.1.1 in ./.local/lib/python3.8/site-packages (from yolov5) (4.10.0.84)
Requirement already satisfied: Pillow>=7.1.2 in ./.local/lib/python3.8/site-packages (from yolov5) (10.4.0)
Requirement already satisfied: psutil in /usr/lib/python3/dist-packages (from yolov5) (5.5.1)
Requirement already satisfied: PyYAML>=5.3.1 in /usr/lib/python3/dist-packages (from yolov5) (5.3.1)
Requirement already satisfied: requests>=2.23.0 in ./.local/lib/python3.8/site-packages (from yolov5) (2.32.3)
Requirement already satisfied: scipy>=1.4.1 in ./.local/lib/python3.8/site-packages (from yolov5) (1.10.1)
Requirement already satisfied: thop>=0.1.1 in ./.local/lib/python3.8/site-packages (from yolov5) (0.1.1.post2209072238)
Requirement already satisfied: torch>=1.7.0 in ./.local/lib/python3.8/site-packages (from yolov5) (2.3.1)
Requirement already satisfied: torchvision>=0.8.1 in ./.local/lib/python3.8/site-packages (from yolov5) (0.18.1)
Requirement already satisfied: tqdm>=4.64.0 in ./.local/lib/python3.8/site-packages (from yolov5) (4.66.4)
Requirement already satisfied: ultralytics>=8.0.100 in ./.local/lib/python3.8/site-packages (from yolov5) (8.2.60)
Requirement already satisfied: tensorboard>=2.4.1 in ./.local/lib/python3.8/site-packages (from yolov5) (2.14.0)
Requirement already satisfied: pandas>=1.1.4 in ./.local/lib/python3.8/site-packages (from yolov5) (2.0.3)
Requirement already satisfied: seaborn>=0.11.0 in ./.local/lib/python3.8/site-packages (from yolov5) (0.13.2)
Requirement already satisfied: setuptools>=65.5.1 in ./.local/lib/python3.8/site-packages (from yolov5) (71.0.3)
Requirement already satisfied: fire in ./.local/lib/python3.8/site-packages (from yolov5) (0.6.0)
Requirement already satisfied: boto3>=1.19.1 in ./.local/lib/python3.8/site-packages (from yolov5) (1.34.145)
Requirement already satisfied: sahi>=0.11.10 in ./.local/lib/python3.8/site-packages (from yolov5) (0.11.18)
Requirement already satisfied: huggingface-hub>=0.12.0 in ./.local/lib/python3.8/site-packages (from yolov5) (0.24.0)
Requirement already satisfied: roboflow>=0.2.29 in ./.local/lib/python3.8/site-packages (from yolov5) (1.1.36)
Requirement already satisfied: gitdb<5,>=4.0.1 in ./.local/lib/python3.8/site-packages (from gitpython>=3.1.30->yolov5) (4.0.11)
Requirement already satisfied: contourpy>=1.0.1 in ./.local/lib/python3.8/site-packages (from matplotlib>=3.3->yolov5) (1.1.1)
Requirement already satisfied: cycler>=0.10 in /usr/lib/python3/dist-packages (from matplotlib>=3.3->yolov5) (0.10.0)
Requirement already satisfied: fonttools>=4.22.0 in ./.local/lib/python3.8/site-packages (from matplotlib>=3.3->yolov5) (4.53.1)
Requirement already satisfied: kiwisolver>=1.0.1 in ./.local/lib/python3.8/site-packages (from matplotlib>=3.3->yolov5) (1.4.5)
Requirement already satisfied: packaging>=20.0 in /usr/lib/python3/dist-packages (from matplotlib>=3.3->yolov5) (20.3)
Requirement already satisfied: pyparsing>=2.3.1 in /usr/lib/python3/dist-packages (from matplotlib>=3.3->yolov5) (2.4.6)
Requirement already satisfied: python-dateutil>=2.7 in ./.local/lib/python3.8/site-packages (from matplotlib>=3.3->yolov5) (2.9.0.post0)
Requirement already satisfied: importlib-resources>=3.2.0; python_version < "3.10" in ./.local/lib/python3.8/site-packages (from matplotlib>=3.3->yolov5) (6.4.0)
Requirement already satisfied: charset-normalizer<4,>=2 in ./.local/lib/python3.8/site-packages (from requests>=2.23.0->yolov5) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests>=2.23.0->yolov5) (2.8)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3/dist-packages (from requests>=2.23.0->yolov5) (1.25.8)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests>=2.23.0->yolov5) (2019.11.28)
Requirement already satisfied: filelock in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (3.15.4)
Requirement already satisfied: typing-extensions>=4.8.0 in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (4.12.2)
Requirement already satisfied: sympy in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (1.13.0)
Requirement already satisfied: networkx in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (3.1)
Requirement already satisfied: jinja2 in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (3.1.4)
Requirement already satisfied: fsspec in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (2024.6.1)
Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.1.105; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (12.1.105)
Requirement already satisfied: nvidia-cuda-runtime-cu12==12.1.105; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (12.1.105)
Requirement already satisfied: nvidia-cuda-cupti-cu12==12.1.105; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (12.1.105)
Requirement already satisfied: nvidia-cudnn-cu12==8.9.2.26; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (8.9.2.26)
Requirement already satisfied: nvidia-cublas-cu12==12.1.3.1; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (12.1.3.1)
Requirement already satisfied: nvidia-cufft-cu12==11.0.2.54; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (11.0.2.54)
Requirement already satisfied: nvidia-curand-cu12==10.3.2.106; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (10.3.2.106)
Requirement already satisfied: nvidia-cusolver-cu12==11.4.5.107; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (11.4.5.107)
Requirement already satisfied: nvidia-cusparse-cu12==12.1.0.106; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (12.1.0.106)
Requirement already satisfied: nvidia-nccl-cu12==2.20.5; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (2.20.5)
Requirement already satisfied: nvidia-nvtx-cu12==12.1.105; platform_system == "Linux" and platform_machine == "x86_64" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (12.1.105)
Requirement already satisfied: triton==2.3.1; platform_system == "Linux" and platform_machine == "x86_64" and python_version < "3.12" in ./.local/lib/python3.8/site-packages (from torch>=1.7.0->yolov5) (2.3.1)
Requirement already satisfied: py-cpuinfo in ./.local/lib/python3.8/site-packages (from ultralytics>=8.0.100->yolov5) (9.0.0)
Requirement already satisfied: ultralytics-thop>=2.0.0 in ./.local/lib/python3.8/site-packages (from ultralytics>=8.0.100->yolov5) (2.0.0)
Requirement already satisfied: absl-py>=0.4 in ./.local/lib/python3.8/site-packages (from tensorboard>=2.4.1->yolov5) (2.1.0)
Requirement already satisfied: grpcio>=1.48.2 in ./.local/lib/python3.8/site-packages (from tensorboard>=2.4.1->yolov5) (1.65.1)
Requirement already satisfied: google-auth<3,>=1.6.3 in ./.local/lib/python3.8/site-packages (from tensorboard>=2.4.1->yolov5) (2.32.0)
Requirement already satisfied: google-auth-oauthlib<1.1,>=0.5 in ./.local/lib/python3.8/site-packages (from tensorboard>=2.4.1->yolov5) (1.0.0)
Requirement already satisfied: markdown>=2.6.8 in ./.local/lib/python3.8/site-packages (from tensorboard>=2.4.1->yolov5) (3.6)
Requirement already satisfied: protobuf>=3.19.6 in ./.local/lib/python3.8/site-packages (from tensorboard>=2.4.1->yolov5) (5.27.2)
Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in ./.local/lib/python3.8/site-packages (from tensorboard>=2.4.1->yolov5) (0.7.2)
Requirement already satisfied: werkzeug>=1.0.1 in ./.local/lib/python3.8/site-packages (from tensorboard>=2.4.1->yolov5) (3.0.3)
Requirement already satisfied: wheel>=0.26 in /usr/lib/python3/dist-packages (from tensorboard>=2.4.1->yolov5) (0.34.2)
Requirement already satisfied: pytz>=2020.1 in ./.local/lib/python3.8/site-packages (from pandas>=1.1.4->yolov5) (2024.1)
Requirement already satisfied: tzdata>=2022.1 in ./.local/lib/python3.8/site-packages (from pandas>=1.1.4->yolov5) (2024.1)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from fire->yolov5) (1.14.0)
Requirement already satisfied: termcolor in ./.local/lib/python3.8/site-packages (from fire->yolov5) (2.4.0)
Requirement already satisfied: botocore<1.35.0,>=1.34.145 in ./.local/lib/python3.8/site-packages (from boto3>=1.19.1->yolov5) (1.34.145)
Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in ./.local/lib/python3.8/site-packages (from boto3>=1.19.1->yolov5) (1.0.1)
Requirement already satisfied: s3transfer<0.11.0,>=0.10.0 in ./.local/lib/python3.8/site-packages (from boto3>=1.19.1->yolov5) (0.10.2)
Requirement already satisfied: shapely>=1.8.0 in ./.local/lib/python3.8/site-packages (from sahi>=0.11.10->yolov5) (2.0.5)
Requirement already satisfied: pybboxes==0.1.6 in ./.local/lib/python3.8/site-packages (from sahi>=0.11.10->yolov5) (0.1.6)
Requirement already satisfied: terminaltables in ./.local/lib/python3.8/site-packages (from sahi>=0.11.10->yolov5) (3.1.10)
Requirement already satisfied: click in /usr/lib/python3/dist-packages (from sahi>=0.11.10->yolov5) (7.0)
Requirement already satisfied: chardet==4.0.0 in ./.local/lib/python3.8/site-packages (from roboflow>=0.2.29->yolov5) (4.0.0)
Requirement already satisfied: opencv-python-headless==4.10.0.84 in ./.local/lib/python3.8/site-packages (from roboflow>=0.2.29->yolov5) (4.10.0.84)
Requirement already satisfied: python-dotenv in ./.local/lib/python3.8/site-packages (from roboflow>=0.2.29->yolov5) (1.0.1)
Requirement already satisfied: requests-toolbelt in ./.local/lib/python3.8/site-packages (from roboflow>=0.2.29->yolov5) (1.0.0)
Requirement already satisfied: filetype in ./.local/lib/python3.8/site-packages (from roboflow>=0.2.29->yolov5) (1.2.0)
Requirement already satisfied: smmap<6,>=3.0.1 in ./.local/lib/python3.8/site-packages (from gitdb<5,>=4.0.1->gitpython>=3.1.30->yolov5) (5.0.1)
Requirement already satisfied: zipp>=3.1.0; python_version < "3.10" in ./.local/lib/python3.8/site-packages (from importlib-resources>=3.2.0; python_version < "3.10"->matplotlib>=3.3->yolov5) (3.19.2)
Requirement already satisfied: mpmath<1.4,>=1.1.0 in ./.local/lib/python3.8/site-packages (from sympy->torch>=1.7.0->yolov5) (1.3.0)
Requirement already satisfied: MarkupSafe>=2.0 in ./.local/lib/python3.8/site-packages (from jinja2->torch>=1.7.0->yolov5) (2.1.5)
Requirement already satisfied: nvidia-nvjitlink-cu12 in ./.local/lib/python3.8/site-packages (from nvidia-cusolver-cu12==11.4.5.107; platform_system == "Linux" and platform_machine == "x86_64"->torch>=1.7.0->yolov5) (12.5.82)
Requirement already satisfied: cachetools<6.0,>=2.0.0 in ./.local/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard>=2.4.1->yolov5) (5.4.0)
Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/lib/python3/dist-packages (from google-auth<3,>=1.6.3->tensorboard>=2.4.1->yolov5) (0.2.1)
Requirement already satisfied: rsa<5,>=3.1.4 in ./.local/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard>=2.4.1->yolov5) (4.9)
Requirement already satisfied: requests-oauthlib>=0.7.0 in ./.local/lib/python3.8/site-packages (from google-auth-oauthlib<1.1,>=0.5->tensorboard>=2.4.1->yolov5) (2.0.0)
Requirement already satisfied: importlib-metadata>=4.4; python_version < "3.10" in ./.local/lib/python3.8/site-packages (from markdown>=2.6.8->tensorboard>=2.4.1->yolov5) (8.0.0)
Requirement already satisfied: pyasn1>=0.1.3 in /usr/lib/python3/dist-packages (from rsa<5,>=3.1.4->google-auth<3,>=1.6.3->tensorboard>=2.4.1->yolov5) (0.4.2)
Requirement already satisfied: oauthlib>=3.0.0 in /usr/lib/python3/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<1.1,>=0.5->tensorboard>=2.4.1->yolov5) (3.1.0)这样算是下好了吗,下好了的话在哪个目录里面呢
-
@小鱼
DeprecationWarning: pkg_resources is deprecated as an API.是这个原因没下载下来吗 -
@LeeSonFirm 这个是下好了,下好了的目录有提示
@LeeSonFirm 在 在使用小鱼的yolov5_ros2功能包时,编译环节出现问题 中说:
Requirement already satisfied: yolov5 in ./.local/lib/python3.8/site-packages (7.0.13)
不过这只是依赖,并不是功能包
-
@小鱼
是的,我找不到yolov5的功能包,请问后续需要怎样操作呢? -
@LeeSonFirm 根据教程下载功能包就可以了
-
@小鱼
我按照教程用那个pip3 install指令没有下载下来,输入代码之后显示的就是我上面发的 -
@小鱼 是需要我去下载您在GitHub上给的yolov5_ros2的源码吗,然后放到这个依赖所在的目录中进行编译?
-
@LeeSonFirm 你看教程,按着教程走就可以了
-
@小鱼 我已经严格按照教程执行,可是输入pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple yolov5之后,我找不到这个功能包,并且无法进行编译
-
@小鱼 不好意思,我是小白,刚接触ros,让您费心了
-
@LeeSonFirm 输入这个命令只是安装yolov5的python库而已,当然找不到功能包,按照这个步骤来:
YOLO_ROS2
基于YOLOV5 的ROS2封装,允许用户使用给定的模型文件和相机参数进行三维空间物体检测和抓取操作。
1. 安装依赖
首先,确保您已经更新了系统并且安装了必要的依赖。以下是一些安装步骤,其中
$ROS_DISTRO
是您的ROS2发行版(例如:foxy
、galactic
):sudo apt update sudo apt install python3-pip ros-$ROS_DISTRO-vision-msgs pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple yolov5
2. 下载编译和运行
下载开源库
mkdir -p yolov5_ws/src cd yolov5_ws/src git clone https://github.com/fishros/yolov5_ros2.git
编译项目并设置环境变量
cd yolov5_ws colcon build source install/setup.bash
现在,您可以运行Yolo_ROS2节点。默认情况下,它将使用CPU来进行检测,使用名为
/image
的图像话题。您可以根据需要更改这些参数:ros2 run yolov5_ros2 yolo_detect_2d --ros-args -p device:=cpu -p image_topic:=/image
如果您要使用真实相机,请修改默认的图像话题(
image_topic:=/image
),然后在另一个终端中运行以下命令来将相机图像转化为ROS话题:ros2 run image_tools cam2image --ros-args -p width:=640 -p height:=480 -p frequency:=30.0 -p device_id:=-1
您也可以使用其他相机,例如
usb_cam
。在这种情况下,安装相应的包并运行usb_cam
节点:sudo apt-get install ros-<ros2-distro>-usb-cam # 安装 ros2 run usb_cam usb_cam_node_exe
3. 订阅结果
Yolo_ROS2将检测结果发布到
/yolo_result
话题中,包括原始像素坐标以及归一化后的相机坐标系下的x和y坐标。您可以使用以下命令查看检测结果:ros2 topic echo /yolo_result
4. 更进一步使用
4.1 参数设置
在运行Yolo_ROS2节点时,您可以使用
-p name:=value
的方式来修改参数值。4.1.1 图像话题
您可以通过指定以下参数来更改图像话题:
image_topic:=/image
4.1.2 计算设备设置
如果您有CUDA支持的显卡,可以选择以下参数来配置计算设备:
device:=cpu
4.1.3 是否实时显示结果
您可以使用以下参数来控制是否实时显示检测结果。设置为
True
将实时显示结果,设置为False
则不会显示:show_result:=False
请注意,实时显示中的
cv2.imshow
可能会卡住。如果只需要验证结果,可以将此参数设置为False
。4.1.4 切换不同Yolov5模型
默认情况下,Yolo_ROS2使用
yolov5s
模型。您可以通过以下参数来更改模型:model:=yolov5m
4.1.5 是否发布结果图像
如果您希望Yolo_ROS2发布检测结果的图像,请使用以下参数:
pub_result_img:=True
这将允许您通过
/result_img
话题查看检测结果的图像。4.1.5 相机参数文件
功能包默认从 /camera/camera_info 话题获取相机参数,在获取成功前,相机参数文件路径可以通过参数进行设置,参数为:camera_info_file,通过该参数可以设置文件路径,注意需要使用绝对目录:
camera_info_file:=/home/fishros/chapt9/src/yolov5_ros2/config/camera_info.yaml