Searches a specified individual group for the top 5 individuals whose faces most closely match a submitted face image, sorted by descending similarity score.
Key concepts
| Term | Description | Related operations |
|---|---|---|
person | An individual representing a natural person | Create an individual, Update an individual, Get individual details, Delete an individual |
face | A face image associated with an individual. One individual can have multiple face images. | Add a face, Delete a face |
group | A collection of individuals. An individual can belong to multiple groups, and a group can contain multiple individuals. | Add individuals to a group, List groups, List individuals in a group, Remove an individual from a group |
Operation description
Call imageScan to submit a synchronous image moderation task for Custom Face Retrieval. For details on constructing HTTP requests, see Request structure. Alternatively, use an SDK — see SDK overview.
Billing
You are charged for calling this operation. For more information about the billing methods, see the billing documentation.
Response timeout
The maximum response time for a synchronous moderation request is 6 seconds. If moderation does not complete within 6 seconds, a timeout error is returned. If you do not require moderation results in real time, you can send asynchronous moderation requests. In most cases, results are returned within 1 second. We recommend that you set the timeout period to 6 seconds for calling synchronous moderation operations. Response time may increase when the system is under heavy load, images are large, or images contain a large number of words.
Image requirements
Image URL must use HTTP or HTTPS.
Supported formats: PNG, JPG, JPEG, BMP, GIF, WEBP.
Maximum image size: 20 MB (applies to both synchronous and asynchronous requests).
Image download timeout: 3 seconds. If the image cannot be downloaded within 3 seconds, a timeout error is returned.
Minimum recommended resolution: 256 × 256 pixels.
Use a stable storage service such as Object Storage Service (OSS) or Content Delivery Network (CDN) to host images, to avoid download failures that affect response time.
QPS limits
50 calls per second per account. Exceeding this limit triggers throttling, which may affect your service.
Request syntax
POST /green/image/scan HTTPS|HTTPRequest headers
This operation uses only common request headers. For more information, see Common request headers.
Request parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| clientInfo | JSONObject | No | {"userId":"120234234","userNick":"Mike","userType":"others"} | Client information serialized from the ClientInfo structure in JSON format. Includes the unique machine identifier (UMID) and International Mobile Equipment Identity (IMEI). For details, see ClientInfo. |
Request body
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| bizType | String | No | edu | The business scenario type. Not required for Custom Face Retrieval. |
| scenes | StringArray | Yes | ["sface-n"] | The detection scenario. Set to sface-n for Custom Face Retrieval. |
| tasks | JSONArray | Yes | The face images to analyze. See the task structure below. |
Table 1. task
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| dataId | String | No | test2NInmOtAON6qYUrtCRgLo-1mwxdi | The ID of the moderation object. Accepts letters, digits, underscores (_), hyphens (-), and periods (.). Maximum length: 128 characters. Use this field to correlate the result with your business data. |
| url | String | Yes | https://example.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png | The URL of the face image to analyze. |
| extras | JSONObject | Yes | {"groupId":"group"} | Additional parameters. Specify the groupId of the individual group to search. To get all group IDs, call the /green/sface/groups operation. |
Response elements
All responses return JSON. For common response parameters, see Common response parameters. The data field contains business-specific results.
The data field may be empty if an error occurs.| Parameter | Type | Example | Description |
|---|---|---|---|
| code | Integer | 200 | The HTTP status code. For details, see Common error codes. |
| results | JSONArray | The moderation results. When code is 200, contains one or more result elements. |
Table 2. result
| Parameter | Type | Example | Description |
|---|---|---|---|
| scene | String | sface-n | The detection scenario. Value: sface-n. |
| label | String | sface-n | The result category. Valid values: sface-n (similar faces found), normal (no similar faces found). |
| suggestion | String | review | The moderation suggestion. Valid values: pass (no action required), review (manual review recommended). |
| rate | Float | 0.999 | The confidence score of the result. Range: 0.00–1.00. A higher value indicates higher confidence. |
| topPersonData | JSONArray | The top 5 individuals most similar to the submitted face image. Returns null if no similar individuals are found. |
Table 3. topPersonData
| Parameter | Type | Description |
|---|---|---|
| persons | JSONArray | The top 5 matched individuals. See the person structure below. |
| faceItem | JSONObject | The detected face location and dimensions in the image. See the faceItem structure below. |
Table 4. person
| Parameter | Type | Example | Description |
|---|---|---|---|
| personId | String | person1 | The ID of the matched individual. |
| faceId | String | 14736649593638 | The ID of the matched face image. |
| rate | Float | 0.999 | The similarity score. The table below shows the relationship between similarity scores and false recognition rates. Use results with a score of 0.9 or higher for reliable matching. |
Similarity score and false recognition rate
Similarity score (rate) | False recognition rate |
|---|---|
| 0.50 | 0.05 |
| 0.60 | 0.01 |
| 0.70 | 0.005 |
| 0.80 | 0.001 |
| 0.90 | 0.0001 |
| 0.92 | 0.00001 |
| 0.94 | 0.000001 |
| 0.96 | 0.0000001 |
Table 5. faceItem
| Parameter | Type | Example | Description |
|---|---|---|---|
| x | Float | 467 | The x-coordinate of the detected face. Unit: pixels. |
| y | Float | 199 | The y-coordinate of the detected face. Unit: pixels. |
| width | Float | 422 | The width of the detected face. Unit: pixels. |
| height | Float | 422 | The height of the detected face. Unit: pixels. |
Examples
Sample request
POST /green/image/scan HTTP/1.1
Common request headers
{
"scenes": [
"sface-n"
],
"tasks": [
{
"dataId": "test2NInmOtAON6qYUrtCRgLo-1mwxdi",
"url": "https://example.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png",
"extras": {
"groupId": "group"
}
}
]
}Sample success response
{
"code": 200,
"data": [
{
"code": 200,
"dataId": "test2NInmOtAON6qYUrtCRgLo-1mwxdi",
"msg": "The call is successful.",
"results": [
{
"topPersonData": [
{
"faceItem": {
"height": 422,
"width": 422,
"x": 467,
"y": 199
},
"persons": [
{
"faceId": "14736649593638",
"personId": "person1",
"rate": "0.999"
},
{
"faceId": "14736649593637",
"personId": "person2",
"rate": "0.998"
}
]
}
],
"label": "sface-n",
"rate": 0.999,
"scene": "sface-n",
"suggestion": "review"
}
],
"taskId": "img2MVcKPU1QGD64LoAb4cK6w-1mwxdi",
"url": "https://example.com/tfs/TB1urBOQFXXXXbMXFXXXXXXXXXX-1442-257.png"
}
],
"msg": "OK",
"requestId": "36D384DA-8023-4E84-BCFD-0C5581352C16"
}