3 track kinect@Bicocca - sdk e camere

1,278 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,278
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
31
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

3 track kinect@Bicocca - sdk e camere

  1. 1. Ing. Matteo Valoriani matteo.valoriani@studentpartner.comKINECT Programming
  2. 2. The ColorImageStream object model KINECT Programming
  3. 3. CAMERA DATA• Events return ImageFrame • PixelDataLength • FrameNumber • Timestamp • Dimensions: Height, Width• Use AllFramesReady event to synchronize KINECT Programming
  4. 4. ColorImageFormatColorImageFormat What it meansUndefined 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. 5. BYTES PER PIXELThe stream Format determines the pixel format and therefore the meaningof the bytes.ColorImageFormat.RgbResolution640x480Fps30  pixel format is Bgra32 32bits (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 bytesStride is the number of bytes for a row of pixels.Stride = width * BytesPerPixel KINECT Programming
  6. 6. KINECT Programming
  7. 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. 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
  9. 9. KINECT Programming
  10. 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
  11. 11. KINECT Programming
  12. 12. What does it see? KINECT Programming
  13. 13. Depth Sensing IR Depth IR Emitter Sensor KINECT Programming
  14. 14. Mathematical Model 𝑑 = 𝑥𝑙 − 𝑥 𝑟 𝑏+𝑥 𝑙 − 𝑥 𝑟 𝑏 = 𝑍−𝑓 𝑍 𝑏∗𝑓 Z= 𝑑b KINECT Programming
  15. 15. Mathematical Model(2) Reference plane distance= Disparity Image Plane KINECT Programming
  16. 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. 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. 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 8Default Mode Near Mode KINECT Programming
  19. 19. FORMULAS• Distance Formula int depth = depthPoint >> DepthImageFrame.PlayerIndexBitmaskWidth;• Player Formula int player = depthPoint & DepthImageFrame.PlayerIndexBitmask; KINECT Programming
  20. 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. 21. PROVIDED DATADepth and Segmentation map KINECT Programming
  22. 22. The DepthImageFrame Object Model KINECT Programming
  23. 23. The DepthImageStream Object Model KINECT Programming
  24. 24. KINECT Programming
  25. 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

×