quality_barrier selects the highest quality item within each time window.
The Problem
A camera outputs 30fps, but your ML model only needs 2fps. Simple approaches:sample(0.5)- Takes whatever frame happens to land on the interval tickthrottle_first(0.5)- Takes the first frame, ignores the rest
The Solution: quality_barrier
session=qb
Image Sharpness Filtering
For camera streams, we providesharpness_barrier which uses the image’s sharpness score.
Let’s use real camera data from the Unitree Go2 robot to demonstrate. We use the Sensor Storage & Replay toolkit, which provides access to recorded robot data:
skip session=qb
sharpness_barrier to select the sharpest frames:
skip session=qb
skip session=qb output=assets/frame_mosaic.jpg
skip session=qb output=assets/sharpness_graph.svg
skip session=qb
skip session=qb output=assets/frame_mosaic2.jpg
skip session=qb output=assets/sharpness_graph2.svg
Usage in Camera Module
Here’s how it’s used in the actual camera module:skip
How Sharpness is Calculated
The sharpness score (0.0 to 1.0) is computed using Sobel edge detection: fromImage.py
skip session=qb
Custom Quality Functions
You can usequality_barrier with any quality metric:
session=qb
API Reference
quality_barrier(quality_func, target_frequency)
RxPY pipe operator that selects the highest quality item within each time window.
| Parameter | Type | Description |
|---|---|---|
quality_func | Callable[[T], float] | Function that returns a quality score for each item |
target_frequency | float | Output frequency in Hz (e.g., 2.0 for 2 items/second) |
.pipe()
sharpness_barrier(target_frequency)
Convenience wrapper for images that uses image.sharpness as the quality function.
| Parameter | Type | Description |
|---|---|---|
target_frequency | float | Output frequency in Hz |
.pipe()