Skip to content

Commit 2f8a2fa

Browse files
authored
Merge pull request #78226 from PatrickFarley/face-headpose-add
[cog serv] Face headpose add
2 parents 975e1f4 + 68cad8a commit 2f8a2fa

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

articles/cognitive-services/Face/Face-API-How-to-Topics/how-to-use-headpose.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
---
2-
title: Use HeadPose to adjust the face rectangle
2+
title: Use the HeadPose attribute
33
titleSuffix: Azure Cognitive Services
4-
description: Learn how to use the HeadPose attribute to automatically rotate the face rectangle.
4+
description: Learn how to use the HeadPose attribute to automatically rotate the face rectangle or detect head gestures in a video feed.
55
author: PatrickFarley
66
manager: nitinme
77

88
ms.service: cognitive-services
99
ms.subservice: face-api
10-
ms.topic: conceptual
11-
ms.date: 04/26/2019
10+
ms.topic: sample
11+
ms.date: 05/29/2019
1212
ms.author: pafarley
1313
---
1414

15-
# Use the HeadPose attribute to adjust the face rectangle
15+
# Use the HeadPose attribute
1616

17-
In this guide, you will use a detected face attribute, HeadPose, to rotate the rectangle of a Face object. The sample code in this guide, from the [Cognitive Services Face WPF](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/tree/master/app-samples/Cognitive-Services-Face-WPF) sample app, uses the .NET SDK.
17+
In this guide, you'll see how you can use the HeadPose attribute of a detected face to enable some key scenarios.
1818

19-
The face rectangle, returned with every detected face, marks the location and size of the face in the image. By default, the rectangle is always aligned with the image (its sides are perfectly vertical and horizontal); this can be inefficient for framing angled faces. In situations where you want to programmatically crop faces in an image, it is advantageous to be able to rotate the rectangle to crop.
19+
## Rotate the face rectangle
2020

21-
## Explore the sample code
21+
The face rectangle, returned with every detected face, marks the location and size of the face in the image. By default, the rectangle is always aligned with the image (its sides are vertical and horizontal); this can be inefficient for framing angled faces. In situations where you want to programmatically crop faces in an image, it's better to be able to rotate the rectangle to crop.
22+
23+
The [Cognitive Services Face WPF](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/tree/master/app-samples/Cognitive-Services-Face-WPF) sample app uses the HeadPose attribute to rotate its detected face rectangles.
24+
25+
### Explore the sample code
2226

2327
You can programmatically rotate the face rectangle by using the HeadPose attribute. If you specify this attribute when detecting faces (see [How to detect faces](HowtoDetectFacesinImage.md)), you will be able to query it later. The following method from the [Cognitive Services Face WPF](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/tree/master/app-samples/Cognitive-Services-Face-WPF) app takes a list of **DetectedFace** objects and returns a list of **[Face](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/blob/master/app-samples/Cognitive-Services-Face-WPF/Sample-WPF/Controls/Face.cs)** objects. **Face** here is a custom class that stores face data, including the updated rectangle coordinates. New values are calculated for **top**, **left**, **width**, and **height**, and a new field **FaceAngle** specifies the rotation.
2428

@@ -98,7 +102,7 @@ public static IEnumerable<Face> CalculateFaceRectangleForRendering(IList<Detecte
98102
}
99103
```
100104

101-
## Display the updated rectangle
105+
### Display the updated rectangle
102106

103107
From here, you can use the returned **Face** objects in your display. The following lines from [FaceDetectionPage.xaml](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/blob/master/app-samples/Cognitive-Services-Face-WPF/Sample-WPF/Controls/FaceDetectionPage.xaml) show how the new rectangle is rendered from this data:
104108

@@ -112,6 +116,17 @@ From here, you can use the returned **Face** objects in your display. The follow
112116
</DataTemplate>
113117
```
114118

119+
## Detect head gestures
120+
121+
You can detect head gestures like nodding and head shaking by tracking HeadPose changes in real time. You can use this feature as a custom liveness detector.
122+
123+
Liveness detection is the task of determining that a subject is a real person and not an image or video representation. A head gesture detector could serve as one way to help verify liveness, especially as opposed to an image representation of a person.
124+
125+
> [!CAUTION]
126+
> To detect head gestures in real time, you'll need to call the Face API at a high rate (more than once per second). If you have a free-tier (f0) subscription, this will not be possible. If you have a paid-tier subscription, make sure you've calculated the costs of making rapid API calls for head gesture detection.
127+
128+
See the [Face API HeadPose Sample](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/tree/master/app-samples/FaceAPIHeadPoseSample) on GitHub for a working example of head gesture detection.
129+
115130
## Next steps
116131

117-
See the [Cognitive Services Face WPF](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/tree/master/app-samples/Cognitive-Services-Face-WPF) app on GitHub for a working example of rotated face rectangles. Or, see the [Face API HeadPose Sample](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/tree/master/app-samples) app, which tracks the HeadPose attribute in real time to detect various head movements (nodding, shaking).
132+
See the [Cognitive Services Face WPF](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/tree/master/app-samples/Cognitive-Services-Face-WPF) app on GitHub for a working example of rotated face rectangles. Or, see the [Face API HeadPose Sample](https://github.com/Azure-Samples/cognitive-services-dotnet-sdk-samples/tree/master/app-samples) app, which tracks the HeadPose attribute in real time to detect head movements.

articles/cognitive-services/Face/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
href: Face-API-How-to-Topics/HowtoIdentifyFacesinImage.md
6060
- name: Add faces
6161
href: Face-API-How-to-Topics/how-to-add-faces.md
62-
- name: Use HeadPose to rotate rectangle
62+
- name: Use the HeadPose attribute
6363
href: Face-API-How-to-Topics/how-to-use-headpose.md
6464
- name: Specify a face recognition model
6565
href: Face-API-How-to-Topics/specify-recognition-model.md

0 commit comments

Comments
 (0)