fixed GUI tool
This commit is contained in:
@@ -36,16 +36,21 @@ namespace Common
|
||||
/// <summary>
|
||||
/// Configuration of the <see cref="ImageProcessor"/>
|
||||
/// </summary>
|
||||
public ScreenshotProcessorConfiguration ImageProcessorConfiguration { get; set; } = new();
|
||||
public ScreenshotProcessorConfiguration ImageProcessorConfiguration { get; }
|
||||
|
||||
public ITesseractConfiguration TesseractConfiguration { get; set; } =
|
||||
new TesseractScreenshotConfiguration();
|
||||
public ITesseractConfiguration TesseractConfiguration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public ScreenshotScanner()
|
||||
public ScreenshotScanner(
|
||||
ScreenshotProcessorConfiguration imageProcessorConfig,
|
||||
ITesseractConfiguration tesseractConfig
|
||||
)
|
||||
{
|
||||
ImageProcessorConfiguration = imageProcessorConfig;
|
||||
TesseractConfiguration = tesseractConfig;
|
||||
|
||||
_processor = MakeProcessor();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
using GUI.Model;
|
||||
using ImageMagick;
|
||||
using Microsoft.Win32;
|
||||
using Ocr.Tesseract.Configuration;
|
||||
using Ocr.Tesseract.Models;
|
||||
using Ocr.Tesseract.Screenshots.Configuration;
|
||||
using Process.Interface;
|
||||
using Serilog;
|
||||
using System;
|
||||
@@ -20,9 +22,16 @@ namespace GUI.ViewModels;
|
||||
|
||||
internal class ImageViewModel : ScreenshotScanner, INotifyPropertyChanged
|
||||
{
|
||||
public ImageViewModel()
|
||||
private static ITesseractConfiguration CreateTesseractConfiguration() =>
|
||||
new TesseractScreenshotConfiguration()
|
||||
{
|
||||
DataPath = "tessdata",
|
||||
Languages = new[] { "eng", "deu" }
|
||||
};
|
||||
|
||||
public ImageViewModel() : base(new(), CreateTesseractConfiguration())
|
||||
{
|
||||
// Scanner.ImageOperationSettings.PropertyChanged += (sender, args) => Task.Run(UpdateImage);
|
||||
ImageProcessorConfiguration.PropertyChanged += (sender, args) => Task.Run(UpdateImage);
|
||||
|
||||
OpenFileCommand = new Command(OpenFile);
|
||||
SaveEditedImageCommand = new Command(SaveEditedImage);
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace GUI.Views
|
||||
/// </summary>
|
||||
public partial class ImageView : Window
|
||||
{
|
||||
private ImageViewModel ViewModel => (ImageViewModel)DataContext;
|
||||
|
||||
public ImageView()
|
||||
{
|
||||
DataContext = new ImageViewModel();
|
||||
@@ -26,18 +28,21 @@ namespace GUI.Views
|
||||
|
||||
private void SldThreshold1_OnDragCompleted(object sender, DragCompletedEventArgs args)
|
||||
{
|
||||
((ImageViewModel)DataContext).ImageProcessorConfiguration.ThresholdWidth = (int)Math.Round(((Slider)sender).Value);
|
||||
var vm = ViewModel;
|
||||
vm.ImageProcessorConfiguration.ThresholdWidth = (int)Math.Round(((Slider)sender).Value);
|
||||
}
|
||||
|
||||
private void SldThreshold2_OnDragCompleted(object sender, DragCompletedEventArgs args)
|
||||
{
|
||||
((ImageViewModel)DataContext).ImageProcessorConfiguration.ThresholdHeight = (int)Math.Round(((Slider)sender).Value);
|
||||
var vm = ViewModel;
|
||||
vm.ImageProcessorConfiguration.ThresholdHeight = (int)Math.Round(((Slider)sender).Value);
|
||||
}
|
||||
|
||||
|
||||
private void SldBorder_OnDragCompleted(object sender, DragCompletedEventArgs e)
|
||||
{
|
||||
((ImageViewModel)DataContext).ImageProcessorConfiguration.Border = (int)Math.Round(((Slider)sender).Value);
|
||||
var vm = ViewModel;
|
||||
vm.ImageProcessorConfiguration.Border = (int)Math.Round(((Slider)sender).Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,25 +50,6 @@ public class ScreenshotProcessor : ImageProcessor
|
||||
|
||||
yield return tImage;
|
||||
yield return tImage.CloneImage().NegateColors();
|
||||
|
||||
// todo filter large connected components
|
||||
|
||||
// var resized = fluent .CloneObject() .Resize( 0.25f, FilterType.Point,
|
||||
// PixelInterpolateMethod.Integer ); yield return resized.ToImage();
|
||||
//
|
||||
// var hlines = resized .GetHLines() .Select(c => new MagickGeometry(c.Item1, c.Item2, c.Item1 +
|
||||
// 3, c.Item2 + 3)) .ToArray(); Log.Information($"Matched {hlines.Length} geometries");
|
||||
//
|
||||
// var rgbImage = resized.CloneObject().ToRgb(); rgbImage.Fill(MagickColors.Red, hlines); yield
|
||||
// return rgbImage.ToImage();
|
||||
|
||||
// if (Settings.FilterConnectedComponents) { var colorImage = fluent .CloneObject()
|
||||
// .GetConnectedComponents( _connectedComponentsSettings, out var components ) .ToRgb();
|
||||
//
|
||||
// var pixels = colorImage.GetPixels(); colorImage.Fill( MagickColors.Red, components .Where(c
|
||||
// => c.IsFilled(pixels)) .Select(c => c.ToGeometry()) );
|
||||
|
||||
// yield return colorImage.ToImage();
|
||||
}
|
||||
|
||||
#region Overrides of Processor<MagickImage,IMagickImageValueProcessorSettings>
|
||||
|
||||
Reference in New Issue
Block a user