/*///////////////////////////////////////// * CONSTRUCTOR(S)/DESTRUCTOR(S) *//////////////////////////////////////// public KinectManager(ColorImageFormat p_colour_format, DepthImageFormat p_depth_format, KinectGame_WindowsXNA p_game) { // Initialise the Kinect selector... this.colour_image_format = p_colour_format; this.depth_image_format = p_depth_format; this.root_game = p_game; this.colour_stream = null; this.depth_stream = null; this.skeleton_stream = null; this.debug_video_stream_dimensions = new Vector2(200, 150); status_map = new Dictionary <KinectStatus, string>(); KinectSensor.KinectSensors.StatusChanged += this.KinectSensorsStatusChanged; // handler function for changes in the Kinect system this.DiscoverSensor(); this.status_map.Add(KinectStatus.Undefined, "UNKNOWN STATUS MESSAGE"); this.status_map.Add(KinectStatus.Connected, "Connected.");//string.Empty); this.status_map.Add(KinectStatus.DeviceNotGenuine, "Detected device is not genuine!"); this.status_map.Add(KinectStatus.DeviceNotSupported, "Detected device is not supported!"); this.status_map.Add(KinectStatus.Disconnected, "Disconnected/Device required!"); this.status_map.Add(KinectStatus.Error, "Error in Kinect sensor!"); this.status_map.Add(KinectStatus.Initializing, "Initialising Kinect sensor..."); this.status_map.Add(KinectStatus.InsufficientBandwidth, "Insufficient bandwidth for Kinect sensor!"); this.status_map.Add(KinectStatus.NotPowered, "Detected device is not powered!"); this.status_map.Add(KinectStatus.NotReady, "Detected device is not ready!"); // Load the status message font: this.msg_font = this.root_game.Content.Load <SpriteFont>("Fonts/Segoe16"); this.msg_label_pos = new Vector2(4.0f, 2.0f); }
/*///////////////////////////////////////// * STARTUP/LOAD FUNCTION(S) *//////////////////////////////////////// public void loadStreamManagers() { // Create/load the Kinect stream managers... if (this.skeleton_stream != null) { this.skeleton_stream.close(this); // close skeleton stream manager if already open } if (this.colour_stream != null) { this.colour_stream.close(this); // close colour stream manager if already open } if (this.depth_stream != null) { this.depth_stream.close(this); // close depth stream manager if already open } /* * NOTE: Stream manager debug video rects arranged in the order = SKELETON - COLOUR - DEPTH (positioned from the top-right corner of the window) * Stream managers use the KinectColorVisualizer & KinectDepthVisualizer XNA effect files (from Microsoft samples) to correctly format the texture data. */ this.colour_stream = new ColourStreamManager(new Rectangle(this.root_game.GraphicsDevice.Viewport.Width - (int)this.debug_video_stream_dimensions.X * 2, 0, (int)this.debug_video_stream_dimensions.X, (int)this.debug_video_stream_dimensions.Y), this.root_game.Content.Load <Effect>("Effects_Shaders/KinectColorVisualizer"), this, this.root_game.GraphicsDevice); this.depth_stream = new DepthStreamManager(new Rectangle(this.root_game.GraphicsDevice.Viewport.Width - (int)this.debug_video_stream_dimensions.X, 0, (int)this.debug_video_stream_dimensions.X, (int)this.debug_video_stream_dimensions.Y), this.root_game.Content.Load <Effect>("Effects_Shaders/KinectDepthVisualizer"), this, this.root_game.GraphicsDevice); this.skeleton_stream = new SkeletonStreamManager(new Rectangle(this.root_game.GraphicsDevice.Viewport.Width - (int)this.debug_video_stream_dimensions.X * 3, 0, (int)this.debug_video_stream_dimensions.X, (int)this.debug_video_stream_dimensions.Y), this, this.root_game.GraphicsDevice, this.root_game.Content.Load <Texture2D>("Textures/Kinect/SkeletonJoint"), this.root_game.Content.Load <Texture2D>("Textures/Kinect/SkeletonBone")); }
/*///////////////////////////////////////// * STARTUP/LOAD FUNCTION(S) */ /////////////////////////////////////// public void loadStreamManagers() { // Create/load the Kinect stream managers... if (this.skeleton_stream != null) this.skeleton_stream.close(this); // close skeleton stream manager if already open if (this.colour_stream != null) this.colour_stream.close(this); // close colour stream manager if already open if (this.depth_stream != null) this.depth_stream.close(this); // close depth stream manager if already open /* * NOTE: Stream manager debug video rects arranged in the order = SKELETON - COLOUR - DEPTH (positioned from the top-right corner of the window) * Stream managers use the KinectColorVisualizer & KinectDepthVisualizer XNA effect files (from Microsoft samples) to correctly format the texture data. */ this.colour_stream = new ColourStreamManager(new Rectangle(this.root_game.GraphicsDevice.Viewport.Width - (int)this.debug_video_stream_dimensions.X * 2, 0, (int)this.debug_video_stream_dimensions.X, (int)this.debug_video_stream_dimensions.Y), this.root_game.Content.Load<Effect>("Effects_Shaders/KinectColorVisualizer"), this, this.root_game.GraphicsDevice); this.depth_stream = new DepthStreamManager(new Rectangle(this.root_game.GraphicsDevice.Viewport.Width - (int)this.debug_video_stream_dimensions.X, 0, (int)this.debug_video_stream_dimensions.X, (int)this.debug_video_stream_dimensions.Y), this.root_game.Content.Load<Effect>("Effects_Shaders/KinectDepthVisualizer"), this, this.root_game.GraphicsDevice); this.skeleton_stream = new SkeletonStreamManager(new Rectangle(this.root_game.GraphicsDevice.Viewport.Width - (int)this.debug_video_stream_dimensions.X * 3, 0, (int)this.debug_video_stream_dimensions.X, (int)this.debug_video_stream_dimensions.Y), this, this.root_game.GraphicsDevice, this.root_game.Content.Load<Texture2D>("Textures/Kinect/SkeletonJoint"), this.root_game.Content.Load<Texture2D>("Textures/Kinect/SkeletonBone")); }