Runarium πββοΈ
A Rust library for generating animated videos and static images from GPS running/cycling data. Convert your FIT files into beautiful route visualizations with customizable configurations.
Features
- π Parse GPS data from FIT files (Garmin, Polar, etc.)
- π¬ Generate animated route videos with progressive drawing
- πΌοΈ Generate static route images
- π Display real-time statistics (pace, heart rate, distance)
- πΊοΈ Overlay routes on custom background images
- π¨ Fully customizable colors, fonts, and styling
- β‘ Fast rendering with OpenCV
- βοΈ Configuration-based API for easy customization
Prerequisites
Before installing, you need to have OpenCV installed on your system.
macOS
# Install OpenCV via Homebrew
# Install LLVM (required for Rust bindings)
# Set up environment variables (add to ~/.zshrc or ~/.bash_profile)
Linux (Ubuntu/Debian)
# Install OpenCV development files
# Set environment variable
# Adjust version as needed
Windows
# Install via vcpkg
# Set environment variables
Installation
Add this to your Cargo.toml:
[]
= "0.1.0" # Replace with actual version
Or install via cargo:
Usage
Quick Start - Video Generation
use Result;
use ;
use progressive_route_with_config;
Quick Start - Static Image
use Result;
use RouteImageConfig;
use ;
use image_route_with_config;
File Structure Required
your-project/
βββ source/
β βββ example.fit # Your FIT file with GPS data
β βββ example.jpg # Background map image
βββ outputs/
βββ video.mp4 # Generated video (created automatically)
βββ route.png # Generated image (created automatically)
Configuration
See CONFIGURATION.md for detailed configuration options including:
- Route scaling and positioning
- Color customization
- Font styles
- Lap data display options
- Visibility controls
Available Colors
Black, White, Red, Green, Blue,
Orange, Yellow, Violet, YellowGreen,
BlueGreen, BlueViolet, RedViolet,
RedOrange, YellowOrange
Available Fonts
Simplex, Plain, Duplex, Complex,
Triplex, ComplexSmall, ScriptSimplex,
ScriptComplex, Italic
HTTP Server
Runarium includes an HTTP server for generating videos and images via REST API.
Running the Server
# Local development
# Using Docker
# Using Makefile
API Endpoints
POST /generate-video- Generate animated route videoPOST /generate-image- Generate static route imageGET /download-video/:video_id- Download generated video (one-time)GET /download-image/:image_id- Download generated image (one-time)GET /health- Health check
Quick Test
# Test video generation
# Test video with custom config
# Test image generation
# Test image with custom config
Example cURL Request
# Generate video with custom configuration
# Download the video (replace VIDEO_ID with response id)
See SERVER.md for complete API documentation.
Examples
Run the included examples:
# Generate a video with configuration
# Generate a static image with configuration
API Reference
Video Generation
progressive_route_with_config
Generates an animated video showing the route being drawn progressively with full configuration control.
Configuration includes:
- Route scale and positioning (
RouteScale) - Colors for route, markers, text, and bars (
RouteColor) - Pace/distance display settings (
PaceDistConfig) - Lap statistics panel settings (
LapDataConfig) - File paths (
FileConfig) - Visibility flags (show_bottom_bar, show_route, show_lap_data)
Output Features:
- Animated route drawing
- Current position marker
- Real-time pace and distance overlay
- Lap statistics panel with heart rate, stride length, and pace bars
Image Generation
image_route_with_config
Generates a static image of the complete route with customizable styling.
Configuration includes:
- Route scale and positioning (
RouteScale) - Route line color (
RouteColor) - File paths (
FileConfig) - Line thickness
Legacy API
Simple functions without configuration are still available:
// Video generation (simple)
Utility Functions
Performance Measurement
use measure;
measure?;
Project Structure
runarium/
βββ src/
β βββ configs/ # Configuration types
β β βββ config.rs # Shared configs (RouteScale, RouteColor, FileConfig)
β β βββ image_config.rs # Image-specific config
β β βββ video_config.rs # Video-specific config
β βββ generators/ # Main generation functions
β β βββ route_image.rs # Static image generation
β β βββ route_video.rs # Animated video generation
β βββ types/ # Data types
β β βββ drawer_data.rs # Drawing utilities data
β β βββ fit_data.rs # FIT file data structures
β βββ utils/ # Utility functions
β βββ converter.rs # Coordinate conversion
β βββ creator.rs # Image/video creation
β βββ element_drawer.rs # Drawing utilities
β βββ performance.rs # Performance measurement
β βββ read_file.rs # FIT file reading
βββ examples/
β βββ video_config.rs # Video generation example
β βββ image_config.rs # Image generation example
β βββ server.rs # HTTP API server
βββ CONFIGURATION.md # Detailed configuration guide
βββ SERVER.md # HTTP server documentation
βββ Dockerfile # Docker container setup
βββ docker-compose.yml # Docker orchestration
Troubleshooting
OpenCV Not Found
error: failed to run custom build command for `opencv`
Solution: Make sure OpenCV is installed and environment variables are set:
# macOS
# Check if OpenCV is found
LIBCLANG_PATH Error
couldn't find any valid shared libraries matching: ['libclang.dylib']
Solution: Set the LIBCLANG_PATH environment variable:
Make it permanent by adding to ~/.zshrc:
FIT File Not Found
ERROR: field size: 1 is not a multiple of the base type
Solution: Ensure your FIT file is in the source/ directory and is a valid FIT file format.
Performance
Typical performance metrics:
- Processing ~5000 GPS points: ~12 seconds
- Video encoding: Real-time (30 FPS)
- Image generation: <1 second
- Memory usage: ~100-200 MB
Module Overview
- configs: Configuration types for customizing output
- generators: Core functions for video and image generation
- types: Data structures for FIT data and drawing
- utils: Helper utilities for file I/O, conversion, and rendering
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
[Add your license here]
Credits
Built with:
- opencv-rust - OpenCV bindings for Rust
- fitparser - FIT file parser
- image - Image processing
Roadmap
- Support for FIT file parsing
- Animated video generation
- Static image generation
- Customizable color schemes
- Configuration-based API
- Font customization
- HTTP REST API server
- Docker deployment support
- Support for multiple file formats (GPX, TCX)
- Command-line interface
- Preset configuration templates
- Web-based visualization
- Real-time preview