You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/Face/Face-API-How-to-Topics/how-to-use-headpose.md
+25-10Lines changed: 25 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,28 @@
1
1
---
2
-
title: Use HeadPose to adjust the face rectangle
2
+
title: Use the HeadPose attribute
3
3
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.
5
5
author: PatrickFarley
6
6
manager: nitinme
7
7
8
8
ms.service: cognitive-services
9
9
ms.subservice: face-api
10
-
ms.topic: conceptual
11
-
ms.date: 04/26/2019
10
+
ms.topic: sample
11
+
ms.date: 05/29/2019
12
12
ms.author: pafarley
13
13
---
14
14
15
-
# Use the HeadPose attribute to adjust the face rectangle
15
+
# Use the HeadPose attribute
16
16
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.
18
18
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
20
20
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
22
26
23
27
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.
24
28
@@ -98,7 +102,7 @@ public static IEnumerable<Face> CalculateFaceRectangleForRendering(IList<Detecte
98
102
}
99
103
```
100
104
101
-
## Display the updated rectangle
105
+
###Display the updated rectangle
102
106
103
107
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:
104
108
@@ -112,6 +116,17 @@ From here, you can use the returned **Face** objects in your display. The follow
112
116
</DataTemplate>
113
117
```
114
118
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
+
115
130
## Next steps
116
131
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.
0 commit comments