Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.Ollama" Version="$(SemanticKernelVersion)-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.OpenAI" Version="$(SemanticKernelVersion)" />
<PackageVersion Include="ModelContextProtocol" Version="0.4.0-preview.3" />
<PackageVersion Include="Maa.Framework" Version="5.3.0" />
<PackageVersion Include="PuppeteerSharp" Version="20.2.4" />
<PackageVersion Include="Tavily" Version="1.0.0" />
<!-- Avalonia packages -->
Expand Down
1 change: 1 addition & 0 deletions src/Everywhere.Core/Everywhere.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<PackageReference Include="Serilog.Sinks.File"/>
<PackageReference Include="System.Drawing.Common"/>
<PackageReference Include="Tavily"/>
<PackageReference Include="Maa.Framework"/>
</ItemGroup>

<ItemGroup>
Expand Down
52 changes: 52 additions & 0 deletions src/Everywhere.Core/Interop/IOcrService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Avalonia.Media.Imaging;

namespace Everywhere.Interop;

/// <summary>
/// Represents an OCR text recognition result.
/// </summary>
/// <param name="Text">The recognized text.</param>
/// <param name="Score">The confidence score (0.0 - 1.0).</param>
/// <param name="Box">The bounding box [x, y, width, height].</param>
public record OcrTextResult(string Text, double Score, int[] Box);

/// <summary>
/// Represents the full OCR recognition result.
/// </summary>
/// <param name="All">All detected text regions.</param>
/// <param name="Best">The best match based on score.</param>
/// <param name="Filtered">Filtered results above threshold.</param>
public record OcrResult(
IReadOnlyList<OcrTextResult> All,
OcrTextResult? Best,
IReadOnlyList<OcrTextResult> Filtered);

/// <summary>
/// OCR service interface for text recognition from images.
/// </summary>
public interface IOcrService
{
/// <summary>
/// Ensures the OCR model is downloaded and ready.
/// </summary>
/// <param name="progress">Optional progress callback (0.0 - 1.0).</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>True if model is ready, false if download failed.</returns>
Task<bool> EnsureModelAsync(IProgress<double>? progress = null, CancellationToken cancellationToken = default);

/// <summary>
/// Performs OCR on the given image.
/// </summary>
/// <param name="image">The image to recognize.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>OCR result or null if recognition failed.</returns>
Task<OcrResult?> RecognizeAsync(Bitmap image, CancellationToken cancellationToken = default);

/// <summary>
/// Performs OCR on image data.
/// </summary>
/// <param name="imageData">PNG or JPEG encoded image data.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>OCR result or null if recognition failed.</returns>
Task<OcrResult?> RecognizeAsync(byte[] imageData, CancellationToken cancellationToken = default);
}
Loading
Loading