facelookuphttps://api.pixlab.io/facelookup
Description
Given a human face, try to locate it in a crowd or group of people. This involve iterating all over the present faces in a given image and perform face to face recognition.
HTTP Methods
GET
Request Parameters
Required
Fields | Type | Description |
---|---|---|
face | URL | Source image URL that hold the face to search for. 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 in order for the lookup to take place. Crop is of particular help here if you want to extract the face of interest. |
crowd | URL | Target image URL holding the crowd or group of faces. This is where the lookup operation should take. Any number of faces can be present in this image. |
key | String | Your 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 return a JSON object after each call. The fields of interest here are the found, confidence and the rectangle values. The following are the JSON fields returned in response body:
Fields | Type | Description |
---|---|---|
status | Integer | Status code 200 indicates success, any other code indicates failure. |
found | Boolean | True if the target face is found in the set of faces. False otherwise. |
confidence | Float | Confidence threshold which is set between 0 .. 1. |
rectangle | Object | JSON object holding the rectangle coordinates namely top, left, width, height of the target face in the set. |
best | Object | If the found field is set to false (i.e. The face was not found in the set), then this object hold the rectangle coordinates of the best candidate face in the set and a confidence threshold. |
error | String | Error message if status != 200. |
Python Example
import requests
import json
# Find a person face in a crowd or group of people. https://pixlab.io/cmd?id=facelookup for additional information.
# This is the target face that we are searching for in the crowd.
face = 'http://static-secure.guim.co.uk/sys-images/Guardian/Pix/pictures/2012/7/9/1341860104423/obama_face.jpg'
# The crowd to look at
crowd = 'http://www.acclaimimages.com/_gallery/_free_images/0519-0908-1001-0556_president_barack_obama_walking_with_a_crowd_of_people_o.jpg'
req = requests.get('https://api.pixlab.io/facelookup',params={
'face': face,
'crowd': crowd,
'key':'My_Pix_Key',
})
reply = req.json()
if reply['status'] != 200:
print (reply['error'])
else:
found = reply['found'] # Boolean value telling whether we got the face or not
if found:
print("Face found with confidence value = "+ str(reply['confidence']))
rectangle = reply['rectangle'] # Rectangle coordinates of the target face
print("Face Coordinates: top: "+str(rectangle['top'])+" left: "+str(rectangle['left'])+" width: "+str(rectangle['width'])+" height:"+str(rectangle['height']))
else:
print("Face NOT found in the target crowd..picking up the best candidate:")
best = reply['best']
rectangle = best['rectangle'] # Rectangle coordinates of the best candidate
print ("Confidence: "+ str(best['confidence']))
print ("Best Candidate Coordinates: top: "+str(rectangle['top'])+" left: "+str(rectangle['left'])+" width: "+str(rectangle['width'])+" height:"+str(rectangle['height']))
See Also
header, nsfw, sfw, ocr, facedetect, facelandmarks, crop, mogrify, facemotion, facecompare, facegenerate, screencapture