Search for faces in an image. The method requires the image
parameter to perform the search. The limit_per_page
parameter is optional and defaults to 30 if not provided. The method returns a list of assets that match the search criteria.
Request Body
Parameter | Type | Description |
---|---|---|
image | binary | An image to perform the search. Can contain more than one face. The image cannot have a size greater than 10MB. |
save_search | boolean | (optional, defaults to true), indicates whether to store the search criteria. Will return the search ID when true. |
strictness | number | (optional, defaults to 5) A number from 0 to 9. Zero returns all matches (may return false positives), and nine is the strictest (less false positives, but more misses). |
extended_result | boolean | (optional, defaults to false) Set this to true to return extended result which will contain the complete asset data for asset ids returned. Searches with this set to true will take longer to run |
filters | string | (optional, JSON as string) Provide filter fields and values to filter results. Note that before using filters, FR Addon Settings must be updated for event hooks with appropriate event criteria. Please contact FileSpin Support to set this up. |
limit_per_page | number | (optional) Can be 1 to 30, defaults to 30. |
Face Search Filters
filters
option provides the ability to filter face search results with the metadata fields associated with the Asset. This is useful when you want to search for faces with specific metadata fields. For example, you can search for faces with metadata fields, such location
set to london
and age
set to 30
, etc.
Note:
filters
option is only available when FR Addon Settings has been updated forevent hooks
with appropriate event criteria- NOTE:
filters
JSON should be passed as a string, like in below cURL examplecurl --request POST \ --url <<API_HOST>>/api/v1/ml/people/facesearch \ --header 'X-FileSpin-Api-Key: UPDATE_ME' \ --header 'content-type: multipart/form-data' \ --form [email protected] \ --form 'filters={"field1": "y"}'
filters
support string, number, boolean and date fields.- Asset Metadata fields that end with
Date
are treated as date fields for the purpose of Face Search Filters. For example,createdDate
,updatedDate
etc. - Date ranges can be passed
{"date": ["2021-01-01T01:01:01Z", "2022-02-02T02:02:02Z"]}
where the date string is formatted as ISO 8601 string (YYYY-MM-DDTHH:MM:SSZ
). First element in the array is the start date and second element is the end date. Dates are inclusive. - fields passed in
filters
are case-sensitive and should match the metadata fields exactly - fields passed in
filters
are ANDed together. For example, if you pass{"location": "earth", "age": 30}
it will return assets that havelocation
set toearth
andage
set to30
. - a field value may contain multiple values. For example,
location
can contain multiple values such asearth mars
. In such cases, the values are ORed together. For example, if you pass{"location": "earth mars"}
it will return assets that havelocation
set toearth
ormars
.
Example filters value
'filters={"location": "earth","age": 30,"isShortlisted": true, "createdDate": ["2021-01-01T01:01:01Z", "2022-02-02T02:02:02Z"]}
Response
A successful POST
request returns a list of assets that match the search criteria. The response format is JSON. If extended_result
is true
, response includes Asset Data for all assets in the page.
Status Code | Description |
---|---|
200 | Successful operation. |
400 | The request body is invalid or missing data. |
{
"data": {
"matches": [ "asset_id1", "asset_id2", "asset_id3" ],
"extended_result": {
"asset_id1": {Asset Data JSON},
"asset_id2": {Asset Data JSON},
"asset_id3": {Asset Data JSON},
}
}
"page": 1,
"search_id": "eed4c602a80a4920a4a9e56b5d3ea161",
"limit_per_page": 30,
"hits": 3
}
Parameter | Type | Description |
---|---|---|
data | JSON | A dictionary with matches that contains a list of asset ids that are direct matches. If include groups is set to true in request, group_matches will be returned with the list of asset ids that the algorithm has determined to be in the same group. |
extended_result | JSON | A dictionary containing the current data for each file id returned in result. Data for each file follows Asset Data Format JSON. If extended_result is false or not set, response will not contain this JSON. |
page | integer | index of the page from the result pages. Index is calculated using limit_per_page |
search_id | string | returned if save_search was set to true in the request |
limit_per_page | integer | As specified in the request or the default |
hits | integer | Total number hits for this search. Pagination can be done using this and limit_per_page |