Architecture Overview
Mini-OpenCV uses a three-layer architecture designed for performance, modularity, and ease of use.
Three-Layer Design
Layer Responsibilities
1. Application Layer
The top-level API that users interact with:
| Component | Purpose |
|---|---|
ImageProcessor | Main entry point for image operations |
PipelineProcessor | Chain multiple operations with async execution |
2. Operator Layer
CUDA kernels implementing image processing algorithms:
| Category | Operations | CUDA Technique |
|---|---|---|
| Pixel | Invert, grayscale, brightness | Per-pixel parallelism |
| Convolution | Gaussian blur, Sobel, custom kernels | Shared memory tiling |
| Histogram | Calculation, equalization | Atomic operations + reduction |
| Geometric | Resize, rotate, flip, affine | Bilinear interpolation |
| Morphology | Erosion, dilation, open/close | Custom structuring elements |
| Threshold | Global, adaptive, Otsu | Histogram-driven |
| Color Space | RGB/HSV/YUV conversion | Matrix operations |
| Filters | Median, bilateral, sharpen | Edge-preserving filters |
3. Infrastructure Layer
Core utilities for GPU computing:
| Component | Purpose |
|---|---|
DeviceBuffer | RAII GPU memory management |
GpuImage | Image container with GPU memory |
CudaError | Error handling and checking |
ImageIO | Image file I/O (JPEG, PNG, BMP) |
StreamManager | CUDA stream pool for async execution |
Data Flow
Memory Model
Zero-Copy Optimization
Key optimizations:
- Lazy Allocation: Memory allocated on first use
- Buffer Reuse: Memory pool for temporary buffers
- Async Transfer: Overlap compute and transfer using CUDA streams
CUDA Stream Pipeline
Multi-stream execution enables overlapping operations:
Supported GPU Architectures
| Architecture | Compute Capability | Example GPUs |
|---|---|---|
| Turing | SM 75 | RTX 20 series, T4 |
| Ampere | SM 80/86 | A100, RTX 30 series |
| Ada Lovelace | SM 89 | RTX 40 series, L4 |
| Hopper | SM 90 | H100 |
Next Steps
- Memory Model - Deep dive into GPU memory management
- CUDA Streams - Async execution details
- Design Decisions - Architecture decision records