SlideShare a Scribd company logo
Introduction to Kinect v2
Tsukasa Sugiura
@UnaNancyOwen
Self-Introduction
Tsukasa Sugiura
Microsoft MVP for Kinect for Windows
 @UnaNancyOwen
 http://UnaNancyOwen.com
 t.sugiura0204@gmail.com
(July 2014 - June 2015)
Agenda
 What is Kinect v2
 Specifications
 New Features
 Demo
 Tutorial
Disclaimer
“This is preliminary software and/or hardware and APIs
are preliminary and subject to change.”
(Kinect for Windows v2は暫定的なものであり、ソフトウェア、ハード
ウェア、およびAPIは製品版で変更される可能性があります。)
Kinect for Windows v1 Sensor
MULTI-ARRAY MIC MOTORIZED TILT
3D DEPTH SENSORS
RGB CAMERA
Kinect for Windows v2 Sensor
MULTI-ARRAY MIC
3D DEPTH SENSOR
( IR Camera + IR Emitters )
RGB CAMERA
Kinect for Windows v2 Sensor
Image by iFixit
IR EMITTERS
IR CAMERA
Specifications
Kinect for Windows v1 Kinect for Windows v2
Color 640×480 @ 30fps 1920×1080 @ 30fps
Depth 320×240 @ 30fps 512×424 @ 30fps
Sensor Structured Light
(PrimeSense Light Coding)
Time of Flight
(ToF)
Range 0.8~4.0 m 0.5~4.5 m
Angle of View
Horizontal / Vertical
57 / 43 degree 70 / 60 degree
Microphone Array ◯ ◯
Specifications
Kinect for Windows v1 Kinect for Windows v2
BodyIndex 6 people 6 people
Body 2 people 6 people
Joint 20 joint/people 25 joint/people
Hand State Open / Closed Open / Closed / Lasso
Gesture ☓ ◯
Face ◯
Speech / Beamforming ◯ ◯
Basic Features
 Color
 1920×1080@30fps / 15fps (Lighting Condition)
 RGBA, YUV, BGRA, Bayer, YUY2
Basic Features
 Depth
 512×424@30fps
 500~4500[mm]
 ToF (Time of Flight)
Basic Features
 Infrared / LongExposureInfrared
 512×424@30fps
 16bit (higher 8 bits)
Basic Features
 BodyIndex
 512×424@30fps
 6 people
 Body Area : 0~5, Other Area : 255 (5 < Index)
255
0 1
Basic Features
 Body
 6 people
 25 joint / people (Add Tip, Thumb, Neck)
 Orientation (Quaternion)
 Hand Type (Right, Left),Hand State (Open, Closed, Lasso), Lean (-1.0f~1.0f)
Basic Features
 Audio
 Beamforming (+/-50 degree)
 Speaker Estimation
 Speech Recognition
Application Features
 Gesture
 Gesture Recognition using Machine Learning
 Discrete (detected true/false), Continuous (progress 0.0f~1.0f)
 Learning Classifier Tool “Visual Gesture Builder”
Video by http://youtu.be/-XYoblrnDpg
Application Features
 Face
 Bounding Box, Rotation, Points (Eye, Nose, Mouth Corner)
 Activity, Appearance, Expression
 Activity … Eye Closed, Mouth Open / Moved, Looking Away
 Appearance … Wearing Glasses
 Expression … Happy
Application Features
 HDFace
 For Creating 3D Face Model
 Points (1347), Triangles (2340), Hair Color, Skin Color
 Fitting Face Model
Application Features
 Other
 Kinect Fusion (3D Shape Reconstruction)
 Controls (Assist in implementation of NUI)
Demo
System / Software Requirements
OS * Windows 8, 8.1, Embedded 8, Embedded 8.1 (x64)
CPU Intel Core i7 3.1GHz (or higher)
RAM 4GB (or more)
GPU * DirectX 11 supported
USB * USB 3.0 (Intel or Renesas Host Controller)
Compiler * Visual Studio 2012, 2013 (Supported Express)
Language Native (C++), Managed (C#,VB.NET), WinRT (C#,HTML)
Other Unity Pro (Add-in), Cinder, openFrameworks (wrapper)
Connection
Kinect for Windows v1 Kinect for Windows v2
PCPC
Example Multiple Connection
PCPC PC
Hub
Server
System
Kinect
Driver
Kinect SDK
Application
Kinect
Driver
Kinect SDK
Application
Kinect
Service
Kinect SDK
Application
Kinect SDK
Application
Kinect for Windows v1 Kinect for Windows v2
Tutorial
 Basic Flow of Programming (C++)
Sensor Stream Frame Data
Sensor Source Reader Frame Data
Kinect for Windows SDK v1
Kinect for Windows SDK v2
 Source independent to each Data
(e.g. ColorSource, DepthSource, InfraredSource, BodyIndexSource, BodySource, …)
 Doesn’t depend on each other Source
(e.g. Doesn't need to Depth Source when retrieve Body Data)
Tutorial
 Sensor
Sensor Source Reader Frame Data
// Sensor
IKinectSensor* pSensor;
HRESULT hResult = S_OK;
hResult = GetDefaultKinectSensor( &pSensor );
if( FAILED( hResult ) ){
std::cerr << "Error : GetDefaultKinectSensor" << std::endl;
return -1;
}
hResult = pSensor->Open();
if( FAILED( hResult ) ){
std::cerr << "Error : IKinectSensor::Open()" << std::endl;
return -1;
}
 IKinectSensor
Tutorial
 Source
Sensor Source Reader Frame Data
// Source
I***FrameSource* pSource;
hResult = pSensor->get_***FrameSource( &pSource );
if( FAILED( hResult ) ){
std::cerr << "Error : IKinectSensor::get_FrameSource()" << std::endl;
return -1;
}
 IColorFrameSource
 IDepthFrameSource
 IInfraredFrameSource
 IBodyIndexFrameSource
 IBodyFrameSource
Tutorial
 Reader
Sensor Source Reader Frame Data
// Reader
I***FrameReader* pReader;
hResult = pSource->OpenReader( &pReader );
if( FAILED( hResult ) ){
std::cerr << "Error : IFrameSource::OpenReader()" << std::endl;
return -1;
}
 IColorFrameReader
 IDepthFrameReader
 IInfraredFrameReader
 IBodyIndexFrameReader
 IBodyFrameReader
Tutorial
 Frame
Sensor Source Reader Frame Data
while( 1 ){
// Frame
I***Frame* pFrame = nullptr;
hResult = pReader->AcquireLatestFrame( &pFrame );
if( SUCCEEDED( hResult ) ){
/* Data */
}
SafeRelease( pFrame );
}
 IColorFrame
 IDepthFrame
 IInfraredFrame
 IBodyIndexFrame
 IBodyFrame
Tutorial
 Data (Depth, Infrared, BodyIndex)
Sensor Source Reader Frame Data
while( 1 ){
// Frame
IDepthFrame* pDepthFrame = nullptr;
hResult = pDepthReader->AcquireLatestFrame( &pDepthFrame );
if( SUCCEEDED( hResult ) ){
unsigned int bufferSize = 0;
unsigned short* pBuffer = nullptr;
hResult = pDepthFrame->AccessUnderlyingBuffer( &bufferSize, &pBuffer );
if( SUCCEEDED( hResult ) ){
/* Processing*/
}
}
SafeRelease( pDepthFrame );
}
 Depth, Infrared … unsigned short
 BodyIndex … unsigned char
Tutorial
 Data (Color)
Sensor Source Reader Frame Data
while( 1 ){
// Frame
IColorFrame* pColorFrame = nullptr;
hResult = pColorReader->AcquireLatestFrame( &pColorFrame );
if( SUCCEEDED( hResult ) ){
unsigned int bufferSize = 0;
unsigned char* pBuffer = nullptr;
hResult = pColorFrame->AccessUnderlyingBuffer( &bufferSize, &pBuffer );
if( SUCCEEDED( hResult ) ){
/* Processing*/
}
}
SafeRelease( pColorFrame );
}
 Color … unsigned char
 Default Color Image Format … YUY2
Tutorial
 Data (Color with Converted Format)
Sensor Source Reader Frame Data
unsigned int buffeerSize = width * height * channel * sizeof(unsigned char);
unsigned char* pBuffer = new unsigned char[bufferSize];
while( 1 ){
// Frame
IColorFrame* pColorFrame = nullptr;
hResult = pReader->AcquireLatestFrame( &pColorFrame );
if( SUCCEEDED( hResult ) ){
hResult = pColorFrame->CopyConvertedFrameDataToArray( bufferSize, pBuffer,
ColorImageFormat::ColorImageFormat_Bgra );
if( SUCCEEDED( hResult ) ){
/* Processing */
}
}
SafeRelease( pColorFrame );
}
delete[] pBuffer;
Tutorial
Sensor Source Reader Frame Data
while( 1 ){
IBodyFrame* pFrame = nullptr;
hResult = pBodyReader->AcquireLatestFrame( &pBodyFrame );
if( SUCCEEDED( hResult ) ){
IBody* pBody[BODY_COUNT] = { 0 };
hResult = pBodyFrame->GetAndRefreshBodyData( BODY_COUNT, pBody );
if( SUCCEEDED( hResult ) ){
/* Processing */
}
for( int count = 0; count < BODY_COUNT; count++ ){
SafeRelease( pBody[count] );
}
}
SafeRelease( pBodyFrame );
}
 Data (Body)
Tutorial
Sensor Source Reader Frame Data
for( int count = 0; count < BODY_COUNT; count++ ){
BOOLEAN bTracked = false;
hResult = pBody[count]->get_IsTracked( &bTracked );
if( SUCCEEDED( hResult ) && bTracked ){
Joint joint[JointType::JointType_Count];
hResult = pBody[count]->GetJoints( JointType::JointType_Count, joint );
if( SUCCEEDED( hResult ) ){
for( int type = 0; type < JointType::JointType_Count; type++ ){
if( joint[type].TrackingState != TrackingState::TrackingState_NotTracked ){
CameraSpacePoint cameraSpacePoint = joint[type].Position;
cameraSpacePoint.x; // x (+/- 1.0f)
cameraSpacePoint.y; // y (+/- 1.0f)
cameraSpacePoint.z; // z (500~4500[mm])
}
}
}
}
}
 Data (Joint)
Tutorial
 Coordinate System
 ColorSpace (Coordinate System of the Color Image)
… Color
 DepthSpace (Coordinate System of the Depth Data)
… Depth, Infrared, BodyIndex
 CameraSpace (Coordinate System with the origin located the Depth Sensor)
… Body (Joint)
Tutorial
 Coordinate Mapper
// Coordinate Mapper
ICoordinateMapper* pCoordinateMapper;
hResult = pSensor->get_CoordinateMapper( &pCoordinateMapper );
if( FAILED( hResult ) ){
std::cerr << "Error : IKinectSensor::get_CoordinateMapper()" << std::endl;
return -1;
}
 ICoordinateMapper::Map○○○FrameTo△△△Space()
… Mapping Coordinate System in the Frame
 ICoordinateMapper::Map○○○PointsTo△△△Space()
… Mapping Coordinate System in the Array of Points
 ICoordinateMapper::Map○○○PointTo△△△Space()
… Mapping Coordinate System in the Point
Reference
 Sample Program
 Kinect2Sample | GitHub
https://github.com/UnaNancyOwen/Kinect2Sample
 Article Series
 Introduction to Kinect for Windows v2 | Build Insider
http://www.buildinsider.net/small/kinectv2cpp
 Blog
 Kinect | Summary?Blog
http://unanancyowen.com/?cat=3

More Related Content

DOCX
Computer science project work
PDF
06_게임엔진구성
PPTX
Khronos Munich 2018 - Halcyon and Vulkan
PPTX
Graphics Output Hardware Devices
PPTX
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
PPTX
Chet deewan's ppt
PDF
Computer Graphics - Lecture 01 - 3D Programming I
PPTX
shivkumar pathak web based manufacturing presentation
Computer science project work
06_게임엔진구성
Khronos Munich 2018 - Halcyon and Vulkan
Graphics Output Hardware Devices
A Certain Slant of Light - Past, Present and Future Challenges of Global Illu...
Chet deewan's ppt
Computer Graphics - Lecture 01 - 3D Programming I
shivkumar pathak web based manufacturing presentation

What's hot (20)

PPTX
Sixth sense technology ppt
PPTX
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
PPTX
第10回FA設備技術勉強会 M5Stackで始める業務のデジタル化
PPTX
Tetris Algorithm
PDF
LISA17 Container Performance Analysis
PPTX
FrameGraph: Extensible Rendering Architecture in Frostbite
PDF
Lecture 4: VR Systems
PDF
Introduction to Extended Reality - XR
PDF
Inside Android's UI
PDF
【Unite Tokyo 2019】大量のオブジェクトを含む広いステージでも大丈夫、そうDOTSならね
DOCX
Virtual keyboard abstract
PDF
COMP 4010 - Lecture 1: Introduction to Virtual Reality
PDF
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
PDF
圏とHaskellの型
PPT
Input devices in computer graphics
ODP
Imprimante 3d presentation
PDF
Python Project on Computer Shop
PDF
How to use KASAN to debug memory corruption in OpenStack environment- (2)
PDF
COMP 4010 - Lecture 7: Introduction to Augmented Reality
PPTX
Neil Sarkar (AdHawk Microsystems): Ultra-Fast Eye Tracking Without Cameras fo...
Sixth sense technology ppt
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
第10回FA設備技術勉強会 M5Stackで始める業務のデジタル化
Tetris Algorithm
LISA17 Container Performance Analysis
FrameGraph: Extensible Rendering Architecture in Frostbite
Lecture 4: VR Systems
Introduction to Extended Reality - XR
Inside Android's UI
【Unite Tokyo 2019】大量のオブジェクトを含む広いステージでも大丈夫、そうDOTSならね
Virtual keyboard abstract
COMP 4010 - Lecture 1: Introduction to Virtual Reality
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
圏とHaskellの型
Input devices in computer graphics
Imprimante 3d presentation
Python Project on Computer Shop
How to use KASAN to debug memory corruption in OpenStack environment- (2)
COMP 4010 - Lecture 7: Introduction to Augmented Reality
Neil Sarkar (AdHawk Microsystems): Ultra-Fast Eye Tracking Without Cameras fo...
Ad

Similar to Kinect v2 Introduction and Tutorial (20)

PPT
Using the Kinect for Fun and Profit by Tam Hanna
PPTX
Nui e biometrics in windows 10
PDF
2 track kinect@Bicocca - hardware e funzinamento
PDF
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
PPTX
Kinect2 hands on
PDF
Programming with kinect v2
PDF
Kinect v1+Processing workshot fabcafe_taipei
PPTX
Visug: Say Hello to my little friend: a session on Kinect
PDF
Develop store apps with kinect for windows v2
PPTX
Develop Store Apps with Kinect for Windows v2
PPTX
Becoming a kinect hacker innovator v2
PPTX
Kinectic vision looking deep into depth
PPTX
Lidnug Presentation - Kinect - The How, Were and When of developing with it
PPTX
Building Kinect applications _Application Fundamentals
PPTX
Writing applications using the Microsoft Kinect Sensor
DOCX
Vipul divyanshu documentation on Kinect and Motion Tracking
PDF
Kinect for Windows SDK - Programming Guide
PPT
The not so short introduction to Kinect
 
PDF
Introduction to Kinect v2
PPT
First kinectslides
Using the Kinect for Fun and Profit by Tam Hanna
Nui e biometrics in windows 10
2 track kinect@Bicocca - hardware e funzinamento
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
Kinect2 hands on
Programming with kinect v2
Kinect v1+Processing workshot fabcafe_taipei
Visug: Say Hello to my little friend: a session on Kinect
Develop store apps with kinect for windows v2
Develop Store Apps with Kinect for Windows v2
Becoming a kinect hacker innovator v2
Kinectic vision looking deep into depth
Lidnug Presentation - Kinect - The How, Were and When of developing with it
Building Kinect applications _Application Fundamentals
Writing applications using the Microsoft Kinect Sensor
Vipul divyanshu documentation on Kinect and Motion Tracking
Kinect for Windows SDK - Programming Guide
The not so short introduction to Kinect
 
Introduction to Kinect v2
First kinectslides
Ad

More from Tsukasa Sugiura (6)

PPTX
Azure Kinect DK C/C++ 開発概要(仮)
PPTX
OpenCVとPCLでのRealSenseのサポート状況+α
PPTX
ViEW2013 「SS-01 画像センサと応用事例の紹介」
PDF
Leap Motion - 1st Review
PDF
OpenCV2.2 Install Guide ver.0.5
PDF
第2回名古屋CV・PRML勉強会 「Kinectの導入」
Azure Kinect DK C/C++ 開発概要(仮)
OpenCVとPCLでのRealSenseのサポート状況+α
ViEW2013 「SS-01 画像センサと応用事例の紹介」
Leap Motion - 1st Review
OpenCV2.2 Install Guide ver.0.5
第2回名古屋CV・PRML勉強会 「Kinectの導入」

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
KodekX | Application Modernization Development
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
A Presentation on Artificial Intelligence
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
“AI and Expert System Decision Support & Business Intelligence Systems”
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Building Integrated photovoltaic BIPV_UPV.pdf
KodekX | Application Modernization Development
Unlocking AI with Model Context Protocol (MCP)
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
A Presentation on Artificial Intelligence
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
The AUB Centre for AI in Media Proposal.docx
Advanced methodologies resolving dimensionality complications for autism neur...
NewMind AI Weekly Chronicles - August'25 Week I
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Machine learning based COVID-19 study performance prediction
Understanding_Digital_Forensics_Presentation.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

Kinect v2 Introduction and Tutorial

  • 1. Introduction to Kinect v2 Tsukasa Sugiura @UnaNancyOwen
  • 2. Self-Introduction Tsukasa Sugiura Microsoft MVP for Kinect for Windows  @UnaNancyOwen  http://UnaNancyOwen.com  t.sugiura0204@gmail.com (July 2014 - June 2015)
  • 3. Agenda  What is Kinect v2  Specifications  New Features  Demo  Tutorial
  • 4. Disclaimer “This is preliminary software and/or hardware and APIs are preliminary and subject to change.” (Kinect for Windows v2は暫定的なものであり、ソフトウェア、ハード ウェア、およびAPIは製品版で変更される可能性があります。)
  • 5. Kinect for Windows v1 Sensor MULTI-ARRAY MIC MOTORIZED TILT 3D DEPTH SENSORS RGB CAMERA
  • 6. Kinect for Windows v2 Sensor MULTI-ARRAY MIC 3D DEPTH SENSOR ( IR Camera + IR Emitters ) RGB CAMERA
  • 7. Kinect for Windows v2 Sensor Image by iFixit IR EMITTERS IR CAMERA
  • 8. Specifications Kinect for Windows v1 Kinect for Windows v2 Color 640×480 @ 30fps 1920×1080 @ 30fps Depth 320×240 @ 30fps 512×424 @ 30fps Sensor Structured Light (PrimeSense Light Coding) Time of Flight (ToF) Range 0.8~4.0 m 0.5~4.5 m Angle of View Horizontal / Vertical 57 / 43 degree 70 / 60 degree Microphone Array ◯ ◯
  • 9. Specifications Kinect for Windows v1 Kinect for Windows v2 BodyIndex 6 people 6 people Body 2 people 6 people Joint 20 joint/people 25 joint/people Hand State Open / Closed Open / Closed / Lasso Gesture ☓ ◯ Face ◯ Speech / Beamforming ◯ ◯
  • 10. Basic Features  Color  1920×1080@30fps / 15fps (Lighting Condition)  RGBA, YUV, BGRA, Bayer, YUY2
  • 11. Basic Features  Depth  512×424@30fps  500~4500[mm]  ToF (Time of Flight)
  • 12. Basic Features  Infrared / LongExposureInfrared  512×424@30fps  16bit (higher 8 bits)
  • 13. Basic Features  BodyIndex  512×424@30fps  6 people  Body Area : 0~5, Other Area : 255 (5 < Index) 255 0 1
  • 14. Basic Features  Body  6 people  25 joint / people (Add Tip, Thumb, Neck)  Orientation (Quaternion)  Hand Type (Right, Left),Hand State (Open, Closed, Lasso), Lean (-1.0f~1.0f)
  • 15. Basic Features  Audio  Beamforming (+/-50 degree)  Speaker Estimation  Speech Recognition
  • 16. Application Features  Gesture  Gesture Recognition using Machine Learning  Discrete (detected true/false), Continuous (progress 0.0f~1.0f)  Learning Classifier Tool “Visual Gesture Builder” Video by http://youtu.be/-XYoblrnDpg
  • 17. Application Features  Face  Bounding Box, Rotation, Points (Eye, Nose, Mouth Corner)  Activity, Appearance, Expression  Activity … Eye Closed, Mouth Open / Moved, Looking Away  Appearance … Wearing Glasses  Expression … Happy
  • 18. Application Features  HDFace  For Creating 3D Face Model  Points (1347), Triangles (2340), Hair Color, Skin Color  Fitting Face Model
  • 19. Application Features  Other  Kinect Fusion (3D Shape Reconstruction)  Controls (Assist in implementation of NUI)
  • 20. Demo
  • 21. System / Software Requirements OS * Windows 8, 8.1, Embedded 8, Embedded 8.1 (x64) CPU Intel Core i7 3.1GHz (or higher) RAM 4GB (or more) GPU * DirectX 11 supported USB * USB 3.0 (Intel or Renesas Host Controller) Compiler * Visual Studio 2012, 2013 (Supported Express) Language Native (C++), Managed (C#,VB.NET), WinRT (C#,HTML) Other Unity Pro (Add-in), Cinder, openFrameworks (wrapper)
  • 22. Connection Kinect for Windows v1 Kinect for Windows v2 PCPC
  • 24. System Kinect Driver Kinect SDK Application Kinect Driver Kinect SDK Application Kinect Service Kinect SDK Application Kinect SDK Application Kinect for Windows v1 Kinect for Windows v2
  • 25. Tutorial  Basic Flow of Programming (C++) Sensor Stream Frame Data Sensor Source Reader Frame Data Kinect for Windows SDK v1 Kinect for Windows SDK v2  Source independent to each Data (e.g. ColorSource, DepthSource, InfraredSource, BodyIndexSource, BodySource, …)  Doesn’t depend on each other Source (e.g. Doesn't need to Depth Source when retrieve Body Data)
  • 26. Tutorial  Sensor Sensor Source Reader Frame Data // Sensor IKinectSensor* pSensor; HRESULT hResult = S_OK; hResult = GetDefaultKinectSensor( &pSensor ); if( FAILED( hResult ) ){ std::cerr << "Error : GetDefaultKinectSensor" << std::endl; return -1; } hResult = pSensor->Open(); if( FAILED( hResult ) ){ std::cerr << "Error : IKinectSensor::Open()" << std::endl; return -1; }  IKinectSensor
  • 27. Tutorial  Source Sensor Source Reader Frame Data // Source I***FrameSource* pSource; hResult = pSensor->get_***FrameSource( &pSource ); if( FAILED( hResult ) ){ std::cerr << "Error : IKinectSensor::get_FrameSource()" << std::endl; return -1; }  IColorFrameSource  IDepthFrameSource  IInfraredFrameSource  IBodyIndexFrameSource  IBodyFrameSource
  • 28. Tutorial  Reader Sensor Source Reader Frame Data // Reader I***FrameReader* pReader; hResult = pSource->OpenReader( &pReader ); if( FAILED( hResult ) ){ std::cerr << "Error : IFrameSource::OpenReader()" << std::endl; return -1; }  IColorFrameReader  IDepthFrameReader  IInfraredFrameReader  IBodyIndexFrameReader  IBodyFrameReader
  • 29. Tutorial  Frame Sensor Source Reader Frame Data while( 1 ){ // Frame I***Frame* pFrame = nullptr; hResult = pReader->AcquireLatestFrame( &pFrame ); if( SUCCEEDED( hResult ) ){ /* Data */ } SafeRelease( pFrame ); }  IColorFrame  IDepthFrame  IInfraredFrame  IBodyIndexFrame  IBodyFrame
  • 30. Tutorial  Data (Depth, Infrared, BodyIndex) Sensor Source Reader Frame Data while( 1 ){ // Frame IDepthFrame* pDepthFrame = nullptr; hResult = pDepthReader->AcquireLatestFrame( &pDepthFrame ); if( SUCCEEDED( hResult ) ){ unsigned int bufferSize = 0; unsigned short* pBuffer = nullptr; hResult = pDepthFrame->AccessUnderlyingBuffer( &bufferSize, &pBuffer ); if( SUCCEEDED( hResult ) ){ /* Processing*/ } } SafeRelease( pDepthFrame ); }  Depth, Infrared … unsigned short  BodyIndex … unsigned char
  • 31. Tutorial  Data (Color) Sensor Source Reader Frame Data while( 1 ){ // Frame IColorFrame* pColorFrame = nullptr; hResult = pColorReader->AcquireLatestFrame( &pColorFrame ); if( SUCCEEDED( hResult ) ){ unsigned int bufferSize = 0; unsigned char* pBuffer = nullptr; hResult = pColorFrame->AccessUnderlyingBuffer( &bufferSize, &pBuffer ); if( SUCCEEDED( hResult ) ){ /* Processing*/ } } SafeRelease( pColorFrame ); }  Color … unsigned char  Default Color Image Format … YUY2
  • 32. Tutorial  Data (Color with Converted Format) Sensor Source Reader Frame Data unsigned int buffeerSize = width * height * channel * sizeof(unsigned char); unsigned char* pBuffer = new unsigned char[bufferSize]; while( 1 ){ // Frame IColorFrame* pColorFrame = nullptr; hResult = pReader->AcquireLatestFrame( &pColorFrame ); if( SUCCEEDED( hResult ) ){ hResult = pColorFrame->CopyConvertedFrameDataToArray( bufferSize, pBuffer, ColorImageFormat::ColorImageFormat_Bgra ); if( SUCCEEDED( hResult ) ){ /* Processing */ } } SafeRelease( pColorFrame ); } delete[] pBuffer;
  • 33. Tutorial Sensor Source Reader Frame Data while( 1 ){ IBodyFrame* pFrame = nullptr; hResult = pBodyReader->AcquireLatestFrame( &pBodyFrame ); if( SUCCEEDED( hResult ) ){ IBody* pBody[BODY_COUNT] = { 0 }; hResult = pBodyFrame->GetAndRefreshBodyData( BODY_COUNT, pBody ); if( SUCCEEDED( hResult ) ){ /* Processing */ } for( int count = 0; count < BODY_COUNT; count++ ){ SafeRelease( pBody[count] ); } } SafeRelease( pBodyFrame ); }  Data (Body)
  • 34. Tutorial Sensor Source Reader Frame Data for( int count = 0; count < BODY_COUNT; count++ ){ BOOLEAN bTracked = false; hResult = pBody[count]->get_IsTracked( &bTracked ); if( SUCCEEDED( hResult ) && bTracked ){ Joint joint[JointType::JointType_Count]; hResult = pBody[count]->GetJoints( JointType::JointType_Count, joint ); if( SUCCEEDED( hResult ) ){ for( int type = 0; type < JointType::JointType_Count; type++ ){ if( joint[type].TrackingState != TrackingState::TrackingState_NotTracked ){ CameraSpacePoint cameraSpacePoint = joint[type].Position; cameraSpacePoint.x; // x (+/- 1.0f) cameraSpacePoint.y; // y (+/- 1.0f) cameraSpacePoint.z; // z (500~4500[mm]) } } } } }  Data (Joint)
  • 35. Tutorial  Coordinate System  ColorSpace (Coordinate System of the Color Image) … Color  DepthSpace (Coordinate System of the Depth Data) … Depth, Infrared, BodyIndex  CameraSpace (Coordinate System with the origin located the Depth Sensor) … Body (Joint)
  • 36. Tutorial  Coordinate Mapper // Coordinate Mapper ICoordinateMapper* pCoordinateMapper; hResult = pSensor->get_CoordinateMapper( &pCoordinateMapper ); if( FAILED( hResult ) ){ std::cerr << "Error : IKinectSensor::get_CoordinateMapper()" << std::endl; return -1; }  ICoordinateMapper::Map○○○FrameTo△△△Space() … Mapping Coordinate System in the Frame  ICoordinateMapper::Map○○○PointsTo△△△Space() … Mapping Coordinate System in the Array of Points  ICoordinateMapper::Map○○○PointTo△△△Space() … Mapping Coordinate System in the Point
  • 37. Reference  Sample Program  Kinect2Sample | GitHub https://github.com/UnaNancyOwen/Kinect2Sample  Article Series  Introduction to Kinect for Windows v2 | Build Insider http://www.buildinsider.net/small/kinectv2cpp  Blog  Kinect | Summary?Blog http://unanancyowen.com/?cat=3