Performance comparison of ORB descriptor matching on CPU (OpenCV with SIMD) vs GPU (CUDA kernel) for sequential frame matching patterns used in visual SLAM.
extract_video_frames.py # Extract frames from video
extract_descriptors.py # Extract ORB features from images
cpu_match.py # CPU matching (OpenCV BFMatcher)
generate_results.py # Benchmark suite with scalability testing
cudaMatch.cu / kernel.cu # CUDA implementation
support.cu / support.h # GPU support functions
images/ # Input images (img*.jpg)
descriptors/ # Output descriptors (des*.npy, des*.bin, meta.txt)
- Python 3.11+ with opencv-python, tqdm
- NVIDIA GPU with CUDA Toolkit 11+ and nvcc compiler
- C++17 compiler
Install Python dependencies using uv:
uv sync
source .venv/bin/activateVerify CUDA setup:
nvcc --version1. Extract frames from video (optional):
python extract_video_frames.py video.mp4 --target-fps 30 [--start-time 10] [--end-time 60]2. Build and benchmark:
make
python generate_results.pyOutputs summary.png with CPU vs GPU performance across feature counts (50 to 5000 features).
If you want to run scripts separately:
Extract frames from video:
python extract_video_frames.py video.mp4 --target-fps 30 --start-time 10 --end-time 60 --output-dir imagesArguments: --target-fps (default 30), --start-time (seconds), --end-time (seconds), --output-dir (default "images")
Extract descriptors:
python extract_descriptors.py --max-features 2000 --images-dir images --output-dir descriptorsArguments: --max-features (default 2000), --images-dir (default "images"), --output-dir (default "descriptors")
Run CPU matching only:
python cpu_match.pyUses descriptors from descriptors/ directory by default.
Run GPU matching only:
./build/cudaMatchUses descriptors from descriptors/ directory.
- Extracts frames at target FPS (default 30)
- Options:
--start-time,--end-time(seconds),--output-dir - Works with game footage (needs texture/detail)
- Outputs:
images/img0.jpg,img1.jpg, etc.
- Extracts ORB features from image sequence
- Default max 2000 features per image
- Outputs:
descriptors/des{N}.npy,des{N}.bin,meta.txt
- Tests feature counts: 50, 100, 500, 1K, 2K, 3K, 4K, 5K (adaptive)
- Automatically stops when images can't provide more features
- Runs CPU (OpenCV) and GPU (CUDA) benchmarks for each count
- Generates performance plot with absolute times and speedup curves
- Outputs:
summary.pngwith dual-axis visualization
- Bidirectional cross-checking (A→B and B→A match)
- SIMD optimized (SSE4.2, AVX2, POPCNT)
- Sequential frame matching (i↔i+1)
- Bidirectional cross-checking (forward + backward kernel launches)
- One block per descriptor, 256 threads per block
- Shared memory parallel reduction
- CUDA events for GPU-synchronized timing (excludes CPU overhead)
Both CPU and GPU use the same cross-checking logic for fair comparison. Expected agreement: 99%+.
descriptors/meta.txt contains: num_images num_features descriptor_dim
Example: 2 2000 32 means 2 frames, 2000 features each, 32-byte ORB descriptors.