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/Implementation/Common/ScreenshotScanner.cs
T
2024-01-10 18:35:04 +01:00

45 lines
1.1 KiB
C#

using ImageMagick;
using Lookup.Memory;
using Ocr.Tesseract.Models;
using Process.Interface;
namespace Common;
/// <summary>
/// Scanner class, scanning <see cref="MagickImage"/>s for <see cref="Word"/>s
/// via optical character recognition. Optimized for digital Screenshots.
/// </summary>
public class ScreenshotScanner
{
/// <summary>
/// The screenshot processor
/// </summary>
protected IProcessor<MagickImage, ScanResult> Processor { get; }
/// <summary>
/// Data storage
/// </summary>
public Lookup.Interface.ILookup<Word, MagickImage> Lookup { get; } =
new MemoryLookup<Word, MagickImage>();
/// <summary>
/// Constructor
/// </summary>
public ScreenshotScanner(IProcessor<MagickImage, ScanResult> processor)
{
Processor = processor;
}
/// <summary>
/// Process the provided <paramref name="images"/> and add the results to
/// the <see cref="Lookup"/>
/// </summary>
/// <param name="images">The <see cref="MagickImage"/>s to process</param>
public void Process(IEnumerable<MagickImage> images)
{
foreach (var kv in Processor.Process(images))
{
Lookup.Add(kv.Word, kv.Image);
}
}
}