Search code examples
javaandroidazureface-api

Azure FaceAPI Face is Not Found in Android Java


I am trying to build a face recognition attendance system using Azure FaceAPI. I created a face list. Then, I downloaded the images' URLs from firebase and then used the detection method to detect each face. I added each face to the face list. Finally, I wanted to test findSimilar method by giving it an existing face with the faces UUID array. These are some parts of the code (I used a thread for each call)

private FaceServiceClient faceServiceClient=new FaceServiceRestClient("https://train.cognitiveservices.azure.com/face/v1.0/",key); 
--
faceServiceClient.createFaceList(faceListId, "mylist", "recognition_04");
--
// in a loop from i=0 --> i < no of images
faces= faceServiceClient.detect(Urls.get(i), false, false, null);
facesIds.add( faceServiceClient.addFacesToFaceList(faceListId, Urls.get(i), null, faces[0].faceRectangle).persistedFaceId);
--
faceServiceClient.findSimilar(id,ids, 1 );

I printed out all the IDs and checked that they exist. However, it always gives an error after calling findSimilar method.

com.microsoft.projectoxford.face.rest.ClientException: Face is not found.

Can someone please tell me what the problem is?


Solution

  • The answer was simply that findSimilar method takes the ID of detected face not a faceID from the faceList. For me, I used an existing faceID just to test. However, I had to detect a face then get its ID.

    faceServiceClient.findSimilar(id,ids, 1 );
    

    Summary: Replace 'id' with detected face ID.