2011年6月19日 星期日

Microsoft Kinect(第三課 SkeletonFrame)

Ref : SketetalViewer_Walkthrough.docx
PART 3—C# SkeletalViewer Sample
1. Open WPF Application
2. Add ref Microsoft.Research.Kinect
3. Add using Microsoft.Research.Kinect.Nui;
4. Copy parts of sample code as follows to test videostream function
4-1 Global variables
Runtime nui;
int totalFrames = 0;
int lastFrames = 0;
DateTime lastTime = DateTime.MaxValue;
const int RED_IDX = 2;
const int GREEN_IDX = 1;
const int BLUE_IDX = 0;
Dictionary<JointID, Brush> jointColors = new Dictionary<JointID, Brush>() { ...

4-2 Window_Loaded event method (Parts of them from example)
Key steps:
4-2-1 Create Runtime object
nui = new Runtime();
4-2-2 Initialize Runtime object
nui.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);
4-2-3 Open VideoStream
nui.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
4-2-4 Set SkeletonFrameReady event
nui.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady);

4-3 Copy methods from example
4-3-1 getDisplayPosition
4-3-2 getBodySegment
4-3-3 nui_SkeletonFrameReady

4-4 Notes: Don't miss Width and Height settings in canvas.
<Canvas Name="skeleton" Width="300" Height="400" Margin="278,20,20,20" Background="Black" ClipToBounds="True" />

5 Download https://sites.google.com/site/csjoublogfiles/home/files/SDKSkeleton.zip

沒有留言:

張貼留言