Troubleshooting¶
Common issues and their solutions.
Build Issues¶
CMake can't find OpenCV¶
Error:
CMake Error at CMakeLists.txt:X (find_package):
Could not find a package configuration file provided by "OpenCV"
Solutions:
-
Verify OpenCV is installed:
-
If not installed, install from system packages:
-
If installed but not found, specify path:
Common paths:
- Ubuntu: /usr/lib/x86_64-linux-gnu/cmake/opencv4
- macOS (Homebrew): /opt/homebrew/Cellar/opencv/4.x.y/lib/cmake/opencv4
Compiler doesn't support C++17¶
Error:
Solutions:
-
Check compiler version:
-
Update compiler:
-
Specify compiler explicitly:
OpenMP not found¶
Warning (non-fatal):
Impact: --jobs parallelism disabled (slower Pass 1).
Solutions:
-
Install OpenMP:
-
Rebuild:
-
Verify:
Runtime Issues¶
Videos not opening¶
Error:
Causes:
- OpenCV built without FFMPEG/GStreamer support
- Codec not supported (e.g., H.265/HEVC)
- File corrupted or incomplete
Solutions:
- Check FFMPEG support:
If empty, OpenCV doesn't have FFMPEG. Reinstall:
# Remove pip version (doesn't include video codecs)
pip3 uninstall opencv-python opencv-python-headless
# Install system package
sudo apt install libopencv-dev
-
Test video file:
-
Convert to compatible codec (H.264):
No frames selected¶
Output:
Causes:
- Quality gates too strict: All frames rejected
- Temporal filter too aggressive:
--min-gaptoo large for short videos - No videos found: Wrong
--root-diror--camera
Solutions:
- Run calibrate to see pass rate:
If pass rate < 10%, relax thresholds:
-
Reduce temporal gap:
-
Verify videos found:
Cache not working¶
Symptom: Pass 1 always recomputes metrics (no "cache hit" messages).
Causes:
--no-cacheflag passed- Video file modified (timestamp or size changed)
- Different
--sample-fpsthan cached run - Cache directory not writable
Solutions:
-
Check cache directory:
-
Check permissions:
-
Verify cache format (should be JSON):
-
Force cache rebuild:
Quality Issues¶
Too many dark frames¶
Symptom: Output contains frames darker than expected.
Solutions:
-
Raise min-brightness:
-
Check calibrate output:
Look at brightness distribution. If median is low (< 50), your videos are naturally dark — may need to accept darker frames or improve lighting.
Too many blurry frames¶
Symptom: Output contains out-of-focus or motion-blurred frames.
Solutions:
-
Raise min-sharpness:
-
Check if blur is pervasive:
If sharpness p95 < 50, most frames are blurry (vehicle motion, turbidity, poor optics). Consider: - Slower vehicle speed - Better image stabilization - Accept some blur as unavoidable
Too many featureless frames (blue water)¶
Symptom: Output dominated by uniform blue/green water.
Solutions:
-
Raise min-entropy:
-
Lower max-per-cell (limit contribution from common scenes):
-
Increase n-bins (fragment common cells):
Missing rare events¶
Symptom: Known interesting frames (organisms, features) not selected.
Causes:
- Quality gates reject them: Too strict thresholds
- Temporal filter rejects them: Too large
--min-gap - Not examined: Too low
--sample-fpsmisses short events - Out-competed: Rare cells have lower interest scores than common cells
Solutions:
-
Relax quality gates:
-
Reduce temporal gap:
-
Increase sample rate:
-
Lower max-per-cell (give rare cells more budget):
Diversity Issues¶
Near-duplicate frames¶
Symptom: Multiple output frames from same video look nearly identical.
Solutions:
-
Increase min-gap:
-
Increase n-bins (separate similar frames into different cells):
Over-sampling common scenes¶
Symptom: One type of scene (e.g., blue water) dominates output.
Solutions:
-
Lower max-per-cell:
-
Raise quality thresholds (reject common low-quality frames):
-
Two-pass sampling: First pass for general diversity, second pass targeting rare conditions (see Tuning Guide)
Under-utilizing frame budget¶
Symptom: Output has far fewer frames than --max-frames.
Causes:
- Insufficient candidates after quality filtering
- Temporal filter too aggressive
- Grid too sparse (too many empty cells)
Solutions:
-
Relax quality gates:
-
Reduce min-gap:
-
Lower n-bins (denser cells):
-
Add more source videos
Performance Issues¶
Slow Pass 1 (metric extraction)¶
Symptom: Pass 1 takes minutes to hours.
Solutions:
- Enable parallelism:
Verify OpenMP is enabled:
-
Use cache: Second run should be ~10× faster (cache hits).
-
Reduce sample rate:
-
Use SSD storage (not spinning disk): Video I/O is bottleneck.
Slow Pass 3 (frame extraction)¶
Symptom: Pass 3 takes long despite few frames.
Cause: Random seeks across videos (each seek ~10–50 ms).
Solutions:
-
Use SSD storage (faster seeks)
-
Pre-sort videos (groups by video are sorted internally, but if selecting from many videos, seeks are unavoidable)
-
Use JPEG (faster encoding):
High memory usage¶
Symptom: Process uses >1 GB RAM.
Causes: Very large candidate pool (hundreds of thousands of frames).
Solutions:
-
Reduce sample rate:
-
Process videos in batches:
-
Not typically an issue: Tool uses ~50 MB per 100K frames (< 500 MB typical).
Unexpected Behavior¶
Different results on repeated runs¶
Expected: Results should be deterministic (same every time).
If not:
-
Check filesystem timestamps (cache key includes
last_modified_time): -
Disable cache:
If results now deterministic, cache was corrupted. Delete and rebuild:
Filenames not as expected¶
Expected format:
If incorrect:
-
Check source video filename: Must match pattern
*Triton*Cam*or similar. -
Verify metadata extraction (in code):
triton_sampling.cppparses filename for vehicle and camera. -
If using custom naming: Modify
parse_metadata()intriton_sampling.cppto match your convention.
Getting Help¶
If issues persist:
-
Check version:
-
Gather diagnostics:
-
Open GitHub issue with:
- Command you ran
- Full error output
calibrateoutput on problem video- System info (OS, OpenCV version, compiler)
Known Limitations¶
Codec Support¶
Limitation: Depends on OpenCV's FFMPEG/GStreamer backend. Some codecs (e.g., H.265/HEVC, AV1) may not be supported.
Workaround: Convert to H.264/AVC:
Large Video Files (>50 GB)¶
Limitation: Seek operations may be slow on very large files.
Workaround: Split into smaller chunks:
Non-Monotonic Timestamps¶
Limitation: If video timestamps are non-sequential (editing artifacts), frame ordering may be incorrect.
Workaround: Re-encode with correct timestamps:
Next Steps¶
- Tuning Guide: Optimize parameters for your data
- Usage: Complete command-line reference
- Algorithm: Understand the sampling pipeline