Version 1.9.72 (Release Notes)


facecomparehttps://api.pixlab.io/facecompare

Description

Given two detected faces in different images, make sure they belong to the same person. This command expect a single face to be present in the source and the target image. If your image contains multiple faces, you can extract the target face via crop using the rectangle coordinates obtained from facedetect or you can simply switch to facelookup instead.

HTTP Methods

GET,POST

Request Parameters

Required

FieldsTypeDescription
srcURLSource image URL. If you want to upload your image directly from your app, call store before invoking this one and use the output link. Only a single face must be present for the comparison to take place. If you want to find a face in a group of faces, call facelookup instead.
targetURLTarget image URL. As said, only a single face must be present in order for the comparison to take place. Crop is of particular help here.
keyStringYour PixLab API Key. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to.

Response

application/json

This command always return a JSON object after each call. The fields of interest here are the same_face and the confidence value. The following are the JSON fields returned in response body:

FieldsTypeDescription
statusIntegerStatus code 200 indicates success, any other code indicates failure.
same_faceBooleanTrue if the present faces belong to the same person. False otherwise.
confidenceFloatConfidence threshold which is set between 0 .. 1. The more this value approaches 1, the highly the present faces belong to the same person.
errorStringError message if status != 200.

Python Example

import requests
import json
# Check whether the given faces belong to the same person or not
src = 'https://static-secure.guim.co.uk/sys-images/Guardian/Pix/pictures/2012/7/9/1341860104423/obama_face.jpg'
target = 'https://static01.nyt.com/images/2011/07/31/sunday-review/FACES/FACES-jumbo.jpg'

#Unrelated face
#target = 'https://s-media-cache-ak0.pinimg.com/736x/60/aa/e4/60aae45858ab6ce9dc5b33cc2e69baf7.jpg'

req = requests.get('https://api.pixlab.io/facecompare',params={
	'src': src,
	'target': target,
	'key':'My_Pix_Key',
})
reply = req.json()
if reply['status'] != 200:
    print (reply['error'])
else:
    print ("Same Face: "+ str(reply['same_face']))
    print ("Confidence: "+ str(reply['confidence']))

See Also