# Image Data Annotation

Organize teleop images, configure Label Studio and copy annotations for machine learning.

## Step 1: Image Data Annotation with Label Studio

Set up the teleoperation image directory, configure environment variables and launch Label Studio to annotate your teleop image data, then copy annotated images to your local computer.

In order to label images captured during teleoperation sessions, you need to organize the files on the robot, configure Label Studio to serve them and then start the annotation server.  After annotation, you can export or copy the labeled images to your computer for further processing.

```bash
mkdir -p /home/rcr/teleop_data/images
```

```bash
mv /home/rcr/teleop_data/session_*/*.jpg /home/rcr/teleop_data/images/
```

```bash
mkdir -p /home/rcr/teleop_data/annotations
```

Set environment variables so Label Studio can serve local files from your `teleop_data` directory.  These variables must be exported in the current shell and persisted in your `~/.profile` so they apply after a reboot.

```bash
export LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true
export LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT="/home/rcr/teleop_data"
env | grep LABEL_STUDIO
```

To make these variables persistent, edit your profile and append the export statements:
```
echo 'export LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true' >> ~/.profile
echo 'export LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT="/home/rcr/teleop_data"' >> ~/.profile
```
Reload the profile with `source ~/.profile` or log out and back in.

```bash
cd /home/rcr/LabelMaker
source bin/activate
label-studio start -p 8080 -b
```

After labeling, you can copy the image dataset off the robot for safekeeping or further training.  From your PC or Mac, run the following command in a terminal, replacing `192.168.1.n` with your robot’s IP address:

```bash
scp -r rcr@192.168.1.n:/home/rcr/teleop_data/images /Users/$USER/Downloads/teleop_images
```

On Windows using `scp` (installed via Git or another package), specify the destination directory accordingly:

```bash
scp -r rcr@192.168.1.n:/home/rcr/teleop_data/images "C:\\Users\\YourName\\Downloads\\teleop_images"
```

