# KI - Ansiktsgjenkjenning

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FitaDjGjgsxcq5m1qxN5A%2FAnsiktsgjenkjenning.jpg?alt=media&#x26;token=eb954ec6-0e27-41f0-9864-7c73f88382d0" alt=""><figcaption></figcaption></figure>

### Litt om ansiktsgjenkjenning

Ansiktsgjenkjenning blir ofte brukt som en identifiseringsmetode. Metoden brukes både på strengt bevoktede arenaer hvor få personer har tilgang, og på noe så dagligdags som på vår egen mobiltelefon. Når ulike maskiner kan kjenne igjen ansikter brukes optisk inndata for å analysere et bilde som blir tatt i sanntid. Analysen blir tatt på bakgrunn av ulike trekk og markører i ansiktet vårt.

### Hvordan fungerer dette prosjektet

AI Lens vil registrere om den ser et ansikt eller ikke i sanntid. Om et menneske nærmer seg vil det bli identifisert og en alarm starter

### Du trenger:

Nezha Inventor's Kit V2

[AI Accessories Pack](https://n00b.no/products/ai?_pos=2&_sid=2ed05be22&_ss=r) eller [micro:bit Smart AI Lens Kit](https://n00b.no/products/micro-bit-smart-ai-lens-kit?_pos=1&_sid=2ed05be22&_ss=r)&#x20;

[micro:bit](https://n00b.no/collections/microbit-startpakker/products/bbc-microbit-v2-go)

Fra settene trenger du disse delene:

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FdTkZTbPndtv34ggafW9T%2FKI-%20Ansikt.jpg?alt=media&#x26;token=615a07ed-ca56-4a2d-95e5-df3ef8a271db" alt=""><figcaption></figcaption></figure>

### Monteringsanvisning

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FQ3w04WuoQ0y9OI58X2hV%2FKI01.jpg?alt=media&#x26;token=81a7326e-f56b-4beb-ab95-5f490877cf88" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FGhoauMXJd2TFiSSMcE9f%2FKI02.jpg?alt=media&#x26;token=4a279c74-fc19-46fd-98da-36b4e513691d" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2F38uQxxPx7aqZgl0Inwtn%2FKI03.jpg?alt=media&#x26;token=ac3200d5-a526-4479-9f44-415a9da26a41" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FFN8uyyAizp8UJb7KA13R%2FKI04.jpg?alt=media&#x26;token=a7ccecb7-2563-4850-a5c7-8b092af65efb" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FfnEcifWuKjFuVNjwngWm%2FKI05.jpg?alt=media&#x26;token=883a60da-e478-4062-9f09-cb0b915b2226" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FJeJ2P8EcYF3BaSjS4w9Y%2FKI06.jpg?alt=media&#x26;token=aa42789a-e97a-4ad4-bbd7-1b14a34bd325" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FW8QhuaqSKWu59mGjyACA%2FKI07.jpg?alt=media&#x26;token=390c433c-f1dd-4fe4-a383-e831da1b51fa" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FhHon2zyp4I2LpzZvJSOa%2FKI08.jpg?alt=media&#x26;token=4b4a58df-3a95-46ca-8827-fb7a3590cae0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FqSz7cj1ogrUnOBpdpEFc%2FKI09.jpg?alt=media&#x26;token=f73e77e6-beea-48a7-9077-ceb806ee77b0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FKySoyCAb4YsHdWwVxDbo%2FKI10.jpg?alt=media&#x26;token=3743c6d9-d308-40ed-bddb-5333a55eba7a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FnpDV1fUmmus3X3UoYlP5%2FKI11.jpg?alt=media&#x26;token=d4d4c8d4-a588-4209-82d0-7a022b25b17e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FXrF003uPoSqW4V8zDQVD%2FKI12.jpg?alt=media&#x26;token=d6762491-feb1-4eea-9f0b-b18630ce650a" alt=""><figcaption></figcaption></figure>

### Koblingsskjema

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2Fz97vbzWFQTWot00mCdrh%2Fai-accessories-pack-case-01-02.jpg?alt=media&#x26;token=e5ffecbd-823f-40c7-83b4-aa4c8d255503" alt=""><figcaption></figcaption></figure>

### **Programmering**

Gå til [makecode.microbit.org](https://makecode.microbit.org/) og trykk på “Nytt prosjekt”. Gi prosjektet ditt et navn. Her kaller vi det **KI - Ansiktsgjenkjenning**. Vi må legge til de ekstra kodeblokkene vi trenger for å gjøre dette prosjektet med Nezha Inventor\`s Kit og AI Lens.

For å gjøre dette trykker man på **Utvidelser/ Add Package**. Det åpner seg da en ny meny hvor vi søker etter og velger PlanetX. Utvidelsespakken vil da laste ned og legge seg i menyen til venstre for redigeringsskjermen.

<figure><img src="https://1303565627-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LtUIvZUCPY8Y5RJNJYV%2Fuploads%2FKrwXjL5fTdYoeujKX5Jx%2FKI13.jpg?alt=media&#x26;token=b47f3298-199d-4ccf-a091-fabced2f1b88" alt=""><figcaption></figcaption></figure>

Vi må så lage programmet vårt for å få til det prosjektet vi ønsker. Se eksempelet under

{% embed url="<https://makecode.microbit.org/_8bXHbb4b7Uod>" %}

Trykk på last ned ikonet nederst på siden. Programmet du har laget vil lagre seg som en .Hex fil. Legg merke til hvor du lagrer filen. Når den er lastet ned kan du simpelthen dra den over til micro:bit ikonet i filutforskeren. Micro:bit blinker oransje bak når programmet lastes over, og stopper når den er ferdig. Programmet er umiddelbart klart til å brukes når micro:bit er koblet til strøm.

### Slik virker det

Du har nå laget et program som gjør at AI lens kjenner igjen ansikter. AI lens analyserer fortløpende og sender videre informasjon til micro:bit. Ved gjenkjenning vil Neopixlene lyse opp og det spilles av en alarmtone fra micro:bit.

### **Test**

Overfør programmet til micro:bit og bygg prosjektet slik som bildene viser.  Test ulike objekter og ansikter og se hvordan ansiktsgjenkjenneren din fungerer
