Freigeben über


FaceClient.DetectAsync Method

Definition

Overloads

DetectAsync(BinaryData, FaceDetectionModel, FaceRecognitionModel, Boolean, IEnumerable<FaceAttributeType>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Int32>, CancellationToken)

Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.

DetectAsync(Uri, FaceDetectionModel, FaceRecognitionModel, Boolean, IEnumerable<FaceAttributeType>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Int32>, CancellationToken)

Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.

DetectAsync(BinaryData, FaceDetectionModel, FaceRecognitionModel, Boolean, IEnumerable<FaceAttributeType>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Int32>, CancellationToken)

Source:
FaceClient.cs

Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.

public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Vision.Face.FaceDetectionResult>>> DetectAsync (BinaryData imageContent, Azure.AI.Vision.Face.FaceDetectionModel detectionModel, Azure.AI.Vision.Face.FaceRecognitionModel recognitionModel, bool returnFaceId, System.Collections.Generic.IEnumerable<Azure.AI.Vision.Face.FaceAttributeType> returnFaceAttributes = default, bool? returnFaceLandmarks = default, bool? returnRecognitionModel = default, int? faceIdTimeToLive = default, System.Threading.CancellationToken cancellationToken = default);
abstract member DetectAsync : BinaryData * Azure.AI.Vision.Face.FaceDetectionModel * Azure.AI.Vision.Face.FaceRecognitionModel * bool * seq<Azure.AI.Vision.Face.FaceAttributeType> * Nullable<bool> * Nullable<bool> * Nullable<int> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Vision.Face.FaceDetectionResult>>>
override this.DetectAsync : BinaryData * Azure.AI.Vision.Face.FaceDetectionModel * Azure.AI.Vision.Face.FaceRecognitionModel * bool * seq<Azure.AI.Vision.Face.FaceAttributeType> * Nullable<bool> * Nullable<bool> * Nullable<int> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Vision.Face.FaceDetectionResult>>>
Public Overridable Function DetectAsync (imageContent As BinaryData, detectionModel As FaceDetectionModel, recognitionModel As FaceRecognitionModel, returnFaceId As Boolean, Optional returnFaceAttributes As IEnumerable(Of FaceAttributeType) = Nothing, Optional returnFaceLandmarks As Nullable(Of Boolean) = Nothing, Optional returnRecognitionModel As Nullable(Of Boolean) = Nothing, Optional faceIdTimeToLive As Nullable(Of Integer) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of IReadOnlyList(Of FaceDetectionResult)))

Parameters

imageContent
BinaryData

The input image binary.

detectionModel
FaceDetectionModel

The 'detectionModel' associated with the detected faceIds. Supported 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default value is 'detection_01'.

recognitionModel
FaceRecognitionModel

The 'recognitionModel' associated with the detected faceIds. Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and 'recognition_02'.

returnFaceId
Boolean

Return faceIds of the detected faces or not. The default value is true.

returnFaceAttributes
IEnumerable<FaceAttributeType>

Analyze and return the one or more specified face attributes in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute analysis has additional computational and time cost.

returnFaceLandmarks
Nullable<Boolean>

Return face landmarks of the detected faces or not. The default value is false.

returnRecognitionModel
Nullable<Boolean>

Return 'recognitionModel' or not. The default value is false.

faceIdTimeToLive
Nullable<Int32>

The number of seconds for the face ID being cached. Supported range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours).

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

imageContent is null.

Remarks

> [!IMPORTANT] > To mitigate potential misuse that can subject people to stereotyping, discrimination, or unfair denial of services, we are retiring Face API attributes that predict emotion, gender, age, smile, facial hair, hair, and makeup. Read more about this decision https://azure.microsoft.com/en-us/blog/responsible-ai-investments-and-safeguards-for-facial-recognition/.

* * No image will be stored. Only the extracted face feature(s) will be stored on server. The faceId is an identifier of the face feature and will be used in "Identify", "Verify", and "Find Similar". The stored face features will expire and be deleted at the time specified by faceIdTimeToLive after the original detection call. * Optional parameters include faceId, landmarks, and attributes. Attributes include headPose, glasses, occlusion, accessories, blur, exposure, noise, mask, and qualityForRecognition. Some of the results returned for specific attributes may not be highly accurate. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Up to 100 faces can be returned for an image. Faces are ranked by face rectangle size from large to small. * For optimal results when querying "Identify", "Verify", and "Find Similar" ('returnFaceId' is true), please use faces that are: frontal, clear, and with a minimum size of 200x200 pixels (100 pixels between eyes). * Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/specify-detection-model * 'detection_02': Face attributes and landmarks are disabled if you choose this detection model. * 'detection_03': Face attributes (mask and headPose only) and landmarks are supported if you choose this detection model. * Different 'recognitionModel' values are provided. If follow-up operations like "Verify", "Identify", "Find Similar" are needed, please specify the recognition model with 'recognitionModel' parameter. The default value for 'recognitionModel' is 'recognition_01', if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/specify-recognition-model.

Applies to

DetectAsync(Uri, FaceDetectionModel, FaceRecognitionModel, Boolean, IEnumerable<FaceAttributeType>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Int32>, CancellationToken)

Source:
FaceClient.cs

Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.

public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Vision.Face.FaceDetectionResult>>> DetectAsync (Uri url, Azure.AI.Vision.Face.FaceDetectionModel detectionModel, Azure.AI.Vision.Face.FaceRecognitionModel recognitionModel, bool returnFaceId, System.Collections.Generic.IEnumerable<Azure.AI.Vision.Face.FaceAttributeType> returnFaceAttributes = default, bool? returnFaceLandmarks = default, bool? returnRecognitionModel = default, int? faceIdTimeToLive = default, System.Threading.CancellationToken cancellationToken = default);
abstract member DetectAsync : Uri * Azure.AI.Vision.Face.FaceDetectionModel * Azure.AI.Vision.Face.FaceRecognitionModel * bool * seq<Azure.AI.Vision.Face.FaceAttributeType> * Nullable<bool> * Nullable<bool> * Nullable<int> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Vision.Face.FaceDetectionResult>>>
override this.DetectAsync : Uri * Azure.AI.Vision.Face.FaceDetectionModel * Azure.AI.Vision.Face.FaceRecognitionModel * bool * seq<Azure.AI.Vision.Face.FaceAttributeType> * Nullable<bool> * Nullable<bool> * Nullable<int> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Vision.Face.FaceDetectionResult>>>
Public Overridable Function DetectAsync (url As Uri, detectionModel As FaceDetectionModel, recognitionModel As FaceRecognitionModel, returnFaceId As Boolean, Optional returnFaceAttributes As IEnumerable(Of FaceAttributeType) = Nothing, Optional returnFaceLandmarks As Nullable(Of Boolean) = Nothing, Optional returnRecognitionModel As Nullable(Of Boolean) = Nothing, Optional faceIdTimeToLive As Nullable(Of Integer) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of IReadOnlyList(Of FaceDetectionResult)))

Parameters

url
Uri

URL of input image.

detectionModel
FaceDetectionModel

The 'detectionModel' associated with the detected faceIds. Supported 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default value is 'detection_01'.

recognitionModel
FaceRecognitionModel

The 'recognitionModel' associated with the detected faceIds. Supported 'recognitionModel' values include 'recognition_01', 'recognition_02', 'recognition_03' or 'recognition_04'. The default value is 'recognition_01'. 'recognition_04' is recommended since its accuracy is improved on faces wearing masks compared with 'recognition_03', and its overall accuracy is improved compared with 'recognition_01' and 'recognition_02'.

returnFaceId
Boolean

Return faceIds of the detected faces or not. The default value is true.

returnFaceAttributes
IEnumerable<FaceAttributeType>

Analyze and return the one or more specified face attributes in the comma-separated string like 'returnFaceAttributes=headPose,glasses'. Face attribute analysis has additional computational and time cost.

returnFaceLandmarks
Nullable<Boolean>

Return face landmarks of the detected faces or not. The default value is false.

returnRecognitionModel
Nullable<Boolean>

Return 'recognitionModel' or not. The default value is false.

faceIdTimeToLive
Nullable<Int32>

The number of seconds for the face ID being cached. Supported range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours).

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

url is null.

Remarks

> [!IMPORTANT] > To mitigate potential misuse that can subject people to stereotyping, discrimination, or unfair denial of services, we are retiring Face API attributes that predict emotion, gender, age, smile, facial hair, hair, and makeup. Read more about this decision https://azure.microsoft.com/en-us/blog/responsible-ai-investments-and-safeguards-for-facial-recognition/.

* * No image will be stored. Only the extracted face feature(s) will be stored on server. The faceId is an identifier of the face feature and will be used in "Identify", "Verify", and "Find Similar". The stored face features will expire and be deleted at the time specified by faceIdTimeToLive after the original detection call. * Optional parameters include faceId, landmarks, and attributes. Attributes include headPose, glasses, occlusion, accessories, blur, exposure, noise, mask, and qualityForRecognition. Some of the results returned for specific attributes may not be highly accurate. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Up to 100 faces can be returned for an image. Faces are ranked by face rectangle size from large to small. * For optimal results when querying "Identify", "Verify", and "Find Similar" ('returnFaceId' is true), please use faces that are: frontal, clear, and with a minimum size of 200x200 pixels (100 pixels between eyes). * Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/specify-detection-model * 'detection_02': Face attributes and landmarks are disabled if you choose this detection model. * 'detection_03': Face attributes (mask and headPose only) and landmarks are supported if you choose this detection model. * Different 'recognitionModel' values are provided. If follow-up operations like "Verify", "Identify", "Find Similar" are needed, please specify the recognition model with 'recognitionModel' parameter. The default value for 'recognitionModel' is 'recognition_01', if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to https://learn.microsoft.com/en-us/azure/ai-services/computer-vision/how-to/specify-recognition-model.

Applies to