Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yolo tracking to tuturiol6 #80

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add yolo tracking to tuturiol6 #80

wants to merge 2 commits into from

Conversation

robin-shaun
Copy link
Contributor

Yolo目标追踪仿真文档

1. 建立仿真环境

参考GAAS全局目标追踪教程

2.制作数据集

2.1.启动仿真(以GAAS第六讲中的小车为例)

roslaunch px4 car_tracking.launch

上述命令会启动仿真,生成一个小车,以及无人机。(在场景中多插入一些干扰物可以提高数据集的质量)
image

robin@robin-G3-3590:~/px4/GAAS/demo/tutorial_6/6_object_tracking$ python px4_mavros_run.py 
robin@robin-G3-3590:~/px4/GAAS/demo/tutorial_6/6_object_tracking$ python init_drone.py 

打开rviz确认小车出现在摄影机的视野中.

![123](https://user-images.githubusercontent.com/20561850/72730638-b38dc000-3bcc-11ea-9f82-cf96b196f9a9.png)

rviz

点击Add-选By topic-/gi/simulation/left/image_raw/Image

image

2.2.利用Rosbag录制照片

之前我们用rviz选择显示的 /gi/simulation/left/image_raw 就代表飞机左目摄像头的信息,我们可以利用Rosbag功能来记录这个topic

#把topic录制下来并保存为Imag.bag
rosbag record /gi/simulation/left/image_raw -O Imag.bag

运行上述命令后相当于给飞机开了录像,接下来我们通过指令或者地面站控制飞机运动,对照着rviz里面显示的"取景器"拍摄**不同角度、不同尺寸(通过调节飞机高度)**的小车图片.拍摄完成后crtl+c退出.

之后利用脚本把.bag文件里头的图片提取出来.
(bag2image.py在/GAAS/demo/tutorial_2/2_Struction_from_Motion中)

python bag2image.py --bag (PATH-TO-YOUR-BAG) --output_path (IMAGE-OUTPUT-FOLDER) --image_topic /gi/simulation/left/image_raw

2.3.对照片进行标注

  • 安装labelimg
sudo apt-get install pyqt5-dev-tools
sudo pip3 install lxml
git clone https://github.com/tzutalin/labelImg.git
cd labelImg
make all
python3 labelImg.py  #打开labelImg
  • labelimg的使用
    • 通过"打开目录"和"更改保存目录"来设定输入图片和输出标签.xml文件的目录.

    • 如下图选择创建区块后在目标处画一个框框,然后输入标签"car",之后点击保存,把标签文件保存成.xml文件
      123

    • 下一张,重复上述操作(由于rosbag采集图像帧率比较高,没必要所有图像都标注,可以挑着选角度不一样的照片标)

3.训练数据集

4.安装配置ROS版YOLO

4.1.安装

参考darknet_ros

4.2.配置

  • darknet_ros:将launch/px4_tracking.launch, config/yolov3-tiny.yaml, config/px4_tracking.yaml, yolo_network_config/cfg/car.cfg, yolo_network_config/weights/car.weights复制到对应目录下
    (如果你自己训练了网络,那么将你的网络配置文件和权重文件命名为car)
  • GAAS: 将yolo_tracking.py复制到GAAS/demo/tutorial_6/6_object_tracking

5.启动追踪仿真

在2.1的基础上,启动darknet_ros

source ~/catkin_ws/devel/setup.bash
roslaunch darknet_ros px4_tracking.launch 

弹出一个框口,并看到terminal中显示FPS和识别的类及其准确率
yolo_tracking1
然后启动追踪程序(该程序需放入对
应目录下)

robin@robin-G3-3590:~/px4/GAAS/demo/tutorial_6/6_object_tracking$ python yolo_tracking.py 

最后用键盘控制小车运动,无人机便能一直追踪小车了

rosrun teleop_twist_keyboard teleop_twist_keyboard.py

这个ros包的安装方式为

sudo apt install ros-kinetic-teleop-twist-keyboard

@Craddock7
Copy link

China's leaving us behind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants