El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Face Retrieval

Updated on 2023-04-25 GMT+08:00

Function

This API is used to search an existing facial image library for one or more faces similar to the input face, and return corresponding confidence levels.

You can input an image or face ID to retrieve faces. If multiple facial images are input, the largest face detected in the images is used for retrieval.

Prerequisites:

Ensure that you have enabled FRS. For detailed operations, see Applying for FRS.

Restrictions:
  • Only images in JPG, PNG, JPEG, or BMP format can be recognized.
  • Use standard JSON format in the body of the application/json request.
  • Do not use carriage return characters in Base64 code.
  • The system does not save images of users.
  • The image size must be less than 8 MB. If the image is too large, the latency is long and the image information volume is small. It is recommended that the image size be less than 1 MB.
  • The image resolution must be less than 4,096 x 2,160. The face resolution in an image must be greater than 80 x 80. It is recommended that the face resolution be greater than 120 x 120.
  • To ensure the recognition effect, facial images need to meet the following requirements:
    1. The illumination should be greater than 200 lux and there is no light reflection or shadow caused by strong light.
    2. The overall image is clear without obvious motion blur and the face in it is not blocked.
    3. The side face angle does not exceed 30°, and the tilt angle and horizontal angle do not exceed 15°. The face in an image must be a vertically placed front face.
  • For details about other restrictions, see Restrictions and Limitations.
Suggestions:
  • A larger image does not significantly improve the recognition algorithm precision but will cause a long latency. Therefore, you are advised to upload an image smaller than 1 MB. Generally, 500 KB is enough.
  • It is recommended that the size of an image stored on OBS be less than 1 MB.
  • It is recommended that the face resolution in an image be greater than 120 x 120.

URI

POST /v2/{project_id}/face-sets/{face_set_name}/search

Table 1 Path parameters

Parameter

Type

Mandatory

Description

project_id

String

Yes

Project ID. For details about how to obtain the ID, see Obtaining the Project ID/Account Name/AK/SK.

face_set_name

String

Yes

Name of a facial image library.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

During API authentication using a token, the token is added to requests to obtain permissions for calling the API. The value of X-Subject-Token in the response header is the obtained token.

Content-Type

Yes

String

MIME type of the request body. The value is application/json.

Table 3 Request body parameters

Parameter

Type

Mandatory

Description

image_url

String

Either image_url, image_file, image_base64, or face_id is mandatory.

Image URL. Currently, only the URL of an OBS bucket on Huawei Cloud is supported and FRS must have the permission to read data in the OBS bucket. For details about how to enable the read permission, see Service Authorization.

image_file

File

Either image_file, image_url, image_base64, or face_id is mandatory.

Local image file, whose size cannot exceed 8 MB. It is recommended that the image size be less than 1 MB. The request format is Multipart.

image_base64

String

Either image_base64, image_url, image_file, or face_id is mandatory.

Image data (Base64-encoded). The value must meet the following requirements:
  • The image size after Base64 encoding cannot exceed 8 MB. It is recommended that the image size be less than 1 MB.
  • The image is in JPG, JPEG, BMP, or PNG format.

face_id

String

Either face_id, image_url, image_file, or image_base64 is mandatory.

Face ID returned by the system after a face is imported

top_n

Integer

No

N faces returned that are most similar to the input one. The default value of N is 10.

The returned faces are sorted by confidence in descending order.

threshold

Double

No

Face similarity threshold. If the similarity degree of a face is lower than the threshold, the face is not returned. The value ranges from 0 to 1. The recommended value is 0.93. The default value is 0.

sort

JSONArray

No

Field sorting. For details, see Sort Syntax.

filter

String

No

Filtering criteria. For details, see Filter Syntax.

return_fields

JsonArray

No

Returned customized field.

Response Parameters

Status code: 200

Table 4 Response body parameter

Parameter

Type

Description

faces

Array of SearchFace objects

Face set to be retrieved. For details, see SearchFace.

Table 5 SearchFace

Parameter

Type

Description

bounding_box

BoundingBox object

Position of a face in an image

similarity

Double

Similarity degree in Face Retrieval

external_fields

Object

Additional field a user customizes

external_image_id

String

ID of the external image to which a face belongs

face_id

String

Face ID, which is a unique ID generated by the system

Table 6 BoundingBox

Parameter

Type

Description

width

Integer

Width of a rectangle

top_left_y

Integer

Vertical coordinate of the upper-left corner of a rectangle

top_left_x

Integer

Horizontal coordinate of the upper-left corner of a rectangle

height

Integer

Height of a rectangle

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code when calling the API failed. This parameter is not included when the API is successfully called.

error_msg

String

Error message returned after the API fails to be called. This parameter is not included when the API is successfully called.

Example Requests

For details about how to obtain the value of X-Auth-Token, see Authentication.

  • Example request (Method 1: Use a Base64-encoded image.)
    POST https://{endpoint}/v2/{project_id}/face-sets/showFaceSet/search
    Request Header:
    Content-Type: application/json
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDT...
    
    Request Body:
    {
      "image_base64": "/9j/4AAQSkZJRgABAgEASABIAAD",
      "sort" : [
        {
          "timestamp" : "asc"
        } 
      ],
      "return_fields" : ["timestamp", "id"],
      "filter" : "timestamp:12"
    }
  • Example request (Method 2: Use an image file.)
    POST https://{endpoint}/v2/{project_id}/face-sets/showFaceSet/search
    Request Header:
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDT...
    
    Request Body:
    image_file: File (image file)
    return_fields: ["timestamp","id"]
    filter: timestamp:12
  • Example request (Method 3: Use the image URL.)
    POST https://{endpoint}/v2/{project_id}/face-sets/showFaceSet/search
    Request Header:
    Content-Type: application/json
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDT...
    
    Request Body:
    {
      "image_url":"/BucketName/ObjectName",
      "sort" : [
        {
          "timestamp" : "asc"
        } 
      ],
      "return_fields" : ["timestamp", "id"],
      "filter" : "timestamp:12"
    }
  • Example request (Method 4: Use the face ID.)
    POST https://{endpoint}/v2/{project_id}/face-sets/showFaceSet/search
    Request Header: 
    Content-Type: application/json 
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDT... 
    
    Request Body: 
    { 
      "face_id":"6KLB1Ktu", 
      "sort" : [ 
        { 
          "timestamp" : "asc" 
        }  
      ], 
      "return_fields" : ["timestamp", "id"], 
      "filter" : "timestamp:12" 
    }

Example Responses

Status code: 200

Response example (successful request)
{
  "faces": [
    {
      "bounding_box": {
        "width": 170,
        "top_left_y": 37,
        "top_left_x": 20,
        "height": 170
      },
      "similarity": 0.996146,
      "external_image_id": "123",
      "external_fields": {
        "id": "home",
        "timestamp": 12
      },
      "face_id": "6KLB1Ktu"
    },
    {
      "bounding_box": {
        "width": 170,
        "top_left_y": 37,
        "top_left_x": 20,
        "height": 170
      },
      "similarity": 0.996146,
      "external_image_id": "12",
      "external_fields": {
        "id": "home1",
        "timestamp": 12
      },
      "face_id": "PexOpqRj"
    }
  ]
}

Status code: 400

Example response (failed request)
{
  "error_code": "FRS.0018",
  "error_msg": "The service inner error."
}

Status Code

For details about the status code, see Status Codes.

Error Code

For details about the error code, see Error Codes.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback