|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: "Microsoft Face" |
| 4 | +description: "Instructions how to integrate Microsoft Face component into Home Assistant." |
| 5 | +date: 2017-01-25 00:00 |
| 6 | +sidebar: true |
| 7 | +comments: false |
| 8 | +sharing: true |
| 9 | +footer: true |
| 10 | +logo: microsoft.png |
| 11 | +ha_category: Hub |
| 12 | +ha_release: "0.37" |
| 13 | +--- |
| 14 | + |
| 15 | +The `microsoft_face` component platform is the main component for Microsoft Azure Cognitive service [Face](https://www.microsoft.com/cognitive-services/en-us/face-api). All data are in a own private instance in the azure cloud. |
| 16 | + |
| 17 | +You need an API key which is free but requires a [Azure registration](https://azure.microsoft.com/de-de/free/) with your microsoft ID. The free resource (*F0*) is limit to 30K request in a month and 20 per minute. If you don't want use a azure cloud, you can also get a API key with registration on [cognitive-services](https://www.microsoft.com/cognitive-services/en-us/subscriptions) but they need to recreate all 90 days. |
| 18 | + |
| 19 | +To enable the Microsoft Face component, add the following lines to your `configuration.yaml`: |
| 20 | + |
| 21 | +```yaml |
| 22 | +# Example configuration.yaml entry |
| 23 | +microsoft_face: |
| 24 | + api_key: YOUR_API_KEY |
| 25 | +``` |
| 26 | +
|
| 27 | +Configuration variables: |
| 28 | +
|
| 29 | +- **api_key** (*Required*): The API key for your Cognitive resource. |
| 30 | +- **timeout** (*Optional)*: Set timeout for api connection (default 10sec). |
| 31 | +
|
| 32 | +### {% linkable_title Person and Groups %} |
| 33 | +
|
| 34 | +For most of service you need set a group or a person. So it process and detect only stuff they will given with this group. Home-Assistent create for all group a entity and allow your to show the state, person and IDs inside UI. |
| 35 | +
|
| 36 | +For manage this feature you have following services they can call with UI, script or rest api. |
| 37 | +
|
| 38 | +- *microsoft_face.create_group* |
| 39 | +- *microsoft_face.delete_group* |
| 40 | +```yaml |
| 41 | +service: microsoft_face.create_group |
| 42 | +data: |
| 43 | + name: 'Family' |
| 44 | +``` |
| 45 | +
|
| 46 | +- *microsoft_face.create_person* |
| 47 | +- *microsoft_face.delete_person* |
| 48 | +```yaml |
| 49 | +service: microsoft_face.create_person |
| 50 | +data: |
| 51 | + group: family |
| 52 | + name: 'Hans Maier' |
| 53 | +``` |
| 54 | +
|
| 55 | +We need add image to a person. We can add multiple image for every person to make the detection better. We can take a picture from a camera or send a local image to our azure resource. |
| 56 | +
|
| 57 | +- *microsoft_face.face_person* |
| 58 | +```yaml |
| 59 | +service: microsoft_face.face_person |
| 60 | +data: |
| 61 | + group: family |
| 62 | + name: 'Hans Maier' |
| 63 | + camera_entity: camera.door |
| 64 | +``` |
| 65 | +
|
| 66 | +For the local image we need *curl*. The personId is present in group entity as attribute. |
| 67 | +
|
| 68 | +```bash |
| 69 | +curl -v -X POST "https://westus.api.cognitive.microsoft.com/face/v1.0/persongroups/{GroupName}/persons/{personId}/persistedFaces" -H "Ocp-Apim-Subscription-Key: {ApiKey}" -H "Content-Type: application/octet-stream" --data "@/tmp/image.jpg" |
| 70 | +``` |
| 71 | +
|
| 72 | +After we done with changes on a group, we need train this group to make our AI fit to handle the new data. |
| 73 | +
|
| 74 | +- *microsoft_face.train_group* |
| 75 | +```yaml |
| 76 | +service: microsoft_face.train_group |
| 77 | +data: |
| 78 | + group: family |
0 commit comments