diff --git a/Regula.DocumentReader.sln b/Regula.DocumentReader.sln index b6f9bcf..d4ed18f 100644 --- a/Regula.DocumentReader.sln +++ b/Regula.DocumentReader.sln @@ -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 @@ -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 diff --git a/src/Regula.DocumentReader.NetCoreExample/Program.cs b/src/Regula.DocumentReader.NetCoreExample/Program.cs index f136f52..6e36d4e 100644 --- a/src/Regula.DocumentReader.NetCoreExample/Program.cs +++ b/src/Regula.DocumentReader.NetCoreExample/Program.cs @@ -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 { @@ -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 { - // 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{ @@ -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}"); diff --git a/src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs b/src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs index ab6da2c..cb608f9 100644 --- a/src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs +++ b/src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs @@ -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 diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs new file mode 100644 index 0000000..6b2c9b8 --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs @@ -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 where T : class + { + AuthenticityCheckResult authenticityCheckResult; + + public AuthenticityResult(AuthenticityCheckResult authenticityCheckResult) + { + this.authenticityCheckResult = authenticityCheckResult; + } + + public AuthenticityCheckResult Payload() + { + return this.authenticityCheckResult; + } + + public List Items() + { + var ls = this.authenticityCheckResult.List; + + return ls as List; + } + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs new file mode 100644 index 0000000..6881167 --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs @@ -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; + } + + } + +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs new file mode 100644 index 0000000..e048305 --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + public class FiberChecks : AuthenticityResult + { + public FiberChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult) + { } + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs new file mode 100644 index 0000000..cdaab73 --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + public class IdentChecks : AuthenticityResult + { + public IdentChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult) + { } + + public IdentResult ChecksByElement(int type) + { + return this.Items()?.FirstOrDefault(t => t.Type == type); + } + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs new file mode 100644 index 0000000..d672ddc --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + public class ImageIdentChecks : AuthenticityResult + { + public ImageIdentChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult) + { } + + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs new file mode 100644 index 0000000..850692d --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + public class OCRSecurityTextChecks : AuthenticityResult + { + public OCRSecurityTextChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult) + { + + } + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs new file mode 100644 index 0000000..8700c0b --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + public class SecurityFeatureChecks : AuthenticityResult + { + public SecurityFeatureChecks(AuthenticityCheckResult authenticityResult) : base(authenticityResult) + { } + + public SecurityFeatureResult ChecksByElement(int type) + { + return this.Items()?.FirstOrDefault(t => t.Type == type); + } + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/RecognitionResponse.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/RecognitionResponse.cs index 8a7ce09..2c5926a 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/RecognitionResponse.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/RecognitionResponse.cs @@ -28,13 +28,13 @@ public Images Images() return result?.Images; } - public AuthenticityCheckList Authenticity() + public AuthenticityCheckList Authenticity(int pageIdx=0) { - var result = ResultByType(Result.AUTHENTICITY); + var result = ResultByType(Result.AUTHENTICITY, pageIdx); return result?.AuthenticityCheckList; } - public T ResultByType(int type) where T: ResultItem + public T ResultByType(int type, int pageIdx=0) where T: ResultItem { foreach(var item in OriginalResponse.ContainerList.List) {