SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
Ing. Matteo Valoriani
               matteo.valoriani@studentpartner.com




KINECT Programming
The ColorImageStream object model




            KINECT Programming
CAMERA DATA
• Events return ImageFrame
  •   PixelDataLength
  •   FrameNumber
  •   Timestamp
  •   Dimensions: Height, Width


• Use AllFramesReady event to synchronize


                      KINECT Programming
ColorImageFormat
ColorImageFormat                 What it means
Undefined                        The image resolution is indeterminate.
RgbResolution640x480Fps30        The image resolution is 640x480, pixel data is
                                 RGB32 format at 30 frames per second.
RgbResolution1280x960Fps12       The image resolution is 1280x960, pixel data is
                                 RGB32 format at 12 frames per second.
YuvResolution640x480Fps15        The image resolution is 640x480, pixel data is
                                 YUV format at 15 frames per second.
RawYuvResolution640x480Fps15     The image resolution is 640x480, pixel data is raw
                                 YUV format at 15 frames per second.

colorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);

                               KINECT Programming
BYTES PER PIXEL
The stream Format determines the pixel format and therefore the meaning
of the bytes.

ColorImageFormat.RgbResolution640x480Fps30  pixel format is Bgra32 32
bits (4 bytes) per pixel.

The 1st byte is the blue channel value, the 2nd is green, and the 3th is red.
The fourth byte determines the alpha or opacity of the pixel (unused)

640x480 = height * width * BytesPerPixel = 640 * 480 * 4 = 122880 bytes

Stride is the number of bytes for a row of pixels.
Stride = width * BytesPerPixel


                                 KINECT Programming
KINECT Programming
private WriteableBitmap _ColorImageBitmap;
private Int32Rect _ColorImageBitmapRect;
private int _ColorImageStride;

private void InitializeKinect(KinectSensor sensor) {

if (sensor != null){
           ColorImageStream colorStream = sensor.ColorStream;
           colorStream.Enable();

           this._ColorImageBitmap = new WriteableBitmap(colorStream.FrameWidth,
                                                            colorStream.FrameHeight, 96, 96,
                                                            PixelFormats.Bgr32, null);
           this._ColorImageBitmapRect = new Int32Rect(0, 0, colorStream.FrameWidth,
                                                           colorStream.FrameHeight);
           this._ColorImageStride = colorStream.FrameWidth * colorStream.FrameBytesPerPixel;
           ColorImageElement.Source = this._ColorImageBitmap;

           sensor.ColorFrameReady += Kinect_ColorFrameReady;
           sensor.Start();
           }
}


                                             KINECT Programming
private void Kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
        {
            using (ColorImageFrame frame = e.OpenColorImageFrame())
            {
                if (frame != null)
                {
                    byte[] pixelData = new byte[frame.PixelDataLength];
                    frame.CopyPixelDataTo(pixelData);

                   this._ColorImageBitmap.WritePixels(this._ColorImageBitmapRect,
                                                       pixelData,
                                                      this._ColorImageStride, 0);
               }
           }
       }




                                   KINECT Programming
KINECT Programming
private void TakePictureButton_Click(object sender, RoutedEventArgs e)   {
           string fileName = "snapshot.jpg";

          if (File.Exists(fileName))     {
              File.Delete(fileName);
          }

          using (FileStream savedSnapshot = new FileStream(fileName, FileMode.CreateNew))   {
              BitmapSource image = (BitmapSource)VideoStreamElement.Source;

              JpegBitmapEncoder jpgEncoder = new JpegBitmapEncoder();
              jpgEncoder.QualityLevel = 70;
              jpgEncoder.Frames.Add(BitmapFrame.Create(image));
              jpgEncoder.Save(savedSnapshot);

              savedSnapshot.Flush();
              savedSnapshot.Close();
              savedSnapshot.Dispose();
          }
      }


                                             KINECT Programming
KINECT Programming
What does it see?




    KINECT Programming
Depth Sensing




                              IR Depth
                 IR Emitter
                               Sensor
  KINECT Programming
Mathematical Model

                               𝑑 = 𝑥𝑙 − 𝑥 𝑟

                              𝑏+𝑥 𝑙 − 𝑥 𝑟         𝑏
                                            =
                                𝑍−𝑓               𝑍

                                            𝑏∗𝑓
                                  Z=
                                             𝑑
b

         KINECT Programming
Mathematical Model(2)
    Reference plane distance



=




                                           Disparity   Image Plane
                      KINECT Programming
Precision
• – spatial x/y resolution: 3mm @2m distance
• – depth z resolution:
  • 1cm @2m distance
  • 10 cm @ 4 m distance
• Operation range: 0.8m~3.5m




                    KINECT Programming
DEPTH DATA

• Returns the distance and player for every pixel
  • Ex: 320x240 = 76,800 pixels
• Distance
  • Distance in mm from Kinect ex: 2,000mm
• Player
  • 1-6 players


                     KINECT Programming
MODE
           Mode       Depth & Player         Center Hip Joint    Other 19 Joints

           Default          Yes                        Yes            Yes
            Near            Yes                        Yes        No, for v1.0



  Meters    .4   .8     3     4                              8

Default
 Mode
 Near
 Mode

                                  KINECT Programming
FORMULAS
• Distance Formula
  int depth = depthPoint >> DepthImageFrame.PlayerIndexBitmaskWidth;



• Player Formula
  int player = depthPoint & DepthImageFrame.PlayerIndexBitmask;




                           KINECT Programming
DEPTH MAP FORMAT
• 320 x 240 resolution
• 16 bits per pixel
   Upper 13 bits: depth in mm: 800 mm to 4000 mm range
   Lower 3 bits: segmentation mask
• Depth value 0 means unknown
   Shadows, low reflectivity, and high reflectivity among the few reasons
• Segmentation index
   0 – no player
   1 – skeleton 0
   2 – skeleton 1
   …
                               KINECT Programming
PROVIDED DATA
Depth and Segmentation map




                        KINECT Programming
The DepthImageFrame Object Model




            KINECT Programming
The DepthImageStream Object Model




            KINECT Programming
KINECT Programming
Kinect.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
Kinect.DepthFrameReady += Kinect_DepthFrameReady;

void Kinect_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e) {

    using (DepthImageFrame frame = e.OpenDepthImageFrame()) {

        if (frame != null) {
            short[] pixelData = new short[frame.PixelDataLength];
            frame.CopyPixelDataTo(pixelData);

            int stride = frame.Width * frame.BytesPerPixel;
            ImageDepth.Source = BitmapSource.Create(frame.Width,
                    frame.Height, 96, 96,
          PixelFormats.Gray16, null, pixelData,
          stride);
        } } }
}

                                    KINECT Programming

Weitere ähnliche Inhalte

Was ist angesagt?

PyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using PythonPyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using Python
pycontw
 
Final_draft_Practice_School_II_report
Final_draft_Practice_School_II_reportFinal_draft_Practice_School_II_report
Final_draft_Practice_School_II_report
Rishikesh Bagwe
 

Was ist angesagt? (20)

Kinect Hacks for Dummies
Kinect Hacks for DummiesKinect Hacks for Dummies
Kinect Hacks for Dummies
 
Kinect for Windows SDK - Programming Guide
Kinect for Windows SDK - Programming GuideKinect for Windows SDK - Programming Guide
Kinect for Windows SDK - Programming Guide
 
Becoming a kinect hacker innovator v2
Becoming a kinect hacker innovator v2Becoming a kinect hacker innovator v2
Becoming a kinect hacker innovator v2
 
Kinect Tutorial
Kinect Tutorial Kinect Tutorial
Kinect Tutorial
 
PyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using PythonPyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using Python
 
Kinect sensor
Kinect sensorKinect sensor
Kinect sensor
 
How Augment your Reality: Different perspective on the Reality / Virtuality C...
How Augment your Reality: Different perspective on the Reality / Virtuality C...How Augment your Reality: Different perspective on the Reality / Virtuality C...
How Augment your Reality: Different perspective on the Reality / Virtuality C...
 
Getmoving as3kinect
Getmoving as3kinectGetmoving as3kinect
Getmoving as3kinect
 
Kinect Sensors as Natural User Interfaces
Kinect Sensors as Natural User InterfacesKinect Sensors as Natural User Interfaces
Kinect Sensors as Natural User Interfaces
 
Odessa .NET User Group - Kinect v2
Odessa .NET User Group - Kinect v2Odessa .NET User Group - Kinect v2
Odessa .NET User Group - Kinect v2
 
Introduction to Kinect v2
Introduction to Kinect v2Introduction to Kinect v2
Introduction to Kinect v2
 
Introduction to development
Introduction to developmentIntroduction to development
Introduction to development
 
Kinect connect
Kinect connectKinect connect
Kinect connect
 
Final_draft_Practice_School_II_report
Final_draft_Practice_School_II_reportFinal_draft_Practice_School_II_report
Final_draft_Practice_School_II_report
 
Advanced Approach to Play a Atari Game
Advanced Approach to Play a Atari GameAdvanced Approach to Play a Atari Game
Advanced Approach to Play a Atari Game
 
DWT-SVD Based Visual Cryptography Scheme for Audio Watermarking
DWT-SVD Based Visual Cryptography Scheme for Audio WatermarkingDWT-SVD Based Visual Cryptography Scheme for Audio Watermarking
DWT-SVD Based Visual Cryptography Scheme for Audio Watermarking
 
A STUDY OF VARIATION OF NORMAL OF POLY-GONS CREATED BY POINT CLOUD DATA FOR A...
A STUDY OF VARIATION OF NORMAL OF POLY-GONS CREATED BY POINT CLOUD DATA FOR A...A STUDY OF VARIATION OF NORMAL OF POLY-GONS CREATED BY POINT CLOUD DATA FOR A...
A STUDY OF VARIATION OF NORMAL OF POLY-GONS CREATED BY POINT CLOUD DATA FOR A...
 
Availability of Mobile Augmented Reality System for Urban Landscape Simulation
Availability of Mobile Augmented Reality System for Urban Landscape SimulationAvailability of Mobile Augmented Reality System for Urban Landscape Simulation
Availability of Mobile Augmented Reality System for Urban Landscape Simulation
 
Riva Vr Rehab 07 Neuro Vr
Riva Vr Rehab 07 Neuro VrRiva Vr Rehab 07 Neuro Vr
Riva Vr Rehab 07 Neuro Vr
 
DISTRIBUTED AND SYNCHRONISED VR MEETING USING CLOUD COMPUTING: Availability a...
DISTRIBUTED AND SYNCHRONISED VR MEETING USING CLOUD COMPUTING: Availability a...DISTRIBUTED AND SYNCHRONISED VR MEETING USING CLOUD COMPUTING: Availability a...
DISTRIBUTED AND SYNCHRONISED VR MEETING USING CLOUD COMPUTING: Availability a...
 

Ähnlich wie 3 track kinect@Bicocca - sdk e camere

Computer graphics
Computer graphicsComputer graphics
Computer graphics
amitsarda3
 

Ähnlich wie 3 track kinect@Bicocca - sdk e camere (20)

Image_Processing_LECTURE_c#_programming.ppt
Image_Processing_LECTURE_c#_programming.pptImage_Processing_LECTURE_c#_programming.ppt
Image_Processing_LECTURE_c#_programming.ppt
 
First kinectslides
First kinectslidesFirst kinectslides
First kinectslides
 
cs247 slides
cs247 slidescs247 slides
cs247 slides
 
Scmad Chapter07
Scmad Chapter07Scmad Chapter07
Scmad Chapter07
 
Work With Images
Work With ImagesWork With Images
Work With Images
 
Introduction to Computer graphics
Introduction to Computer graphicsIntroduction to Computer graphics
Introduction to Computer graphics
 
Bitmap management like a boss
Bitmap management like a bossBitmap management like a boss
Bitmap management like a boss
 
Resize image vb.net
Resize image vb.netResize image vb.net
Resize image vb.net
 
Image processing for robotics
Image processing for roboticsImage processing for robotics
Image processing for robotics
 
A New Algorithm for Digital Colour Image Encryption and Decryption
A New Algorithm for Digital Colour Image Encryption and DecryptionA New Algorithm for Digital Colour Image Encryption and Decryption
A New Algorithm for Digital Colour Image Encryption and Decryption
 
Stupid Canvas Tricks
Stupid Canvas TricksStupid Canvas Tricks
Stupid Canvas Tricks
 
Unit 11. Graphics
Unit 11. GraphicsUnit 11. Graphics
Unit 11. Graphics
 
426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools426 lecture 4: AR Developer Tools
426 lecture 4: AR Developer Tools
 
Rendering Techniques for Augmented Reality and a Look Ahead at AR Foundation
Rendering Techniques for Augmented Reality and a Look Ahead at AR FoundationRendering Techniques for Augmented Reality and a Look Ahead at AR Foundation
Rendering Techniques for Augmented Reality and a Look Ahead at AR Foundation
 
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...
Данило Ульянич “C89 OpenGL for ARM microcontrollers on Cortex-M. Basic functi...
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Image compression 14_04_2020 (1)
Image compression 14_04_2020 (1)Image compression 14_04_2020 (1)
Image compression 14_04_2020 (1)
 
COSC 426 Lect. 3 -AR Developer Tools
COSC 426 Lect. 3 -AR Developer ToolsCOSC 426 Lect. 3 -AR Developer Tools
COSC 426 Lect. 3 -AR Developer Tools
 
Prinsip gambar digital
Prinsip gambar digitalPrinsip gambar digital
Prinsip gambar digital
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 

Mehr von Matteo Valoriani

Uxconf2012 - Interactive technologies for children: new frontiers
Uxconf2012 - Interactive technologies for children: new frontiersUxconf2012 - Interactive technologies for children: new frontiers
Uxconf2012 - Interactive technologies for children: new frontiers
Matteo Valoriani
 

Mehr von Matteo Valoriani (20)

Immerge yourself in a new Reality
Immerge yourself in a new RealityImmerge yourself in a new Reality
Immerge yourself in a new Reality
 
Hour ofcode
Hour ofcodeHour ofcode
Hour ofcode
 
Debug, Analyze and Optimize Games with Intel Tools
Debug, Analyze and Optimize Games with Intel Tools Debug, Analyze and Optimize Games with Intel Tools
Debug, Analyze and Optimize Games with Intel Tools
 
More Personal Computing: Windows 10, Kinect and Wearables
More Personal Computing: Windows 10, Kinect and WearablesMore Personal Computing: Windows 10, Kinect and Wearables
More Personal Computing: Windows 10, Kinect and Wearables
 
Etna dev 2016 - Deep Dive Holographic Applications
Etna dev 2016 - Deep Dive Holographic ApplicationsEtna dev 2016 - Deep Dive Holographic Applications
Etna dev 2016 - Deep Dive Holographic Applications
 
Etna dev 2016 - Introduction to Holographic Development
Etna dev 2016 - Introduction to Holographic DevelopmentEtna dev 2016 - Introduction to Holographic Development
Etna dev 2016 - Introduction to Holographic Development
 
Etna dev 2016 - Introduction to Mixed Reality with HoloLens
Etna dev 2016 - Introduction to Mixed Reality with HoloLensEtna dev 2016 - Introduction to Mixed Reality with HoloLens
Etna dev 2016 - Introduction to Mixed Reality with HoloLens
 
Mixed Reality from demo to product
Mixed Reality from demo to productMixed Reality from demo to product
Mixed Reality from demo to product
 
Intel RealSense Hands-on Lab - Rome
Intel RealSense Hands-on Lab - RomeIntel RealSense Hands-on Lab - Rome
Intel RealSense Hands-on Lab - Rome
 
Develop store apps with kinect for windows v2
Develop store apps with kinect for windows v2Develop store apps with kinect for windows v2
Develop store apps with kinect for windows v2
 
Programming with RealSense using .NET
Programming with RealSense using .NETProgramming with RealSense using .NET
Programming with RealSense using .NET
 
Face recognition
Face recognitionFace recognition
Face recognition
 
Communitydays2015
Communitydays2015Communitydays2015
Communitydays2015
 
Tecnologie e Startup: ICT è solo una commodity?
Tecnologie e Startup: ICT è solo una commodity? Tecnologie e Startup: ICT è solo una commodity?
Tecnologie e Startup: ICT è solo una commodity?
 
Intel real sense handson
Intel real sense handsonIntel real sense handson
Intel real sense handson
 
Communityday2013
Communityday2013Communityday2013
Communityday2013
 
Communitydays2014
Communitydays2014Communitydays2014
Communitydays2014
 
Corso pratico di C# - 2013
Corso pratico di C# - 2013Corso pratico di C# - 2013
Corso pratico di C# - 2013
 
Smart and beyond - Perchè
Smart and beyond - PerchèSmart and beyond - Perchè
Smart and beyond - Perchè
 
Uxconf2012 - Interactive technologies for children: new frontiers
Uxconf2012 - Interactive technologies for children: new frontiersUxconf2012 - Interactive technologies for children: new frontiers
Uxconf2012 - Interactive technologies for children: new frontiers
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

3 track kinect@Bicocca - sdk e camere

  • 1. Ing. Matteo Valoriani matteo.valoriani@studentpartner.com KINECT Programming
  • 2. The ColorImageStream object model KINECT Programming
  • 3. CAMERA DATA • Events return ImageFrame • PixelDataLength • FrameNumber • Timestamp • Dimensions: Height, Width • Use AllFramesReady event to synchronize KINECT Programming
  • 4. ColorImageFormat ColorImageFormat What it means Undefined The image resolution is indeterminate. RgbResolution640x480Fps30 The image resolution is 640x480, pixel data is RGB32 format at 30 frames per second. RgbResolution1280x960Fps12 The image resolution is 1280x960, pixel data is RGB32 format at 12 frames per second. YuvResolution640x480Fps15 The image resolution is 640x480, pixel data is YUV format at 15 frames per second. RawYuvResolution640x480Fps15 The image resolution is 640x480, pixel data is raw YUV format at 15 frames per second. colorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); KINECT Programming
  • 5. BYTES PER PIXEL The stream Format determines the pixel format and therefore the meaning of the bytes. ColorImageFormat.RgbResolution640x480Fps30  pixel format is Bgra32 32 bits (4 bytes) per pixel. The 1st byte is the blue channel value, the 2nd is green, and the 3th is red. The fourth byte determines the alpha or opacity of the pixel (unused) 640x480 = height * width * BytesPerPixel = 640 * 480 * 4 = 122880 bytes Stride is the number of bytes for a row of pixels. Stride = width * BytesPerPixel KINECT Programming
  • 7. private WriteableBitmap _ColorImageBitmap; private Int32Rect _ColorImageBitmapRect; private int _ColorImageStride; private void InitializeKinect(KinectSensor sensor) { if (sensor != null){ ColorImageStream colorStream = sensor.ColorStream; colorStream.Enable(); this._ColorImageBitmap = new WriteableBitmap(colorStream.FrameWidth, colorStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null); this._ColorImageBitmapRect = new Int32Rect(0, 0, colorStream.FrameWidth, colorStream.FrameHeight); this._ColorImageStride = colorStream.FrameWidth * colorStream.FrameBytesPerPixel; ColorImageElement.Source = this._ColorImageBitmap; sensor.ColorFrameReady += Kinect_ColorFrameReady; sensor.Start(); } } KINECT Programming
  • 8. private void Kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e) { using (ColorImageFrame frame = e.OpenColorImageFrame()) { if (frame != null) { byte[] pixelData = new byte[frame.PixelDataLength]; frame.CopyPixelDataTo(pixelData); this._ColorImageBitmap.WritePixels(this._ColorImageBitmapRect, pixelData, this._ColorImageStride, 0); } } } KINECT Programming
  • 10. private void TakePictureButton_Click(object sender, RoutedEventArgs e) { string fileName = "snapshot.jpg"; if (File.Exists(fileName)) { File.Delete(fileName); } using (FileStream savedSnapshot = new FileStream(fileName, FileMode.CreateNew)) { BitmapSource image = (BitmapSource)VideoStreamElement.Source; JpegBitmapEncoder jpgEncoder = new JpegBitmapEncoder(); jpgEncoder.QualityLevel = 70; jpgEncoder.Frames.Add(BitmapFrame.Create(image)); jpgEncoder.Save(savedSnapshot); savedSnapshot.Flush(); savedSnapshot.Close(); savedSnapshot.Dispose(); } } KINECT Programming
  • 12. What does it see? KINECT Programming
  • 13. Depth Sensing IR Depth IR Emitter Sensor KINECT Programming
  • 14. Mathematical Model 𝑑 = 𝑥𝑙 − 𝑥 𝑟 𝑏+𝑥 𝑙 − 𝑥 𝑟 𝑏 = 𝑍−𝑓 𝑍 𝑏∗𝑓 Z= 𝑑 b KINECT Programming
  • 15. Mathematical Model(2) Reference plane distance = Disparity Image Plane KINECT Programming
  • 16. Precision • – spatial x/y resolution: 3mm @2m distance • – depth z resolution: • 1cm @2m distance • 10 cm @ 4 m distance • Operation range: 0.8m~3.5m KINECT Programming
  • 17. DEPTH DATA • Returns the distance and player for every pixel • Ex: 320x240 = 76,800 pixels • Distance • Distance in mm from Kinect ex: 2,000mm • Player • 1-6 players KINECT Programming
  • 18. MODE Mode Depth & Player Center Hip Joint Other 19 Joints Default Yes Yes Yes Near Yes Yes No, for v1.0 Meters .4 .8 3 4 8 Default Mode Near Mode KINECT Programming
  • 19. FORMULAS • Distance Formula int depth = depthPoint >> DepthImageFrame.PlayerIndexBitmaskWidth; • Player Formula int player = depthPoint & DepthImageFrame.PlayerIndexBitmask; KINECT Programming
  • 20. DEPTH MAP FORMAT • 320 x 240 resolution • 16 bits per pixel Upper 13 bits: depth in mm: 800 mm to 4000 mm range Lower 3 bits: segmentation mask • Depth value 0 means unknown Shadows, low reflectivity, and high reflectivity among the few reasons • Segmentation index 0 – no player 1 – skeleton 0 2 – skeleton 1 … KINECT Programming
  • 21. PROVIDED DATA Depth and Segmentation map KINECT Programming
  • 22. The DepthImageFrame Object Model KINECT Programming
  • 23. The DepthImageStream Object Model KINECT Programming
  • 25. Kinect.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30); Kinect.DepthFrameReady += Kinect_DepthFrameReady; void Kinect_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e) { using (DepthImageFrame frame = e.OpenDepthImageFrame()) { if (frame != null) { short[] pixelData = new short[frame.PixelDataLength]; frame.CopyPixelDataTo(pixelData); int stride = frame.Width * frame.BytesPerPixel; ImageDepth.Source = BitmapSource.Create(frame.Width, frame.Height, 96, 96, PixelFormats.Gray16, null, pixelData, stride); } } } } KINECT Programming