This repository has been archived on 2024-06-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
thesis-src/Examples/CLI/Program.cs
T
Simon Gruber 8ada606fa6 a
2023-11-22 07:46:10 +01:00

68 lines
1.5 KiB
C#

using CLI.Monitor;
using CLI.Processor;
using Common.Extensions;
using ImageMagick;
using Ocr.Tesseract.Screenshots.Threshold;
using System.Diagnostics.CodeAnalysis;
namespace CLI;
public class Program
{
public Task Run(string[] args)
{
var scans = (
from processor in MakeThresholdVariations()
from path in ExpandPaths(args)
select (Key: path, Task: processor.Process(new MagickImage(path)))
).ToArray();
return new CliTaskMonitor(scans).Run();
}
[SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeNotEvident")]
private static IEnumerable<EvaluationProcessor> MakeThresholdVariations()
{
for (int i = 0; i <= 24; i += 2)
{
yield return new(new ThresholdAdaptiveProcessor(i));
}
for (int i = 0; i <= 100; i += 10)
{
yield return new(new ThresholdProcessor(i));
}
yield return new(new AutoThresholdProcessor(AutoThresholdMethod.Kapur));
yield return new(new AutoThresholdProcessor(AutoThresholdMethod.OTSU));
yield return new(new AutoThresholdProcessor(AutoThresholdMethod.Triangle));
}
private static IEnumerable<string> ExpandPaths(params string[] paths) =>
paths.SelectMany(p => p.ExpandPath());
#region Main
public static int Main(string[] args)
{
Console.WriteLine("Starting up");
try
{
new Program()
.Run(args)
.Wait();
Console.WriteLine("Completed");
return 0;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return 1;
}
}
#endregion
}