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.