<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Comment Feed for Channel 9 - Detecting the Kinect sensor state change/disconnection example</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/coding4fun/kinect/Detecting-the-Kinect-sensor-state-changedisconnection-example/RSS"></atom:link>
	<image>
		<url>http://files.channel9.msdn.com/thumbnail/49cf26d3-3f37-4b9f-bb5c-3e358c577a7b.png</url>
		<title>Channel 9 - Detecting the Kinect sensor state change/disconnection example</title>
		<link></link>
	</image>
	<description>Today&#39;s project is a simple example, but one that will help you add that professional and completeness to your Kinect for Windows SDK applications... [# KINECTSDK] HowTo: Detect the sensor state change and sensor disconnectionIf we go ahead we can see in KinectSensor we have a special event to capture the States of sensors: StatusChanged.This event also can be used to detect when you connect or disconnect a sensor to the USB port. An example with this code in a console application: ... When we launched the application we can see how the timestamp, shows a small difference between the connected sensor and active sensor (lines 2y3 vs 4.5 lines)    1: 20:23:32.9637224 - Start sample application   2: 20:23:40.0351074 - New Status: Initializing   3: 20:23:40.0351074 - Sensor Status: Initializing   4: 20:23:44.7783652 - New Status: Connected   5: 20:23:44.7783652 - Sensor Status: Connected   6: 20:23:51.2279666 - New Status: Disconnected   7: 20:23:51.2279666 - Sensor Status: Disconnected   8: 20:23:59.2548372 - New Status: Initializing   9: 20:23:59.2558370 - Sensor Status: Initializing  10: 20:24:03.5861851 - New Status: Connected  11: 20:24:03.5861851 - Sensor Status: Connected  12: 20:24:08.8158976 - New Status: Disconnected  13: 20:24:08.8158976 - Sensor Status: DisconnectedIf we also want to take advantage of this event to initialize the sensor, we must bear in mind that we can only do so when the State of the sensor is &amp;quot;connected&amp;quot;. The complete example below shows one way of doing it. Project Information URL: http://elbruno.com/2012/03/06/kinectsdk-howto-detect-the-sensor-state-change-and-sensor-disconnection/ using System; 
using Microsoft.Kinect;

namespace KinectStatus01 
{ 
    class Program 
    { 
        private static KinectSensor _kinect; 
        static void Main(string[] args) 
         { 
             Console.WriteLine(&amp;quot;{0} - Start sample application&amp;quot;, DateTime.Now.TimeOfDay.ToString()); 
             KinectSensor.KinectSensors.StatusChanged &amp;#43;= KinectSensorsStatusChanged; 
             Console.ReadLine(); 
             if(_kinect != null) 
             { 
                 _kinect.Stop(); 
             } 
         } 
  

         static void KinectSensorsStatusChanged(object sender, StatusChangedEventArgs e) 
         { 
             Console.WriteLine(&amp;quot;{0} - New Status: {1}&amp;quot;, DateTime.Now.TimeOfDay.ToString(), e.Status); 
             _kinect = e.Sensor; 
             if (e.Sensor != null) 
             { 
                 Console.WriteLine(&amp;quot;{0} - Sensor Status: {1}&amp;quot;, DateTime.Now.TimeOfDay.ToString(), _kinect.Status); 
                 if (_kinect.Status == KinectStatus.Connected) 
                 { 
                     _kinect.DepthStream.Enable(); 
                     _kinect.ColorStream.Enable(); 
                     _kinect.SkeletonStream.Enable(); 
                     _kinect.Start(); 
                     Console.WriteLine(&amp;quot;{0} - Sensor Started&amp;quot;, DateTime.Now.TimeOfDay.ToString()); 
                 } 
             } 
             else 
             { 
                 Console.WriteLine(&amp;quot;{0} - No Sensor&amp;quot;, DateTime.Now.TimeOfDay.ToString()); 
             } 
         } 
     } 
}

&amp;nbsp; Contact Information: Blog: http://elbruno.com/ Twitter: @elbruno </description>
	<link></link>
	<language>en</language>
	<pubDate>Wed, 22 May 2013 09:24:10 GMT</pubDate>
	<lastBuildDate>Wed, 22 May 2013 09:24:10 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<item>
		<title>Re: Detecting the Kinect sensor state change/disconnection example</title>
		<description>
			<![CDATA[<p>Greg,</p><p>The code seems to have a small error. I tried it, and while it does start, it does not report the status of my Kinect for Windows sensor. I think this *may* have something to do with line 27, where in the list of arguments for console.writeline there is &quot;ect.Status&quot;. Did you mean e.Status, or _kinect.Status? Or is it something else entirely?</p><p>posted by Nerdenator</p>]]>
		</description>
		<link>http://channel9.msdn.com/coding4fun/kinect/Detecting-the-Kinect-sensor-state-changedisconnection-example#c634727828112427913</link>
		<pubDate>Wed, 16 May 2012 16:33:31 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/coding4fun/kinect/Detecting-the-Kinect-sensor-state-changedisconnection-example#c634727828112427913</guid>
		<dc:creator>Nerdenator</dc:creator>
	</item>
	<item>
		<title>Re: Detecting the Kinect sensor state change/disconnection example</title>
		<description>
			<![CDATA[<p>@<a href="/coding4fun/kinect/Detecting-the-Kinect-sensor-state-changedisconnection-example#c634727828112427913?areaType=Blogs&amp;areaName=Coding4FunKinect">Nerdenator</a>: Good catch, thank you.</p><p>Yep, there was a bug on line 27 (now fixed). I switched it to e.Status and it seems to work for me.</p><p>In looking at the original post though, looks like the author later updated it to use _kinect.Status. Either one should work.</p><p>(Just a side note, I cannot take any credit for this project/code. The original author, <a title="http://elbruno.com/" href="http://elbruno.com/">http://elbruno.com/,</a>&nbsp;deserves all the kudo's and credit, etc&nbsp;for it. I'm just the messenger...</p><p>&nbsp;<img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif?v=c9' alt='Wink' /></p><p>posted by gduncan411</p>]]>
		</description>
		<link>http://channel9.msdn.com/coding4fun/kinect/Detecting-the-Kinect-sensor-state-changedisconnection-example#c634727905658913438</link>
		<pubDate>Wed, 16 May 2012 18:42:45 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/coding4fun/kinect/Detecting-the-Kinect-sensor-state-changedisconnection-example#c634727905658913438</guid>
		<dc:creator>gduncan411</dc:creator>
	</item>
</channel>
</rss>