FaceSessionClient.DetectFromSessionImage Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
DetectFromSessionImage(RequestContent, String, String, Nullable<Boolean>, IEnumerable<FaceAttributeType>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Int32>, RequestContext)
- Source:
- FaceSessionClient.cs
[Protocol Method] Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler DetectFromSessionImage(String, Nullable<FaceDetectionModel>, Nullable<FaceRecognitionModel>, Nullable<Boolean>, IEnumerable<FaceAttributeType>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Int32>, CancellationToken) convenience overload with strongly typed models first.
public virtual Azure.Response DetectFromSessionImage (Azure.Core.RequestContent content, string detectionModel = default, string recognitionModel = default, bool? returnFaceId = default, System.Collections.Generic.IEnumerable<Azure.AI.Vision.Face.FaceAttributeType> returnFaceAttributes = default, bool? returnFaceLandmarks = default, bool? returnRecognitionModel = default, int? faceIdTimeToLive = default, Azure.RequestContext context = default);
abstract member DetectFromSessionImage : Azure.Core.RequestContent * string * string * Nullable<bool> * seq<Azure.AI.Vision.Face.FaceAttributeType> * Nullable<bool> * Nullable<bool> * Nullable<int> * Azure.RequestContext -> Azure.Response
override this.DetectFromSessionImage : Azure.Core.RequestContent * string * string * Nullable<bool> * seq<Azure.AI.Vision.Face.FaceAttributeType> * Nullable<bool> * Nullable<bool> * Nullable<int> * Azure.RequestContext -> Azure.Response
Public Overridable Function DetectFromSessionImage (content As RequestContent, Optional detectionModel As String = Nothing, Optional recognitionModel As String = Nothing, Optional returnFaceId As Nullable(Of Boolean) = Nothing, 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 context As RequestContext = Nothing) As Response
Parameters
- content
- RequestContent
The content to send as the body of the request.
- detectionModel
- String
The 'detectionModel' associated with the detected faceIds. Supported 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default value is 'detection_01'. 'detection_03' is recommended since its accuracy is improved on smaller faces (64x64 pixels) and rotated face orientations. Allowed values: "detection_01" | "detection_02" | "detection_03".
- recognitionModel
- String
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'. Allowed values: "recognition_01" | "recognition_02" | "recognition_03" | "recognition_04".
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.
Return face landmarks of the detected faces or not. The default value is false.
Return 'recognitionModel' or not. The default value is false. This is only applicable when returnFaceId = true.
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).
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
content
is null.
Service returned a non-success status code.
Examples
This sample shows how to call DetectFromSessionImage and parse the result.
Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
FaceSessionClient client = new FaceSessionClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
sessionImageId = "aa93ce80-9a9b-48bd-ae1a-1c7543841e92",
});
Response response = client.DetectFromSessionImage(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result[0].GetProperty("faceRectangle").GetProperty("top").ToString());
Console.WriteLine(result[0].GetProperty("faceRectangle").GetProperty("left").ToString());
Console.WriteLine(result[0].GetProperty("faceRectangle").GetProperty("width").ToString());
Console.WriteLine(result[0].GetProperty("faceRectangle").GetProperty("height").ToString());
Applies to
DetectFromSessionImage(String, Nullable<FaceDetectionModel>, Nullable<FaceRecognitionModel>, Nullable<Boolean>, IEnumerable<FaceAttributeType>, Nullable<Boolean>, Nullable<Boolean>, Nullable<Int32>, CancellationToken)
- Source:
- FaceSessionClient.cs
Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.
public virtual Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Vision.Face.FaceDetectionResult>> DetectFromSessionImage (string sessionImageId, Azure.AI.Vision.Face.FaceDetectionModel? detectionModel = default, Azure.AI.Vision.Face.FaceRecognitionModel? recognitionModel = default, bool? returnFaceId = default, 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 DetectFromSessionImage : string * Nullable<Azure.AI.Vision.Face.FaceDetectionModel> * Nullable<Azure.AI.Vision.Face.FaceRecognitionModel> * Nullable<bool> * seq<Azure.AI.Vision.Face.FaceAttributeType> * Nullable<bool> * Nullable<bool> * Nullable<int> * System.Threading.CancellationToken -> Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Vision.Face.FaceDetectionResult>>
override this.DetectFromSessionImage : string * Nullable<Azure.AI.Vision.Face.FaceDetectionModel> * Nullable<Azure.AI.Vision.Face.FaceRecognitionModel> * Nullable<bool> * seq<Azure.AI.Vision.Face.FaceAttributeType> * Nullable<bool> * Nullable<bool> * Nullable<int> * System.Threading.CancellationToken -> Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.AI.Vision.Face.FaceDetectionResult>>
Public Overridable Function DetectFromSessionImage (sessionImageId As String, Optional detectionModel As Nullable(Of FaceDetectionModel) = Nothing, Optional recognitionModel As Nullable(Of FaceRecognitionModel) = Nothing, Optional returnFaceId As Nullable(Of Boolean) = Nothing, 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 Response(Of IReadOnlyList(Of FaceDetectionResult))
Parameters
- sessionImageId
- String
Id of session image.
- detectionModel
- Nullable<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'. 'detection_03' is recommended since its accuracy is improved on smaller faces (64x64 pixels) and rotated face orientations.
- recognitionModel
- Nullable<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'.
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.
Return face landmarks of the detected faces or not. The default value is false.
Return 'recognitionModel' or not. The default value is false. This is only applicable when returnFaceId = true.
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
sessionImageId
is null.
Examples
This sample shows how to call DetectFromSessionImage.
Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
FaceSessionClient client = new FaceSessionClient(endpoint, credential);
Response<IReadOnlyList<FaceDetectionResult>> response = client.DetectFromSessionImage("aa93ce80-9a9b-48bd-ae1a-1c7543841e92");
Remarks
Please refer to https://video2.skills-academy.com/rest/api/face/face-detection-operations/detect-from-session-image-id for more details.