This folder contains the C++ implementation of AnomaVision inference using ONNX Runtime and OpenCV. It is designed for real-time anomaly detection on edge devices and environments where Python is not available.
- C++17 or later
- CMake ≥ 3.15
- ONNX Runtime (prebuilt or built from source)
- OpenCV
# From project root
cmake -S . -B build
cmake --build build --config ReleaseMake sure to update CMakeLists.txt with the correct paths to ONNX Runtime and OpenCV on your system.
./build/Release/onnx_inference.exe model.onnx D:/01-DATA/test \
--save_viz D:/output --alpha 0.5 --thresh 13.0Options:
--save_viz out_dir→ save annotated results--alpha→ heatmap blending factor (default: 0.5)--thresh→ anomaly threshold (default: 13.0)
Found 10 images
Processing 000.png (1/10)
Score: 29.88 Anomalous: YES Time: 31.53 ms
Number of anomalous pixels: 4271 Ratio: 0.085
Processing 007.png (2/10)
Score: 59.71 Anomalous: YES Time: 33.93 ms
Number of anomalous pixels: 6068 Ratio: 0.121
...
- Average inference time ≈ 38.9 ms (~25.7 FPS)
- Visualization windows display heatmaps + bounding boxes
- Results saved if
--save_vizis provided
-
detect.cpp→ entry point (CLI parser, launches app) -
oop_anomaly_detector.h/.cpp→ modular pipelineConfig→ runtime parametersPreprocessor→ image normalization & resizeONNXModel→ inference with ONNX RuntimePostprocessor→ thresholding, scores, masksVisualizer→ overlay, annotations, bounding boxesApp→ orchestrates the full workflow
✅ This C++ module makes AnomaVision truly edge-ready, combining Python flexibility with C++ performance.