Face Search

1. See all photos

API:

MethodURL
GEThttps://cloud.computervision.com.vn/api/v2/face_search/images

Params:

KeyValueDescription
offset100Number of records to ignore
limit50Maximum number of records to return

Demo Python:

import requests
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
offset = 100
limit = 50
response = requests.get(
"https://cloud.computervision.com.vn/api/v2/face_search/images?offset=%s&limit=%s"
% (offset, limit),
auth = (api_key, api_secret)
)
print(response.json())

2. Face search

API:

MethodURLcontent-type
POSThttps://cloud.computervision.com.vn/api/v2/face_search/searchapplication/json

Body:

{
"image": {
"base64": string // base64 encoding of the image
}
}

Demo Python:

import requests
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
payload = "{\"image\":{\"base64\":\"iVBORw0KGgoAAAANSU...\"}}"
response = requests.post(
"https://cloud.computervision.com.vn/api/v2/face_search/search",
auth=(api_key, api_secret),
data = payload
print(response.json())

3. Add photo

API:

MethodURLcontent-type
POSThttps://cloud.computervision.com.vn/api/v2/face_search/imagesapplication/json

Body:

{
"image": {
"base64": string, // Base64 encoding of the image,
"metadata": json // Optional. Any key-value metadata to save with the image, except those "user", "encoding", "_id" already used by the system
}
}

Demo Python:

import requests
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
payload = "{\"image\":{\"base64\":\"iVBORw0KGgoAAAANSU...\"}}"
response = requests.post(
"https://cloud.computervision.com.vn/api/v2/face_search/images",
auth=(api_key, api_secret),
data = payload
print(response.json())

4. Update metadata

API:

MethodURLcontent-type
PUThttps://cloud.computervision.com.vn/api/v2/face_search/images/<image_id>application/json

Body:

{
"image_id": 123456,
"metadata": {
"name": "example",
"label": "for bar",
...
}
}

Demo Python:

import requests
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
payload = "{\"image_id\":123456,\"metadata\":{\"name\":\"example\",\"label\":\"for bar\"}}"
response = requests.post(
"https://cloud.computervision.com.vn/api/v2/face_search/images/<image_id>",
data = payload,
auth = (api_key, api_secret)
)
print(response.json())

5. Delete multiple photos

API:

MethodURLcontent-type
DELETEhttps://cloud.computervision.com.vn/api/v2/face_search/imagesapplication/json

Body:

{
"ids": [
123456, // photo id to delete
987654, // photo id to delete
...
]
}

Demo Python:

import requests
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
payload = "{\"ids\":[<image-id-you-want-to-delete>,<image-id-you-want-to-delete>,...]}"
response = requests.post(
"https://cloud.computervision.com.vn/api/v2/face_search/images",
data = payload,
auth = (api_key, api_secret)
)
print(response.json())

6. Response

The response will be a JSON with the following format:

{
"result": [xxxx],
"status_code": int,
"message": string
}

Different api will return different results.

See all photos:

  • result: An array of image elements, each containing the image's id and the corresponding image URL.

Face search:

  • result: The array contains the matching image elements, each containing the image id and the corresponding image URL.

Add photos:

  • result: The JSON contains the newly added image information.

Delete multiple photos:

  • result: None.

Error code table:

CodeMessage
0Success
1The photo does not contain content
2Url is unavailable
3Incorrect image format
4Out of requests
5Incorrect api_key or api_secret
6Incorrect format type