Initial .NET scaffold: Core, Console, WPF projects

Introduced solution structure for AIFotoONLUS migration to .NET. Added Core library with YOLO-based detection/recognition engine using OpenCvSharp, Console batch runner, and WPF demo frontend with MVVM. Implemented model loading, directory processing, progress reporting, and preferences. Added README with build/run instructions.
This commit is contained in:
MaddoScientisto 2026-02-15 15:16:56 +01:00
commit 769afc08fb
18 changed files with 976 additions and 0 deletions

View file

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="6.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AIFotoONLUS.Core\AIFotoONLUS.Core.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,84 @@
using AIFotoONLUS.Core;
using System;
using System.IO;
using System.Linq;
namespace AIFotoONLUS.ConsoleApp
{
internal static class Program
{
private static int Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Usage: AIFotoONLUS.Console -d <directory> -c <output.csv> [-tn|--textnegative]");
return 1;
}
string? directory = null;
string? csvPath = null;
bool textNegative = false;
for (int i = 0; i < args.Length; i++)
{
var a = args[i];
if (a == "-d" || a == "--directory")
{
if (i + 1 < args.Length) directory = args[++i];
}
else if (a == "-c" || a == "--csv")
{
if (i + 1 < args.Length) csvPath = args[++i];
}
else if (a == "-tn" || a == "--textnegative")
{
textNegative = true;
}
}
if (string.IsNullOrEmpty(directory) || string.IsNullOrEmpty(csvPath))
{
Console.WriteLine("Missing required arguments.");
return 1;
}
if (!Directory.Exists(directory))
{
Console.WriteLine($"Directory not found: {directory}");
return 1;
}
var cfg = new ModelConfiguration
{
DetectionCfg = Path.Combine("models", "detection.cfg"),
DetectionWeights = Path.Combine("models", "detection.weights"),
RecognitionCfg = Path.Combine("models", "recognition.cfg"),
RecognitionWeights = Path.Combine("models", "recognition.weights"),
ConfidenceThreshold = 0.5,
NmsThreshold = 0.4
};
try
{
using var engine = new NumberRecognitionEngine(cfg);
var results = engine.ProcessDirectory(directory, textNegative).ToList();
using var sw = new StreamWriter(csvPath, false);
sw.WriteLine("filename,text");
foreach (var r in results)
{
sw.WriteLine($"{r.FileName},{r.Text}");
}
Console.WriteLine($"Results written to {csvPath}");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
return 2;
}
return 0;
}
}
}