# Object Recognition with YOLO \[Melodic]

## Download package

{% hint style="info" %}
When you receive your R1mini, this package should already be installed and setup. To run YOLO, move onto the "Run YOLO" section.
{% endhint %}

In \~/catkin\_ws/src/, run the below line in the terminal shell to download the package to run YOLO on the R1mini.

```
sudo git clone --recursive https://github.com/PinkWink/darknet_ros
```

Next return to \~/catkin\_ws and build the workspace.

Next, update the \~/.bashrc file by running the below line in the terminal shell.

```
source ~/.bashrc
```

## Setup

Next, move to the yolo\_network\_config/weights folder by entering the below line in the terminal shell.

```
cd ~/catkin_ws/src/darknet_ros/darkent_ros/yolo_network_config/weights
```

Then, download the weights for YOLOv3 Tiny by entering the below line in the terminal shell.

```
sudo wget http://pjereddie.com/media/files/yolov3-tiny.weights
```

## Adjust Camera Settings

Afterwards, run the below line to turn on the camera. The camera needs to be on for us to capture its output rostopic to subscribe to with YOLO.

```
roslaunch jetson_camera jetson_camera.launch
```

Next, run the below line to find a list of rostopsics. The topic we are looking for should be called /main\_camera/image\_raw.

![Image courtesy of Omorobot.](https://3827101858-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-McPC4jDSGGTd1f6bAav%2F-Md_gMIHIuOkWGzxbp0R%2F-Md_in0AaQ2O7VL_0fIf%2Fimage_raw.png?alt=media\&token=a866d03e-f169-4cfe-a752-a738e05b5659)

Next, return home and run the below line to enter the launch directory of darknet\_ros.

```
cd catkin_ws/src/darknet_ros/darknet_ros/launch
```

Run the below line to open darknet\_ros.launch in nano.

```
nano darknet_ros.launch
```

Next, we edit darknet\_ros.launch so that the default for \<arg name="image"> continues to run normally. In darknet\_ros.launch, change the command at the arrows to reflect the images below.

![](https://3827101858-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-McPC4jDSGGTd1f6bAav%2F-Md_j96FLCpSg_VoZaym%2F-Md_jnExTSKbl-PyvRxc%2Fd1.png?alt=media\&token=6a0371b3-8226-4f06-b171-cbad10c16e7a)

## Run YOLO

To run YOLO, enter the below command into the terminal shell.

```
roslaunch darknet_ros darknet_ros.launch
```

To see the visual output from YOLO, run the below command in the terminal shell to open rqt\_image\_view.

```
rqt_image_view
```

![Image courtesy of Omorobot.](https://3827101858-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-McPC4jDSGGTd1f6bAav%2F-Md_o3ByFKwPLD-lW7MJ%2F-Md_oS4aqyAM0EGMHdXF%2Fi2.png?alt=media\&token=011889f2-bb0c-4391-9496-ddad1ea989cf)
