Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions Regula.DocumentReader.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30503.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Regula.DocumentReader.WebClient", "src\Regula.DocumentReader.WebClient\Regula.DocumentReader.WebClient.csproj", "{21FC9582-EA65-4043-ABF6-BD436E3CCD10}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Regula.DocumentReader.NetCoreExample", "src\Regula.DocumentReader.NetCoreExample\Regula.DocumentReader.NetCoreExample.csproj", "{21FC9582-EA65-4043-ABF6-BD436E3CCD10}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Regula.DocumentReader.WebClient", "src\Regula.DocumentReader.WebClient\Regula.DocumentReader.WebClient.csproj", "{21FC9582-EA65-4043-ABF6-BD436E3CCD10}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Regula.DocumentReader.NetCoreExample", "src\Regula.DocumentReader.NetCoreExample\Regula.DocumentReader.NetCoreExample.csproj", "{EA417402-2843-4CA5-B712-4CD9425C02E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +16,10 @@ Global
{21FC9582-EA65-4043-ABF6-BD436E3CCD10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21FC9582-EA65-4043-ABF6-BD436E3CCD10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21FC9582-EA65-4043-ABF6-BD436E3CCD10}.Release|Any CPU.Build.0 = Release|Any CPU
{EA417402-2843-4CA5-B712-4CD9425C02E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA417402-2843-4CA5-B712-4CD9425C02E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA417402-2843-4CA5-B712-4CD9425C02E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA417402-2843-4CA5-B712-4CD9425C02E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
23 changes: 16 additions & 7 deletions src/Regula.DocumentReader.NetCoreExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Regula.DocumentReader.WebClient.Api;
using Regula.DocumentReader.WebClient.Model;
using Regula.DocumentReader.WebClient.Model.Ext;
using Regula.DocumentReader.WebClient.Model.Ext.Autheticity;

namespace Regula.DocumentReader.NetCoreExample
{
Expand All @@ -27,15 +28,16 @@ public static void Main()
var uvPage0 = File.ReadAllBytes("UV.jpg");

var requestParams = new RecognitionParams()
.WithScenario(Scenario.FULL_PROCESS)
.WithScenario(Scenario.FULL_AUTH)
.WithResultTypeOutput(new List<int>
{
// actual results, keep only required
Result.STATUS, Result.TEXT, Result.IMAGES, Result.DOCUMENT_TYPE,
// legacy results
Result.MRZ_TEXT, Result.VISUAL_TEXT, Result.BARCODE_TEXT, Result.RFID_TEXT,
Result.VISUAL_GRAPHICS, Result.BARCODE_GRAPHICS, Result.RFID_GRAPHICS,
Result.LEXICAL_ANALYSIS
// actual results
Result.STATUS, Result.AUTHENTICITY, Result.TEXT, Result.IMAGES,
Result.DOCUMENT_TYPE, Result.DOCUMENT_TYPE_CANDIDATES,
// legacy results
Result.MRZ_TEXT, Result.VISUAL_TEXT, Result.BARCODE_TEXT, Result.RFID_TEXT,
Result.VISUAL_GRAPHICS, Result.BARCODE_GRAPHICS, Result.RFID_GRAPHICS,
Result.LEXICAL_ANALYSIS
});

var request = new RecognitionRequest(requestParams, new List<ProcessRequestImage>{
Expand All @@ -62,6 +64,13 @@ public static void Main()
int docNumberMrzValidity = docNumberField.SourceValidity(Source.MRZ);
int docNumberMrzVisualMatching = docNumberField.CrossSourceComparison(Source.MRZ, Source.VISUAL);

var docAuthenticity = response.Authenticity();
var docIRB900 = docAuthenticity.IrB900Checks();
var docIRB900Blank = docIRB900?.ChecksByElement(SecurityFeatureType.BLANK);

var docImagePattern = docAuthenticity.ImagePattern();
var docImagePatternBlank = docImagePattern?.ChecksByElement(SecurityFeatureType.BLANK);

Console.WriteLine("-----------------------------------------------------------------");
Console.WriteLine($" Document Overall Status: {docOverallStatus}");
Console.WriteLine($" Document Optical Text Status: {docOpticalTextStatus}");
Expand Down
2 changes: 1 addition & 1 deletion src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Regula Document Reader Web API
*
* Documents recognition as easy as reading two bytes. # Clients: * [JavaScript](https://github.com/regulaforensics/DocumentReader-web-js-client) client for the browser and node.js based on axios * [Java](https://github.com/regulaforensics/DocumentReader-web-java-client) client compatible with jvm and android * [Python](https://github.com/regulaforensics/DocumentReader-web-python-client) 3.5+ client * [C#](https://github.com/regulaforensics/DocumentReader-web-csharp-client) client for .NET & .NET Core
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity
{
public abstract class AuthenticityResult<T> where T : class
{
AuthenticityCheckResult authenticityCheckResult;

public AuthenticityResult(AuthenticityCheckResult authenticityCheckResult)
{
this.authenticityCheckResult = authenticityCheckResult;
}

public AuthenticityCheckResult Payload()
{
return this.authenticityCheckResult;
}

public List<T> Items()
{
var ls = this.authenticityCheckResult.List;

return ls as List<T>;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity
{
public static class Authenticity
{

public static SecurityFeatureChecks UvLuminescenceChecks(this AuthenticityCheckList auth)
{
return auth.securityFeatureOrNull(AuthenticityResultType.UV_LUMINESCENCE);
}

public static SecurityFeatureChecks IrB900Checks(this AuthenticityCheckList auth)
{
return auth.securityFeatureOrNull(AuthenticityResultType.IR_B900);
}

public static IdentChecks ImagePattern(this AuthenticityCheckList auth)
{
return auth.identOrNull(AuthenticityResultType.IMAGE_PATTERN);
}

public static SecurityFeatureChecks AxialProtectionChecks(this AuthenticityCheckList auth)
{
return auth.securityFeatureOrNull(AuthenticityResultType.AXIAL_PROTECTION);
}

public static FiberChecks UVFiberChecks(this AuthenticityCheckList auth)
{
return auth.filberOrNull(AuthenticityResultType.UV_FIBERS);
}

public static IdentChecks IRVisibilityChecks(this AuthenticityCheckList auth)
{
return auth.identOrNull(AuthenticityResultType.IR_VISIBILITY);
}

public static OCRSecurityTextChecks OCRSecurityTextChecks(this AuthenticityCheckList auth)
{
return auth.ocrSecurityTextOrNull(AuthenticityResultType.OCR_SECURITY_TEXT);
}

public static ImageIdentChecks IpiChecks(this AuthenticityCheckList auth)
{
return auth.imageIdentOrNull(AuthenticityResultType.IPI);
}

public static SecurityFeatureChecks EmbededImageChecks(this AuthenticityCheckList auth)
{
return auth.securityFeatureOrNull(AuthenticityResultType.PHOTO_EMBED_TYPE);
}

public static SecurityFeatureChecks HologramsChecks(this AuthenticityCheckList auth)
{
return auth.securityFeatureOrNull(AuthenticityResultType.HOLOGRAMS);
}

public static SecurityFeatureChecks ImageAreaChecks(this AuthenticityCheckList auth)
{
return auth.securityFeatureOrNull(AuthenticityResultType.PHOTO_AREA);
}

public static IdentChecks portraitComparisonChecks(this AuthenticityCheckList auth)
{
return auth.identOrNull(AuthenticityResultType.PORTRAIT_COMPARISON);
}

public static SecurityFeatureChecks BarcodeFormatCheckChecks(this AuthenticityCheckList auth)
{
return auth.securityFeatureOrNull(AuthenticityResultType.BARCODE_FORMAT_CHECK);
}

public static IdentChecks KinegramChecks(this AuthenticityCheckList auth)
{
return auth.identOrNull(AuthenticityResultType.KINEGRAM);
}

public static IdentChecks LetterScreenChecks(this AuthenticityCheckList auth)
{
return auth.identOrNull(AuthenticityResultType.LETTER_SCREEN);
}


private static AuthenticityCheckResult resultByType(this AuthenticityCheckList auth, int type)
{
return auth?.List.FirstOrDefault(t => t.Type == type);
}

private static FiberChecks filberOrNull(this AuthenticityCheckList auth, int type)
{
AuthenticityCheckResult result = auth.resultByType(type);
return result != null ? new FiberChecks(result) : null;
}

private static IdentChecks identOrNull(this AuthenticityCheckList auth, int type)
{
AuthenticityCheckResult result = auth.resultByType(type);
return result != null ? new IdentChecks(result) : null;
}

private static ImageIdentChecks imageIdentOrNull(this AuthenticityCheckList auth, int type)
{
AuthenticityCheckResult result = auth.resultByType(type);
return result != null ? new ImageIdentChecks(result) : null;
}

private static OCRSecurityTextChecks ocrSecurityTextOrNull(this AuthenticityCheckList auth, int type)
{
AuthenticityCheckResult result = auth.resultByType(type);
return result != null ? new OCRSecurityTextChecks(result) : null;
}

private static SecurityFeatureChecks securityFeatureOrNull(this AuthenticityCheckList auth, int type)
{
AuthenticityCheckResult result = auth.resultByType(type);
return result != null ? new SecurityFeatureChecks(result) : null;
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity
{
public class FiberChecks : AuthenticityResult<FiberResult>
{
public FiberChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult)
{ }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity
{
public class IdentChecks : AuthenticityResult<IdentResult>
{
public IdentChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult)
{ }

public IdentResult ChecksByElement(int type)
{
return this.Items()?.FirstOrDefault(t => t.Type == type);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity
{
public class ImageIdentChecks : AuthenticityResult<PhotoIdentResult>
{
public ImageIdentChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult)
{ }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity
{
public class OCRSecurityTextChecks : AuthenticityResult<OCRSecurityTextResult>
{
public OCRSecurityTextChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult)
{

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity
{
public class SecurityFeatureChecks : AuthenticityResult<SecurityFeatureResult>
{
public SecurityFeatureChecks(AuthenticityCheckResult authenticityResult) : base(authenticityResult)
{ }

public SecurityFeatureResult ChecksByElement(int type)
{
return this.Items()?.FirstOrDefault(t => t.Type == type);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public Images Images()
return result?.Images;
}

public AuthenticityCheckList Authenticity()
public AuthenticityCheckList Authenticity(int pageIdx=0)
{
var result = ResultByType<AuthenticityResult>(Result.AUTHENTICITY);
var result = ResultByType<AuthenticityResult>(Result.AUTHENTICITY, pageIdx);
return result?.AuthenticityCheckList;
}

public T ResultByType<T>(int type) where T: ResultItem
public T ResultByType<T>(int type, int pageIdx=0) where T: ResultItem
{
foreach(var item in OriginalResponse.ContainerList.List)
{
Expand Down