tencent cloud

Feedback

SearchPersons

Last updated: 2023-02-27 15:22:52

1. API Description

Domain name for API request: iai.tencentcloudapi.com.

This API is used to recognize top K persons in one or more groups who are similar to the person in a given image and rank the similarity in a descending order.

Up to 10 faces in an image can be recognized at a time, and up to 100 groups can be searched in at a time.

The maximum number of faces in groups that can be searched for at a time is subject to the group's algorithm model version (FaceModelVersion), which is 1 million for v2.0 or 3 million for v3.0.

This API fuses the features of all face images of a person; for example, if a person has 4 face images, it will fuse the features of the 4 face images and generate the summarized facial features of the person to make the person search (i.e., judging whether the face image to be recognized is of a specified person) more accurate. By contrast, the SearchFaces and SearchFacesReturnsByGroup APIs recognize each face image of a person as an independent one for search.

  • Please use the signature algorithm v3 to calculate the signature in the common parameters, that is, set the SignatureMethod parameter to TC3-HMAC-SHA256.
  • This feature is available only to groups whose algorithm model version (FaceModelVersion) is 3.0.
We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: SearchPersons.
Version Yes String Common Params. The value used for this API: 2020-03-03.
Region No String Common Params. This parameter is not required for this API.
GroupIds.N Yes Array of String List of groups to be searched in (up to 100). The array element value is the GroupId in the CreateGroup API.
Image No String Base64-encoded image data, which cannot exceed 5 MB.
The long side cannot exceed 4,000 px for images in JPG format or 2,000 px for images in other formats.
If there are multiple faces in the image, only the face with the largest size will be selected.
PNG, JPG, JPEG, and BMP images are supported, while GIF images are not.
Url No String Image URL. The image cannot exceed 5 MB in size after being Base64-encoded.
The long side cannot exceed 4,000 px for images in JPG format or 2,000 px for images in other formats.
Either Url or Image must be provided; if both are provided, only Url will be used.
We recommend storing the image in Tencent Cloud, as a Tencent Cloud URL can guarantee higher download speed and stability.
The download speed and stability of non-Tencent Cloud URLs may be low.
PNG, JPG, JPEG, and BMP images are supported, while GIF images are not.
MaxFaceNum No Integer Maximum number of recognizable faces. Default value: 1 (i.e., detecting only the face with the largest size in the image). Maximum value: 10.
MaxFaceNum is used to control the number of faces to be searched for if there are multiple faces in the input image to be recognized.
For example, if the input image in Image or Url contains multiple faces and MaxFaceNum is 5, top 5 faces with the largest size in the image will be recognized.
MinFaceSize No Integer Minimum height and width of face in px. Default value: 34. A value below 34 will affect the search accuracy. We recommend setting this parameter to 80.
MaxPersonNum No Integer Number of the most similar persons returned for one single recognized face image. Default value: 5. Maximum value: 100.
For example, if MaxFaceNum is 1 and MaxPersonNum is 8, information of the top 8 most similar persons will be returned.
The greater the value, the longer the processing time. We recommend setting a value below 10.
QualityControl No Integer Image quality control.
0: no control.
1: low quality requirement. The image has one or more of the following problems: extreme blurriness, covered eyes, covered nose, and covered mouth.
2: average quality requirement. The image has at least three of the following problems: excessive brightness, excessive dimness, blurriness or average blurriness, covered eyebrows, covered cheeks, and covered chin.
3: high-quality requirement. The image has one to two of the following problems: excessive brightness, excessive dimness, average blurriness, covered eyebrows, covered cheeks, and covered chin.
4: very high-quality requirement. The image is optimal in all dimensions or only has a slight problem in one dimension.
Default value: 0.
If the image quality does not meet the requirement, the returned result will prompt that the detected image quality is unsatisfactory.
FaceMatchThreshold No Float In the output parameter Score, the result will be returned only if the result value is greater than or equal to the FaceMatchThreshold value. Default value: 0. Value range: [0.0,100.0).
NeedPersonInfo No Integer Whether to return person details. 0: no; 1: yes. Default value: 0. Other values will be considered as 0 by default.
NeedRotateDetection No Integer Whether to enable the support for rotated image recognition. 0: no; 1: yes. Default value: 0. When the face in the image is rotated and the image has no EXIF information, if this parameter is not enabled, the face in the image cannot be correctly detected and recognized. If you are sure that the input image contains EXIF information or the face in the image will not be rotated, do not enable this parameter, as the overall time consumption may increase by hundreds of milliseconds after it is enabled.

3. Output Parameters

Parameter Name Type Description
Results Array of Result Recognition result.
PersonNum Integer Number of the persons included in searched groups. If the quality of all faces in the input image does not meet the requirement, 0 will be returned.
FaceModelVersion String Algorithm model version used for face recognition.
Note: this field may return null, indicating that no valid values can be obtained.
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Searching for person

Input Example

https://iai.tencentcloudapi.com/?Action=SearchPersons
&Url=http://test.image.myqcloud.com/testA.jpg
&MaxFaceNum=2
&MinFaceSize=40
&MaxPersonNum=3
&GroupIds.0=TencentShenZhenEmployee
&<Common request parameters>

Output Example

{
    "Response": {
        "Results": [
            {
                "RetCode": 0,
                "Candidates": [
                    {
                        "PersonId": "person1",
                        "FaceId": "",
                        "Score": 100,
                        "PersonName": null,
                        "Gender": null,
                        "PersonGroupInfos": null
                    },
                    {
                        "PersonId": "person2",
                        "FaceId": "",
                        "Score": 60,
                        "PersonName": null,
                        "Gender": null,
                        "PersonGroupInfos": null
                    },
                    {
                        "PersonId": "person3",
                        "FaceId": "",
                        "Score": 50,
                        "PersonName": null,
                        "Gender": null,
                        "PersonGroupInfos": null
                    }
                ],
                "FaceRect": {
                    "X": 139,
                    "Y": 59,
                    "Width": 124,
                    "Height": 162
                }
            },
            {
                "RetCode": 0,
                "Candidates": [
                    {
                        "PersonId": "person2",
                        "FaceId": "",
                        "Score": 100,
                        "PersonName": null,
                        "Gender": null,
                        "PersonGroupInfos": null
                    },
                    {
                        "PersonId": "person1",
                        "FaceId": "",
                        "Score": 60,
                        "PersonName": null,
                        "Gender": null,
                        "PersonGroupInfos": null
                    },
                    {
                        "PersonId": "person3",
                        "FaceId": "",
                        "Score": 20,
                        "PersonName": null,
                        "Gender": null,
                        "PersonGroupInfos": null
                    }
                ],
                "FaceRect": {
                    "X": 328,
                    "Y": 70,
                    "Width": 119,
                    "Height": 162
                }
            }
        ],
        "PersonNum": 5,
        "FaceModelVersion": "3.0",
        "RequestId": "c4608852-ff60-4a01-8dc3-367f6046baaf"
    }
}

Example2 Sample error

This example shows the error that will occur if an image URL is incorrect.

Input Example

https://iai.tencentcloudapi.com/?Action=SearchPersons
&Url=http://test.image.myqcloud.com/testA
&GroupIds.0=TencentShenZhenEmployee
&<Common request parameters>

Output Example

{
    "Response": {
        "RequestId": "527ecffe-4c6a-47c9-8217-4dd2e3f018da"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
AuthFailure.InvalidAuthorization Authentication failed.
FailedOperation.AcrossVersionsError This operation cannot be performed across algorithm model versions.
FailedOperation.FaceSizeTooSmall The face frame size is smaller than the MinFaceSize value, and the face is filtered out.
FailedOperation.ImageDecodeFailed Image decoding failed.
FailedOperation.ImageDownloadError An error occurred while downloading the image.
FailedOperation.ImageFacedetectFailed Face detection failed.
FailedOperation.ImageResolutionExceed The image resolution is too high.
FailedOperation.ImageResolutionTooSmall The image short edge resolution is smaller than 64.
FailedOperation.ImageSizeExceed The size of the Base64-encoded image cannot exceed 5 MB.
FailedOperation.RequestLimitExceeded The request frequency exceeds the limit.
FailedOperation.RequestTimeout The backend service timed out.
FailedOperation.SearchFacesExceed The number of faces searched for exceeds the limit.
FailedOperation.ServerError The algorithm service is exceptional. Please retry.
InternalError Internal error.
InvalidParameter.InvalidParameter Invalid parameter.
InvalidParameterValue.FaceMatchThresholdIllegal Invalid FaceMatchThreshold parameter.
InvalidParameterValue.GroupIdIllegal The group ID contains invalid characters. It can contain only letters, digits, and special symbols (-%@#&_).
InvalidParameterValue.GroupIdNotExist The group ID does not exist.
InvalidParameterValue.GroupIdsExceed The list of groups passed in exceeds the limit.
InvalidParameterValue.ImageEmpty Empty image.
InvalidParameterValue.ImageEmptyError Empty image.
InvalidParameterValue.NoFaceInGroups There are no faces in the specified group.
InvalidParameterValue.NoFaceInPhoto There are no faces in the image.
InvalidParameterValue.QualityControlIllegal Invalid QualityControl parameter.
InvalidParameterValue.SearchPersonsExceed The number of persons searched for exceeds the limit.
InvalidParameterValue.UnsupportedGroupFaceModelVersion This operation is not supported by algorithm model v2.0 or below.
InvalidParameterValue.UrlIllegal Invalid URL format.
MissingParameter.ErrorParameterEmpty A required parameter is empty.
ResourceUnavailable.ChargeStatusException The account is in arrears.
ResourceUnavailable.Freeze The account is frozen.
ResourceUnavailable.GetAuthInfoError Failed to get the authentication information.
ResourceUnavailable.InArrears The account is in arrears.
ResourceUnavailable.LowBalance Insufficient balance.
ResourceUnavailable.NotExist The billing status is unknown. Please check whether the service has been activated in the console.
ResourceUnavailable.NotReady The service is not activated.
ResourceUnavailable.Recover The resource has been repossessed.
ResourceUnavailable.StopUsing The service has been suspended for the account.
ResourceUnavailable.UnknownStatus The billing status is unknown.
ResourcesSoldOut.ChargeStatusException The billing status is exceptional.
UnsupportedOperation.UnknowMethod Unknown method name.