kinect : just for fun?
Post on 18-Oct-2014
2.997 views
DESCRIPTION
Slide della sessione "Kinect: Just for fun?" tenutasi all'evento DomusDotNet Live il 13/09/2011.TRANSCRIPT
![Page 1: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/1.jpg)
Kinect : just for fun ?Roma, 13 Settembre 2011
Massimo BonanniSenior Developer @ THAOS s.r.l.
http://codetailor.blogspot.com
http://twitter.com/massimobonanni
![Page 2: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/2.jpg)
2
Agenda• Natural User Interface• Introduzione al Kinect
– Cosa c’è dentro– Architettura
• Kinect SDK– Camera Data– Depth data– Skeletal tracking– Audio
• Q&A (se ce la facciamo )
![Page 3: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/3.jpg)
3
Natural User Interface NUISi definisce NUI l’interfaccia di un sistema in cui gli utenti riescono ad interagire utilizando un approccio «naturale» cioè riescono ad utilizzare le funzionalità del sistema senza l’uso di dispositivi artificiali (come mouse, trackball o tastiera)
![Page 4: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/4.jpg)
4
NUI : Evoluzione delle interfacce
![Page 5: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/5.jpg)
5
NUI : Interfacce CLI
![Page 6: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/6.jpg)
6
NUI : Interfacce GUI
![Page 7: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/7.jpg)
7
NUI : Natural
Touch
Gestures
Voice
Augmented Reality
Touchless
Object Recognition
![Page 8: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/8.jpg)
8
NUI: Vantaggi
• Rapido apprendimento delle funzionalità;
• L’utente è in grado di diventare «esperto» sull’interfaccia in minor tempo;
• Può aiutare portatori di handicap nell’utilizzo del sistema
![Page 9: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/9.jpg)
9
Kinect: Cosa c’è dentro
• Video Camera RGB (640x480 CMOS)• Sensori di profondità: proiettore IR + Camera IR (640x480 CMOS)• Inclinazione motorizzata (±23 gradi)• 4 Microfoni
Video Camera RGB
Batteria MicrofoniInclinazione Motorizzata
Sensori di Profondità (3D)
![Page 10: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/10.jpg)
10
Kinect: Cosa c’è dentro
![Page 11: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/11.jpg)
11
Kinect: Architettura hardware
![Page 12: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/12.jpg)
12
Kinect: Come funziona
Il proiettore ad infrarossi illumina il soggetto con dei pattern
1
La camera infrarossi misura la distanza con un approccio «a luce strutturata»
2
L’SDK è in grado di convertire lo stream della depth cam in dati utilizzabili
3
La nostra applicazione utilizza le info dell’SDK
4
![Page 13: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/13.jpg)
13
Kinect: Cosa serve
Gli ingredienti per un buon fun:• Kinect;• Cavo usb per collegamento a
pc;• Kinect SDK;• DirectX9;• .........tanta fantasia!!!
![Page 14: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/14.jpg)
14
Kinect: Requisiti minimi
• Sistema Operativo – Windows 7 (x86 and x64)
• Hardware– Processore dual-core 2.66GHz o superiore– 2Gb ram– Scheda grafica DiretcX9 o superiore– Kinect con cavo usb per collegamento al pc
• Software– Visual Studio 2010 Express o superiori– .NET Framework 4.0– Runtime DirectX 9– Speech Platform Runtime SDK (solo per l’audio)
![Page 15: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/15.jpg)
15
Kinect: Architettura
L’SDK mette a disposizione una serie di strumenti e una libreria di classi in grado di interagire con i sensori del dispositivo fornendo allo sviluppatore oggetti ed eventi.
![Page 16: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/16.jpg)
16
Kinect: Architettura
Il device restituisce 3 stream:– Video– Depth– Audio
![Page 17: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/17.jpg)
17
Kinect: Architettura
I componenti dell’SDK sono i seguenti:
Video Components Audio Components
Windows components
1
2
35
4
Kernel-mode drivers for Kinect for Windows
DMO codec for mic array
Applications
Kinect for Windows SDK
User-created components
USB Hub
Windows Core Audio and Speech APIs
Device setup
Audio stream controlVideo stream control
WinUSB device stack USBAudio audio stackWinUSB camera stack
Motor Audio mic arrayCameras
NUI APIA/V capture and transcodingMedia Foundation | DirectShow
User Mode
Kernel Mode
Kinect sensor
Hardware
Device access
![Page 18: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/18.jpg)
18
Kinect: Architettura1. Hardware
L’hardware comprende i sensori visti in precedenza è l’hub USB che permette il loro collegamento al pc.
2. Microsoft Kinect drivers :a) Permettono l’accesso all’array di microfoni con le API Audio standard di Windows.b) Forniscono gli stream della video camera e dei sensori di profondità.c) Forniscono la possibilità di utilizzare più device contemporaneamente.
3. NUI APIUn insieme di API che permettono di recuperare i dati dai sensori di immagine e di controllare il device stesso (ad esempio brandeggiare il dispositivo).
4. KinectAudio DMOEstende le funzionalità dell’array di microfoni supportato in Windows 7 per fornire le funzionalità di Beamforming (mappatura sonora dell’area) e localizzazione della sorgente sonora.
5. Windows 7 standard APIsLe API audio, speech e media presenti in Windows 7 e Microsoft Speech.
![Page 19: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/19.jpg)
19
Kinect: La classe Runtime
La classe Runtime permette l’accesso alle funzionalità del Kinect:
![Page 20: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/20.jpg)
20
Kinect: La classe Runtime
La classe Runtime va istanziata e inizializzata:
Nui = New Runtime Nui.Initialize(RuntimeOptions.UseColor)
Funzionalità richieste alla
Runtime
![Page 21: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/21.jpg)
21
Kinect: Camera Data
La classe Runtime mette a disposizione l’evento VideoFrameReady per la gestione dei frame video
Public Event VideoFrameReady(sender As Object,
e As ImageFrameReadyEventArgs)
![Page 22: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/22.jpg)
22
Kinect: ImageFrameReadyEventArgs
![Page 23: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/23.jpg)
23
Kinect: Camera DataPer utilizzare l’evento VideoFrameReady è necessario:
1. Istanziare la classe Runtime;2. Inizializzare la classe Runtime con l’opzione
RuntimeOptions.UseColor;3. Sottoscriversi all’evento VideoFrameReady;4. Aprire lo stream video.Nui = New Runtime Nui.Initialize(RuntimeOptions.UseColor) AddHandler Nui.VideoFrameReady, AddressOf VideoFrameReadyHandler Nui.VideoStream.Open(ImageStreamType.Video, 2,
ImageResolution.Resolution640x480, ImageType.Color)
E’ anche possibile eseguire un polling direttamente sullo stream video.
![Page 24: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/24.jpg)
24
Kinect: Camera Data• Risoluzioni ammesse
– 640x480– 1280x1024
• Numero di bytes per pixel 4 o 2
• Formato immagine:– RGB (pixel da 4 bytes: blu, verde, rosso e alfa)– YUV (pixel da 4 bytes: ciano, magenta, giallo e nero)– YUV-RAW (pixel da 2 bytes: ciano, magenta, giallo e nero,
solo 640x480 15 fps)
![Page 25: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/25.jpg)
25
DemoVideo Camera
![Page 26: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/26.jpg)
26
Kinect: Depth Data
La classe Runtime mette a disposizione l’evento DepthFrameReady per la gestione dei frame di profondità:
Public Event DepthFrameReady(sender As Object,
e As ImageFrameReadyEventArgs)
![Page 27: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/27.jpg)
27
Kinect: Depth DataPer utilizzare l’evento DepthFrameReady è necessario:
1. Istanziare la classe Runtime;2. Inizializzare la classe Runtime con l’opzione
RuntimeOptions.UseDepth o RuntimeOptions.UseDepthAndPlayerIndex;
3. Sottoscriversi all’evento DepthFrameReady;4. Aprire lo stream video.
Nui = New Runtime Nui.Initialize(RuntimeOptions.UseDepth) AddHandler Nui.DepthFrameReady, AddressOf DepthFrameReadyHandler Nui.VideoStream.Open(ImageStreamType.Depth, 2,
ImageResolution.Resolution640x480, ImageType.Depth)
E’ anche possibile eseguire polling direttamente sullo stream di profondità
![Page 28: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/28.jpg)
28
Kinect: Depth Data
• Risoluzioni ammesse– 320x240– 80x60
• Numero di bytes per pixel 2
• Contenuto immagine:– Solo distanza (in millimetri, tra 800mm e 4000mm)– Distanza e player index (player index 1, 2 o 0 se non c’è
un player)
![Page 29: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/29.jpg)
29
Kinect: Depth DataRuntimeOptions.UseDepth
RuntimeOptions.UseDepthAndPlayerIndex
Dim distance(0, 0) = Bits(0) + CLng(Bits(1) << 8)
Dim distance(0, 0) = CLng(Bits(0) >> 3) + CLng(Bits(1) << 8)
![Page 30: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/30.jpg)
30
Kinect: Depth Data
Esempio di UseDepthAndPlayerIndex
![Page 31: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/31.jpg)
31
DemoDepth Data
![Page 32: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/32.jpg)
32
Kinect: Skeletal tracking• L’SDK permette di avere informazioni riguardo la posizione di
alcuni punti del corpo dei player rilevati.• L’algoritmo di skeletal tracking è basato sul «Machine
Learning»• La classe Runtime mette a disposizione l’evento
SkeletonFrameReady per la gestione dei frame di di skeletal tracking:
Public Event SkeletonFrameReady(sender As Object,
e As SkeletonFrameReadyEventArgs)
E’ anche possibile eseguire polling sullo Skeleton Engine esposto dalla Runtime.
![Page 33: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/33.jpg)
33
Kinect: Skeletal tracking
![Page 34: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/34.jpg)
34
Kinect: Skeletal TrackingPer utilizzare l’evento SkeletonFrameReady è necessario:
1. Istanziare la classe Runtime;2. Inizializzare la classe Runtime con l’opzione
RuntimeOptions.UseSkeletalTracking;3. Sottoscriversi all’evento SkeletonFrameReady.
Nui = New RuntimeNui.Initialize(RuntimeOptions.UseSkeletalTracking) AddHandler Nui.SkeletonFrameReady, AddressOf SkeletonFrameReadyHandler
![Page 35: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/35.jpg)
35
Kinect: SkeletonDataLa classe SkeletonData contiene le informazioni sugli «scheletri» dei player rilevati:
– Al massimo due player contemporanei (più altri 4 con informazioni ridotte);
– Ogni «scheletro» può essere Tracked o NotTracked;
– Ogni scheletro prevede un array di 20 Joint ognuno con la propria posizione (x,y,z);
– Ogni Joint può essere Tracked, NotTracked o Inferred (NotTracked è raro).
![Page 36: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/36.jpg)
36
Kinect: Joints• Ogni scheletro ha 20 oggetti Joint che tracciano la posizione del corpo
del player;• La posizione del joint nello spazio è contenuta nella proprietà Position
(di tipo Vector):– X: posizione x (compreso tra -1 e 1);– Y: posizione y (compreso tra -1 e 1);– Z: distanza dal device (in metri).
![Page 37: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/37.jpg)
37
Kinect: Skeletal Tracking
• Il rilevamento dei sensori è affetto da errore (problemi costruttivi, luminosità eccessiva dell’ambiente, rumore visivo e via discorrendo) e i dati restituiti hanno delle fluttuazioni che non sempre sono gradite nelle applicazioni.
• Lo Skeleton Engine esposto dalla Runtime fornisce la possibilità di impostare dei filtri per eliminare il rumore:
Nui.SkeletonEngine.TransformSmooth = True Dim parameters = New TransformSmoothParameters() With {.Smoothing = 1.0F, .Correction = 0.1F, .Prediction = 0.1F, .JitterRadius = 0.05F,.MaxDeviationRadius = 0.05F} _Nui.SkeletonEngine.SmoothParameters = parameters
![Page 38: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/38.jpg)
38
Kinect: Skeletal Tracking
• Smoothing : specifica lo smoothing da applicare. I valori sono compresi tra 0 e 1. Più il valore si avvicia a 1 e più viene applicato il fattore di smoothing;
• Correction : specifica la correzione da apportare ai dati. I valori sono compresi tra 0 e 1. Più piccolo il valore inserito e meno è la correzione sui dati grezzi;
• Prediction : specifica il numero di frame previsti;• Jitter Radius : specifica il raggio di riduzione del jitter (in metri). Ogni
jitter esterno al raggio è riportato nel raggio impostato;• MaximumDeviation Radius : specifica il raggio massimo (in metri) che
i punti filtrati possono deviare rispetto ai dati grezzi
Non esistono dei valori «buoni» da utilizzare, è necessario eseguire delle prove per capire quali sono i più adatti per la specifica applicazione
![Page 39: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/39.jpg)
39
DemoSkeletal Tracking
![Page 40: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/40.jpg)
40
Kinect: Audio
Il device dispone di una batteria di 4 microfoni con delle funzionalità di audio processing hardware:
• Multichannel echo cancellation (MEC)• Sound position tracking• Noise suppression e Noise reduction
![Page 41: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/41.jpg)
41
Kinect: AudioLa classe KinectAudioData permette di :• Configurare le funzionalità del dispositivo:
– FeatureMode: ;– MicArrayMode: ;– ....
• Gestire i parametri di filtro:– AcousticEchoSuppression;– NoiseSuppression;– ....
• Gestire lo stream audio proveniente dai microfoni:– Start();– Stop();– ....
• Capire la provenienza del suono:– SoundSourcePosition;– SoundSourcePositionConfidence;– ....
![Page 42: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/42.jpg)
42
Kinect: Speech Recognition
L’SDK del Kinect si integra perfettamente con lo Speech Platform SDK per implementare voice recognition.
![Page 43: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/43.jpg)
43
DemoBeamforming
![Page 44: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/44.jpg)
44
Q&A (non sparate sul Kinect )
![Page 45: Kinect : Just for fun?](https://reader033.vdocuments.site/reader033/viewer/2022061105/54433945afaf9feb098b48ef/html5/thumbnails/45.jpg)
45
Riferimenti
• Kinect SDK Web Sitehttp://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/default.aspx
• Coding4Fun Kinect Toolkit http://c4fkinect.codeplex.com/
• Kinect Toolbox http://kinecttoolbox.codeplex.com/
• Channel 9 Kinect for Windows SDK Quickstartshttp://dev9.channel9.msdn.com/Series/KinectSDKQuickstarts
• Coding4Fun @ Channel 9http://dev9.channel9.msdn.com/coding4fun/kinect