I am going to explain how to use Face Recognition API with mobile. We can detect, identify, analyze, organize, and tag faces in photos with this api.
I want to make sample with all Face API References but I start with Face Detect. Let’s see
I create a new Xamarin.Forms app with .netstandart library then I install Media nuget package.
Don’t forget to use your key in Ocp-Apim-Subscription-Key inputhttps://blogs.msdn.microsoft.com/kwill/2017/05/17/http-401-access-denied-when-calling-azure-cognitive-services-apis/
First of all I create my own VM architecture for our sample. If you have any question you can mail at me about my VM architecture.I developed this project in 2 hours without Face API (XF architecture, plugins, etc..) but you know Azure Cognitive Services API implementation 5 min. max
- Behaviors: BindableBehavior and Event To Command
- Converters: Some usable converters and Event Converters
- Helpers: Some usable helper classes
- Models: API request and response classes and common classes
- Pages: Pages
- Provider: API Service Manager
- Services: Dialog, Media, Navigation, etc..
- ViewModels > Base: ViewModelBase and ViewModelLocator
- ViewModels: ViewModels for Pages
- Views: Popup Pages
Hint: If you want to create a new page, you need to know 3 rules1-) Create Page in Pages folder
2-) Create ViewModel in ViewModels folder (Check RegisterDependencies method for it)
2.1-) If your page name MainPage, your ViewModel name should be MainPageViewModel (Check OnAutoWireViewModelChanged method for it)
3-) Add xmlns to you page
You can check NavigationService class for Navigation architecture. I want to convert shell architecture this class with next push btw
You need to review FaceDetectRequest, FaceDetectResponse and FaceDetectUrlHelper classes for how to work with Face API. BaseAddress is https://westeurope.api.cognitive.microsoft.com/face/v1.0/
You have to select any attributes for api request. (select multiple if you want btw)
I chose age, gender, smile, glasses and emotion attributes in config page and I take my own picture with glasses