Search code examples
angularazureazure-cognitive-servicesface-api

Create FaceListId FaceAPI Microsoft Azure


What I'm using

FaceAPI, AngularFire2, FireStore, Angular v6

What I'm trying to do

I want Find similar faces with photo in Firebase Storage, I have the DownloadURL to compare.

Issue

I do not know how to create the FaceListId, I do not understand the documentation.

https://eastus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524b

Observations

I not idea as start. I have working FaceAPI - Detect but I need Find Similar.


Solution

  • According to Create FaceListId RestAPI, we could use it to create an empty face list with user-specified faceListId, name and an optional userData.

    put https://[location].api.cognitive.microsoft.com/face/v1.0/facelists/{faceListId} 
    

    If you want to create a facelist you could use the API documentation for test.

    PUT https://westus.api.cognitive.microsoft.com/face/v1.0/facelists/tomtest HTTP/1.1
    Host: westus.api.cognitive.microsoft.com
    Content-Type: application/json
    Ocp-Apim-Subscription-Key: xxxx    
    {
    
        "name": "tomtestlist",
    
        "userData": "it is optional"
    
    }
    

    Test Result:

    enter image description here

    If you need Find Similar, you could follow the blow steps:

    1.The create facelistid RestAPi just create the empty list. We also need to add face into the facelist.

    2.Use the detect api to get the faceid.

    3.use the Find similar API

    https://[location].api.cognitive.microsoft.com/face/v1.0/findsimilars 
    
    {
        "faceId": "faceid get from detect api",
        "largeFaceListId": "tomtest",
        "maxNumOfCandidatesReturned": 10,
        "mode": "matchPerson"
    }
    

    Note: Face list is a list of faces, up to 1,000 faces, please consider LargeFaceList when the face number is large. It can support up to 1,000,000 faces.