68 lines
1.5 KiB
C#
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
|
|
}
|