- C# 60.7%
- Python 38.4%
- Batchfile 0.9%
- Changed the repository URL in the AIFotoONLUS.Core project file to point to the new Forgejo instance. - Removed the inclusion of the XML documentation file in the NuGet package. - Added a new CSV file containing test data for image processing, including filenames and associated text values. |
||
|---|---|---|
| .forgejo/workflows | ||
| models | ||
| scripts | ||
| src | ||
| .gitattributes | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| AIFotoONLUS.sln | ||
| AiGareFrontend.exe | ||
| AiSettingsNew.json | ||
| det.py | ||
| det2.py | ||
| det3.py | ||
| det4.py | ||
| gitversion.json | ||
| guida.txt | ||
| Intelligenza artificiale foto.zip | ||
| README.md | ||
| script.bat | ||
| settings.json | ||
| sni.dll | ||
AIFotoONLUS Number Recognition Library
This library provides a small, focused engine to detect and recognize numeric text (digits) in images using Darknet (YOLO) models via OpenCvSharp's DNN API. It is suitable for batch processing folders of images or individual files.
Features
- Detection network (Darknet/Yolo) to find candidate text regions.
- Recognition network (Darknet/Yolo) to identify digits inside detected crops.
- Single-file and directory-level processing APIs.
- Parallel processing with per-thread network instances for throughput.
- Diagnostic helpers to dump network output shapes and optionally save crop images.
Basic usage
-
Create a
ModelConfigurationinstance that points to your Darknet.cfgand.weightsfiles for both detection and recognition networks, configure confidence and NMS thresholds and provide a list of number class labels. -
Create an instance of
NumberRecognitionEngine:
using var engine = new NumberRecognitionEngine(modelConfig, logger: null);
- Process a single image:
var result = engine.ProcessImage("/path/to/image.jpg");
Console.WriteLine(result.Text);
- Process a directory (parallelized):
var results = await engine.ProcessDirectoryAsync("/path/to/images", recursive: false);
foreach (var r in results) Console.WriteLine($"{r.FileName}: {r.Text}");
Configuration notes
-
ModelConfigurationcontrols model file paths, input sizes, thresholds and whether to save cropped images for diagnostics. Make sure the paths are accessible to the process and the model files match the expected network architectures. -
The engine expects detection network outputs in the YOLO-style layout:
[cx, cy, w, h, objectness, class1, class2, ...].
Threading & diagnostics
-
For directory/batch processing the engine creates per-thread Net instances so OpenCV forward calls can run concurrently. It also contains fallback logic that will perform processing with shared nets under a lock if needed.
-
When
EnableCropSavingis enabled in configuration, each recognized crop is saved tologs/cropswith a timestamp and optional context label to aid debugging false positives/negatives.
Troubleshooting
- If the engine returns no detections, verify the model files are correct and
compatible with the expected output layout. Use
ProcessFileWithDiagnosticsto inspect output layer shapes.
License & Notes This project is provided as-is. See repository for licensing information and for the model files distribution terms (models are usually not redistributed with code and must be obtained separately).