Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Overview

As images are being sent over a connection with limited bandwidth, it is important to be able to compress (AKA encode) these images to minimize data usage. However, better compression is slower, and which is mutually exclusive to the goal of minimizing Autonomy’s control loop latency. Additionally, some compression is lossy, which degrades the quality of the final image after it is decompressed (AKA decoded).

...

Profiling: Testing performance.

Dataset

The dataset remains consistent between all runs. The dataset is a series of images taken at 30 FPS over exactly 10 seconds (300 frames), numbered consecutively starting from 10: https://uofwaterloo-my.sharepoint.com/personal/uwarg_uwaterloo_ca/_layouts/15/onedrive.aspx?ga=1&id=%2Fpersonal%2Fuwarg%5Fuwaterloo%5Fca%2FDocuments%2FSubteam%20Folders%2FAutonomy%2FEncode%20Test%20Dataset%202024

...

Expand
titleExample
Code Block
languagepy
IMAGE_COUNT = 300
IMAGE_FILES_FPS = 30  # Will never change

simulated_fps = 10  # As though the camera is at 10 FPS in this run
# Loops over every 30 / 10 = 3rd image
for i in range(0, 300, IMAGE_FILES_FPS / simulated_fps):
    # Load image i
    ...

    # Do something with it
    ...

Profile run categories

Encoding:

  • AVIF

    • Quality (integer 0-63 inclusive) (start with 20)

    • Effort (integer 0-9 inclusive) (start with 0)

  • JPEG

    • Quality (integer 0-100 inclusive)

  • H.264 (do NOT save as a video file)

    • Chroma subsampling

      • 4:4:4

      • 4:2:2

    • Others?

...

Run each at least 5 times and record each individual result.

Measuring performance

Disable the Python garbage collector when measuing performance. This is dangerous, so make sure that the garbage collector is disabled for as short a period as possible.

Expand
titleExample
Code Block
languagepy
import gc

gc.disable()
# Start measuring

# Done measuring
gc.enable()

Time

Time taken by encoding each individual image is independent of all other code.

Expand
titleExample
Code Block
languagepy
# Load image
...

# Encode image
time_before = time.time_ns()
encoded_data = encode(image)
time_after = time.time_ns()

total_time += time_after - time_before

# Other (e.g. saving, decoding)

Space

Measure the space of each encoded image.

Expand
titleExample
Code Block
languagepy
# Load image
...

# Encode image
encoded_data = encode(image)
encoded_space = encoded_data.size()

total_space += encoded_data.size()

# Other (e.g. saving, decoding)

Quality

Decode and save the final images as PNG files. After running the test, note visible differences. Example criteria:

  • Is it noticeably different?

  • Quality of edges (e.g. between landing pad and ground, H portion and rest of landing pad)

Getting started

Clone and setup the virtual environment: https://github.com/UWARG/profile-encode

Get each step working before moving to the next step:

  1. Encode part working with any non default setting

  2. Decoding and saving

  3. Time profiling

  4. Space profiling

...