Face Search processing explained

Face Search Request

To perform Face Search on all detected faces you need to make a face matching request through REST API via endpoint: /api/v1/Faces/Search

Example of search request:

{
"image": {
"data": "base64 encoded image"
},
"threshold": 40,
"faceDetectorConfig": {
"minFaceSize": 30,
"maxFaceSize": 500,
"confidenceThreshold": 600
},
"faceDetectorResourceId": "cpu", // "cpu" or "gpu" or "accurate_cpu" or "accurate_gpu"
"templateGeneratorResourceId": "cpu" // "cpu" or "gpu"
}

The minimum value for the threshold accepted by API is 30. A value of 30 represents a value, where one in a thousand (10 ^ 3) faces can be false positive.

Example of search response:

{
"searchSessionId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}

The response contains SearchSessionId which can be used to query data via GraphQL API.

All match results are stored in the database, and each search request will create:

  • SearchSession object in database, which identifies each search by its searchSessionId.

  • SearchSessionObject for each matched face above requested threshold

Querying face search results

Only GraphQL can be used to query for results of face search functionality. You can either traverse SearchSessionObjects and its linked Faces or vice versa.

Example of GraphQL query:

query {
faces (where: { searchSessionObjects: { some: { searchSessionId: { eq:"3fa85f64-5717-4562-b3fc-2c963f66afa6"}}}}) {
items {
imageDataId
age
gender
createdAt
}
}
}

Deleting face search results data

The face search feature can produce large amounts of SearchSessionObjects data, which can lead to reduced performance when querying data.

You can setup cleanup process of this data by making request through REST API via endpoint: /api/v1/Setup/SearchSessionsCleanup

Example of search results cleanup process configuration request:

{
"enabled": true,
"maxItemsCount": 100000000,
"maxSessionAge": "7.00:00:00",
"interval": "01:00:00"
}

Property name

Property type

Property summary

Valid values

Default value

Interval

TimeSpan or null

The interval of cleanup.


01:00:00

MaxSessionAge

TimeSpan or null

The maximum age of Search sessions which will be stored. When the cleanup runs, all Search sessions older than MaxSessionAge will be removed.


7.00:00:00

MaxItemsCount

integer or null

The maximum count of Search sessions items (associations between search session and matched face) for which the Search sessions will be stored. When the cleanup runs, the count of Search sessions to delete to meet this constraint is computed and afterwards these Search sessions will be removed.

NOTES:

  • After each cleanup the number of Search sessions items will be always less or equal than MaxItemsCount

  • If oldest search sessions contain no Search session items then they will be also removed whatever the value of MaxItemsCount property is.

Greater than zero or null

100000000