![]() |
VOOZH | about |
dotnet add package IdentityDocument.Processing --version 1.2.0
NuGet\Install-Package IdentityDocument.Processing -Version 1.2.0
<PackageReference Include="IdentityDocument.Processing" Version="1.2.0" />
<PackageVersion Include="IdentityDocument.Processing" Version="1.2.0" />Directory.Packages.props
<PackageReference Include="IdentityDocument.Processing" />Project file
paket add IdentityDocument.Processing --version 1.2.0
#r "nuget: IdentityDocument.Processing, 1.2.0"
#:package IdentityDocument.Processing@1.2.0
#addin nuget:?package=IdentityDocument.Processing&version=1.2.0Install as a Cake Addin
#tool nuget:?package=IdentityDocument.Processing&version=1.2.0Install as a Cake Tool
IdentityDocument.Processing is a .NET library that combines Azure Computer Vision and ML.NET to process images of identity documents (ID cards, passports, licenses, etc.).
It extracts raw text from images and maps it into structured fields such as First Name, Last Name, Document Number, Dates, and more.
dotnet add package IdentityDocument.Processing
Program.csusing IdentityDocument.Processing.Abstractions;
using IdentityDocument.Processing.Services;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using ocr_project.Services.ComputerVisionAzure;
using OpenAI.Chat;
var builder = WebApplication.CreateBuilder(args);
var configuration = builder.Configuration;
// Azure Computer Vision
builder.Services.AddSingleton(provider =>
{
return new ComputerVisionClient(
new ApiKeyServiceClientCredentials(configuration["AzureVision:Key"]))
{
Endpoint = configuration["AzureVision:Endpoint"]
};
});
// OpenAI Chat client
builder.Services.AddSingleton<ChatClient>(sp =>
{
var apiKey = configuration["OpenAI:ApiKey"];
if (string.IsNullOrWhiteSpace(apiKey))
throw new InvalidOperationException("OpenAI:ApiKey is missing.");
var model = configuration["OpenAI:Model"] ?? "gpt-4o-mini";
return new ChatClient(model, apiKey);
});
// Register services
builder.Services.AddScoped<IOpenIAService, OpenIAService>();
builder.Services.AddScoped<IComputerVisionAzureServices, ComputerVisionAzureServices>();
builder.Services.AddScoped<IIdentityDocumentServices, IdentityDocumentService>();
var app = builder.Build();
app.Run();
using IdentityDocument.Processing.Abstractions;
using Microsoft.AspNetCore.Http;
namespace MyApp.Services
{
public class DocumentProcessingService : IDocumentProcessingServices
{
private readonly IIdentityDocumentServices _identityDocService;
public DocumentProcessingService(IIdentityDocumentServices identityDocService)
{
_identityDocService = identityDocService;
}
public async Task<FileUploadResponse> IdentityDocumentProcessingImgs(ICollection<IFormFile> files)
{
if (files == null || files.Count == 0)
throw new ArgumentException("At least one image must be provided.");
var result = await _identityDocService.IdentityDocumentProsessingImgs(files);
if (result == null)
throw new InvalidOperationException("Document could not be processed.");
return new FileUploadResponse
{
FirstNames = result.FirstNames,
LastNames = result.LastNames,
Country = result.Country,
DocumentNumber = result.DocumentNumber,
BirthDate = ParseDate(result.BirthDate),
IssueDate = ParseDate(result.IssueDate),
ExpiryDate = ParseDate(result.ExpiryDate),
Sex = result.Sex,
Nationality = result.Nationality
};
}
private DateTime? ParseDate(string? value, string format = "yyyy-MM-dd")
{
if (string.IsNullOrWhiteSpace(value)) return null;
if (DateTime.TryParseExact(value, format,
System.Globalization.CultureInfo.InvariantCulture,
System.Globalization.DateTimeStyles.None,
out var date))
return date;
return null;
}
}
}
{
"AzureVision": {
"Endpoint": "https://<your-cv-endpoint>.cognitiveservices.azure.com/",
"Key": "YOUR_AZURE_CV_KEY"
},
"OpenAI": {
"ApiKey": "YOUR_OPENAI_API_KEY",
"Model": "gpt-4o-mini"
}
}
Contributions are welcome:
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 net7.0 is compatible. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.