Sort of finds the receipt not really
Need to read more into params and figure out best config and then run with it
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
<PackageReference Include="Deadpikle.AvaloniaProgressRing" Version="0.10.11-preview20251127001" />
|
||||
<PackageReference Include="DialogHost.Avalonia" Version="0.10.4" />
|
||||
<PackageReference Include="Xaml.Behaviors.Interactions.DragAndDrop.DataGrid" Version="11.3.9.5" />
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.13.0.20260226" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' ">
|
||||
<PackageReference Include="OpenCvSharp4.runtime.osx.10.15-universal" Version="4.7.0.20230224" />
|
||||
|
||||
@@ -20,6 +20,7 @@ using MayShow.Helpers;
|
||||
using MayShow.Interfaces;
|
||||
using MayShow.Models;
|
||||
using MayShows.Helpers;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace MayShow.ViewModels;
|
||||
|
||||
@@ -516,6 +517,29 @@ class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
|
||||
return "report_data.json";
|
||||
}
|
||||
|
||||
public void TestReceiptFinding(object f) => TestReceiptFindingImpl((ReportFile)f);
|
||||
|
||||
private void TestReceiptFindingImpl(ReportFile file)
|
||||
{
|
||||
LogInfo("Running receipt edge detection...");
|
||||
using var src = new Mat(file.FilePath, ImreadModes.Grayscale);
|
||||
using var dst = new Mat();
|
||||
using var blur = new Mat();
|
||||
using var dilated = new Mat();
|
||||
Cv2.GaussianBlur(src, blur, new OpenCvSharp.Size(5.0, 5.0), 0.0, 0.0, BorderTypes.Constant);
|
||||
// Cv2.Threshold(dst, dst, 160, 255, ThresholdTypes.Binary & ThresholdTypes.Otsu);
|
||||
var kernel = Cv2.GetStructuringElement(MorphShapes.Rect, new Size(9,9));
|
||||
Cv2.Dilate(blur, dilated, kernel);
|
||||
Cv2.Canny(dilated, dst, 40, 60, 3);
|
||||
using (new OpenCvSharp.Window("src image", src))
|
||||
using (new OpenCvSharp.Window("blur image", blur))
|
||||
using (new OpenCvSharp.Window("dilated image", dilated))
|
||||
using (new OpenCvSharp.Window("dst image", dst))
|
||||
{
|
||||
Cv2.WaitKey();
|
||||
}
|
||||
}
|
||||
|
||||
public byte[]? GetFont(string faceName)
|
||||
{
|
||||
LogInfo(string.Format("Loading font {0}", faceName));
|
||||
|
||||
@@ -210,6 +210,12 @@
|
||||
<TextBlock FontSize="12"><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Open File</TextBlock>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).TestReceiptFinding}"
|
||||
CommandParameter="{Binding}">
|
||||
<Button.Content>
|
||||
<TextBlock FontSize="12"><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> TEST RECEIPT FIND</TextBlock>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
Reference in New Issue
Block a user