Repository: Microsoft/Cognitive-Face-Windows Branch: master Commit: a8e0448d1ee7 Files: 70 Total size: 499.0 KB Directory structure: gitextract_vv6euq7q/ ├── .gitignore ├── .gitmodules ├── CONTRIBUTING.md ├── ClientLibrary/ │ ├── 35MSSharedLib1024.snk │ ├── Contract/ │ │ ├── Accessory.cs │ │ ├── AddPersistedFaceResult.cs │ │ ├── Blur.cs │ │ ├── Candidate.cs │ │ ├── ClientError.cs │ │ ├── CreatePersonResult.cs │ │ ├── Exposure.cs │ │ ├── Face.cs │ │ ├── FaceAttributes.cs │ │ ├── FaceLandmarks.cs │ │ ├── FaceList.cs │ │ ├── FaceListMetadata.cs │ │ ├── FaceMetadata.cs │ │ ├── FaceRectangle.cs │ │ ├── FacialHair.cs │ │ ├── FeatureCoordinate.cs │ │ ├── GlassesTypes.cs │ │ ├── GroupResult.cs │ │ ├── Hair.cs │ │ ├── HeadPose.cs │ │ ├── IdentifyResult.cs │ │ ├── LargeFaceList.cs │ │ ├── LargePersonGroup.cs │ │ ├── Makeup.cs │ │ ├── Noise.cs │ │ ├── Occlusion.cs │ │ ├── PersistedFace.cs │ │ ├── Person.cs │ │ ├── PersonGroup.cs │ │ ├── SimilarFace.cs │ │ ├── SimilarPersistedFace.cs │ │ ├── TrainingStatus.cs │ │ └── VerifyResult.cs │ ├── FaceAPIException.cs │ ├── FaceClientSDK.nuspec │ ├── FaceServiceClient.cs │ ├── IFaceServiceClient.cs │ ├── Microsoft.ProjectOxford.Face.csproj │ ├── Microsoft.ProjectOxford.Face.sln │ ├── Properties/ │ │ └── AssemblyInfo.cs │ └── packages.config ├── LICENSE-IMAGE.md ├── LICENSE.md ├── README.md ├── Sample-WPF/ │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── Controls/ │ │ ├── Face.cs │ │ ├── FaceDetectionPage.xaml │ │ ├── FaceDetectionPage.xaml.cs │ │ ├── FaceFindSimilarPage.xaml │ │ ├── FaceFindSimilarPage.xaml.cs │ │ ├── FaceGroupingPage.xaml │ │ ├── FaceGroupingPage.xaml.cs │ │ ├── FaceIdentificationPage.xaml │ │ ├── FaceIdentificationPage.xaml.cs │ │ ├── FaceVerificationPage.xaml │ │ ├── FaceVerificationPage.xaml.cs │ │ └── UIHelper.cs │ ├── FaceAPI-WPF-Samples.csproj │ ├── FaceAPI-WPF-Samples.sln │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── Properties/ │ │ └── AssemblyInfo.cs │ └── packages.config └── ThirdPartyNotices.txt ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. # User-specific files *.suo *.user *.userosscache *.sln.docstates # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ x64/ x86/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ # Visual Studio 2015 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* # NUNIT *.VisualState.xml TestResult.xml # Build Results of an ATL Project [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c # DNX project.lock.json project.fragment.lock.json artifacts/ *_i.c *_p.c *_i.h *.ilk *.meta *.obj *.pch *.pdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *.log *.vspscc *.vssscc .builds *.pidb *.svclog *.scc # Chutzpah Test files _Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb *.opendb *.opensdf *.sdf *.cachefile *.VC.db *.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx *.sap # TFS 2012 Local Workspace $tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user # JustCode is a .NET coding add-in .JustCode # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # NCrunch _NCrunch_* .*crunch*.local.xml nCrunchTemp_* # MightyMoose *.mm.* AutoTest.Net/ # Web workbench (sass) .sass-cache/ # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml # TODO: Comment the next line if you want to checkin your web deploy settings # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj # Microsoft Azure Web App publish settings. Comment the next line if you want to # checkin your Azure Web App publish settings, but sensitive information contained # in these scripts will be unencrypted PublishScripts/ # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore **/packages/* # except build/, which is used as an MSBuild target. !**/packages/build/ # Uncomment if necessary however generally it will be regenerated when needed #!**/packages/repositories.config # NuGet v3's project.json files produces more ignoreable files *.nuget.props *.nuget.targets # Microsoft Azure Build Output csx/ *.build.csdef # Microsoft Azure Emulator ecf/ rcf/ # Windows Store app package directories and files AppPackages/ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt # Visual Studio cache files # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache !*.[Cc]ache/ # Others ClientBin/ ~$* *~ *.dbmdl *.dbproj.schemaview *.pfx *.publishsettings node_modules/ orleans.codegen.cs # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm # SQL Server files *.mdf *.ldf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings # Microsoft Fakes FakesAssemblies/ # GhostDoc plugin setting file *.GhostDoc.xml # Node.js Tools for Visual Studio .ntvs_analysis.dat # Visual Studio 6 build log *.plg # Visual Studio 6 workspace options file *.opt # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts **/*.DesktopClient/ModelManifest.xml **/*.Server/GeneratedArtifacts **/*.Server/ModelManifest.xml _Pvt_Extensions # Paket dependency manager .paket/paket.exe paket-files/ # FAKE - F# Make .fake/ # JetBrains Rider .idea/ *.sln.iml ================================================ FILE: .gitmodules ================================================ [submodule "Cognitive-Common-Windows"] path = Cognitive-Common-Windows url = https://github.com/Microsoft/Cognitive-Common-Windows.git ================================================ FILE: CONTRIBUTING.md ================================================ Contributing to Microsoft Cognitive Services Client Libraries & Samples =============================================== So, you want to contribute on a client library or sample for one of the Microsoft Cognitive Services. Here's what you need to know. 1. Each SDK should include both a client library and a sample showing the API in action 2. When working on an SDK, it's important that we are consistent from project to project, so we ask you to follow the coding guidelines below: - Windows [(Coding guidelines for C#)](https://msdn.microsoft.com/en-us/library/ff926074.aspx) -- also reference our [common Windows code](https://github.com/Microsoft/Cognitive-common-windows) for building samples - Android [(Coding guidelines for Java)]() - iOS Objective-C [(Coding guidelines for Cocoa)]() - Optional: Client Javascript ([Coding guidelines for npm]()) 3. Samples are important for illustrating how to actually call into the API. Samples should be as visual and reusable as possible. - Do: - Create a UI sample when possible. - Make your sample user friendly. Expect that developers will want to try different mainline scenarios and key APIs. - Create code that's easy for other developers to copy/paste into their own solutions - Consider: - Adding UI to allow devs to quickly copy/paste subscription keys, instead of updating them in the code or using a config file. The FaceAPI-WPF-Samples.sln provides an example. - Don't: - Leave your subscription key in the source of samples. You do not want your key to be abused by others. Happy coding! ================================================ FILE: ClientLibrary/Contract/Accessory.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { using Newtonsoft.Json; using Newtonsoft.Json.Converters; /// /// Accessory type /// [JsonConverter(typeof(StringEnumConverter))] public enum AccessoryType { /// /// Headwear /// Headwear, /// /// Glasses /// Glasses, /// /// Mask /// Mask } /// /// Face accessory class contains accessory information /// public class Accessory { #region Properties /// /// Indicating the accessory type /// public AccessoryType Type { get; set; } /// /// Indicating the confidence for accessory type /// public double Confidence { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/AddPersistedFaceResult.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { /// /// Represents face stored in FaceList or Person /// public class AddPersistedFaceResult { #region Properties /// /// Gets or sets the persisted face identifier. /// /// /// The persisted face identifier. /// public Guid PersistedFaceId { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/Blur.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { using Newtonsoft.Json; using Newtonsoft.Json.Converters; /// /// Definition of blur level /// [JsonConverter(typeof(StringEnumConverter))] public enum BlurLevel { /// /// Low blur level indicating a clear face image /// Low, /// /// Medium blur level indicating a slightly blurry face image /// Medium, /// /// High blur level indicating a extremely blurry face image /// High } /// /// Face Blur class contains blur information /// public class Blur { #region Properties /// /// Indicating the blur level of face image /// public BlurLevel BlurLevel { get; set; } /// /// Blur value is in range [0, 1]. Larger value means the face image is more blurry. /// [0, 0.25) is low blur level. /// [0.25, 0.75) is medium blur level. /// [0.75, 1] is high blur level. /// public double Value { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/Candidate.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { /// /// The identified candidate entity. /// public class Candidate { #region Properties /// /// Gets or sets the person identifier. /// /// /// The person identifier. /// public Guid PersonId { get; set; } /// /// Gets or sets the confidence. /// /// /// The confidence. /// public double Confidence { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/ClientError.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System.Runtime.Serialization; namespace Microsoft.ProjectOxford.Face.Contract { /// /// Represents client error with detailed error message and error code /// [DataContract] public class ClientError { #region Constructors /// /// Initializes a new instance of the class /// public ClientError() { } #endregion Constructors #region Properties /// /// Gets or sets the detailed error message and error code /// [DataMember(Name = "error")] public ClientExceptionMessage Error { get; set; } #endregion Properties } /// /// Represents detailed error message and error code /// [DataContract] public class ClientExceptionMessage { #region Properties /// /// Gets or sets the detailed error code /// [DataMember(Name = "code")] public string ErrorCode { get; set; } /// /// Gets or sets the detailed error message /// [DataMember(Name = "message")] public string Message { get; set; } #endregion Properties } /// /// Represents client error with detailed error message and error code /// [DataContract] public class ServiceError { #region Constructors /// /// Initializes a new instance of the class /// public ServiceError() { } #endregion Constructors #region Properties /// /// Gets or sets the detailed error message and error code /// [DataMember(Name = "statusCode")] public string ErrorCode { get; set; } /// /// Gets or sets the detailed error message and error code /// [DataMember(Name = "message")] public string Message { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/CreatePersonResult.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { /// /// The class for person creation result. /// public class CreatePersonResult { #region Properties /// /// Gets or sets the person identifier. /// /// /// The person identifier. /// public Guid PersonId { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/Exposure.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { using Newtonsoft.Json; using Newtonsoft.Json.Converters; /// /// Definition of exposure level /// [JsonConverter(typeof(StringEnumConverter))] public enum ExposureLevel { /// /// Indicating face image is in under exposure /// UnderExposure, /// /// Indicating face image is in good exposure /// GoodExposure, /// /// Indicating face image is in over exposure /// OverExposure } /// /// Face Exposure class contains exposure information /// public class Exposure { #region Properties /// /// Indicating exposure level of face image /// public ExposureLevel ExposureLevel { get; set; } /// /// Exposure value is in range [0, 1]. Larger value means the face image is more brighter. /// [0, 0.25) is under exposure. /// [0.25, 0.75) is good exposure. /// [0.75, 1] is over exposure. /// public double Value { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/Face.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { /// /// The detected face entity. /// public class Face { #region Properties /// /// Gets or sets the face identifier. /// /// /// The face identifier. /// public Guid FaceId { get; set; } /// /// Gets or sets the face rectangle. /// /// /// The face rectangle. /// public FaceRectangle FaceRectangle { get; set; } /// /// Gets or sets the face landmarks. /// /// /// The face landmarks. /// public FaceLandmarks FaceLandmarks { get; set; } /// /// Gets or sets the face attributes. /// /// /// The face attributes. /// public FaceAttributes FaceAttributes { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/FaceAttributes.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using Newtonsoft.Json; using Newtonsoft.Json.Converters; namespace Microsoft.ProjectOxford.Face.Contract { using Microsoft.ProjectOxford.Common.Contract; /// /// The face attributes class that holds Age/Gender/Head Pose/Smile/Facial Hair information. /// public class FaceAttributes { #region Properties /// /// Gets or sets the age value. /// /// /// The age value. /// public double Age { get; set; } /// /// Gets or sets the gender. /// /// /// The gender. /// public string Gender { get; set; } /// /// Gets or sets the head pose. /// /// /// The head pose. /// public HeadPose HeadPose { get; set; } /// /// Gets or sets the smile value. Represents the confidence of face is smiling. /// /// /// The smile value. /// public double Smile { get; set; } /// /// Gets or sets the facial hair. /// /// /// The facial hair. /// public FacialHair FacialHair { get; set; } /// /// Gets or sets the emotion. /// /// /// The emotion. /// public EmotionScores Emotion { get; set; } /// /// Gets or sets the glasses type. /// /// /// The glasses type. /// [JsonConverter(typeof(StringEnumConverter))] public Glasses Glasses { get; set; } /// /// Gets or sets the blur /// /// /// The blur type /// public Blur Blur { get; set; } /// /// Gets or sets the exposure /// /// /// The exposure type /// public Exposure Exposure { get; set; } /// /// Gets or sets the noise /// /// /// The noise type /// public Noise Noise { get; set; } /// /// Gets or sets the makeup /// /// /// The makeup type /// public Makeup Makeup { get; set; } /// /// Gets or sets the accessories /// /// /// The accessory type array /// public Accessory[] Accessories { get; set; } /// /// Gets or sets the occlusion /// /// /// The occlusion type /// public Occlusion Occlusion { get; set; } /// /// Gets or sets the hair /// /// /// The hair type /// public Hair Hair { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/FaceLandmarks.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// The face landmarks class. /// public class FaceLandmarks { #region Properties /// /// Gets or sets the pupil left. /// /// /// The pupil left. /// public FeatureCoordinate PupilLeft { get; set; } /// /// Gets or sets the pupil right. /// /// /// The pupil right. /// public FeatureCoordinate PupilRight { get; set; } /// /// Gets or sets the nose tip. /// /// /// The nose tip. /// public FeatureCoordinate NoseTip { get; set; } /// /// Gets or sets the mouth left. /// /// /// The mouth left. /// public FeatureCoordinate MouthLeft { get; set; } /// /// Gets or sets the mouth right. /// /// /// The mouth right. /// public FeatureCoordinate MouthRight { get; set; } /// /// Gets or sets the eyebrow left outer. /// /// /// The eyebrow left outer. /// public FeatureCoordinate EyebrowLeftOuter { get; set; } /// /// Gets or sets the eyebrow left inner. /// /// /// The eyebrow left inner. /// public FeatureCoordinate EyebrowLeftInner { get; set; } /// /// Gets or sets the eye left outer. /// /// /// The eye left outer. /// public FeatureCoordinate EyeLeftOuter { get; set; } /// /// Gets or sets the eye left top. /// /// /// The eye left top. /// public FeatureCoordinate EyeLeftTop { get; set; } /// /// Gets or sets the eye left bottom. /// /// /// The eye left bottom. /// public FeatureCoordinate EyeLeftBottom { get; set; } /// /// Gets or sets the eye left inner. /// /// /// The eye left inner. /// public FeatureCoordinate EyeLeftInner { get; set; } /// /// Gets or sets the eyebrow right inner. /// /// /// The eyebrow right inner. /// public FeatureCoordinate EyebrowRightInner { get; set; } /// /// Gets or sets the eyebrow right outer. /// /// /// The eyebrow right outer. /// public FeatureCoordinate EyebrowRightOuter { get; set; } /// /// Gets or sets the eye right inner. /// /// /// The eye right inner. /// public FeatureCoordinate EyeRightInner { get; set; } /// /// Gets or sets the eye right top. /// /// /// The eye right top. /// public FeatureCoordinate EyeRightTop { get; set; } /// /// Gets or sets the eye right bottom. /// /// /// The eye right bottom. /// public FeatureCoordinate EyeRightBottom { get; set; } /// /// Gets or sets the eye right outer. /// /// /// The eye right outer. /// public FeatureCoordinate EyeRightOuter { get; set; } /// /// Gets or sets the nose root left. /// /// /// The nose root left. /// public FeatureCoordinate NoseRootLeft { get; set; } /// /// Gets or sets the nose root right. /// /// /// The nose root right. /// public FeatureCoordinate NoseRootRight { get; set; } /// /// Gets or sets the nose left alar top. /// /// /// The nose left alar top. /// public FeatureCoordinate NoseLeftAlarTop { get; set; } /// /// Gets or sets the nose right alar top. /// /// /// The nose right alar top. /// public FeatureCoordinate NoseRightAlarTop { get; set; } /// /// Gets or sets the nose left alar out tip. /// /// /// The nose left alar out tip. /// public FeatureCoordinate NoseLeftAlarOutTip { get; set; } /// /// Gets or sets the nose right alar out tip. /// /// /// The nose right alar out tip. /// public FeatureCoordinate NoseRightAlarOutTip { get; set; } /// /// Gets or sets the upper lip top. /// /// /// The upper lip top. /// public FeatureCoordinate UpperLipTop { get; set; } /// /// Gets or sets the upper lip bottom. /// /// /// The upper lip bottom. /// public FeatureCoordinate UpperLipBottom { get; set; } /// /// Gets or sets the under lip top. /// /// /// The under lip top. /// public FeatureCoordinate UnderLipTop { get; set; } /// /// Gets or sets the under lip bottom. /// /// /// The under lip bottom. /// public FeatureCoordinate UnderLipBottom { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/FaceList.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// The face list class /// public class FaceList : FaceListMetadata { #region Properties /// /// Gets or sets the persisted faces. /// /// /// The persisted faces. /// public PersistedFace[] PersistedFaces { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/FaceListMetadata.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// The face list metadata class. /// public class FaceListMetadata { #region Properties /// /// Gets or sets the face list identifier. /// /// /// The face list identifier. /// public string FaceListId { get; set; } /// /// Gets or sets the name. /// /// /// The name. /// public string Name { get; set; } /// /// Gets or sets the user data. /// /// /// The user data. /// public string UserData { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/FaceMetadata.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { /// /// Face metadata class. /// public class FaceMetadata { #region Properties /// /// Gets or sets the face identifier. /// /// /// The face identifier. /// public Guid FaceId { get; set; } /// /// Gets or sets the user data. /// /// /// The user data. /// public string UserData { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/FaceRectangle.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// The face rectangle entity. /// public class FaceRectangle { #region Properties /// /// Gets or sets the width. /// /// /// The width. /// public int Width { get; set; } /// /// Gets or sets the height. /// /// /// The height. /// public int Height { get; set; } /// /// Gets or sets the left. /// /// /// The left of the face rectangle. /// public int Left { get; set; } /// /// Gets or sets the top. /// /// /// The top of the face rectangle. /// public int Top { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/FacialHair.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// Represents length of moustache, beard and sideburn /// public class FacialHair { #region Properties /// /// Gets or sets the moustache value. Represents the length of moustache. /// /// /// The moustache value. /// public double Moustache { get; set; } /// /// Gets or sets the beard value. Represents the length of beard. /// /// /// The beard value. /// public double Beard { get; set; } /// /// Gets or sets the sideburns value. Represents the length of sideburns. /// /// /// The sideburns value. /// public double Sideburns { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/FeatureCoordinate.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// The class for feature coordinate. /// public class FeatureCoordinate { #region Properties /// /// Gets or sets the x in pixel. /// /// /// The x of the feature coordinate. /// public double X { get; set; } /// /// Gets or sets the y in pixel. /// /// /// The y of the feature coordinate. /// public double Y { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/GlassesTypes.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows/ // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// Enumeration which represents the type of wearing glasses /// public enum Glasses { /// /// Indicates not wearing any glasses /// NoGlasses, /// /// Indicates wearing sunglasses /// Sunglasses, /// /// Indicates wearing reading glasses /// ReadingGlasses, /// /// Indicates wearing swimming goggles /// SwimmingGoggles } } ================================================ FILE: ClientLibrary/Contract/GroupResult.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Collections.Generic; namespace Microsoft.ProjectOxford.Face.Contract { /// /// The class for group result. /// public class GroupResult { #region Properties /// /// Gets or sets the groups. The groups are ranked by number of faces. /// /// /// The groups. /// public List Groups { get; set; } /// /// Gets or sets the messy group. Messy group contains all the faces which cannot find any similar faces from original faces. /// /// /// The messy group. /// public Guid[] MessyGroup { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/Hair.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { using Newtonsoft.Json; using Newtonsoft.Json.Converters; /// /// Hair color type /// [JsonConverter(typeof(StringEnumConverter))] public enum HairColorType { /// /// unknown /// Unknown, /// /// White /// White, /// /// Gray /// Gray, /// /// Blond /// Blond, /// /// Brown /// Brown, /// /// Red /// Red, /// /// Black /// Black, /// /// Other /// Other } /// /// Face HiarColor class contains hair color information /// public class HairColor { /// /// Indicating the hair color type /// public HairColorType Color { get; set; } /// /// Indicating the confidence for hair color type /// public double Confidence { get; set; } } /// /// Face Hair class contains hair information /// public class Hair { #region Properties /// /// Indicating the confidence of a bald head /// public double Bald { get; set; } /// /// Indicating whether hair is occluded or not /// public bool Invisible { get; set; } /// /// Indicating all possible hair colors with confidences /// public HairColor[] HairColor { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/HeadPose.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// The head pose entity. /// public class HeadPose { #region Properties /// /// Gets or sets the roll. /// /// /// The roll of the face pose. /// public double Roll { get; set; } /// /// Gets or sets the yaw. /// /// /// The yaw of the face pose. /// public double Yaw { get; set; } /// /// Gets or sets the pitch. /// /// /// The pitch of the face pose. /// public double Pitch { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/IdentifyResult.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { /// /// The identification result. /// public class IdentifyResult { #region Properties /// /// Gets or sets the face identifier. /// /// /// The face identifier. /// public Guid FaceId { get; set; } /// /// Gets or sets the candidates. /// /// /// The candidates. /// public Candidate[] Candidates { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/LargeFaceList.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// The large face list class. /// public class LargeFaceList { #region Properties /// /// Gets or sets the large face list identifier. /// /// /// The large face list identifier. /// public string LargeFaceListId { get; set; } /// /// Gets or sets the name. /// /// /// The name. /// public string Name { get; set; } /// /// Gets or sets the user data. /// /// /// The user data. /// public string UserData { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/LargePersonGroup.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// The large person group entity. /// public class LargePersonGroup { #region Properties /// /// Gets or sets the large person group identifier. /// /// /// The large person group identifier. /// public string LargePersonGroupId { get; set; } /// /// Gets or sets the name. /// /// /// The name of the large person group. /// public string Name { get; set; } /// /// Gets or sets the user data. /// /// /// The user data. /// public string UserData { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/Makeup.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// Face Makeup class contains makeup information /// public class Makeup { #region Properties /// /// Indicating whether eye has makeup or not /// public bool EyeMakeup { get; set; } /// /// Indicating whether lip has makeup or not /// public bool LipMakeup { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/Noise.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { using Newtonsoft.Json; using Newtonsoft.Json.Converters; /// /// Definition of noise level /// [JsonConverter(typeof(StringEnumConverter))] public enum NoiseLevel { /// /// Low noise level indicating a clear face image /// Low, /// /// Medium noise level indicating a slightly noisy face image /// Medium, /// /// High noise level indicating a extremely noisy face image /// High } /// /// Face Noise class contains noise information /// public class Noise { #region Properties /// /// Indicating noise level of face image /// public NoiseLevel NoiseLevel { get; set; } /// /// Noise value is in range [0, 1]. Larger value means the face image is more noisy. /// [0, 0.3) is low noise level. /// [0.3, 0.7) is medium noise level. /// [0.7, 1] is high noise level. /// public double Value { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/Occlusion.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// Face Occlusion class contains occlusion information /// public class Occlusion { #region Properties /// /// Indicating whether forehead is occluded or not /// public bool ForeheadOccluded { get; set; } /// /// Indicating whether eye is occluded or not /// public bool EyeOccluded { get; set; } /// /// Indicating whether mouth is occluded or not /// public bool MouthOccluded { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/PersistedFace.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { /// /// The persisted face entity. /// public class PersistedFace { #region Properties /// /// Gets or sets the persisted face identifier. /// /// /// The persisted face identifier. /// public Guid PersistedFaceId { get; set; } /// /// Gets or sets the user data. /// /// /// The user data. /// public string UserData { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/Person.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { /// /// The person entity. /// public class Person { #region Properties /// /// Gets or sets the person identifier. /// /// /// The person identifier. /// public Guid PersonId { get; set; } /// /// Gets or sets the persisted face ids. /// /// /// The persisted face ids. /// public Guid[] PersistedFaceIds { get; set; } /// /// Gets or sets the name. /// /// /// The name of the person. /// public string Name { get; set; } /// /// Gets or sets the profile. /// /// /// The profile. /// public string UserData { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/PersonGroup.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// The person group entity. /// public class PersonGroup { #region Properties /// /// Gets or sets the person group identifier. /// /// /// The person group identifier. /// public string PersonGroupId { get; set; } /// /// Gets or sets the name. /// /// /// The name of the person group. /// public string Name { get; set; } /// /// Gets or sets the user data. /// /// /// The user data. /// public string UserData { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/SimilarFace.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { /// /// The class for similar face. /// public class SimilarFace { #region Properties /// /// Gets or sets the face identifier. /// /// /// The face identifier. /// public Guid FaceId { get; set; } /// /// Gets or sets the confidence. /// /// /// The confidence. /// public double Confidence { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/SimilarPersistedFace.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { /// /// The class for similar persisted face. /// public class SimilarPersistedFace { #region Properties /// /// Gets or sets the persisted face identifier. /// /// /// The persisted face identifier. /// public Guid PersistedFaceId { get; set; } /// /// Gets or sets the confidence value. /// /// /// The confidence value. /// public double Confidence { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/TrainingStatus.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; namespace Microsoft.ProjectOxford.Face.Contract { #region Enumerations /// /// Enumeration represents status of training /// public enum Status { /// /// Training succeeded /// Succeeded, /// /// Training failed /// Failed, /// /// Training still in progress /// Running } #endregion Enumerations /// /// The training status entity. /// public class TrainingStatus { #region Properties /// /// Gets or sets the status. /// /// /// The status. /// public Status Status { get; set; } /// /// Gets or sets the create time. /// /// /// The create time. /// public DateTime CreatedDateTime { get; set; } /// /// Gets or sets the last action time. /// /// /// The last action time. /// public DateTime LastActionDateTime { get; set; } /// /// Gets or sets the last successful training time. /// /// /// The last successful training time. /// public DateTime? LastSuccessfulTrainingDateTime { get; set; } /// /// Gets or sets the message. /// /// /// The message. /// public string Message { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/Contract/VerifyResult.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // namespace Microsoft.ProjectOxford.Face.Contract { /// /// The verify result entity. /// public class VerifyResult { #region Properties /// /// Gets or sets a value indicating whether this instance is same. /// /// /// true if this instance is same; otherwise, false. /// public bool IsIdentical { get; set; } /// /// Gets or sets the confidence. /// /// /// The confidence. /// public double Confidence { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/FaceAPIException.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Net; namespace Microsoft.ProjectOxford.Face { /// /// Represents client error with detailed error message and error code /// public class FaceAPIException : Exception { #region Constructors /// /// Initializes a new instance of the class /// public FaceAPIException() { } /// /// Initializes a new instance of the class /// /// Code represents the error category /// Message represents the detailed error description /// Http status code public FaceAPIException(string errorCode, string errorMessage, HttpStatusCode statusCode) : base(errorMessage + "(" + errorCode + ")") { this.ErrorCode = errorCode; this.ErrorMessage = errorMessage; this.HttpStatus = statusCode; } #endregion Constructors #region Properties /// /// Gets or sets the error code /// public string ErrorCode { get; set; } /// /// Gets or sets the error message /// public string ErrorMessage { get; set; } /// /// Gets or sets http status of http response. /// /// /// The HTTP status. /// public HttpStatusCode HttpStatus { get; set; } #endregion Properties } } ================================================ FILE: ClientLibrary/FaceClientSDK.nuspec ================================================ Microsoft.ProjectOxford.Face Microsoft Cognitive Services Face API Client Library 1.4.0 Microsoft Microsoft https://github.com/Microsoft/Cognitive-Face-Windows/blob/master/LICENSE.md https://azure.microsoft.com/en-us/services/cognitive-services/face/ https://portalstoragewuprod.azureedge.net/media/Default/Media/FaceAPI/Icons_Vision_Face.svg true Microsoft Cognitive Services Face API Client Library Use Face API Client Library to enrich your apps with Microsoft's state-of-the-art cloud-based face algorithms. Million Scale support via LargePersonGroup/LargeFaceList. © Microsoft Corporation. All rights reserved. Face Oxford ProjectOxford Microsoft Cognitive CognitiveServices ================================================ FILE: ClientLibrary/FaceServiceClient.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using Microsoft.ProjectOxford.Face.Contract; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; namespace Microsoft.ProjectOxford.Face { using Face = Microsoft.ProjectOxford.Face.Contract.Face; /// /// The face service client proxy implementation. /// public class FaceServiceClient : IDisposable, IFaceServiceClient { #region Fields /// /// The default service host. /// private const string DEFAULT_API_ROOT = "https://westus.api.cognitive.microsoft.com/face/v1.0"; /// /// The JSON content type header. /// private const string JsonContentTypeHeader = "application/json"; /// /// The stream content type header. /// private const string StreamContentTypeHeader = "application/octet-stream"; /// /// The subscription key name. /// private const string SubscriptionKeyName = "ocp-apim-subscription-key"; /// /// The detect. /// private const string DetectQuery = "detect"; /// /// The verify. /// private const string VerifyQuery = "verify"; /// /// The train query. /// private const string TrainQuery = "train"; /// /// The training query. /// private const string TrainingQuery = "training"; /// /// The person groups. /// private const string PersonGroupsQuery = "persongroups"; /// /// The person groups. /// private const string LargePersonGroupsQuery = "largepersongroups"; /// /// The persons. /// private const string PersonsQuery = "persons"; /// /// The persisted faces query string. /// private const string PersistedFacesQuery = "persistedfaces"; /// /// The face list query /// private const string FaceListsQuery = "facelists"; /// /// The face list query /// private const string LargeFaceListsQuery = "largefacelists"; /// /// The endpoint for Find Similar API. /// private const string FindSimilarsQuery = "findsimilars"; /// /// The identify. /// private const string IdentifyQuery = "identify"; /// /// The group. /// private const string GroupQuery = "group"; /// /// The settings /// private static JsonSerializerSettings s_settings = new JsonSerializerSettings() { DateFormatHandling = DateFormatHandling.IsoDateFormat, NullValueHandling = NullValueHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver() }; /// /// The subscription key. /// private readonly string _subscriptionKey; /// /// The root URI for the service endpoint. /// private readonly string _apiRoot; /// /// The HTTP client /// private HttpClient _httpClient; #endregion Fields #region Constructors /// /// Initializes a new instance of the class. /// /// The subscription key. public FaceServiceClient(string subscriptionKey) : this(subscriptionKey, DEFAULT_API_ROOT) { } /// /// Initializes a new instance of the class. /// /// The subscription key. /// Root URI for the service endpoint. public FaceServiceClient(string subscriptionKey, string apiRoot) { this._subscriptionKey = subscriptionKey; this._apiRoot = apiRoot?.TrimEnd('/'); this._httpClient = new HttpClient(); this._httpClient.DefaultRequestHeaders.Add(SubscriptionKeyName, this._subscriptionKey); } /// /// Finalizes an instance of the class. /// ~FaceServiceClient() { this.Dispose(false); } #endregion Constructors #region Properties /// /// Gets service endpoint address, overridable by subclasses, default to free subscription's endpoint. /// protected virtual string ServiceHost => this._apiRoot; /// /// Gets default request headers for all following http request /// public HttpRequestHeaders DefaultRequestHeaders { get { return this._httpClient.DefaultRequestHeaders; } } #endregion Properties #region Face Methods /// /// Detects an URL asynchronously. /// /// The image URL. /// If set to true [return face ID]. /// If set to true [return face landmarks]. /// Face attributes need to be returned. /// The detected faces. public async Task DetectAsync(string imageUrl, bool returnFaceId = true, bool returnFaceLandmarks = false, IEnumerable returnFaceAttributes = null) { if (returnFaceAttributes != null) { var requestUrl = $"{this.ServiceHost}/{DetectQuery}?returnFaceId={returnFaceId}&returnFaceLandmarks={returnFaceLandmarks}&returnFaceAttributes={GetAttributeString(returnFaceAttributes)}"; return await this.SendRequestAsync(HttpMethod.Post, requestUrl, new { url = imageUrl }); } else { var requestUrl = $"{this.ServiceHost}/{DetectQuery}?returnFaceId={returnFaceId}&returnFaceLandmarks={returnFaceLandmarks}"; return await this.SendRequestAsync(HttpMethod.Post, requestUrl, new { url = imageUrl }); } } /// /// Detects an image asynchronously. /// /// The image stream. /// If set to true [return face ID]. /// If set to true [return face landmarks]. /// Face attributes need to be returned. /// The detected faces. public async Task DetectAsync(Stream imageStream, bool returnFaceId = true, bool returnFaceLandmarks = false, IEnumerable returnFaceAttributes = null) { if (returnFaceAttributes != null) { var requestUrl = $"{this.ServiceHost}/{DetectQuery}?returnFaceId={returnFaceId}&returnFaceLandmarks={returnFaceLandmarks}&returnFaceAttributes={GetAttributeString(returnFaceAttributes)}"; return await this.SendRequestAsync(HttpMethod.Post, requestUrl, imageStream); } else { var requestUrl = $"{this.ServiceHost}/{DetectQuery}?returnFaceId={returnFaceId}&returnFaceLandmarks={returnFaceLandmarks}"; return await this.SendRequestAsync(HttpMethod.Post, requestUrl, imageStream); } } /// /// Finds the similar faces asynchronously. /// /// The face identifier. /// The face identifiers. /// The max number of candidates returned. /// /// The similar faces. /// public async Task FindSimilarAsync(Guid faceId, Guid[] faceIds, int maxNumOfCandidatesReturned = 20) { return await this.FindSimilarAsync(faceId, faceIds, FindSimilarMatchMode.matchPerson, maxNumOfCandidatesReturned); } /// /// Finds the similar faces asynchronously. /// /// The face identifier. /// The face identifiers. /// Algorithm mode option, default as "matchPerson". /// The max number of candidates returned. /// /// The similar faces. /// public async Task FindSimilarAsync(Guid faceId, Guid[] faceIds, FindSimilarMatchMode mode, int maxNumOfCandidatesReturned = 20) { var requestUrl = $"{this.ServiceHost}/{FindSimilarsQuery}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { faceId = faceId, faceIds = faceIds, maxNumOfCandidatesReturned = maxNumOfCandidatesReturned, mode = mode.ToString() }); } /// /// Finds the similar faces asynchronously. /// /// The face identifier. /// The face list identifier. /// The max number of candidates returned. /// /// The similar persisted faces. /// public async Task FindSimilarAsync(Guid faceId, string faceListId, int maxNumOfCandidatesReturned = 20) { return await this.FindSimilarAsync(faceId, faceListId, FindSimilarMatchMode.matchPerson, maxNumOfCandidatesReturned); } /// /// Finds the similar faces asynchronously. /// /// The face identifier. /// The face list identifier. /// Algorithm mode option, default as "matchPerson". /// The max number of candidates returned. /// /// The similar persisted faces. /// public async Task FindSimilarAsync(Guid faceId, string faceListId, FindSimilarMatchMode mode, int maxNumOfCandidatesReturned = 20) { return await this.FindSimilarAsync(faceId, faceListId, null, mode, maxNumOfCandidatesReturned); } /// /// Finds the similar faces asynchronously. /// /// The face identifier. /// The face list identifier. /// The large face list identifier. /// Algorithm mode option, default as "matchPerson". /// The max number of candidates returned. /// /// The similar persisted faces. /// public async Task FindSimilarAsync( Guid faceId, string faceListId = null, string largeFaceListId = null, FindSimilarMatchMode mode = FindSimilarMatchMode.matchPerson, int maxNumOfCandidatesReturned = 20) { var requestUrl = $"{this.ServiceHost}/{FindSimilarsQuery}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { faceId = faceId, faceListId = faceListId, largeFaceListId = largeFaceListId, maxNumOfCandidatesReturned = maxNumOfCandidatesReturned, mode = mode.ToString() }); } /// /// Groups the face asynchronously. /// /// The face ids. /// /// Task object. /// public async Task GroupAsync(Guid[] faceIds) { var requestUrl = $"{this.ServiceHost}/{GroupQuery}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { faceIds = faceIds }); } /// /// Identities the faces in a given person group asynchronously. /// /// The person group id. /// The face ids. /// The maximum number of candidates returned for each face. /// The identification results public async Task IdentifyAsync(string personGroupId, Guid[] faceIds, int maxNumOfCandidatesReturned = 1) { return await this.IdentifyAsync(personGroupId, faceIds, 0.5f, maxNumOfCandidatesReturned); } /// /// Identities the faces in a given person group asynchronously. /// /// The person group id. /// The face ids. /// user-specified confidence threshold. /// The maximum number of candidates returned for each face. /// The identification results public async Task IdentifyAsync(string personGroupId, Guid[] faceIds, float confidenceThreshold, int maxNumOfCandidatesReturned = 1) { return await this.IdentifyAsync(faceIds, personGroupId, null, confidenceThreshold, maxNumOfCandidatesReturned); } /// /// Identities the faces in a given person group or large person group asynchronously. /// /// The face ids. /// The person group id. /// The large person group id. /// user-specified confidence threshold. /// The maximum number of candidates returned for each face. /// The identification results public async Task IdentifyAsync( Guid[] faceIds, string personGroupId = null, string largePersonGroupId = null, float confidenceThreshold = 0.5f, int maxNumOfCandidatesReturned = 1) { var requestUrl = $"{this.ServiceHost}/{IdentifyQuery}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { faceIds = faceIds, personGroupId = personGroupId, largePersonGroupId = largePersonGroupId, confidenceThreshold = confidenceThreshold, maxNumOfCandidatesReturned = maxNumOfCandidatesReturned }); } /// /// Verifies whether the specified two faces belong to the same person asynchronously. /// /// The face id 1. /// The face id 2. /// The verification result. public async Task VerifyAsync(Guid faceId1, Guid faceId2) { var requestUrl = $"{this.ServiceHost}/{VerifyQuery}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { faceId1 = faceId1, faceId2 = faceId2 }); } /// /// Verifies whether the specified face belong to the specified person asynchronously. /// /// the face ID /// the person group ID /// the person ID /// The verification result. public async Task VerifyAsync(Guid faceId, string personGroupId, Guid personId) { return await this.VerifyAsync(faceId, personId, personGroupId); } /// /// Verify whether one face belong to a person. /// /// The face id. /// The person id. /// The person group id. /// The large person group id. /// Verification result. public async Task VerifyAsync( Guid faceId, Guid personId, string personGroupId = null, string largePersonGroupId = null) { var requestUrl = $"{this.ServiceHost}/{VerifyQuery}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { faceId = faceId, personGroupId = personGroupId, largePersonGroupId = largePersonGroupId, personId = personId }); } #endregion #region FaceList Methods /// /// Creates the face list asynchronously. /// /// The face list identifier. /// The name. /// The user data. /// /// Task object. /// public async Task CreateFaceListAsync(string faceListId, string name, string userData = null) { var requestUrl = $"{this.ServiceHost}/{FaceListsQuery}/{faceListId}"; await this.SendRequestAsync( HttpMethod.Put, requestUrl, new { name = name, userData = userData }); } /// /// Deletes the face list asynchronously. /// /// The face list identifier. /// /// Task object. /// public async Task DeleteFaceListAsync(string faceListId) { var requestUrl = $"{this.ServiceHost}/{FaceListsQuery}/{faceListId}"; await this.SendRequestAsync(HttpMethod.Delete, requestUrl, null); } /// /// Gets the face list asynchronously. /// /// The face list identifier. /// /// Face list object. /// public async Task GetFaceListAsync(string faceListId) { var requestUrl = $"{this.ServiceHost}/{FaceListsQuery}/{faceListId}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// List the face lists asynchronously. /// /// /// FaceListMetadata array. /// public async Task ListFaceListsAsync() { var requestUrl = $"{this.ServiceHost}/{FaceListsQuery}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Updates the face list asynchronously. /// /// The face list identifier. /// The name. /// The user data. /// /// Task object. /// public async Task UpdateFaceListAsync(string faceListId, string name, string userData) { var requestUrl = $"{this.ServiceHost}/{FaceListsQuery}/{faceListId}"; await this.SendRequestAsync( new HttpMethod("PATCH"), requestUrl, new { name = name, userData = userData }); } #endregion #region FaceList Face Methods /// /// Adds the face to face list asynchronously. /// /// The face list identifier. /// The face image URL. /// The user data. /// The target face. /// /// Add face result. /// public async Task AddFaceToFaceListAsync( string faceListId, string imageUrl, string userData = null, FaceRectangle targetFace = null) { var targetFaceString = targetFace == null ? string.Empty : $"{targetFace.Left},{targetFace.Top},{targetFace.Width},{targetFace.Height}"; var requestUrl = $"{this.ServiceHost}/{FaceListsQuery}/{faceListId}/{PersistedFacesQuery}?userData={userData}&targetFace={targetFaceString}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { url = imageUrl }); } /// /// Adds the face to face list asynchronously. /// /// The face list identifier. /// The face image stream. /// The user data. /// The target face. /// /// Add face result. /// public async Task AddFaceToFaceListAsync( string faceListId, Stream imageStream, string userData = null, FaceRectangle targetFace = null) { var targetFaceString = targetFace == null ? string.Empty : $"{targetFace.Left},{targetFace.Top},{targetFace.Width},{targetFace.Height}"; var requestUrl = $"{this.ServiceHost}/{FaceListsQuery}/{faceListId}/{PersistedFacesQuery}?userData={userData}&targetFace={targetFaceString}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, imageStream); } /// /// Deletes the face from face list asynchronously. /// /// The face list identifier. /// The persisted face id. /// Task object. public async Task DeleteFaceFromFaceListAsync(string faceListId, Guid persistedFaceId) { var requestUrl = $"{this.ServiceHost}/{FaceListsQuery}/{faceListId}/{PersistedFacesQuery}/{persistedFaceId}"; await this.SendRequestAsync(HttpMethod.Delete, requestUrl, null); } #endregion #region PersonGroup Methods /// /// Creates the person group asynchronously. /// /// The person group identifier. /// The name. /// The user data. /// Task object. public async Task CreatePersonGroupAsync(string personGroupId, string name, string userData = null) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}"; await this.SendRequestAsync( HttpMethod.Put, requestUrl, new { name = name, userData = userData }); } /// /// Deletes a person group asynchronously. /// /// The person group id. /// Task object. public async Task DeletePersonGroupAsync(string personGroupId) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}"; await this.SendRequestAsync(HttpMethod.Delete, requestUrl, null); } /// /// Gets a person group asynchronously. /// /// The person group id. /// The person group entity. public async Task GetPersonGroupAsync(string personGroupId) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Gets person group training status asynchronously. /// /// The person group id. /// The person group training status. public async Task GetPersonGroupTrainingStatusAsync(string personGroupId) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{TrainingQuery}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Gets person groups asynchronously. /// /// Person group entity array. [Obsolete("use ListPersonGroupsAsync instead")] public async Task GetPersonGroupsAsync() { return await this.ListPersonGroupsAsync(); } /// /// Asynchronously list the top person groups whose Id is larger than "start". /// /// person group Id bar. List the person groups whose Id is larger than "start". /// the number of person groups to list. /// Person group entity array. public async Task ListPersonGroupsAsync(string start = "", int top = 1000) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}?start={start}&top={top.ToString(CultureInfo.InvariantCulture)}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Trains the person group asynchronously. /// /// The person group id. /// Task object. public async Task TrainPersonGroupAsync(string personGroupId) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{TrainQuery}"; await this.SendRequestAsync(HttpMethod.Post, requestUrl, null); } /// /// Updates a person group asynchronously. /// /// The person group id. /// The name. /// The user data. /// Task object. public async Task UpdatePersonGroupAsync(string personGroupId, string name, string userData = null) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}"; await this.SendRequestAsync( new HttpMethod("PATCH"), requestUrl, new { name = name, userData = userData }); } #endregion #region PersonGroup Person Methods /// /// Creates a person asynchronously. /// /// The person group id. /// The name. /// The user data. /// The CreatePersonResult entity. public async Task CreatePersonAsync( string personGroupId, string name, string userData = null) { return await this.CreatePersonInPersonGroupAsync(personGroupId, name, userData); } /// /// Creates a person asynchronously. /// /// The person group id. /// The name. /// The user data. /// The CreatePersonResult entity. public async Task CreatePersonInPersonGroupAsync( string personGroupId, string name, string userData = null) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{PersonsQuery}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { name = name, userData = userData }); } /// /// Deletes a person asynchronously. /// /// The person group id. /// The person id. /// Task object. public async Task DeletePersonAsync(string personGroupId, Guid personId) { await this.DeletePersonFromPersonGroupAsync(personGroupId, personId); } /// /// Deletes a person asynchronously. /// /// The person group id. /// The person id. /// Task object. public async Task DeletePersonFromPersonGroupAsync(string personGroupId, Guid personId) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{PersonsQuery}/{personId}"; await this.SendRequestAsync(HttpMethod.Delete, requestUrl, null); } /// /// Gets a person asynchronously. /// /// The person group id. /// The person id. /// The person entity. public async Task GetPersonAsync(string personGroupId, Guid personId) { return await this.GetPersonInPersonGroupAsync(personGroupId, personId); } /// /// Gets a person asynchronously. /// /// The person group id. /// The person id. /// The person entity. public async Task GetPersonInPersonGroupAsync(string personGroupId, Guid personId) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{PersonsQuery}/{personId}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Gets persons inside a person group asynchronously. /// /// The person group id. /// /// The person entity array. /// [Obsolete("use ListPersonsAsync instead")] public async Task GetPersonsAsync(string personGroupId) { return await this.ListPersonsAsync(personGroupId); } /// /// List the top persons whose Id is larger than "start" inside a person group asynchronously. /// /// The person group id. /// Person Id bar. List the persons whose Id is larger than "start". /// The number of persons to list.> /// /// The person entity array. /// public async Task ListPersonsAsync(string personGroupId, string start = "", int top = 1000) { return await this.ListPersonsInPersonGroupAsync(personGroupId, start, top); } /// /// List the top persons whose Id is larger than "start" inside a person group asynchronously. /// /// The person group id. /// Person Id bar. List the persons whose Id is larger than "start". /// The number of persons to list.> /// /// The person entity array. /// public async Task ListPersonsInPersonGroupAsync( string personGroupId, string start = "", int top = 1000) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{PersonsQuery}?start={start}&top={top.ToString(CultureInfo.InvariantCulture)}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Updates a person asynchronously. /// /// The person group id. /// The person id. /// The name. /// The user data. /// Task object. public async Task UpdatePersonAsync(string personGroupId, Guid personId, string name, string userData = null) { await this.UpdatePersonInPersonGroupAsync(personGroupId, personId, name, userData); } /// /// Updates a person asynchronously. /// /// The person group id. /// The person id. /// The name. /// The user data. /// Task object. public async Task UpdatePersonInPersonGroupAsync( string personGroupId, Guid personId, string name, string userData = null) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{PersonsQuery}/{personId}"; await this.SendRequestAsync( new HttpMethod("PATCH"), requestUrl, new { name = name, userData = userData }); } #endregion #region PersonGroup PersonFace Methods /// /// Adds a face to a person asynchronously. /// /// The person group id. /// The person id. /// The face image URL. /// The user data. /// The target face. /// /// Add person face result. /// public async Task AddPersonFaceAsync( string personGroupId, Guid personId, string imageUrl, string userData = null, FaceRectangle targetFace = null) { return await this.AddPersonFaceInPersonGroupAsync(personGroupId, personId, imageUrl, userData, targetFace); } /// /// Adds a face to a person asynchronously. /// /// The person group id. /// The person id. /// The face image URL. /// The user data. /// The target face. /// /// Add person face result. /// public async Task AddPersonFaceInPersonGroupAsync( string personGroupId, Guid personId, string imageUrl, string userData = null, FaceRectangle targetFace = null) { var targetFaceString = targetFace == null ? string.Empty : $"{targetFace.Left},{targetFace.Top},{targetFace.Width},{targetFace.Height}"; var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{PersonsQuery}/{personId}/{PersistedFacesQuery}?userData={userData}&targetFace={targetFaceString}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { url = imageUrl }); } /// /// Adds a face to a person asynchronously. /// /// The person group id. /// The person id. /// The face image stream. /// The user data. /// The target face. /// /// Add person face result. /// public async Task AddPersonFaceAsync( string personGroupId, Guid personId, Stream imageStream, string userData = null, FaceRectangle targetFace = null) { return await this.AddPersonFaceInPersonGroupAsync( personGroupId, personId, imageStream, userData, targetFace); } /// /// Adds a face to a person asynchronously. /// /// The person group id. /// The person id. /// The face image stream. /// The user data. /// The target face. /// /// Add person face result. /// public async Task AddPersonFaceInPersonGroupAsync( string personGroupId, Guid personId, Stream imageStream, string userData = null, FaceRectangle targetFace = null) { var targetFaceString = targetFace == null ? string.Empty : $"{targetFace.Left},{targetFace.Top},{targetFace.Width},{targetFace.Height}"; var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{PersonsQuery}/{personId}/{PersistedFacesQuery}?userData={userData}&targetFace={targetFaceString}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, imageStream); } /// /// Deletes a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// /// Task object. /// public async Task DeletePersonFaceAsync(string personGroupId, Guid personId, Guid persistedFaceId) { await this.DeletePersonFaceFromPersonGroupAsync(personGroupId, personId, persistedFaceId); } /// /// Deletes a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// /// Task object. /// public async Task DeletePersonFaceFromPersonGroupAsync( string personGroupId, Guid personId, Guid persistedFaceId) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{PersonsQuery}/{personId}/{PersistedFacesQuery}/{persistedFaceId}"; await this.SendRequestAsync(HttpMethod.Delete, requestUrl, null); } /// /// Gets a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// /// The person face entity. /// public async Task GetPersonFaceAsync(string personGroupId, Guid personId, Guid persistedFaceId) { return await this.GetPersonFaceInPersonGroupAsync(personGroupId, personId, persistedFaceId); } /// /// Gets a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// /// The person face entity. /// public async Task GetPersonFaceInPersonGroupAsync(string personGroupId, Guid personId, Guid persistedFaceId) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{PersonsQuery}/{personId}/{PersistedFacesQuery}/{persistedFaceId}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Updates a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// The user data. /// /// Task object. /// public async Task UpdatePersonFaceAsync( string personGroupId, Guid personId, Guid persistedFaceId, string userData) { await this.UpdatePersonFaceInPersonGroupAsync(personGroupId, personId, persistedFaceId, userData); } /// /// Updates a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// The user data. /// /// Task object. /// public async Task UpdatePersonFaceInPersonGroupAsync( string personGroupId, Guid personId, Guid persistedFaceId, string userData) { var requestUrl = $"{this.ServiceHost}/{PersonGroupsQuery}/{personGroupId}/{PersonsQuery}/{personId}/{PersistedFacesQuery}/{persistedFaceId}"; await this.SendRequestAsync( new HttpMethod("PATCH"), requestUrl, new { userData = userData }); } #endregion #region LargeFaceList Methods /// /// Creates the large face list asynchronously. /// /// The large face list identifier. /// The name. /// The user data. /// Task object. public async Task CreateLargeFaceListAsync(string largeFaceListId, string name, string userData = null) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}"; await this.SendRequestAsync( HttpMethod.Put, requestUrl, new { name = name, userData = userData }); } /// /// Deletes the large face list asynchronously. /// /// The large face list identifier. /// public async Task object. public async Task DeleteLargeFaceListAsync(string largeFaceListId) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}"; await this.SendRequestAsync(HttpMethod.Delete, requestUrl, null); } /// /// Gets the large face list asynchronously. /// /// The large face list identifier. /// Face list object. public async Task GetLargeFaceListAsync(string largeFaceListId) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Gets large face list training status asynchronously. /// /// The large face list id. /// The large face list training status. public async Task GetLargeFaceListTrainingStatusAsync(string largeFaceListId) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}/{TrainingQuery}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Lists the large face lists asynchronously. /// /// The start point string in listing large face lists /// The number of large face lists to list /// LargeFaceListMetadata array. public async Task ListLargeFaceListsAsync(string start = "", int top = 1000) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}?start={start}&top={top.ToString(CultureInfo.InvariantCulture)}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Trains the large face list asynchronously. /// /// The large face list id. /// public async Task object. public async Task TrainLargeFaceListAsync(string largeFaceListId) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}/{TrainQuery}"; await this.SendRequestAsync(HttpMethod.Post, requestUrl, null); } /// /// Updates the large face list asynchronously. /// /// The large face list identifier. /// The name. /// The user data. /// public async Task object. public async Task UpdateLargeFaceListAsync(string largeFaceListId, string name, string userData) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}"; await this.SendRequestAsync( new HttpMethod("PATCH"), requestUrl, new { name = name, userData = userData }); } #endregion #region LargeFaceList Face Methods /// /// Adds the face to large face list asynchronously. /// /// The large face list identifier. /// The face image URL. /// The user data. /// The target face. /// /// Add face result. /// public async Task AddFaceToLargeFaceListAsync( string largeFaceListId, string imageUrl, string userData = null, FaceRectangle targetFace = null) { var targetFaceString = targetFace == null ? string.Empty : $"{targetFace.Left},{targetFace.Top},{targetFace.Width},{targetFace.Height}"; var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}/{PersistedFacesQuery}?userData={userData}&targetFace={targetFaceString}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { url = imageUrl }); } /// /// Adds the face to large face list asynchronously. /// /// The large face list identifier. /// The face image stream. /// The user data. /// The target face. /// /// Add face result. /// public async Task AddFaceToLargeFaceListAsync( string largeFaceListId, Stream imageStream, string userData = null, FaceRectangle targetFace = null) { var targetFaceString = targetFace == null ? string.Empty : $"{targetFace.Left},{targetFace.Top},{targetFace.Width},{targetFace.Height}"; var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}/{PersistedFacesQuery}?userData={userData}&targetFace={targetFaceString}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, imageStream); } /// /// Deletes the face from large face list asynchronously. /// /// The large face list identifier. /// The persisted face identifier. /// public async Task object. public async Task DeleteFaceFromLargeFaceListAsync(string largeFaceListId, Guid persistedFaceId) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}/{PersistedFacesQuery}/{persistedFaceId}"; await this.SendRequestAsync(HttpMethod.Delete, requestUrl, null); } /// /// Gets the face in large face list asynchronously. /// /// The large face list identifier. /// The persisted face identifier. /// Persisted Face object. public async Task GetFaceInLargeFaceListAsync(string largeFaceListId, Guid persistedFaceId) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}/{PersistedFacesQuery}/{persistedFaceId}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Lists the faces in large face lists asynchronously. /// /// The large face list identifier. /// The start point string to list faces in large face lists. /// The number of faces to list. /// PersistedFace array. public async Task ListFacesInLargeFaceListAsync( string largeFaceListId, string start = "", int top = 1000) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}/{PersistedFacesQuery}?start={start}&top={top.ToString(CultureInfo.InvariantCulture)}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Updates the face in large face list asynchronously. /// /// The large face list identifier. /// The persisted face identifier. /// The user data. /// public async Task object. public async Task UpdateFaceInLargeFaceListAsync(string largeFaceListId, Guid persistedFaceId, string userData) { var requestUrl = $"{this.ServiceHost}/{LargeFaceListsQuery}/{largeFaceListId}/{PersistedFacesQuery}/{persistedFaceId}"; await this.SendRequestAsync( new HttpMethod("PATCH"), requestUrl, new { userData = userData }); } #endregion #region LargePersonGroup Methods /// /// Creates the large person group asynchronously. /// /// The large person group identifier. /// The name. /// The user data. /// public async Task object. public async Task CreateLargePersonGroupAsync(string largePersonGroupId, string name, string userData = null) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}"; await this.SendRequestAsync( HttpMethod.Put, requestUrl, new { name = name, userData = userData }); } /// /// Deletes a large person group asynchronously. /// /// The large person group id. /// public async Task object. public async Task DeleteLargePersonGroupAsync(string largePersonGroupId) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}"; await this.SendRequestAsync(HttpMethod.Delete, requestUrl, null); } /// /// Gets a large person group asynchronously. /// /// The large person group id. /// The large person group entity. public async Task GetLargePersonGroupAsync(string largePersonGroupId) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Gets large person group training status asynchronously. /// /// The large person group id. /// The large person group training status. public async Task GetLargePersonGroupTrainingStatusAsync(string largePersonGroupId) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{TrainingQuery}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Asynchronously list the top large person groups whose Id is larger than "start". /// /// the start point string in listing large person groups /// the number of large person groups to list /// The large person group entity array. public async Task ListLargePersonGroupsAsync(string start = "", int top = 1000) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}?start={start}&top={top.ToString(CultureInfo.InvariantCulture)}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Trains the large person group asynchronously. /// /// The large person group id. /// public async Task object. public async Task TrainLargePersonGroupAsync(string largePersonGroupId) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{TrainQuery}"; await this.SendRequestAsync(HttpMethod.Post, requestUrl, null); } /// /// Updates a large person group asynchronously. /// /// The large person group id. /// The name. /// The user data. /// public async Task object. public async Task UpdateLargePersonGroupAsync(string largePersonGroupId, string name, string userData = null) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}"; await this.SendRequestAsync( new HttpMethod("PATCH"), requestUrl, new { name = name, userData = userData }); } #endregion #region LargePersonGroup Person Methods /// /// Creates a person in large person group asynchronously. /// /// The large person group id. /// The name. /// The user data. /// The CreatePersonResult entity. public async Task CreatePersonInLargePersonGroupAsync( string largePersonGroupId, string name, string userData = null) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{PersonsQuery}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { name = name, userData = userData }); } /// /// Deletes a person from large person group asynchronously. /// /// The large person group id. /// The person id. /// public async Task object. public async Task DeletePersonFromLargePersonGroupAsync(string largePersonGroupId, Guid personId) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{PersonsQuery}/{personId}"; await this.SendRequestAsync(HttpMethod.Delete, requestUrl, null); } /// /// Gets a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The person entity. public async Task GetPersonInLargePersonGroupAsync(string largePersonGroupId, Guid personId) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{PersonsQuery}/{personId}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Asynchronously list the top persons in large person group whose Id is larger than "start". /// /// The large person group id. /// The start point string in listing persons /// The number of persons to list /// Person entity array. public async Task ListPersonsInLargePersonGroupAsync( string largePersonGroupId, string start = "", int top = 1000) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{PersonsQuery}?start={start}&top={top.ToString(CultureInfo.InvariantCulture)}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Updates a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The name. /// The user data. /// public async Task object. public async Task UpdatePersonInLargePersonGroupAsync( string largePersonGroupId, Guid personId, string name, string userData = null) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{PersonsQuery}/{personId}"; await this.SendRequestAsync( new HttpMethod("PATCH"), requestUrl, new { name = name, userData = userData }); } #endregion #region LargePersonGroup PersonFace Methods /// /// Adds a face to a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The face image URL. /// The user data. /// The target face. /// /// Add person face result. /// public async Task AddPersonFaceInLargePersonGroupAsync( string largePersonGroupId, Guid personId, string imageUrl, string userData = null, FaceRectangle targetFace = null) { var targetFaceString = targetFace == null ? string.Empty : $"{targetFace.Left},{targetFace.Top},{targetFace.Width},{targetFace.Height}"; var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{PersonsQuery}/{personId}/{PersistedFacesQuery}?userData={userData}&targetFace={targetFaceString}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, new { url = imageUrl }); } /// /// Adds a face to a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The face image stream. /// The user data. /// The Target Face. /// /// Add person face result. /// public async Task AddPersonFaceInLargePersonGroupAsync( string largePersonGroupId, Guid personId, Stream imageStream, string userData = null, FaceRectangle targetFace = null) { var targetFaceString = targetFace == null ? string.Empty : $"{targetFace.Left},{targetFace.Top},{targetFace.Width},{targetFace.Height}"; var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{PersonsQuery}/{personId}/{PersistedFacesQuery}?userData={userData}&targetFace={targetFaceString}"; return await this.SendRequestAsync( HttpMethod.Post, requestUrl, imageStream); } /// /// Deletes a face of a person from large person group asynchronously. /// /// The large person group id. /// The person id. /// The persisted face id. /// public async Task object. public async Task DeletePersonFaceFromLargePersonGroupAsync( string largePersonGroupId, Guid personId, Guid persistedFaceId) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{PersonsQuery}/{personId}/{PersistedFacesQuery}/{persistedFaceId}"; await this.SendRequestAsync(HttpMethod.Delete, requestUrl, null); } /// /// Gets a face of a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The persisted face id. /// The person face entity. public async Task GetPersonFaceInLargePersonGroupAsync( string largePersonGroupId, Guid personId, Guid persistedFaceId) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{PersonsQuery}/{personId}/{PersistedFacesQuery}/{persistedFaceId}"; return await this.SendRequestAsync(HttpMethod.Get, requestUrl, null); } /// /// Updates a face of a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The persisted face id. /// The user data. /// public async Task object. public async Task UpdatePersonFaceInLargePersonGroupAsync( string largePersonGroupId, Guid personId, Guid persistedFaceId, string userData = null) { var requestUrl = $"{this.ServiceHost}/{LargePersonGroupsQuery}/{largePersonGroupId}/{PersonsQuery}/{personId}/{PersistedFacesQuery}/{persistedFaceId}"; await this.SendRequestAsync( new HttpMethod("PATCH"), requestUrl, new { userData = userData }); } #endregion #region Methods /// /// Gets face attribute query string from attribute types /// /// Face attribute types /// Face attribute query string public static string GetAttributeString(IEnumerable types) { return string.Join(",", types.Select(attr => { var attrStr = attr.ToString(); return char.ToLowerInvariant(attrStr[0]) + attrStr.Substring(1); }).ToArray()); } /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// public void Dispose() { this.Dispose(true); GC.SuppressFinalize(this); } /// /// Releases unmanaged and - optionally - managed resources. /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. protected virtual void Dispose(bool disposing) { if (disposing) { if (this._httpClient != null) { this._httpClient.Dispose(); this._httpClient = null; } } } /// /// Sends the request asynchronous. /// /// The type of the request. /// The type of the response. /// The HTTP method. /// The request URL. /// The request body. /// The response. /// The client exception. private async Task SendRequestAsync(HttpMethod httpMethod, string requestUrl, TRequest requestBody) { var request = new HttpRequestMessage(httpMethod, this.ServiceHost); request.RequestUri = new Uri(requestUrl); if (requestBody != null) { if (requestBody is Stream) { request.Content = new StreamContent(requestBody as Stream); request.Content.Headers.ContentType = new MediaTypeHeaderValue(StreamContentTypeHeader); } else { request.Content = new StringContent(JsonConvert.SerializeObject(requestBody, s_settings), Encoding.UTF8, JsonContentTypeHeader); } } HttpResponseMessage response = await this._httpClient.SendAsync(request); if (response.IsSuccessStatusCode) { string responseContent = null; if (response.Content != null) { responseContent = await response.Content.ReadAsStringAsync(); } if (!string.IsNullOrWhiteSpace(responseContent)) { return JsonConvert.DeserializeObject(responseContent, s_settings); } return default(TResponse); } else { if (response.Content != null && response.Content.Headers.ContentType.MediaType.Contains(JsonContentTypeHeader)) { var errorObjectString = await response.Content.ReadAsStringAsync(); ClientError clientEx = JsonConvert.DeserializeObject(errorObjectString); if (clientEx.Error != null) { throw new FaceAPIException(clientEx.Error.ErrorCode, clientEx.Error.Message, response.StatusCode); } else { ServiceError serviceEx = JsonConvert.DeserializeObject(errorObjectString); if (serviceEx.ErrorCode != null) { throw new FaceAPIException(serviceEx.ErrorCode, serviceEx.Message, response.StatusCode); } else { throw new FaceAPIException("Unknown", "Unknown Error", response.StatusCode); } } } response.EnsureSuccessStatusCode(); } return default(TResponse); } #endregion Methods } } ================================================ FILE: ClientLibrary/IFaceServiceClient.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Collections.Generic; using System.IO; using System.Net.Http.Headers; using System.Threading.Tasks; using Microsoft.ProjectOxford.Face.Contract; namespace Microsoft.ProjectOxford.Face { using Face = Microsoft.ProjectOxford.Face.Contract.Face; #region Enumerations /// /// Supported face attribute types /// public enum FaceAttributeType { /// /// Analyses age /// Age, /// /// Analyses gender /// Gender, /// /// Analyses head pose /// HeadPose, /// /// Analyses whether is smiling /// Smile, /// /// Analyses facial hair /// FacialHair, /// /// Analyses glasses type /// Glasses, /// /// Analyses emotion /// Emotion, /// /// Analyses hair /// Hair, /// /// Analyses makeup /// Makeup, /// /// Analyses occlusion /// Occlusion, /// /// Analyses accessory /// Accessories, /// /// Analyses blur /// Blur, /// /// Analyses exposure /// Exposure, /// /// Analyses noise /// Noise } /// /// two working modes of Face - Find Similar /// public enum FindSimilarMatchMode { /// /// matchPerson mode of Face - Find Similar, return the similar faces of the same person with the query face. /// matchPerson, /// /// matchFace mode of Face - Find Similar, return the similar faces of the query face, ignoring if they belong to the same person. /// matchFace } #endregion Enumerations /// /// The face service client proxy interface. /// public interface IFaceServiceClient { #region Properties /// /// Gets default request headers for all following http request /// HttpRequestHeaders DefaultRequestHeaders { get; } #endregion Properties #region Face Methods /// /// Detects an URL asynchronously. /// /// The image URL. /// If set to true [return face ID]. /// If set to true [return face landmarks]. /// Return face attributes. /// The detected faces. Task DetectAsync(string imageUrl, bool returnFaceId = true, bool returnFaceLandmarks = false, IEnumerable returnFaceAttributes = null); /// /// Detects an image asynchronously. /// /// The image stream. /// If set to true [return face ID]. /// If set to true [return face landmarks]. /// Return face attributes. /// The detected faces. Task DetectAsync(Stream imageStream, bool returnFaceId = true, bool returnFaceLandmarks = false, IEnumerable returnFaceAttributes = null); /// /// Finds the similar faces asynchronously. /// /// The face identifier. /// The face identifiers. /// The max number of candidates returned. /// /// The similar faces. /// Task FindSimilarAsync(Guid faceId, Guid[] faceIds, int maxNumOfCandidatesReturned = 20); /// /// Finds the similar faces asynchronously. /// /// The face identifier. /// The face identifiers. /// Algorithm mode option, default as "matchPerson". /// The max number of candidates returned. /// /// The similar faces. /// Task FindSimilarAsync(Guid faceId, Guid[] faceIds, FindSimilarMatchMode mode, int maxNumOfCandidatesReturned = 20); /// /// Finds the similar faces asynchronously. /// /// The face identifier. /// The face list identifier. /// The max number of candidates returned. /// /// The similar persisted faces. /// [Obsolete("use the FindSimilarAsync support both Face List and Large Face List instead")] Task FindSimilarAsync(Guid faceId, string faceListId, int maxNumOfCandidatesReturned = 20); /// /// Finds the similar faces asynchronously. /// /// The face identifier. /// The face list identifier. /// Algorithm mode option, default as "matchPerson". /// The max number of candidates returned. /// /// The similar persisted faces. /// [Obsolete("use the FindSimilarAsync support both Face List and Large Face List instead")] Task FindSimilarAsync(Guid faceId, string faceListId, FindSimilarMatchMode mode, int maxNumOfCandidatesReturned = 20); /// /// Finds the similar faces asynchronously. /// /// The face identifier. /// The face list identifier. /// The large face list identifier. /// Algorithm mode option, default as "matchPerson". /// The max number of candidates returned. /// /// The similar persisted faces. /// Task FindSimilarAsync(Guid faceId, string faceListId = null, string largeFaceListId = null, FindSimilarMatchMode mode = FindSimilarMatchMode.matchPerson, int maxNumOfCandidatesReturned = 20); /// /// Groups the face asynchronously. /// /// The face ids. /// Task object. Task GroupAsync(Guid[] faceIds); /// /// Identities the faces in a given person group asynchronously. /// /// The person group id. /// The face ids. /// The maximum number of candidates returned for each face. /// The identification results [Obsolete("use the IdentifyAsync support both Person Group and Large Person Group instead")] Task IdentifyAsync(string personGroupId, Guid[] faceIds, int maxNumOfCandidatesReturned = 1); /// /// Identities the faces in a given person group asynchronously. /// /// The person group id. /// The face ids. /// user-specified confidence threshold. /// The maximum number of candidates returned for each face. /// The identification results [Obsolete("use the IdentifyAsync support both Person Group and Large Person Group instead")] Task IdentifyAsync(string personGroupId, Guid[] faceIds, float confidenceThreshold, int maxNumOfCandidatesReturned = 1); /// /// Identities the faces in a given person group or large person group asynchronously. /// /// The face ids. /// The person group id. /// The large person group id. /// user-specified confidence threshold. /// The maximum number of candidates returned for each face. /// The identification results Task IdentifyAsync(Guid[] faceIds, string personGroupId = null, string largePersonGroupId = null, float confidenceThreshold = 0.5f, int maxNumOfCandidatesReturned = 1); /// /// Verifies whether the specified two faces belong to the same person asynchronously. /// /// The face id 1. /// The face id 2. /// The verification result. Task VerifyAsync(Guid faceId1, Guid faceId2); /// /// Verify whether one face belong to a person. /// /// The face id. /// The person group id. /// The person id. /// Verification result. [Obsolete("use the VerifyAsync supports both Person Group and Large Person Group instead")] Task VerifyAsync(Guid faceId, string personGroupId, Guid personId); /// /// Verify whether one face belong to a person. /// /// The face id. /// The person id. /// The person group id. /// The large person group id. /// Verification result. Task VerifyAsync(Guid faceId, Guid personId, string personGroupId = null, string largePersonGroupId = null); #endregion #region FaceList Methods /// /// Creates the face list asynchronously. /// /// The face list identifier. /// The name. /// The user data. /// Task object. Task CreateFaceListAsync(string faceListId, string name, string userData = null); /// /// Deletes the face list asynchronously. /// /// The face list identifier. /// Task object. Task DeleteFaceListAsync(string faceListId); /// /// Gets the face list asynchronously. /// /// The face list identifier. /// Face list object. Task GetFaceListAsync(string faceListId); /// /// Lists the face lists asynchronously. /// /// FaceListMetadata array. Task ListFaceListsAsync(); /// /// Updates the face list asynchronously. /// /// The face list identifier. /// The name. /// The user data. /// Task object. Task UpdateFaceListAsync(string faceListId, string name, string userData); #endregion #region FaceList Face Methods /// /// Adds the face to face list asynchronously. /// /// The face list identifier. /// The face image URL. /// The user data. /// The target face. /// /// Add face result. /// Task AddFaceToFaceListAsync(string faceListId, string imageUrl, string userData = null, FaceRectangle targetFace = null); /// /// Adds the face to face list asynchronously. /// /// The face list identifier. /// The face image stream. /// The user data. /// The target face. /// /// Add face result. /// Task AddFaceToFaceListAsync(string faceListId, Stream imageStream, string userData = null, FaceRectangle targetFace = null); /// /// Deletes the face from face list asynchronously. /// /// The face list identifier. /// The persisted face identifier. /// Task object. Task DeleteFaceFromFaceListAsync(string faceListId, Guid persistedFaceId); #endregion #region PersonGroup Methods /// /// Creates the person group asynchronously. /// /// The person group identifier. /// The name. /// The user data. /// Task object. Task CreatePersonGroupAsync(string personGroupId, string name, string userData = null); /// /// Deletes a person group asynchronously. /// /// The person group id. /// Task object. Task DeletePersonGroupAsync(string personGroupId); /// /// Gets a person group asynchronously. /// /// The person group id. /// The person group entity. Task GetPersonGroupAsync(string personGroupId); /// /// Gets person group training status asynchronously. /// /// The person group id. /// The person group training status. Task GetPersonGroupTrainingStatusAsync(string personGroupId); /// /// Asynchronously list the person groups. /// /// Person group entity array. [Obsolete("use ListPersonGroupsAsync instead")] Task GetPersonGroupsAsync(); /// /// Asynchronously list the top person groups whose Id is larger than "start". /// /// the start point string in listing person groups /// the number of person groups to list /// Person group entity array. Task ListPersonGroupsAsync(string start = "", int top = 1000); /// /// Trains the person group asynchronously. /// /// The person group id. /// Task object. Task TrainPersonGroupAsync(string personGroupId); /// /// Updates a person group asynchronously. /// /// The person group id. /// The name. /// The user data. /// Task object. Task UpdatePersonGroupAsync(string personGroupId, string name, string userData = null); #endregion #region PersonGroup Person Methods /// /// Creates a person asynchronously. /// /// The person group id. /// The name. /// The user data. /// The CreatePersonResult entity. [Obsolete("use CreatePersonInPersonGroupAsync instead")] Task CreatePersonAsync(string personGroupId, string name, string userData = null); /// /// Creates a person asynchronously. /// /// The person group id. /// The name. /// The user data. /// The CreatePersonResult entity. Task CreatePersonInPersonGroupAsync(string personGroupId, string name, string userData = null); /// /// Deletes a person asynchronously. /// /// The person group id. /// The person id. /// Task object. [Obsolete("use DeletePersonFromPersonGroupAsync instead")] Task DeletePersonAsync(string personGroupId, Guid personId); /// /// Deletes a person asynchronously. /// /// The person group id. /// The person id. /// Task object. Task DeletePersonFromPersonGroupAsync(string personGroupId, Guid personId); /// /// Gets a person asynchronously. /// /// The person group id. /// The person id. /// The person entity. [Obsolete("use GetPersonInPersonGroupAsync instead")] Task GetPersonAsync(string personGroupId, Guid personId); /// /// Gets a person asynchronously. /// /// The person group id. /// The person id. /// The person entity. Task GetPersonInPersonGroupAsync(string personGroupId, Guid personId); /// /// Gets persons inside a person group asynchronously. /// /// The person group id. /// /// The person entity array. /// [Obsolete("use ListPersonsInPersonGroupAsync instead")] Task GetPersonsAsync(string personGroupId); /// /// Asynchronously list the top persons whose Id is larger than "start". /// /// The person group id. /// The start point string in listing persons /// The number of persons to list /// Person entity array. [Obsolete("use ListPersonsInPersonGroupAsync instead")] Task ListPersonsAsync(string personGroupId, string start = "", int top = 1000); /// /// Asynchronously list the top persons whose Id is larger than "start". /// /// The person group id. /// The start point string in listing persons /// The number of persons to list /// Person entity array. Task ListPersonsInPersonGroupAsync(string personGroupId, string start = "", int top = 1000); /// /// Updates a person asynchronously. /// /// The person group id. /// The person id. /// The name. /// The user data. /// Task object. [Obsolete("use UpdatePersonInPersonGroupAsync instead")] Task UpdatePersonAsync(string personGroupId, Guid personId, string name, string userData = null); /// /// Updates a person asynchronously. /// /// The person group id. /// The person id. /// The name. /// The user data. /// Task object. Task UpdatePersonInPersonGroupAsync(string personGroupId, Guid personId, string name, string userData = null); #endregion #region PersonGroup PersonFace Methods /// /// Adds a face to a person asynchronously. /// /// The person group id. /// The person id. /// The face image URL. /// The user data. /// The target face. /// /// Add person face result. /// [Obsolete("use AddPersonFaceInPersonGroupAsync instead")] Task AddPersonFaceAsync(string personGroupId, Guid personId, string imageUrl, string userData = null, FaceRectangle targetFace = null); /// /// Adds a face to a person asynchronously. /// /// The person group id. /// The person id. /// The face image URL. /// The user data. /// The target face. /// /// Add person face result. /// Task AddPersonFaceInPersonGroupAsync(string personGroupId, Guid personId, string imageUrl, string userData = null, FaceRectangle targetFace = null); /// /// Adds a face to a person asynchronously. /// /// The person group id. /// The person id. /// The face image stream. /// The user data. /// The Target Face. /// /// Add person face result. /// [Obsolete("use AddPersonFaceInPersonGroupAsync instead")] Task AddPersonFaceAsync(string personGroupId, Guid personId, Stream imageStream, string userData = null, FaceRectangle targetFace = null); /// /// Adds a face to a person asynchronously. /// /// The person group id. /// The person id. /// The face image stream. /// The user data. /// The Target Face. /// /// Add person face result. /// Task AddPersonFaceInPersonGroupAsync(string personGroupId, Guid personId, Stream imageStream, string userData = null, FaceRectangle targetFace = null); /// /// Deletes a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// Task object. [Obsolete("use DeletePersonFaceFromPersonGroupAsync instead")] Task DeletePersonFaceAsync(string personGroupId, Guid personId, Guid persistedFaceId); /// /// Deletes a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// Task object. Task DeletePersonFaceFromPersonGroupAsync(string personGroupId, Guid personId, Guid persistedFaceId); /// /// Gets a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// The person face entity. [Obsolete("use GetPersonFaceInPersonGroupAsync instead")] Task GetPersonFaceAsync(string personGroupId, Guid personId, Guid persistedFaceId); /// /// Gets a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// The person face entity. Task GetPersonFaceInPersonGroupAsync(string personGroupId, Guid personId, Guid persistedFaceId); /// /// Updates a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// The user data. /// Task object. [Obsolete("use UpdatePersonFaceInPersonGroupAsync instead")] Task UpdatePersonFaceAsync(string personGroupId, Guid personId, Guid persistedFaceId, string userData = null); /// /// Updates a face of a person asynchronously. /// /// The person group id. /// The person id. /// The persisted face id. /// The user data. /// Task object. Task UpdatePersonFaceInPersonGroupAsync(string personGroupId, Guid personId, Guid persistedFaceId, string userData = null); #endregion #region LargeFaceList Methods /// /// Creates the large face list asynchronously. /// /// The large face list identifier. /// The name. /// The user data. /// Task object. Task CreateLargeFaceListAsync(string largeFaceListId, string name, string userData = null); /// /// Deletes the large face list asynchronously. /// /// The large face list identifier. /// Task object. Task DeleteLargeFaceListAsync(string largeFaceListId); /// /// Gets the large face list asynchronously. /// /// The large face list identifier. /// Face list object. Task GetLargeFaceListAsync(string largeFaceListId); /// /// Gets large face list training status asynchronously. /// /// The large face list id. /// The large face list training status. Task GetLargeFaceListTrainingStatusAsync(string largeFaceListId); /// /// Lists the large face lists asynchronously. /// /// The start point string in listing large face lists /// The number of large face lists to list /// LargeFaceListMetadata array. Task ListLargeFaceListsAsync(string start = "", int top = 1000); /// /// Trains the large face list asynchronously. /// /// The large face list id. /// Task object. Task TrainLargeFaceListAsync(string largeFaceListId); /// /// Updates the large face list asynchronously. /// /// The large face list identifier. /// The name. /// The user data. /// Task object. Task UpdateLargeFaceListAsync(string largeFaceListId, string name, string userData); #endregion #region LargeFaceList Face Methods /// /// Adds the face to large face list asynchronously. /// /// The large face list identifier. /// The face image URL. /// The user data. /// The target face. /// /// Add face result. /// Task AddFaceToLargeFaceListAsync(string largeFaceListId, string imageUrl, string userData = null, FaceRectangle targetFace = null); /// /// Adds the face to large face list asynchronously. /// /// The large face list identifier. /// The face image stream. /// The user data. /// The target face. /// /// Add face result. /// Task AddFaceToLargeFaceListAsync(string largeFaceListId, Stream imageStream, string userData = null, FaceRectangle targetFace = null); /// /// Deletes the face from large face list asynchronously. /// /// The large face list identifier. /// The persisted face identifier. /// Task object. Task DeleteFaceFromLargeFaceListAsync(string largeFaceListId, Guid persistedFaceId); /// /// Gets the face in large face list asynchronously. /// /// The large face list identifier. /// The persisted face identifier. /// Persisted Face object. Task GetFaceInLargeFaceListAsync(string largeFaceListId, Guid persistedFaceId); /// /// Lists the faces in large face lists asynchronously. /// /// The large face list identifier. /// The start point string to list faces in large face lists. /// The number of faces to list. /// PersistedFace array. Task ListFacesInLargeFaceListAsync(string largeFaceListId, string start = "", int top = 1000); /// /// Updates the face in large face list asynchronously. /// /// The large face list identifier. /// The persisted face identifier. /// The user data. /// Task object. Task UpdateFaceInLargeFaceListAsync(string largeFaceListId, Guid persistedFaceId, string userData); #endregion #region LargePersonGroup Methods /// /// Creates the large person group asynchronously. /// /// The large person group identifier. /// The name. /// The user data. /// Task object. Task CreateLargePersonGroupAsync(string largePersonGroupId, string name, string userData = null); /// /// Deletes a large person group asynchronously. /// /// The large person group id. /// Task object. Task DeleteLargePersonGroupAsync(string largePersonGroupId); /// /// Gets a large person group asynchronously. /// /// The large person group id. /// The large person group entity. Task GetLargePersonGroupAsync(string largePersonGroupId); /// /// Gets large person group training status asynchronously. /// /// The large person group id. /// The large person group training status. Task GetLargePersonGroupTrainingStatusAsync(string largePersonGroupId); /// /// Asynchronously list the top large person groups whose Id is larger than "start". /// /// the start point string in listing large person groups /// the number of large person groups to list /// The large person group entity array. Task ListLargePersonGroupsAsync(string start = "", int top = 1000); /// /// Trains the large person group asynchronously. /// /// The large person group id. /// Task object. Task TrainLargePersonGroupAsync(string largePersonGroupId); /// /// Updates a large person group asynchronously. /// /// The large person group id. /// The name. /// The user data. /// Task object. Task UpdateLargePersonGroupAsync(string largePersonGroupId, string name, string userData = null); #endregion #region LargePersonGroup Person Methods /// /// Creates a person in large person group asynchronously. /// /// The large person group id. /// The name. /// The user data. /// The CreatePersonResult entity. Task CreatePersonInLargePersonGroupAsync(string largePersonGroupId, string name, string userData = null); /// /// Deletes a person from large person group asynchronously. /// /// The large person group id. /// The person id. /// Task object. Task DeletePersonFromLargePersonGroupAsync(string largePersonGroupId, Guid personId); /// /// Gets a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The person entity. Task GetPersonInLargePersonGroupAsync(string largePersonGroupId, Guid personId); /// /// Asynchronously list the top persons in large person group whose Id is larger than "start". /// /// The large person group id. /// The start point string in listing persons /// The number of persons to list /// Person entity array. Task ListPersonsInLargePersonGroupAsync(string largePersonGroupId, string start = "", int top = 1000); /// /// Updates a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The name. /// The user data. /// Task object. Task UpdatePersonInLargePersonGroupAsync(string largePersonGroupId, Guid personId, string name, string userData = null); #endregion #region LargePersonGroup PersonFace Methods /// /// Adds a face to a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The face image URL. /// The user data. /// The target face. /// /// Add person face result. /// Task AddPersonFaceInLargePersonGroupAsync(string largePersonGroupId, Guid personId, string imageUrl, string userData = null, FaceRectangle targetFace = null); /// /// Adds a face to a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The face image stream. /// The user data. /// The Target Face. /// /// Add person face result. /// Task AddPersonFaceInLargePersonGroupAsync(string largePersonGroupId, Guid personId, Stream imageStream, string userData = null, FaceRectangle targetFace = null); /// /// Deletes a face of a person from large person group asynchronously. /// /// The large person group id. /// The person id. /// The persisted face id. /// Task object. Task DeletePersonFaceFromLargePersonGroupAsync(string largePersonGroupId, Guid personId, Guid persistedFaceId); /// /// Gets a face of a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The persisted face id. /// The person face entity. Task GetPersonFaceInLargePersonGroupAsync(string largePersonGroupId, Guid personId, Guid persistedFaceId); /// /// Updates a face of a person in large person group asynchronously. /// /// The large person group id. /// The person id. /// The persisted face id. /// The user data. /// Task object. Task UpdatePersonFaceInLargePersonGroupAsync(string largePersonGroupId, Guid personId, Guid persistedFaceId, string userData = null); #endregion } } ================================================ FILE: ClientLibrary/Microsoft.ProjectOxford.Face.csproj ================================================  11.0 Debug AnyCPU {25D58BA5-660F-407B-803C-22B4547C09DC} Library Properties Microsoft.ProjectOxford.Face Microsoft.ProjectOxford.Face en-US 512 {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Profile111 v4.5 SAK SAK SAK SAK true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 true 35MSSharedLib1024.snk true packages\Microsoft.ProjectOxford.Common.1.0.324\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\Microsoft.ProjectOxford.Common.dll True packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True ================================================ FILE: ClientLibrary/Microsoft.ProjectOxford.Face.sln ================================================  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.ProjectOxford.Face", "Microsoft.ProjectOxford.Face.csproj", "{25D58BA5-660F-407B-803C-22B4547C09DC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {25D58BA5-660F-407B-803C-22B4547C09DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {25D58BA5-660F-407B-803C-22B4547C09DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {25D58BA5-660F-407B-803C-22B4547C09DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {25D58BA5-660F-407B-803C-22B4547C09DC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ================================================ FILE: ClientLibrary/Properties/AssemblyInfo.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System.Reflection; using System.Resources; [assembly: AssemblyTitle("Microsoft.ProjectOxford.Face")] [assembly: AssemblyDescription("Microsoft.ProjectOxford.Face")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("Microsoft ProjectOxford")] [assembly: AssemblyCopyright("Copyright © 2017 Microsoft")] [assembly: AssemblyTrademark("Microsoft")] [assembly: NeutralResourcesLanguage("en")] [assembly: AssemblyVersion("1.4.0")] [assembly: AssemblyFileVersion("1.4.0")] ================================================ FILE: ClientLibrary/packages.config ================================================  ================================================ FILE: LICENSE-IMAGE.md ================================================ Copyright (c) Microsoft Corporation All rights reserved. Microsoft Cognitive Services Client SDK License for Sample Image *This license applies only to the sample images. The SDK code is licensed separately, please refer to [LICENSE]()* Microsoft may make sample images available in connection with the SDK for the purposes of illustrating the operation of Microsoft Cognitive Services (https://www.microsoft.com/cognitive-services). If no separate license terms are provided with the images, Microsoft grants you a personal, nonexclusive, revocable, royalty-free right to use the images solely within your organization to test the operation of Microsoft Cognitive Services, provided that you agree to indemnify, hold harmless, and defend Microsoft and its suppliers from and against any claims or lawsuits, including attorneys’ fees, that arise or result from the use or distribution of the images. Except as expressly provided in this section you have no license to modify or distribute the images. ================================================ FILE: LICENSE.md ================================================ Microsoft Cognitive Services SDK Copyright (c) Microsoft Corporation All rights reserved. *This license applies only to the SDK code. Sample images are licensed separately, please refer to [LICENSE-IMAGE]()* MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # This repository has been retired. Please visit the [Face QuickStart](https://docs.microsoft.com/en-us/azure/cognitive-services/face/quickstarts/client-libraries?tabs=visual-studio&pivots=programming-language-csharp) to get started with the latest Face SDKs. ### Microsoft Face API: Windows Client Library & Sample This repo contains the Windows client library & sample for the Microsoft Face API, an offering within [Microsoft Cognitive Services](https://azure.microsoft.com/en-us/services/cognitive-services/), formerly known as Project Oxford. * [Learn about the Face API](https://azure.microsoft.com/en-us/services/cognitive-services/face/) * [Documentation & API Reference & SDKs](https://docs.microsoft.com/en-us/azure/cognitive-services/face/) ## The Client Library The client library is a thin C\# client wrapper for Microsoft Face API. The easiest way to use this client library is to get microsoft.projectoxford.face package from [nuget](https://nuget.org). Please go to [Face API Package in nuget](https://www.nuget.org/packages/Microsoft.ProjectOxford.Face/) for more details. ## The Sample This sample is a Windows WPF application to demonstrate the use of Face API. It demonstrates face detection, face verification, face grouping, finding similar faces, and face identification. ### Build the Sample 1. Starting in the folder where you clone the repository (this folder). 2. In a git command line tool, type `git submodule init` (or do this through a UI). 3. Pull in the shared Windows code by calling `git submodule update`. 4. Start Microsoft Visual Studio 2015 and select `File > Open > Project/Solution`. 5. Go to `Sample-WPF Folder`. 6. Double-click the Visual Studio 2015 Solution (.sln) file FaceAPI-WPF-Samples. 7. Press Ctrl+Shift+B, or select `Build > Build Solution`. ### Run the Sample After the build is complete, press F5 to run the sample. First, you must obtain a Face API subscription key by [following instructions on our website](https://azure.microsoft.com/en-us/try/cognitive-services/?api=face-api). Locate the text edit box saying "Paste your subscription key here to start" on the top right corner. Paste your subscription key. You can choose to persist your subscription key in your machine by clicking "Save Key" button. When you want to delete the subscription key from the machine, click "Delete Key" to remove it from your machine. Click on "Select Scenario" to use samples of different scenarios, and follow the instructions on screen. Microsoft will receive the images you upload and may use them to improve Face API and related services. By submitting an image, you confirm you have consent from everyone in it. There are sample images to be used with this sample application. You can find these images under Face \> Windows \> Data folder. Please note the use of these images is licensed under [LICENSE-IMAGE](/LICENSE-IMAGE.md). ## Contributing We welcome contributions. Feel free to file issues and pull requests on the repo and we'll address them as we can. Learn more about how you can help on our [Contribution Rules & Guidelines](/CONTRIBUTING.md). You can reach out to us anytime with questions and suggestions using our communities below: - **Support questions:** [StackOverflow](https://stackoverflow.com/questions/tagged/microsoft-cognitive) - **Feedback & feature requests:** [Cognitive Services UserVoice Forum](https://cognitive.uservoice.com) This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. ## Updates * [Face API Release Notes](https://docs.microsoft.com/en-us/azure/cognitive-services/face/releasenotes) ## License All Microsoft Cognitive Services SDKs and samples are licensed with the MIT License. For more details, see [LICENSE](/LICENSE.md). Sample images are licensed separately, please refer to [LICENSE-IMAGE](/LICENSE-IMAGE.md). ## Developer Code of Conduct Developers using Cognitive Services, including this client library & sample, are expected to follow the “Developer Code of Conduct for Microsoft Cognitive Services”, found at [http://go.microsoft.com/fwlink/?LinkId=698895](http://go.microsoft.com/fwlink/?LinkId=698895). ================================================ FILE: Sample-WPF/App.config ================================================  ================================================ FILE: Sample-WPF/App.xaml ================================================  ================================================ FILE: Sample-WPF/App.xaml.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System.Windows; namespace Microsoft.ProjectOxford.Face { /// /// Interaction logic for App.xaml /// public partial class App : Application { #region Constructors /// /// Prevents a default instance of the class from being created /// private App() { this.DispatcherUnhandledException += App_DispatcherUnhandledException; } #endregion Constructors #region Methods /// /// Show unhandled exception in message box /// /// Event sender /// Event arguments private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { if (e.Exception is FaceAPIException) { var ex = e.Exception as FaceAPIException; MessageBox.Show(ex.ErrorMessage, "Face API Calling Error", MessageBoxButton.OK); } else { if (e.Exception.InnerException != null) { MessageBox.Show(e.Exception.InnerException.ToString(), "Error", MessageBoxButton.OK); } else { MessageBox.Show(e.Exception.ToString(), "Error", MessageBoxButton.OK); } } e.Handled = true; } #endregion Methods } } ================================================ FILE: Sample-WPF/Controls/Face.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Media; namespace Microsoft.ProjectOxford.Face.Controls { /// /// Face view model /// public class Face : INotifyPropertyChanged { #region Fields /// /// Face age text string /// private string _age; /// /// Face gender text string /// private string _gender; /// /// confidence value of this face to a target face /// private double _confidence; /// /// Person name /// private string _personName; /// /// Face height in pixel /// private int _height; /// /// Face position X relative to image left-top in pixel /// private int _left; /// /// Face position Y relative to image left-top in pixel /// private int _top; /// /// Face width in pixel /// private int _width; /// /// Indicates the headPose /// private string _headPose; /// /// Facial hair display string /// private string _facialHair; /// /// Indicates the glasses type /// private string _glasses; /// /// Indicates the emotion /// private string _emotion; /// /// Indicates the hair /// private string _hair; /// /// Indicates the makeup /// private string _makeup; /// /// Indicates the eye occlusion /// private string _eyeOcclusion; /// /// Indicates the forehead occlusion /// private string _foreheadOcclusion; /// /// Indicates the mouth occlusion /// private string _mouthOcclusion; /// /// Indicates the accessories /// private string _accessories; /// /// Indicates the blur /// private string _blur; /// /// Indicates the exposure /// private string _exposure; /// /// Indicates the noise /// private string _noise; #endregion Fields #region Events /// /// Implement INotifyPropertyChanged interface /// public event PropertyChangedEventHandler PropertyChanged; #endregion Events #region Properties /// /// Gets or sets age text string /// public string Age { get { return _age; } set { _age = value; OnPropertyChanged(); } } /// /// Gets or sets gender text string /// public string Gender { get { return _gender; } set { _gender = value; OnPropertyChanged(); } } /// /// Gets or sets confidence value /// public double Confidence { get { return _confidence; } set { _confidence = value; OnPropertyChanged(); } } /// /// Gets face rectangle on image /// public System.Windows.Int32Rect UIRect { get { return new System.Windows.Int32Rect(Left, Top, Width, Height); } } /// /// Gets or sets image path /// public ImageSource ImageFile { get; set; } /// /// Gets or sets face id /// public string FaceId { get; set; } /// /// Gets or sets person's name /// public string PersonName { get { return _personName; } set { _personName = value; OnPropertyChanged(); } } /// /// Gets or sets face height /// public int Height { get { return _height; } set { _height = value; OnPropertyChanged(); } } /// /// Gets or sets face position X /// public int Left { get { return _left; } set { _left = value; OnPropertyChanged(); } } /// /// Gets or sets face position Y /// public int Top { get { return _top; } set { _top = value; OnPropertyChanged(); } } /// /// Gets or sets face width /// public int Width { get { return _width; } set { _width = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the head pose value. /// public string HeadPose { get { return _headPose; } set { _headPose = value; OnPropertyChanged(); } } /// /// Gets or sets facial hair display string /// public string FacialHair { get { return _facialHair; } set { _facialHair = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the glasses type /// public string Glasses { get { return _glasses; } set { _glasses = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the emotion type /// public string Emotion { get { return _emotion; } set { _emotion = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the hair type /// public string Hair { get { return _hair; } set { _hair = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the makeup type /// public string Makeup { get { return _makeup; } set { _makeup = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the occlusion type of eye /// public string EyeOcclusion { get { return _eyeOcclusion; } set { _eyeOcclusion = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the occlusion type of forehead /// public string ForeheadOcclusion { get { return _foreheadOcclusion; } set { _foreheadOcclusion = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the occlusion type of mouth /// public string MouthOcclusion { get { return _mouthOcclusion; } set { _mouthOcclusion = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the accessories type /// public string Accessories { get { return _accessories; } set { _accessories = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the blur type /// public string Blur { get { return _blur; } set { _blur = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the exposure type /// public string Exposure { get { return _exposure; } set { _exposure = value; OnPropertyChanged(); } } /// /// Gets or sets a value indicating the noise type /// public string Noise { get { return _noise; } set { _noise = value; OnPropertyChanged(); } } #endregion Properties #region Methods /// /// NotifyProperty Helper functions /// /// property type /// property change caller private void OnPropertyChanged([CallerMemberName]string caller = null) { var handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(caller)); } } #endregion Methods } } ================================================ FILE: Sample-WPF/Controls/FaceDetectionPage.xaml ================================================  Demo 2: ================================================ FILE: Sample-WPF/Controls/FaceVerificationPage.xaml.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using ClientContract = Microsoft.ProjectOxford.Face.Contract; namespace Microsoft.ProjectOxford.Face.Controls { /// /// Interaction logic for FaceVerification.xaml /// public partial class FaceVerificationPage : Page, INotifyPropertyChanged { #region Fields /// /// Description dependency property /// public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register("Description", typeof(string), typeof(FaceVerificationPage)); /// /// Temporary group id for create person database. /// private static string sampleGroupId = Guid.NewGuid().ToString(); /// /// Face detection result container for image on the left /// private ObservableCollection _leftResultCollection = new ObservableCollection(); /// /// Face detection result container for image on the right /// private ObservableCollection _rightResultCollection = new ObservableCollection(); /// /// Face detected for face to person verification /// private ObservableCollection _rightFaceResultCollection = new ObservableCollection(); /// /// Faces collection which contains all faces of the person /// private ObservableCollection _facesCollection = new ObservableCollection(); /// /// Face to face verification result /// private string _faceVerifyResult; /// /// Face to person verification result /// private string _personVerifyResult; /// /// max concurrent process number for client query. /// private int _maxConcurrentProcesses; #endregion Fields #region Constructors /// /// Initializes a new instance of the class /// public FaceVerificationPage() { InitializeComponent(); _maxConcurrentProcesses = 4; } #endregion Constructors #region Events /// /// Implement INotifyPropertyChanged interface /// public event PropertyChangedEventHandler PropertyChanged; #endregion Events #region Properties /// /// Gets or sets description for UI rendering /// public string Description { get { return (string)GetValue(DescriptionProperty); } set { SetValue(DescriptionProperty, value); } } /// /// Gets face detection results for image on the left /// public ObservableCollection LeftResultCollection { get { return _leftResultCollection; } } /// /// Gets max image size for UI rendering /// public int MaxImageSize { get { return 300; } } /// /// Gets face detection results for image on the right /// public ObservableCollection RightResultCollection { get { return _rightResultCollection; } } /// /// Gets face detection results for face to person verification /// public ObservableCollection RightFaceResultCollection { get { return _rightFaceResultCollection; } } /// /// Gets faces of the person /// public ObservableCollection FacesCollection { get { return _facesCollection; } } /// /// Gets or sets selected face verification result /// public string FaceVerifyResult { get { return _faceVerifyResult; } set { _faceVerifyResult = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("FaceVerifyResult")); } } } /// /// Gets or sets selected face person verification result /// public string PersonVerifyResult { get { return _personVerifyResult; } set { _personVerifyResult = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("PersonVerifyResult")); } } } /// /// Gets or sets group id. /// public string GroupId { get { return sampleGroupId; } set { sampleGroupId = value; } } /// /// Person for verification /// public Person Person { get; set; } = new Person(); #endregion Properties #region Methods /// /// Pick image for detection, get detection result and put detection results into LeftResultCollection /// /// Event sender /// Event argument private async void LeftImagePicker_Click(object sender, RoutedEventArgs e) { // Show image picker, show jpg type files only Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".jpg"; dlg.Filter = "Image files(*.jpg, *png, *.bmp, *.gif) | *.jpg; *.png; *.bmp; *.gif"; var result = dlg.ShowDialog(); if (result.HasValue && result.Value) { FaceVerifyResult = string.Empty; // User already picked one image var pickedImagePath = dlg.FileName; var renderingImage = UIHelper.LoadImageAppliedOrientation(pickedImagePath); var imageInfo = UIHelper.GetImageInfoForRendering(renderingImage); LeftImageDisplay.Source = renderingImage; // Clear last time detection results LeftResultCollection.Clear(); FaceVerifyButton.IsEnabled = (LeftResultCollection.Count!=0 && RightResultCollection.Count!=0); MainWindow.Log("Request: Detecting in {0}", pickedImagePath); var sw = Stopwatch.StartNew(); // Call detection REST API, detect faces inside the image using (var fileStream = File.OpenRead(pickedImagePath)) { try { MainWindow mainWindow = Window.GetWindow(this) as MainWindow; string subscriptionKey = mainWindow._scenariosControl.SubscriptionKey; string endpoint = mainWindow._scenariosControl.SubscriptionEndpoint; var faceServiceClient = new FaceServiceClient(subscriptionKey,endpoint); var faces = await faceServiceClient.DetectAsync(fileStream); // Handle REST API calling error if (faces == null) { return; } MainWindow.Log("Response: Success. Detected {0} face(s) in {1}", faces.Length, pickedImagePath); // Convert detection results into UI binding object for rendering foreach (var face in UIHelper.CalculateFaceRectangleForRendering(faces, MaxImageSize, imageInfo)) { // Detected faces are hosted in result container, will be used in the verification later LeftResultCollection.Add(face); } FaceVerifyButton.IsEnabled = (LeftResultCollection.Count != 0 && RightResultCollection.Count != 0); } catch (FaceAPIException ex) { MainWindow.Log("Response: {0}. {1}", ex.ErrorCode, ex.ErrorMessage); return; } } } GC.Collect(); } /// /// Pick image for detection, get detection result and put detection results into RightResultCollection /// /// Event sender /// Event argument private async void RightImagePicker_Click(object sender, RoutedEventArgs e) { // Show image picker, show jpg type files only Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".jpg"; dlg.Filter = "Image files(*.jpg, *.png, *.bmp, *.gif) | *.jpg; *.png; *.bmp; *.gif"; var result = dlg.ShowDialog(); if (result.HasValue && result.Value) { FaceVerifyResult = string.Empty; // User already picked one image var pickedImagePath = dlg.FileName; var renderingImage = UIHelper.LoadImageAppliedOrientation(pickedImagePath); var imageInfo = UIHelper.GetImageInfoForRendering(renderingImage); RightImageDisplay.Source = renderingImage; // Clear last time detection results RightResultCollection.Clear(); FaceVerifyButton.IsEnabled = (LeftResultCollection.Count != 0 && RightResultCollection.Count != 0); MainWindow.Log("Request: Detecting in {0}", pickedImagePath); var sw = Stopwatch.StartNew(); // Call detection REST API, detect faces inside the image using (var fileStream = File.OpenRead(pickedImagePath)) { try { MainWindow mainWindow = Window.GetWindow(this) as MainWindow; string subscriptionKey = mainWindow._scenariosControl.SubscriptionKey; string endpoint = mainWindow._scenariosControl.SubscriptionEndpoint; var faceServiceClient = new FaceServiceClient(subscriptionKey, endpoint); var faces = await faceServiceClient.DetectAsync(fileStream); // Handle REST API calling error if (faces == null) { return; } MainWindow.Log("Response: Success. Detected {0} face(s) in {1}", faces.Length, pickedImagePath); // Convert detection results into UI binding object for rendering foreach (var face in UIHelper.CalculateFaceRectangleForRendering(faces, MaxImageSize, imageInfo)) { // Detected faces are hosted in result container, will be used in the verification later RightResultCollection.Add(face); } FaceVerifyButton.IsEnabled = (LeftResultCollection.Count != 0 && RightResultCollection.Count != 0); } catch (FaceAPIException ex) { MainWindow.Log("Response: {0}. {1}", ex.ErrorCode, ex.ErrorMessage); return; } } } GC.Collect(); } /// /// Verify two detected faces, get whether these two faces belong to the same person /// /// Event sender /// Event argument private async void Face2FaceVerification_Click(object sender, RoutedEventArgs e) { // Call face to face verification, verify REST API supports one face to one face verification only // Here, we handle single face image only if (LeftResultCollection.Count == 1 && RightResultCollection.Count == 1) { FaceVerifyResult = "Verifying..."; var faceId1 = LeftResultCollection[0].FaceId; var faceId2 = RightResultCollection[0].FaceId; MainWindow.Log("Request: Verifying face {0} and {1}", faceId1, faceId2); // Call verify REST API with two face id try { MainWindow mainWindow = Window.GetWindow(this) as MainWindow; string subscriptionKey = mainWindow._scenariosControl.SubscriptionKey; string endpoint = mainWindow._scenariosControl.SubscriptionEndpoint; var faceServiceClient = new FaceServiceClient(subscriptionKey, endpoint); var res = await faceServiceClient.VerifyAsync(Guid.Parse(faceId1), Guid.Parse(faceId2)); // Verification result contains IsIdentical (true or false) and Confidence (in range 0.0 ~ 1.0), // here we update verify result on UI by FaceVerifyResult binding FaceVerifyResult = string.Format("Confidence = {0:0.00}, {1}", res.Confidence, res.IsIdentical ? "two faces belong to same person" : "two faces not belong to same person"); MainWindow.Log("Response: Success. Face {0} and {1} {2} to the same person", faceId1, faceId2, res.IsIdentical ? "belong" : "not belong"); } catch (FaceAPIException ex) { MainWindow.Log("Response: {0}. {1}", ex.ErrorCode, ex.ErrorMessage); return; } } else { MessageBox.Show("Verification accepts two faces as input, please pick images with only one detectable face in it.", "Warning", MessageBoxButton.OK); } GC.Collect(); } /// /// Pick image folder to detect faces and using these faces to create the person database /// /// /// private async void PersonImageFolderPicker_Click(object sender, RoutedEventArgs e) { bool groupExists = false; MainWindow mainWindow = Window.GetWindow(this) as MainWindow; string subscriptionKey = mainWindow._scenariosControl.SubscriptionKey; string endpoint = mainWindow._scenariosControl.SubscriptionEndpoint; var faceServiceClient = new FaceServiceClient(subscriptionKey, endpoint); // Test whether the group already exists try { MainWindow.Log("Request: Group {0} will be used to build a person database. Checking whether the group exists.", this.GroupId); await faceServiceClient.GetLargePersonGroupAsync(this.GroupId); groupExists = true; MainWindow.Log("Response: Group {0} exists.", this.GroupId); } catch (FaceAPIException ex) { if (ex.ErrorCode != "LargePersonGroupNotFound") { MainWindow.Log("Response: {0}. {1}", ex.ErrorCode, ex.ErrorMessage); return; } else { MainWindow.Log("Response: Group {0} did not exist previously.", this.GroupId); } } if (groupExists) { var cleanGroup = System.Windows.MessageBox.Show(string.Format("Requires a clean up for group \"{0}\" before setting up a new person database. Click OK to proceed, group \"{0}\" will be cleared.", this.GroupId), "Warning", MessageBoxButton.OKCancel); if (cleanGroup == MessageBoxResult.OK) { await faceServiceClient.DeleteLargePersonGroupAsync(this.GroupId); this.GroupId = Guid.NewGuid().ToString(); PersonVerifyResult = string.Empty; Person.Faces.Clear(); } else { return; } } // Show folder picker System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog(); var result = dlg.ShowDialog(); // Set the suggestion count is intent to minimum the data preparation step only, // it's not corresponding to service side constraint const int SuggestionCount = 15; if (result == System.Windows.Forms.DialogResult.OK) { FacesCollection.Clear(); PersonVerifyButton.IsEnabled = (FacesCollection.Count != 0 && RightFaceResultCollection.Count != 0); // Call create large person group REST API // Create large person group API call will failed if group with the same name already exists MainWindow.Log("Request: Creating group \"{0}\"", this.GroupId); try { await faceServiceClient.CreateLargePersonGroupAsync(this.GroupId, this.GroupId); MainWindow.Log("Response: Success. Group \"{0}\" created", this.GroupId); } catch (FaceAPIException ex) { MainWindow.Log("Response: {0}. {1}", ex.ErrorCode, ex.ErrorMessage); return; } int processCount = 0; bool forceContinue = false; MainWindow.Log("Request: Preparing person for verification, detecting faces in chosen folder."); // Enumerate top level directories, each directory contains one person's images var tasks = new List(); var tag = System.IO.Path.GetFileName(dlg.SelectedPath); Person = new Person(); Person.PersonName = tag; var faces = new ObservableCollection(); Person.Faces = faces; // Call create person REST API, the new create person id will be returned MainWindow.Log("Request: Creating person \"{0}\"", Person.PersonName); Person.PersonId = (await faceServiceClient.CreatePersonInLargePersonGroupAsync(this.GroupId, Person.PersonName)).PersonId.ToString(); MainWindow.Log("Response: Success. Person \"{0}\" (PersonID:{1}) created", Person.PersonName, Person.PersonId); string img; var imageList = new ConcurrentBag( Directory.EnumerateFiles(dlg.SelectedPath, "*.*", SearchOption.AllDirectories) .Where(s => s.ToLower().EndsWith(".jpg") || s.ToLower().EndsWith(".png") || s.ToLower().EndsWith(".bmp") || s.ToLower().EndsWith(".gif"))); // Enumerate images under the person folder, call detection int invalidImageCount = 0; while (imageList.TryTake(out img)) { tasks.Add(Task.Factory.StartNew( async (obj) => { var imgPath = obj as string; using (var fStream = File.OpenRead(imgPath)) { try { var persistFace = await faceServiceClient.AddPersonFaceInLargePersonGroupAsync(this.GroupId, Guid.Parse(Person.PersonId), fStream, imgPath); return new Tuple(imgPath, persistFace); } catch (FaceAPIException ex) { // if operation conflict, retry. if (ex.ErrorCode.Equals("ConcurrentOperationConflict")) { imageList.Add(imgPath); return null; } // if operation cause rate limit exceed, retry. else if (ex.ErrorCode.Equals("RateLimitExceeded")) { imageList.Add(imgPath); return null; } else if (ex.ErrorMessage.Contains("more than 1 face in the image.")) { Interlocked.Increment(ref invalidImageCount); } // Here we simply ignore all detection failure in this sample // You may handle these exceptions by check the Error.Error.Code and Error.Message property for ClientException object return new Tuple(imgPath, null); } } }, img).Unwrap().ContinueWith((detectTask) => { // Update detected faces for rendering var detectionResult = detectTask?.Result; if (detectionResult?.Item2 == null) { return; } this.Dispatcher.Invoke( new Action , string, ClientContract.AddPersistedFaceResult>( UIHelper.UpdateFace), FacesCollection, detectionResult.Item1, detectionResult.Item2); })); processCount++; if (processCount >= SuggestionCount && !forceContinue) { var continueProcess = System.Windows.Forms.MessageBox.Show( "The images loaded have reached the recommended count, may take long time if proceed. Would you like to continue to load images?", "Warning", System.Windows.Forms.MessageBoxButtons.YesNo); if (continueProcess == System.Windows.Forms.DialogResult.Yes) { forceContinue = true; } else { break; } } if (tasks.Count >= _maxConcurrentProcesses || imageList.IsEmpty) { await Task.WhenAll(tasks); tasks.Clear(); } } Person.Faces = FacesCollection; PersonVerifyButton.IsEnabled = (FacesCollection.Count != 0 && RightFaceResultCollection.Count != 0); if (invalidImageCount > 0) { MainWindow.Log("Warning: more or less than one face is detected in {0} images, can not add to face list.", invalidImageCount); } MainWindow.Log("Response: Success. Total {0} faces are detected.", Person.Faces.Count); } GC.Collect(); } /// /// Pick image for detection, and using the detected face as the face to person verify. /// /// /// private async void FaceImagePicker_Click(object sender, RoutedEventArgs e) { // Show image picker, show jpg type files only Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".jpg"; dlg.Filter = "Image files(*.jpg, *.png, *.bmp, *.gif) | *.jpg; *.png; *.bmp; *.gif"; var result = dlg.ShowDialog(); if (result.HasValue && result.Value) { PersonVerifyResult = string.Empty; // User already picked one image var pickedImagePath = dlg.FileName; var renderingImage = UIHelper.LoadImageAppliedOrientation(pickedImagePath); var imageInfo = UIHelper.GetImageInfoForRendering(renderingImage); RightImageDisplay2.Source = renderingImage; // Clear last time detection results RightFaceResultCollection.Clear(); PersonVerifyButton.IsEnabled = (FacesCollection.Count != 0 && RightFaceResultCollection.Count != 0); MainWindow.Log("Request: Detecting in {0}", pickedImagePath); var sw = Stopwatch.StartNew(); // Call detection REST API, detect faces inside the image using (var fileStream = File.OpenRead(pickedImagePath)) { try { MainWindow mainWindow = Window.GetWindow(this) as MainWindow; string subscriptionKey = mainWindow._scenariosControl.SubscriptionKey; string endpoint = mainWindow._scenariosControl.SubscriptionEndpoint; var faceServiceClient = new FaceServiceClient(subscriptionKey, endpoint); var faces = await faceServiceClient.DetectAsync(fileStream); // Handle REST API calling error if (faces == null) { return; } MainWindow.Log("Response: Success. Detected {0} face(s) in {1}", faces.Length, pickedImagePath); // Convert detection results into UI binding object for rendering foreach (var face in UIHelper.CalculateFaceRectangleForRendering(faces, MaxImageSize, imageInfo)) { // Detected faces are hosted in result container, will be used in the verification later RightFaceResultCollection.Add(face); } PersonVerifyButton.IsEnabled = (FacesCollection.Count != 0 && RightFaceResultCollection.Count != 0); } catch (FaceAPIException ex) { MainWindow.Log("Response: {0}. {1}", ex.ErrorCode, ex.ErrorMessage); return; } } } GC.Collect(); } /// /// Verify the face with the person, get whether these two faces belong to the same person /// /// Event sender /// Event argument private async void Face2PersonVerification_Click(object sender, RoutedEventArgs e) { // Call face to face verification, verify REST API supports one face to one person verification only // Here, we handle single face image only if (Person != null && Person.Faces.Count != 0 && RightFaceResultCollection.Count == 1) { PersonVerifyResult = "Verifying..."; var faceId = RightFaceResultCollection[0].FaceId; MainWindow.Log("Request: Verifying face {0} and person {1}", faceId, Person.PersonName); // Call verify REST API with two face id try { MainWindow mainWindow = Window.GetWindow(this) as MainWindow; string subscriptionKey = mainWindow._scenariosControl.SubscriptionKey; string endpoint = mainWindow._scenariosControl.SubscriptionEndpoint; var faceServiceClient = new FaceServiceClient(subscriptionKey, endpoint); var res = await faceServiceClient.VerifyAsync(Guid.Parse(faceId), Guid.Parse(Person.PersonId), largePersonGroupId: this.GroupId); // Verification result contains IsIdentical (true or false) and Confidence (in range 0.0 ~ 1.0), // here we update verify result on UI by PersonVerifyResult binding PersonVerifyResult = string.Format("{0} ({1:0.0})", res.IsIdentical ? "the face belongs to the person" : "the face not belong to the person", res.Confidence); MainWindow.Log("Response: Success. Face {0} {1} person {2}", faceId, res.IsIdentical ? "belong" : "not belong", Person.PersonName); } catch (FaceAPIException ex) { MainWindow.Log("Response: {0}. {1}", ex.ErrorCode, ex.ErrorMessage); return; } } else { MessageBox.Show("Verification accepts one person containing face(s) and one face as input, please check.", "Warning", MessageBoxButton.OK); } GC.Collect(); } #endregion Methods } /// /// Person structure for UI binding /// public class Person : INotifyPropertyChanged { #region Fields /// /// Person's faces from database /// private ObservableCollection _faces = new ObservableCollection(); /// /// Person's id /// private string _personId; /// /// Person's name /// private string _personName; #endregion Fields #region Events /// /// Implement INotifyPropertyChanged interface /// public event PropertyChangedEventHandler PropertyChanged; #endregion Events #region Properties /// /// Gets or sets person's faces from database /// public ObservableCollection Faces { get { return _faces; } set { _faces = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("Faces")); } } } /// /// Gets or sets person's id /// public string PersonId { get { return _personId; } set { _personId = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("PersonId")); } } } /// /// Gets or sets person's name /// public string PersonName { get { return _personName; } set { _personName = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("PersonName")); } } } #endregion Properties } } ================================================ FILE: Sample-WPF/Controls/UIHelper.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; namespace Microsoft.ProjectOxford.Face.Controls { /// /// UI helper functions /// internal static class UIHelper { #region Methods /// /// Rotate image by its orientation /// /// image path /// image for rendering public static BitmapImage LoadImageAppliedOrientation(string imagePath) { var im = new BitmapImage(); im.BeginInit(); im.UriSource = new Uri(imagePath, UriKind.RelativeOrAbsolute); im.Rotation = GetImageOrientation(imagePath); im.EndInit(); return im; } /// /// Get image orientation flag. /// /// image path /// public static Rotation GetImageOrientation(string imagePath) { using (var fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) { // See WIC Photo metadata policies for orientation query // https://msdn.microsoft.com/en-us/library/windows/desktop/ee872007(v=vs.85).aspx const string query = "System.Photo.Orientation"; var metadata = (BitmapMetadata)(BitmapFrame.Create(fs).Metadata); if (metadata != null && metadata.ContainsQuery(query)) { var orientationFlag = metadata.GetQuery(query); if (orientationFlag != null) { switch ((ushort)orientationFlag) { case 6: return Rotation.Rotate90; case 3: return Rotation.Rotate180; case 8: return Rotation.Rotate270; } } } } return Rotation.Rotate0; } /// /// Calculate the rendering face rectangle /// /// Detected face from service /// Image rendering size /// Image width and height /// Face structure for rendering public static IEnumerable CalculateFaceRectangleForRendering(IEnumerable faces, int maxSize, Tuple imageInfo) { var imageWidth = imageInfo.Item1; var imageHeight = imageInfo.Item2; float ratio = (float)imageWidth / imageHeight; int uiWidth = 0; int uiHeight = 0; if (ratio > 1.0) { uiWidth = maxSize; uiHeight = (int)(maxSize / ratio); } else { uiHeight = maxSize; uiWidth = (int)(ratio * uiHeight); } int uiXOffset = (maxSize - uiWidth) / 2; int uiYOffset = (maxSize - uiHeight) / 2; float scale = (float)uiWidth / imageWidth; foreach (var face in faces) { yield return new Face() { FaceId = face.FaceId.ToString(), Left = (int)((face.FaceRectangle.Left * scale) + uiXOffset), Top = (int)((face.FaceRectangle.Top * scale) + uiYOffset), Height = (int)(face.FaceRectangle.Height * scale), Width = (int)(face.FaceRectangle.Width * scale), }; } } /// /// Get image basic information for further rendering usage /// /// image file /// Image width and height public static Tuple GetImageInfoForRendering(BitmapImage imageFile) { try { return new Tuple(imageFile.PixelWidth, imageFile.PixelHeight); } catch { return new Tuple(0, 0); } } /// /// Append detected face to UI binding collection /// /// UI binding collection /// Original image path, used for rendering face region /// Face structure returned from service public static void UpdateFace(ObservableCollection collections, string imagePath, Microsoft.ProjectOxford.Face.Contract.AddPersistedFaceResult face) { var renderingImage = LoadImageAppliedOrientation(imagePath); collections.Add(new Face() { ImageFile = renderingImage, FaceId = face.PersistedFaceId.ToString(), }); } /// /// Append detected face to UI binding collection /// /// UI binding collection /// Original image path, used for rendering face region /// Face structure returned from service public static void UpdateFace(ObservableCollection collections, string imagePath, Microsoft.ProjectOxford.Face.Contract.Face face) { var renderingImage = LoadImageAppliedOrientation(imagePath); collections.Add(new Face() { ImageFile = renderingImage, Left = face.FaceRectangle.Left, Top = face.FaceRectangle.Top, Width = face.FaceRectangle.Width, Height = face.FaceRectangle.Height, FaceId = face.FaceId.ToString(), }); } /// /// Logging helper function /// /// log output instance /// message to append /// log string public static string AppendLine(this string log, string newMessage) { return string.Format("{0}[{3}]: {2}{1}", log, Environment.NewLine, newMessage, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")); } #endregion Methods } public static class ControlHelper { public static readonly DependencyProperty PassMouseWheelToParentProperty = DependencyProperty.RegisterAttached("PassMouseWheelToParent", typeof(bool), typeof(UIElement), new PropertyMetadata((bool)false)); public static void SetPassMouseWheelToParent(UIElement obj, bool value) { obj.SetValue(PassMouseWheelToParentProperty, value); if (value) { obj.PreviewMouseWheel += Obj_PreviewMouseWheel; } else { obj.PreviewMouseWheel -= Obj_PreviewMouseWheel; } } public static bool GetPassMouseWheelToParent(UIElement obj) { return (bool)obj.GetValue(PassMouseWheelToParentProperty); } private static void Obj_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e) { if (!e.Handled) { e.Handled = true; var eventArg = new System.Windows.Input.MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta); eventArg.RoutedEvent = UIElement.MouseWheelEvent; eventArg.Source = sender; var parent = FindVisualParent((DependencyObject)sender); if (parent != null) parent.RaiseEvent(eventArg); } } /// /// Finds a parent of a given item on the visual tree. /// /// The type of the queried item. /// A direct or indirect child of the queried item. /// The first parent item that matches the submitted type parameter. /// If not matching item can be found, a null reference is being returned. public static T FindVisualParent(DependencyObject child) where T : DependencyObject { // get parent item DependencyObject parentObject = VisualTreeHelper.GetParent(child); // we’ve reached the end of the tree if (parentObject == null) return null; // check if the parent matches the type we’re looking for T parent = parentObject as T; if (parent != null) { return parent; } else { // use recursion to proceed with next level return FindVisualParent(parentObject); } } } } ================================================ FILE: Sample-WPF/FaceAPI-WPF-Samples.csproj ================================================  Debug AnyCPU {A25DFB19-C947-4A66-AEDE-FB2A960916AD} WinExe Properties ClientLibrary FaceAPI-WPF-Samples v4.5.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 ..\ true publish\ true Disk false Foreground 7 Days false false true 0 1.2.5 false false true AnyCPU true full false bin\Debug\ DEBUG;TRACE prompt 4 AnyCPU pdbonly true bin\Release\ TRACE prompt 4 packages\Microsoft.ProjectOxford.Common.1.0.324\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\Microsoft.ProjectOxford.Common.dll True packages\Microsoft.ProjectOxford.Face.1.4.0\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Microsoft.ProjectOxford.Face.dll True packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll True packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll True 4.0 MSBuild:Compile Designer MSBuild:Compile Designer MSBuild:Compile Designer MSBuild:Compile Designer MSBuild:Compile Designer Designer MSBuild:Compile MSBuild:Compile Designer App.xaml Code FaceIdentificationPage.xaml FaceFindSimilarPage.xaml FaceGroupingPage.xaml FaceVerificationPage.xaml FaceDetectionPage.xaml MainWindow.xaml Code Code Designer False Microsoft .NET Framework 4.5 %28x86 and x64%29 true False .NET Framework 3.5 SP1 false {735929f0-f8f1-4d93-b027-5d034fa7892b} SampleUserControlLibrary ================================================ FILE: Sample-WPF/FaceAPI-WPF-Samples.sln ================================================ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FaceAPI-WPF-Samples", "FaceAPI-WPF-Samples.csproj", "{A25DFB19-C947-4A66-AEDE-FB2A960916AD}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleUserControlLibrary", "..\Cognitive-Common-Windows\SampleUserControlLibrary\SampleUserControlLibrary.csproj", "{735929F0-F8F1-4D93-B027-5D034FA7892B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {A25DFB19-C947-4A66-AEDE-FB2A960916AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A25DFB19-C947-4A66-AEDE-FB2A960916AD}.Debug|Any CPU.Build.0 = Debug|Any CPU {A25DFB19-C947-4A66-AEDE-FB2A960916AD}.Release|Any CPU.ActiveCfg = Release|Any CPU {A25DFB19-C947-4A66-AEDE-FB2A960916AD}.Release|Any CPU.Build.0 = Release|Any CPU {735929F0-F8F1-4D93-B027-5D034FA7892B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {735929F0-F8F1-4D93-B027-5D034FA7892B}.Debug|Any CPU.Build.0 = Debug|Any CPU {735929F0-F8F1-4D93-B027-5D034FA7892B}.Release|Any CPU.ActiveCfg = Release|Any CPU {735929F0-F8F1-4D93-B027-5D034FA7892B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection( ) = preSolution EndGlobalSection EndGlobal ================================================ FILE: Sample-WPF/MainWindow.xaml ================================================  ================================================ FILE: Sample-WPF/MainWindow.xaml.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System.ComponentModel; using System.Net; using System.Runtime.CompilerServices; using System.Windows; using Microsoft.ProjectOxford.Face.Controls; using SampleUserControlLibrary; namespace Microsoft.ProjectOxford.Face { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow { #region Constants private const string DefaultEndpoint = "https://westus.api.cognitive.microsoft.com/face/v1.0/"; #endregion #region Constructors /// /// Initializes a new instance of the class /// public MainWindow() { InitializeComponent(); ServicePointManager.DefaultConnectionLimit = 1000; // You can use the next line to insert your own subscription key, instead of using UI to set license key. this.ViewModel = new MainViewModel() { FaceDetectionDescription = "Locate faces in an image. You can pick an image by 'Choose Image'. Detected faces will be shown on the image by rectangles surrounding the face, and related attributes will be shown in a list.", FaceVerificationDescription = "There are two demos in Face Verification sample.", FacePersonVerificationDescription = "Face to person verification determines whether one face belongs to one person. You can pick an image folder containing one person's single face, and another single face image. Then click 'Verify' to get the verification result.", FaceFaceVerificationDescription = "Face to Face Verification determines whether two faces belong to the same person. You can pick single face image, the detected face will be shown on the image. Then click 'Verify' to get the verification result.", FaceGroupingDescription = "Put similar faces to same group according to appearance similarity. You can pick an image folder for grouping by 'Group', doing this will group all detected faces and shown under Grouping Result.", FaceFindSimilarDescription = "Find similar faces for the query face from all the candidates. You can pick an image folder, and all detected faces inside the folder will be treated as candidate. Use 'Open Query Face' to pick the query faces. The result will be list as 'query face's thumbnail', 'similar faces' thumbnails with similarity ranked'. Both of 'MatchPerson' mode and 'MatchFace' mode results will be listed. 'MatchPerson' mode return the top candidate faces among those recognized as the same person with the query face, so if no candidate faces are recognized as the same person with the query face, no one will be returned, while 'MatchFace' mode returns the top candidate faces with highest similarity confidence without checking if the returned face belong to the same person with the query face.", FaceIdentificationDescription = "Tell whom an input face belongs to given a tagged person database. Here we only handle tagged person database in following format: 1). One root folder. 2). Sub-folders are named as person's name. 3). Each person's images are put into their own sub-folder. Pick the root folder, then choose an image to identify, all faces will be shown on the image with the identified person's name.", }; this.DataContext = this.ViewModel; this._scenariosControl.SampleScenarioList = new Scenario[] { new Scenario() { PageClass = typeof(FaceDetectionPage), Title = "Face Detection", }, new Scenario() { PageClass = typeof(FaceFindSimilarPage), Title = "Face Find Similar", }, new Scenario() { PageClass = typeof(FaceGroupingPage), Title = "Face Grouping", }, new Scenario() { PageClass = typeof(FaceIdentificationPage), Title = "Face Identification", }, new Scenario() { PageClass = typeof(FaceVerificationPage), Title = "Face Verification", }, }; // Set the default endpoint when main windows is initiated. var mainWindow = GetWindow(this) as MainWindow; mainWindow?._scenariosControl.SetSubscriptionPageEndpoint(DefaultEndpoint); } #endregion Constructors #region Properties /// /// Gets view model instance for MainWindow /// public MainViewModel ViewModel { get; private set; } #endregion Properties #region Methods /// /// Log message in main window log pane /// /// format string /// format arguments public static void Log(string format, params object[] args) { ((MainWindow)Application.Current.MainWindow)._scenariosControl.Log(string.Format(format, args)); } #endregion Methods #region Nested Types /// /// View model for MainWindow, covers display image, text /// public class MainViewModel : INotifyPropertyChanged { #region Events /// /// Implements INotifyPropertyChanged interface /// public event PropertyChangedEventHandler PropertyChanged; #endregion Events #region Properties /// /// Gets or sets description of face detection /// public string FaceDetectionDescription { get; set; } /// /// Gets or sets description of face verification /// public string FaceVerificationDescription { get; set; } /// /// Gets or sets description of face to face verification /// public string FaceFaceVerificationDescription { get; set; } /// /// Gets or sets description of face to person verification /// public string FacePersonVerificationDescription { get; set; } /// /// Gets or sets description of face grouping /// public string FaceGroupingDescription { get; set; } /// /// Gets or sets description of find similar face /// public string FaceFindSimilarDescription { get; set; } /// /// Gets or sets description of identification /// public string FaceIdentificationDescription { get; set; } #endregion Properties #region Methods /// /// Helper function for INotifyPropertyChanged interface /// /// Property type /// Property name private void OnPropertyChanged([CallerMemberName]string caller = null) { var handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(caller)); } } #endregion Methods } #endregion Nested Types } } ================================================ FILE: Sample-WPF/Properties/AssemblyInfo.cs ================================================ // // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/Cognitive-Face-Windows // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Microsoft.ProjectOxford.Face")] [assembly: AssemblyDescription("Microsoft.ProjectOxford.Face")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("Microsoft ProjectOxford")] [assembly: AssemblyCopyright("Copyright © 2017 Microsoft")] [assembly: AssemblyTrademark("Microsoft")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // In order to begin building localizable applications, set // CultureYouAreCodingWith in your .csproj file // inside a . For example, if you are using US english // in your source files, set the to en-US. Then uncomment // the NeutralResourceLanguage attribute below. Update the "en-US" in // the line below to match the UICulture setting in the project file. // [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] [assembly: ThemeInfo( ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located // (used if a resource is not found in the page, // or application resource dictionaries) ResourceDictionaryLocation.SourceAssembly // where the generic resource dictionary is located // (used if a resource is not found in the page, // app, or any theme specific resource dictionaries) )] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.2.5")] [assembly: AssemblyFileVersion("1.2.5")] ================================================ FILE: Sample-WPF/packages.config ================================================  ================================================ FILE: ThirdPartyNotices.txt ================================================ THIRD-PARTY SOFTWARE NOTICES AND INFORMATION Do Not Translate or Localize This project incorporates components from the projects listed below. The original copyright notices and licenses under which Microsoft received such components are set forth below. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise. 1. newtonsoft.json version 8.0.2 (https://github.com/JamesNK/Newtonsoft.Json) %% newtonsoft.json NOTICES AND INFORMATION BEGIN HERE ========================================= The MIT License (MIT) Copyright (c) 2007 James Newton-King Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ========================================= END OF newtonsoft.json NOTICES AND INFORMATION