Face Search
1. See all photos
API:
Method | URL |
---|---|
GET | https://cloud.computervision.com.vn/api/v2/face_search/images |
Params:
Key | Value | Description |
---|---|---|
offset | 100 | Number of records to ignore |
limit | 50 | Maximum number of records to return |
Demo Python:
import requestsapi_key = "YOUR_API_KEY"api_secret = "YOUR_API_SECRET"offset = 100limit = 50response = 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:
Method | URL | content-type |
---|---|---|
POST | https://cloud.computervision.com.vn/api/v2/face_search/search | application/json |
Body:
{"image": {"base64": string // base64 encoding of the image}}
Demo Python:
import requestsapi_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 = payloadprint(response.json())
3. Add photo
API:
Method | URL | content-type |
---|---|---|
POST | https://cloud.computervision.com.vn/api/v2/face_search/images | application/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 requestsapi_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 = payloadprint(response.json())
4. Update metadata
API:
Method | URL | content-type |
---|---|---|
PUT | https://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 requestsapi_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:
Method | URL | content-type |
---|---|---|
DELETE | https://cloud.computervision.com.vn/api/v2/face_search/images | application/json |
Body:
{"ids": [123456, // photo id to delete987654, // photo id to delete...]}
Demo Python:
import requestsapi_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:
Code | Message |
---|---|
0 | Success |
1 | The photo does not contain content |
2 | Url is unavailable |
3 | Incorrect image format |
4 | Out of requests |
5 | Incorrect api_key or api_secret |
6 | Incorrect format type |