<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Abhijit&#039;s World of .NET &#187; .NET 4.0</title>
	<atom:link href="http://abhijitjana.net/category/net-4-0/feed/" rel="self" type="application/rss+xml" />
	<link>http://abhijitjana.net</link>
	<description>Success is a journey , It’s not a destination</description>
	<lastBuildDate>Mon, 13 Feb 2012 18:09:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='abhijitjana.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/5686a1e614b4b192b9ff56ffbb1c9000?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Abhijit&#039;s World of .NET &#187; .NET 4.0</title>
		<link>http://abhijitjana.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://abhijitjana.net/osd.xml" title="Abhijit&#039;s World of .NET" />
	<atom:link rel='hub' href='http://abhijitjana.net/?pushpress=hub'/>
		<item>
		<title>JScript Debugger&#8211; &#8220;Unable to attach the process. Another debugger might be attached to the process&#8221; &#8211; while application is running from Visual Studio. [ Solution ]</title>
		<link>http://abhijitjana.net/2012/01/20/jscript-debugger-unable-to-attach-the-process-another-debugger-might-be-attached-to-the-process-while-application-is-running-from-visual-studio-solution/</link>
		<comments>http://abhijitjana.net/2012/01/20/jscript-debugger-unable-to-attach-the-process-another-debugger-might-be-attached-to-the-process-while-application-is-running-from-visual-studio-solution/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 16:57:48 +0000</pubDate>
		<dc:creator>Abhijit Jana</dc:creator>
				<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[ASP.NET 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[ASP.NET 4.5]]></category>
		<category><![CDATA[Visual Studio 2011]]></category>
		<category><![CDATA[codeproject]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Debugging]]></category>

		<guid isPermaLink="false">https://abhijitjana.wordpress.com/?p=3416</guid>
		<description><![CDATA[IE Developer toolbar provide us a fantastic and easiest way to debug JavaScript with in browser.&#160; If the web site is hosted on IIS and you are trying&#160; debug JavaScript using IE Developer tool bar, it will work fine if you the correct browser setting for debugging. If you are running your web application directly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3416&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>IE Developer toolbar provide us a fantastic and easiest way to debug JavaScript with in browser.&#160; If the web site is hosted on IIS and you are trying&#160; debug JavaScript using IE Developer tool bar, it will work fine if you the correct browser setting for debugging. If you are running your web application directly from visual studio, you might came across the problem of “<strong>Unable to attach to the process</strong>”&#160; while click on “<strong>Start debugging</strong>” button in IE Developer toolbar. In this post I am going to talk about the resolution of the same and will also talk about little bit behind the scene.</p>
<p><span id="more-3416"></span><br />
<h2><font><font color="#000080"><font>Problem:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></font>&#160;</font></h2>
<p>IE Developer Toolbar – JS Debugger Error <font><strong>“Unable to attach the process. Another debugger might be attached to the process” </strong></font>. </p>
<h3><font>Steps :</font></h3>
<p>1. Run an <strong>ASP.NET</strong> application from <strong>Visual Studio</strong>.</p>
<p>2. Once application launched, Press <strong>F12</strong> in browser to launch Developer Toolbar.</p>
<p>3. Move to “<strong>Script”</strong> Tab and Click on “<strong>Start Debugging</strong>” . <font size="1">Put necessary breakpoints on the script function as required before click</font>.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;padding-top:0;border-width:0;margin:0 auto;" title="image" border="0" alt="image" src="http://abhijitjana.files.wordpress.com/2012/01/image4.png?w=429&#038;h=94" width="429" height="94" /></p>
<p>On click of “<strong>Start Debugging</strong>”, you will receive below error message. which says, already another debugger attached and you can not attach with current IE Process for debugging.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;padding-top:0;border-width:0;margin:0 auto;" title="image" border="0" alt="image" src="http://abhijitjana.files.wordpress.com/2012/01/image5.png?w=560&#038;h=209" width="560" height="209" /></p>
<h2><font color="#000080">Solution :&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></h2>
<p>Follow the below steps for resolve this issue.</p>
<p>1. Go back to Visual Studio and&#160; Select “<strong>Detach All</strong>” from “<strong>Debug</strong>” menu.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;padding-top:0;border-width:0;margin:0 auto;" title="image" border="0" alt="image" src="http://abhijitjana.files.wordpress.com/2012/01/image6.png?w=440&#038;h=223" width="440" height="223" /></p>
<p>2. Now click on “<strong>Start Debugging</strong>” from IE Developer Toolbar.&#160; No error , and you can continue with debugging and other work.</p>
<h2><font color="#646b86"></font><font color="#000080"><font>Behind the scene :&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font><font color="#646b86"></font></h2>
<p>Visual Studio automatically instantiate an Internet explorer process to launch the web sites. You can check the process level using “<strong>Process Explorer</strong>”. </p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;padding-top:0;border-width:0;margin:0 auto;" title="image" border="0" alt="image" src="http://abhijitjana.files.wordpress.com/2012/01/image7.png?w=505&#038;h=152" width="505" height="152" /></p>
<p>Also, it attached the process&#160; “<strong>iexplore.exe</strong>” automatically&#160; during launch of site that helps us debug&#160; JavaScript from visual studio itself. You can check&#160; it from Solution explorer itself</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;padding-top:0;border-width:0;margin:0 auto;" title="image" border="0" alt="image" src="http://abhijitjana.files.wordpress.com/2012/01/image8.png?w=614&#038;h=191" width="614" height="191" /></p>
<p>Which mean, while your site is running in browser, “<strong>iexplore.exe</strong>” ( Process for Internet Explorer) is already attached .&#160; One of the most simplest way to check this out is, navigate to&#160; <strong><a href="http://dailydotnettips.com/2012/01/20/how-to-get-list-of-attached-processes-in-visual-studio-while-debugging/" target="_blank">Debug &gt; Windows&gt; Processes</a> .&#160; </strong>This will list out all attached process with in visual studio . For any typical ASP.NET web application which is running from visual studio will have two process and <strong>iexplore</strong> is one of them.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;padding-top:0;border-width:0;margin:0 auto;" title="image" border="0" alt="image" src="http://abhijitjana.files.wordpress.com/2012/01/image9.png?w=775&#038;h=180" width="775" height="180" /></p>
<p>That’s why when you are trying to attach the same process from IE Developer tool bar, it is throwing error<strong> <font></font>“Unable to attach the process. Another debugger might be attached to the process” . </strong></p>
<p><em>So now we know what was the causing the issue and let’s have a look what we did to resolve this.&#160; </em></p>
<p>As a resolution,&#160; we used “<strong>Detach All</strong>” from debug menu, which actually detach all the process which is attached with visual studio except local ASP.NET Development server process&#160; ( <strong>WebDev.WebServer40.EXE</strong> ).&#160; </p>
<blockquote><p><strong>Note :</strong> “<strong>Detach All”</strong> will detach all the attached process apart from ASP.NET Development server. Because detaching the development server is nothing but stopping your application. If you want to stop, either <strong>stop debugging</strong> or “<strong>Terminate</strong>” the local development sever process.</p>
</blockquote>
<p>“<strong>Detach All”</strong> will remove iexplore.exe from the list of attached process. So, you can go ahead and start the debugging in IE Developer toolbar.</p>
<p><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:block;float:none;border-top:0;border-right:0;padding-top:0;margin:0 auto;" title="image" border="0" alt="image" src="http://abhijitjana.files.wordpress.com/2012/01/image10.png?w=765&#038;h=178" width="765" height="178" /></p>
<h3><font color="#000080">Detaching a Particular Process Instead “Detach All”&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font></h3>
<p>If there are multiple processes attached and if you want to detach only <strong>“IE</strong> <strong>Process”,</strong> you can simply do it from process attach window, by selecting&#160; “<strong>Detach Process</strong>” from the content menu of the “<strong>iexplore.exe</strong>”.&#160; This will help you to retain on other process in attached state.</p>
<p><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:block;float:none;border-top:0;border-right:0;padding-top:0;margin:0 auto;" title="image" border="0" alt="image" src="http://abhijitjana.files.wordpress.com/2012/01/image11.png?w=734&#038;h=255" width="734" height="255" /></p>
<blockquote><p>To know more about <strong>Processes Window</strong>, check out this post <a href="http://dailydotnettips.com/2012/01/20/how-to-get-list-of-attached-processes-in-visual-studio-while-debugging/">How to get list of attached processes in Visual Studio while debugging ?</a></p>
</blockquote>
<p>Hope this helps !</p>
<p>Cheers !</p>
<p>Abhijit</p>
<br />Filed under: <a href='http://abhijitjana.net/category/net-4-0/'>.NET 4.0</a>, <a href='http://abhijitjana.net/category/asp-net-4-0/'>ASP.NET 4.0</a>, <a href='http://abhijitjana.net/category/asp-net-4-5/'>ASP.NET 4.5</a>, <a href='http://abhijitjana.net/category/tips-and-tricks/'>Tips and Tricks</a>, <a href='http://abhijitjana.net/category/visual-studio/'>Visual Studio</a>, <a href='http://abhijitjana.net/category/visual-studio-2010/'>Visual Studio 2010</a>, <a href='http://abhijitjana.net/category/visual-studio-2011/'>Visual Studio 2011</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abhijitjana.wordpress.com/3416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abhijitjana.wordpress.com/3416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abhijitjana.wordpress.com/3416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abhijitjana.wordpress.com/3416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abhijitjana.wordpress.com/3416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abhijitjana.wordpress.com/3416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abhijitjana.wordpress.com/3416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abhijitjana.wordpress.com/3416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abhijitjana.wordpress.com/3416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abhijitjana.wordpress.com/3416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abhijitjana.wordpress.com/3416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abhijitjana.wordpress.com/3416/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abhijitjana.wordpress.com/3416/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abhijitjana.wordpress.com/3416/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3416&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abhijitjana.net/2012/01/20/jscript-debugger-unable-to-attach-the-process-another-debugger-might-be-attached-to-the-process-while-application-is-running-from-visual-studio-solution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2d57d87d3990f59469b6b6bd8f03f490?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Abhijit Jana</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2012/01/image4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2012/01/image5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2012/01/image6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2012/01/image7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2012/01/image8.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2012/01/image9.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2012/01/image10.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2012/01/image11.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>25 Tips on ASP.NET, C#, MEF, Visual Studio, Profiler &#8211; September 2011 Links</title>
		<link>http://abhijitjana.net/2011/09/30/25-tips-on-asp-net-c-mef-visual-studio-profiler-september-2011-links/</link>
		<comments>http://abhijitjana.net/2011/09/30/25-tips-on-asp-net-c-mef-visual-studio-profiler-september-2011-links/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 13:24:28 +0000</pubDate>
		<dc:creator>Abhijit Jana</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[ASP.NET 4.0]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[dailydotnettips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">https://abhijitjana.wordpress.com/2011/09/30/25-tips-on-asp-net-c-mef-visual-studio-profiler-september-2011-links/</guid>
		<description><![CDATA[Daily .NET Tips is aiming to sharing useful coding tips and tricks for .NET Developers. This site completely design for sharing Tips and Tricks, useful Code Snippet which anyone use in daily development work and targeted anything related with .NET.&#160;&#160; This month we have wide range of tips including ASP.NET, C#, MEF, Visual Studio, Profiler [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3253&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://dailydotnettips.com">Daily .NET Tips </a>is aiming to sharing useful coding tips and tricks for .NET Developers. This site completely design for sharing Tips and Tricks, useful Code Snippet which anyone use in daily development work and targeted anything related with .NET.&#160;&#160; This month we have wide range of tips including ASP.NET, C#, MEF, Visual Studio, Profiler etc. In this post I am quickly listing down all the tips which are published over the month September 2011</p>
<p><span id="more-3253"></span>
<ol>
<li><a href="http://dailydotnettips.com/2011/09/28/how-to-enable-tier-interaction-profiling-tip-in-visual-studio-2010-profiler/">How to enable Tier Interaction Profiling ( TIP ) in Visual Studio 2010 Profiler ?</a></li>
<li><a href="http://dailydotnettips.com/2011/09/27/highlighting-execution-hot-path-in-visual-studio-2010-profiler-call-tree/">Highlighting Execution Hot Path in Visual Studio 2010 Profiler Call Tree</a></li>
<li><a href="http://dailydotnettips.com/2011/09/26/create-work-item-in-tfs-for-specific-visual-studio-2010-profiler-report/">Create Work Item in TFS for Specific Visual Studio 2010 Profiler Report</a></li>
<li><a href="http://dailydotnettips.com/2011/09/25/setting-up-noise-reduction-option-for-performance-reports-in-visual-studio-2010-profiler/">Setting Up Noise Reduction Option for Performance Reports in Visual Studio 2010 Profiler</a></li>
<li><a href="http://dailydotnettips.com/2011/09/24/how-to-change-default-performance-report-name-in-visual-studio-2010/">How to change Default Performance Report Name in Visual Studio 2010 ?</a></li>
<li><a href="http://dailydotnettips.com/2011/09/20/using-code-definition-widow-with-call-hierarchy-in-visual-studio-2010/">Using Code Definition Window with Call Hierarchy in Visual Studio 2010</a></li>
<li><a href="http://dailydotnettips.com/2011/09/19/navigate-code-using-code-definition-window-in-visual-studio/">Navigate Code Using Code Definition Window in Visual Studio</a></li>
<li><a href="http://dailydotnettips.com/2011/09/18/data-schema-comparison-in-visual-studio-2010/">Data Schema Comparison in Visual Studio 2010</a></li>
<li><a href="http://dailydotnettips.com/2011/09/17/sort-generic-list-using-lambda-expression-for-dynamic-type-and-dynamic-property/">Sort Generic List Using Lambda Expression For Dynamic Type And Dynamic Property</a></li>
<li><a href="http://dailydotnettips.com/2011/09/16/how-to-pass-command-line-arguments-using-visual-studio/">How to Pass Command Line Arguments using Visual Studio ?</a></li>
<li><a href="http://dailydotnettips.com/2011/09/15/specifying-assembly-information-in-visual-studio/">Specifying Assembly Information in Visual Studio</a></li>
<li><a href="http://dailydotnettips.com/2011/09/14/install-a-shared-assembly-to-the-gac-as-post-build-event-from-visual-studio/">Install a shared Assembly to the GAC as post build event from Visual Studio</a></li>
<li><a href="http://dailydotnettips.com/2011/09/13/programmatically-get-assembly-version/">Programmatically Get Assembly Version</a></li>
<li><a href="http://dailydotnettips.com/2011/09/12/maps-keys-to-a-collection-of-values-using-lookup-collection/">Maps Keys to a Collection of Values using Lookup Collection</a></li>
<li><a href="http://dailydotnettips.com/2011/09/11/conditional-binding-expression-with-asp-net-gridview/">Conditional Binding Expression with ASP.NET GridView</a></li>
<li><a href="http://dailydotnettips.com/2011/09/10/how-to-change-selected-date-background-color-of-current-week-in-asp-net-calendar/">How to change selected date background color of current week in ASP.NET Calendar ?</a></li>
<li><a href="http://dailydotnettips.com/2011/09/09/how-to-change-background-color-of-current-week-in-asp-net-calendar/">How to Change Background Color of Current Week in ASP.NET Calendar ?</a></li>
<li><a href="http://dailydotnettips.com/2011/09/08/how-to-enable-code-coverage-in-visual-studio-2010/">How to enable code coverage in Visual Studio 2010 ?</a></li>
<li><a href="http://dailydotnettips.com/2011/09/07/setting-up-policies-for-extensible-parts-in-mef/">Setting up Policies for Extensible Parts in MEF</a></li>
<li><a href="http://dailydotnettips.com/2011/09/06/importconstructor-to-inject-constructor-mef/">Use of ImportConstructor to inject Constructor code in MEF</a></li>
<li><a href="http://dailydotnettips.com/2011/09/05/writing-metadata-in-contracts-of-mef/">Writing Metadata in Contracts of MEF</a></li>
<li><a href="http://dailydotnettips.com/2011/09/04/working-with-compositionbatch-in-mef/">Working with CompositionBatch in MEF</a></li>
<li><a href="http://dailydotnettips.com/2011/09/03/allow-recomposition-in-mef/">Allow Recomposition in MEF</a></li>
<li><a href="http://dailydotnettips.com/2011/09/02/getting-lazy-with-mef/">Getting Lazy with MEF</a></li>
<li><a href="http://dailydotnettips.com/2011/09/01/partnotdiscoverable-attribute-in-mef/">PartNotDiscoverable attribute in MEF</a></li>
</ol>
<p>&#160;</p>
<p>To get regular updates visit <a href="http://dailydotnettips.com">http://dailydotnettips.com</a> and follow <a href="http://twitter.com/dailydotnettips">@dailydotnettips</a> at Twitter </p>
<br />Filed under: <a href='http://abhijitjana.net/category/net-4-0/'>.NET 4.0</a>, <a href='http://abhijitjana.net/category/asp-net-4-0/'>ASP.NET 4.0</a>, <a href='http://abhijitjana.net/category/tips-and-tricks/'>Tips and Tricks</a>, <a href='http://abhijitjana.net/category/visual-studio/'>Visual Studio</a>, <a href='http://abhijitjana.net/category/visual-studio-2010/'>Visual Studio 2010</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abhijitjana.wordpress.com/3253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abhijitjana.wordpress.com/3253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abhijitjana.wordpress.com/3253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abhijitjana.wordpress.com/3253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abhijitjana.wordpress.com/3253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abhijitjana.wordpress.com/3253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abhijitjana.wordpress.com/3253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abhijitjana.wordpress.com/3253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abhijitjana.wordpress.com/3253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abhijitjana.wordpress.com/3253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abhijitjana.wordpress.com/3253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abhijitjana.wordpress.com/3253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abhijitjana.wordpress.com/3253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abhijitjana.wordpress.com/3253/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3253&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abhijitjana.net/2011/09/30/25-tips-on-asp-net-c-mef-visual-studio-profiler-september-2011-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2d57d87d3990f59469b6b6bd8f03f490?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Abhijit Jana</media:title>
		</media:content>
	</item>
		<item>
		<title>Development With Kinect .NET SDK (Part V) &#8211; Developing Application using Multiple Kinect Devices</title>
		<link>http://abhijitjana.net/2011/09/23/development-with-kinect-net-sdk-part-v-developing-application-using-multiple-kinect-devices/</link>
		<comments>http://abhijitjana.net/2011/09/23/development-with-kinect-net-sdk-part-v-developing-application-using-multiple-kinect-devices/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 14:15:28 +0000</pubDate>
		<dc:creator>Abhijit Jana</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Kinect]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[kinect SDK]]></category>
		<category><![CDATA[Kinect SDK With Multiple Devices]]></category>
		<category><![CDATA[Kinect Tutorial]]></category>
		<category><![CDATA[multiple Kinect Devices]]></category>

		<guid isPermaLink="false">https://abhijitjana.wordpress.com/?p=3238</guid>
		<description><![CDATA[This is the fifth post in the series of Development With Kinect .NET SDK.  In this post I am going to discuss about interacting with multiple Kinect devices with in a single system using Kinect .NET SDK. Before going forward, I will strongly recommend you to read my previous post where I have discussed about [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3238&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is the fifth post in the series of <a href="http://abhijitjana.net/tag/kinect-tutorial/">Development With Kinect .NET SDK.</a>  In this post I am going to discuss about interacting with multiple Kinect devices with in a single system using Kinect .NET SDK. Before going forward, I will strongly recommend you to read my previous post where I have discussed about <a href="http://abhijitjana.net/2011/09/20/development-with-kinect-net-sdk-part-iv-connecting-multiple-kinect-devices-with-system/">Connecting Multiple Kinect Devices with System</a>  which will help you setup your system with multiple devices.</p>
<p><span id="more-3238"></span></p>
<p>Once both devices configured and setup properly,  you can run the below code snippet to check if Kinect SDK detects both of  the  devices.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image65.png?w=586&#038;h=178" alt="image" width="586" height="178" border="0" /></p>
<p>Once you have the correct device count you can start with application development. During this exercise we will be applying all the learning that we have gained over the past few articles.</p>
<p>Let’s start with the a New “<em><span style="color:#000080;">WPF</span></em>” Project and named it as “<em><span style="color:#000080;">MultipleKinectDemo</span></em>”</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image66.png?w=648&#038;h=422" alt="image" width="648" height="422" align="left" border="0" /></p>
<p>Navigate to solution explorer, Right Click on the Project and Select “<em><span style="color:#000080;">Add Reference</span></em>” and add “<span style="color:#000080;"><em>Microsoft.Research.Kinect.dll</em></span>” as reference assembly.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image67.png?w=354&#038;h=229" alt="image" width="354" height="229" border="0" /></p>
<p>Add a new class named “<em><span style="color:#000080;">KinectDevice</span></em>”  which will be  a container entity for multiple Kinect devices.   Below is the code snippet for the <em><span style="color:#000080;">KinectDevice.cs</span></em>.</p>
<p><pre class="brush: csharp;">
using Microsoft.Research.Kinect.Nui;
/// &lt;summary&gt;
/// Kinect Device
/// &lt;/summary&gt;
public sealed class KinectDevice
{
    /// &lt;summary&gt;
    /// Gets or sets the name of the device.
    /// &lt;/summary&gt;
    /// &lt;value&gt;The name of the device.&lt;/value&gt;
    public string DeviceName { get; set; }

    /// &lt;summary&gt;
    /// Gets or sets the kinect runtime.
    /// &lt;/summary&gt;
    /// &lt;value&gt;The kinect runtime.&lt;/value&gt;
    public Runtime KinectRuntime { get; set; }
}
</pre></p>
<p>In the above class “<em><span style="color:#000080;">KinectRuntime</span></em>” is type of  Kinect <span style="text-decoration:underline;"><span style="color:#000080;text-decoration:underline;">Runtime</span></span> and  We will be creating a <span style="text-decoration:underline;"><em><span style="color:#000080;text-decoration:underline;">List&lt;KinectDevice&gt;</span></em></span> to contain the multiple object of devices.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image68.png?w=409&#038;h=488" alt="image" width="409" height="488" border="0" /></p>
<p>Capturing <span style="color:#000080;">video</span>, <span style="color:#000080;">Depth</span> <span style="color:#000080;">images</span> are same as we did earlier for a single kinect, but the new steps involves with initializing of multiple Kinect devices.   The Kinect .NET SDK does provide support for multiple Kinect devices.   Runtime class has a <span style="color:#000080;">overloaded constructed</span> where it take index as argument.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image69.png?w=329&#038;h=114" alt="image" width="329" height="114" border="0" /></p>
<p>You can create a new <span style="color:#000080;">Runtime</span> object and pass the index of sensors  as  <span style="text-decoration:underline;"><em><span style="color:#000080;text-decoration:underline;"> r</span><span style="color:#000080;text-decoration:underline;">untimeNui = new Runtime(index)</span></em></span>.</p>
<p>In our application we will create a <span style="text-decoration:underline;"><em><span style="color:#000080;text-decoration:underline;">List&lt;KinectDevice</span></em></span>&gt; and store the  each runtime object  .</p>
<p>Before that, create a basic US as shown in below,</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;padding-top:0;border-width:0;margin:0 auto;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image70.png?w=641&#038;h=461" alt="image" width="641" height="461" border="0" /></p>
<p>Very straight forward UI, you can check out the XAML markup which in given in then end.</p>
<p>Let’s do it now Step by Step</p>
<h2><span style="color:#000080;">Detect Kinect Devices </span><span style="color:#000080;"><br />
</span></h2>
<p>First of all we need to detect the devices. Kinect SDK APIs provides a class “<em><span style="color:#000080;">Device</span></em>” which r<em><span style="color:#000080;">epresents a system’s Kinect sensors</span></em>. It’s has a property “<span style="color:#000080;">Count</span>” which holds the number of Kinect been detected.  Write the blow code snippet in the Detect Button click event.</p>
<p><pre class="brush: csharp;">
 /// &lt;summary&gt;
        /// Handles the Click event of the buttonDetect control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonDetect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Device device = new Device();
                this.DeviceCount = device.Count;
                this.buttonDetect.Content = string.Format(&quot;Kinect Device Detected {0}&quot;, this.DeviceCount.ToString());
            }
            catch (Exception exp)
            {
                MessageBox.Show(string.Format(&quot;Error Occured in Device Detection : &quot;, exp.Message));
            }
        }
</pre></p>
<p><span style="color:#000080;">this.DeviceCount</span> is a private properties which defined locally to the current class.</p>
<p><pre class="brush: csharp;">
        /// &lt;summary&gt;
        /// Gets or sets the device count.
        /// &lt;/summary&gt;
        /// &lt;value&gt;The device count.&lt;/value&gt;
        private int DeviceCount { get; set; }
</pre></p>
<p>After successfully detection of the devices, we changed the content of the Button with number of detected device.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;padding-top:0;border-width:0;margin:0 auto;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image71.png?w=409&#038;h=46" alt="image" width="409" height="46" border="0" /></p>
<h2><span style="color:#000080;">Multiple Kinect Runtime</span></h2>
<p>As discussed earlier, Kinect .SDK support detection of multiple SDK and Runtime class has a overloaded constructor that takes index as arguments.  Below code snippets shows how we can initialize multiple Kinect Runtime</p>
<p><pre class="brush: csharp;">
 /// &lt;summary&gt;
        /// Handles the Click event of the buttonInitializeRuntime control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonInitializeRuntime_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                for (int i = 0; i &lt; this.DeviceCount; i++)
                {
                    kinectDevices.Add(new KinectDevice
                                        {
                                            KinectRuntime = new Runtime(i),
                                            DeviceName = string.Format(&quot;{0} {1}&quot;,
                                            DeviceName, i.ToString())
                                        });
                }

                this.buttonKinectOne.IsEnabled = true;
                this.buttonKinectTwo.IsEnabled = true;
            }
            catch (Exception exp)
            {
                MessageBox.Show(string.Format(&quot;Runtime Initialization Failed : &quot;, exp.Message));
            }
        }
</pre></p>
<p><span style="color:#000080;">kinectDevices</span> is a <em><span style="color:#000080;">List of KinectDevice</span></em> which I have discussed earlier.</p>
<p><pre class="brush: csharp;">
        /// &lt;summary&gt;
        /// Kinect Device Place Holder
        /// &lt;/summary&gt;
        List&lt;KinectDevice&gt; kinectDevices = new List&lt;KinectDevice&gt;();
</pre></p>
<h2><span style="color:#000080;">Taking Control over Individual Kinect  </span></h2>
<p>Once we have the runtime initialized, we can easily take control over the individual Kinect.<span style="color:#000080;"> kinectDevices[0]</span> and <span style="color:#000080;">kinectDevices[1]</span> are the runtime container for individual Kinect. Below code snippets show how we can detect the first Kinect devices.</p>
<p><pre class="brush: csharp;">
  /// &lt;summary&gt;
        /// Handles the Click event of the buttonKinectOne control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonKinectOne_Click(object sender, RoutedEventArgs e)
        {
            KinectDevice deviceOne = kinectDevices[0];
            Runtime deviceRuntimeOne = deviceOne.KinectRuntime;
            deviceRuntimeOne.Initialize(RuntimeOptions.UseColor);
            deviceRuntimeOne.NuiCamera.ElevationAngle = 0;
            deviceName1.Content = deviceOne.DeviceName;
            deviceRuntimeOne.VideoFrameReady += new EventHandler&lt;ImageFrameReadyEventArgs&gt;(deviceRuntimeOne_VideoFrameReady);
            deviceRuntimeOne.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
        }
</pre></p>
<p>As we have the specific Kinect runtime, we can easily take care of <span style="color:#000080;">VideoFrameReady</span> event and  <span style="color:#000080;">VideoStream</span>.Open() method.</p>
<p><pre class="brush: csharp;">
 /// &lt;summary&gt;
        /// Handles the VideoFrameReady event of the deviceRuntimeOnce control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;Microsoft.Research.Kinect.Nui.ImageFrameReadyEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void deviceRuntimeOne_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
        {
            image1.Source = e.ImageFrame.ToBitmapSource();
            PlanarImage imageData = e.ImageFrame.Image;
            camera1Small.Source = BitmapSource.Create(imageData.Width, imageData.Height, 96, 96, PixelFormats.Cmyk32, null, imageData.Bits, imageData.Width * imageData.BytesPerPixel);
        }
</pre></p>
<p>Similar we can write the code for <span style="color:#000080;">kinectDevices[1]</span></p>
<p>Well, this is the base, rest things are very similar to work with single Kinect device.</p>
<p><strong><span style="color:#000080;">Here is the complete code snippet of the application</span></strong></p>
<p><pre class="brush: csharp;">
/// Developing Application using Multiple Kinect
/// Author : Abhijit Jana
/// Date : 17 - 09 2011
/// ---------------------------------------------------------------------------

namespace MultipleKinectDemo
{
    using System;
    using System.Collections.Generic;
    using System.Windows;
    using Coding4Fun.Kinect.Wpf;
    using Microsoft.Research.Kinect.Nui;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;

    /// &lt;summary&gt;
    /// Interaction logic for MainWindow.xaml
    /// &lt;/summary&gt;
    public partial class MainWindow : Window
    {
        /// &lt;summary&gt;
        /// Gets or sets the device count.
        /// &lt;/summary&gt;
        /// &lt;value&gt;The device count.&lt;/value&gt;
        private int DeviceCount { get; set; }

        /// &lt;summary&gt;
        /// Kinect Device Place Holder
        /// &lt;/summary&gt;
        List&lt;KinectDevice&gt; kinectDevices = new List&lt;KinectDevice&gt;();

        private const string DeviceName = &quot;Kinect Sensors Device&quot;;

        /// &lt;summary&gt;
        /// Initializes a new instance of the &lt;see cref=&quot;MainWindow&quot;/&gt; class.
        /// &lt;/summary&gt;
        public MainWindow()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainWindow_Loaded);
            Unloaded += new RoutedEventHandler(MainWindow_Unloaded);
        }

        /// &lt;summary&gt;
        /// Handles the Unloaded event of the MainWindow control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void MainWindow_Unloaded(object sender, RoutedEventArgs e)
        {
            foreach (KinectDevice device in kinectDevices)
            {
                device.KinectRuntime.Uninitialize();
            }
        }

        /// &lt;summary&gt;
        /// Handles the Loaded event of the MainWindow control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            this.buttonKinectOne.IsEnabled = false;
            this.buttonKinectTwo.IsEnabled = false;
        }

        /// &lt;summary&gt;
        /// Handles the Click event of the buttonDetect control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonDetect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Device device = new Device();
                this.DeviceCount = device.Count;
                this.buttonDetect.Content = string.Format(&quot;Kinect Device Detected {0}&quot;, this.DeviceCount.ToString());
            }
            catch (Exception exp)
            {
                MessageBox.Show(string.Format(&quot;Error Occured in Device Detection : &quot;, exp.Message));
            }
        }

        /// &lt;summary&gt;
        /// Handles the Click event of the buttonInitializeRuntime control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonInitializeRuntime_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                for (int i = 0; i &lt; this.DeviceCount; i++)
                {
                    kinectDevices.Add(new KinectDevice
                                        {
                                            KinectRuntime = new Runtime(i),
                                            DeviceName = string.Format(&quot;{0} {1}&quot;,
                                            DeviceName, i.ToString())
                                        });
                }

                this.buttonKinectOne.IsEnabled = true;
                this.buttonKinectTwo.IsEnabled = true;
            }
            catch (Exception exp)
            {
                MessageBox.Show(string.Format(&quot;Runtime Initialization Failed : &quot;, exp.Message));
            }
        }

        /// &lt;summary&gt;
        /// Handles the Click event of the buttonKinectOne control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonKinectOne_Click(object sender, RoutedEventArgs e)
        {
            KinectDevice deviceOne = kinectDevices[0];
            Runtime deviceRuntimeOne = deviceOne.KinectRuntime;
            deviceRuntimeOne.Initialize(RuntimeOptions.UseColor);
            deviceRuntimeOne.NuiCamera.ElevationAngle = 0;
            deviceName1.Content = deviceOne.DeviceName;
            deviceRuntimeOne.VideoFrameReady += new EventHandler&lt;ImageFrameReadyEventArgs&gt;(deviceRuntimeOne_VideoFrameReady);
            deviceRuntimeOne.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
        }

        /// &lt;summary&gt;
        /// Handles the VideoFrameReady event of the deviceRuntimeOnce control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;Microsoft.Research.Kinect.Nui.ImageFrameReadyEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void deviceRuntimeOne_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
        {
            image1.Source = e.ImageFrame.ToBitmapSource();
            PlanarImage imageData = e.ImageFrame.Image;
            camera1Small.Source = BitmapSource.Create(imageData.Width, imageData.Height, 96, 96, PixelFormats.Cmyk32, null, imageData.Bits, imageData.Width * imageData.BytesPerPixel);
        }

        /// &lt;summary&gt;
        /// Handles the Click event of the buttonKinectTwo control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonKinectTwo_Click(object sender, RoutedEventArgs e)
        {
            KinectDevice deviceTwo = kinectDevices[1];
            Runtime deviceRuntimeTwo = deviceTwo.KinectRuntime;
            deviceRuntimeTwo.Initialize(RuntimeOptions.UseColor);
            deviceRuntimeTwo.NuiCamera.ElevationAngle = 0;
            deviceName2.Content = deviceTwo.DeviceName;
            deviceRuntimeTwo.VideoFrameReady += new EventHandler&lt;ImageFrameReadyEventArgs&gt;(deviceRuntimeTwo_VideoFrameReady);
            deviceRuntimeTwo.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
        }

        /// &lt;summary&gt;
        /// Handles the VideoFrameReady event of the deviceRuntimeTwo control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;Microsoft.Research.Kinect.Nui.ImageFrameReadyEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void deviceRuntimeTwo_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
        {
            image2.Source = e.ImageFrame.ToBitmapSource();
            PlanarImage imageData = e.ImageFrame.Image;
            camera2Small.Source = BitmapSource.Create(imageData.Width, imageData.Height, 96, 96, PixelFormats.Cmyk32, null, imageData.Bits, imageData.Width * imageData.BytesPerPixel);
        }

        /// &lt;summary&gt;
        /// Handles the Click event of the camera1Up control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void camera1Up_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                kinectDevices[0].KinectRuntime.NuiCamera.ElevationAngle = kinectDevices[0].KinectRuntime.NuiCamera.ElevationAngle + 5;
            }
            catch (ArgumentOutOfRangeException aore)
            {

                MessageBox.Show(&quot;Elevation angle must be between Elevation Minimum/Maximum&quot;);
            }

            catch (Exception)
            {

            }

        }

        /// &lt;summary&gt;
        /// Handles the Click event of the camera1Down control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void camera1Down_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                kinectDevices[0].KinectRuntime.NuiCamera.ElevationAngle = kinectDevices[0].KinectRuntime.NuiCamera.ElevationAngle - 5;
            }
            catch (ArgumentOutOfRangeException argumentExcpetion)
            {
                MessageBox.Show(&quot;Elevation angle must be between Elevation Minimum/Maximum&quot;);
            }
        }

        /// &lt;summary&gt;
        /// Handles the Click event of the camera2Up control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void camera2Up_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                kinectDevices[1].KinectRuntime.NuiCamera.ElevationAngle = kinectDevices[1].KinectRuntime.NuiCamera.ElevationAngle + 5;
            }
            catch (ArgumentOutOfRangeException argumentExcpetion)
            {

                MessageBox.Show(&quot;Elevation angle must be between Elevation Minimum/Maximum&quot;);
            }
        }

        /// &lt;summary&gt;
        /// Handles the Click event of the camera2Down control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void camera2Down_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                kinectDevices[1].KinectRuntime.NuiCamera.ElevationAngle = kinectDevices[1].KinectRuntime.NuiCamera.ElevationAngle - 5;
            }
            catch (ArgumentOutOfRangeException aore)
            {
                MessageBox.Show(&quot;Elevation angle must be between Elevation Minimum/Maximum&quot;);
            }
        }
    }
}

</pre></p>
<p><strong><span style="color:#000080;">XAML Markup. just drag and drop control <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </span></strong></p>
<p><pre class="brush: xml;">
&lt;Grid&gt;
        &lt;Border BorderBrush=&quot;Silver&quot; BorderThickness=&quot;5&quot; Height=&quot;257&quot; HorizontalAlignment=&quot;Left&quot;
                Margin=&quot;32,207,0,0&quot; Name=&quot;border1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;269&quot;&gt;&lt;/Border&gt;
        &lt;Border BorderBrush=&quot;Silver&quot; BorderThickness=&quot;5&quot; Height=&quot;257&quot; Name=&quot;border2&quot; Width=&quot;269&quot; Margin=&quot;488,206,46,90&quot;&gt;
            &lt;Image Height=&quot;246&quot; Name=&quot;image2&quot; Stretch=&quot;Fill&quot; Width=&quot;259&quot; /&gt;
        &lt;/Border&gt;
        &lt;Button Content=&quot;Kinect 1&quot; Height=&quot;42&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;35,480,0,0&quot; Name=&quot;buttonKinectOne&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;266&quot; Click=&quot;buttonKinectOne_Click&quot; /&gt;
        &lt;Button Content=&quot;Kinect 2&quot; Height=&quot;42&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,480,51,0&quot; Name=&quot;buttonKinectTwo&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;259&quot; Click=&quot;buttonKinectTwo_Click&quot; /&gt;
        &lt;Button Content=&quot;Detect Kinects&quot; Height=&quot;40&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;243,12,0,0&quot; Name=&quot;buttonDetect&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;280&quot; Click=&quot;buttonDetect_Click&quot; /&gt;
        &lt;Label Content=&quot;Camera Device Name&quot; Height=&quot;26&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;32,180,0,0&quot; Name=&quot;deviceName1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;271&quot; /&gt;
        &lt;Label Content=&quot;Camera Device Name&quot; Height=&quot;26&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;486,180,0,0&quot; Name=&quot;deviceName2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;271&quot; /&gt;
        &lt;Image Height=&quot;249&quot; Name=&quot;image1&quot; Stretch=&quot;Fill&quot; Margin=&quot;35,211,502,93&quot; /&gt;
        &lt;Button Content=&quot;Initialize Runtime&quot; Height=&quot;38&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;243,67,0,0&quot; Name=&quot;buttonInitializeRuntime&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;280&quot; Click=&quot;buttonInitializeRuntime_Click&quot; /&gt;
        &lt;Button Content=&quot;UP&quot; FontWeight=&quot;ExtraBold&quot; Height=&quot;43&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;307,356,0,0&quot; Name=&quot;camera1Up&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;41&quot; Click=&quot;camera1Up_Click&quot; /&gt;
        &lt;Button Content=&quot;Down&quot; FontWeight=&quot;ExtraBold&quot; Height=&quot;43&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;307,413,0,0&quot; Name=&quot;camera1Down&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;41&quot; Click=&quot;camera1Down_Click&quot; /&gt;
        &lt;Image Height=&quot;109&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;254,228,0,0&quot; Name=&quot;camera1Small&quot; Stretch=&quot;Fill&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;127&quot; /&gt;
        &lt;Border BorderBrush=&quot;#FFB10E00&quot; BorderThickness=&quot;1&quot; Height=&quot;121&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;248,222,0,0&quot; Name=&quot;border3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;140&quot;&gt;&lt;/Border&gt;
        &lt;Button Content=&quot;UP&quot; FontWeight=&quot;ExtraBold&quot; Height=&quot;43&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;441,356,0,0&quot; Name=&quot;camera2Up&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;41&quot; Click=&quot;camera2Up_Click&quot; /&gt;
        &lt;Button Content=&quot;Down&quot; FontWeight=&quot;ExtraBold&quot; Height=&quot;43&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;441,413,0,0&quot; Name=&quot;camera2Down&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;41&quot; Click=&quot;camera2Down_Click&quot; /&gt;
        &lt;Border BorderBrush=&quot;#FFB10E00&quot; BorderThickness=&quot;1&quot; Height=&quot;121&quot; Name=&quot;border4&quot; Width=&quot;140&quot; Margin=&quot;402,222,261,210&quot;&gt;
            &lt;Image Height=&quot;118&quot; Name=&quot;camera2Small&quot; Stretch=&quot;Fill&quot; Width=&quot;133&quot; /&gt;
        &lt;/Border&gt;
    &lt;/Grid&gt;
</pre></p>
<p>Here is the output of the above application.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;padding-top:0;border:0;margin:0 auto;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image72.png?w=510&#038;h=365" alt="image" width="510" height="365" border="0" /></p>
<h2><strong><strong><a href="https://skydrive.live.com/?cid=6ab190a26079cd46&amp;sc=documents&amp;nl=1&amp;uc=1&amp;id=6AB190A26079CD46%21218">Download Complete Project </a></strong></strong></h2>
<p>Hope this helps !<br />
Cheers !<br />
Aj</p>
<br />Filed under: <a href='http://abhijitjana.net/category/net-4-0/'>.NET 4.0</a>, <a href='http://abhijitjana.net/category/kinect/'>Kinect</a>, <a href='http://abhijitjana.net/category/visual-studio-2010/'>Visual Studio 2010</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abhijitjana.wordpress.com/3238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abhijitjana.wordpress.com/3238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abhijitjana.wordpress.com/3238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abhijitjana.wordpress.com/3238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abhijitjana.wordpress.com/3238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abhijitjana.wordpress.com/3238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abhijitjana.wordpress.com/3238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abhijitjana.wordpress.com/3238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abhijitjana.wordpress.com/3238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abhijitjana.wordpress.com/3238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abhijitjana.wordpress.com/3238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abhijitjana.wordpress.com/3238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abhijitjana.wordpress.com/3238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abhijitjana.wordpress.com/3238/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3238&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abhijitjana.net/2011/09/23/development-with-kinect-net-sdk-part-v-developing-application-using-multiple-kinect-devices/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2d57d87d3990f59469b6b6bd8f03f490?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Abhijit Jana</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image65.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image66.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image67.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image68.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image69.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image70.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image71.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image72.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Development With Kinect .NET SDK (Part IV) &#8211; Connecting Multiple Kinect Devices with System</title>
		<link>http://abhijitjana.net/2011/09/20/development-with-kinect-net-sdk-part-iv-connecting-multiple-kinect-devices-with-system/</link>
		<comments>http://abhijitjana.net/2011/09/20/development-with-kinect-net-sdk-part-iv-connecting-multiple-kinect-devices-with-system/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 04:24:50 +0000</pubDate>
		<dc:creator>Abhijit Jana</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Kinect]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Configure Multiple Kinect]]></category>
		<category><![CDATA[How to Connect Multiple Kinects]]></category>
		<category><![CDATA[kinect SDK]]></category>
		<category><![CDATA[Kinect Tutorial]]></category>

		<guid isPermaLink="false">https://abhijitjana.wordpress.com/2011/09/20/development-with-kinect-net-sdk-part-iv-connecting-multiple-kinect-devices-with-system/</guid>
		<description><![CDATA[This is the fourth post in the series of Development With Kinect .NET SDK. In few of my previous posts I have covered Setting up Kinect Devices and Getting Started with Kinect Development ( Part I) , Exploring NUI APIs with Camera ( Part II)  and Adjusting Kinect Camera Angle (Part III). Till now whatever [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3208&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is the fourth post in the series of Development With Kinect .NET SDK. In few of my previous posts I have covered <a href="http://abhijitjana.net/2011/09/14/development-with-kinect-net-sdk-part-i-installation-and-development-environment-setup/">Setting up Kinect Devices and Getting Started with Kinect Development ( Part I)</a> , <a href="http://abhijitjana.net/2011/09/17/development-with-kinect-net-sdk-part-ii-using-nui-apis-with-camera/" target="_blank">Exploring NUI APIs with Camera ( Part II)</a>  and <a href="http://abhijitjana.net/2011/09/18/development-with-kinect-net-sdk-part-iii-adjusting-the-kinect-camera-angle/" target="_blank">Adjusting Kinect Camera Angle (Part III)</a>. Till now whatever I have covered, that comes under dealing with  single  Kinect devices. Let’s have some more fun with multiple Kinect devices.  The Kinect .NET SDK does provide support for multiple Kinect devices.   In this post I am going to discuss how you can configure two devices with your system.</p>
<p><span id="more-3208"></span></p>
<p>The Kinect SDK does provide support for Multiple Kinect devices and we can plug multiple devices in a same system.  Let’s first check the configuration related with H/W. What will happen if we plugged in multiple Kinect.</p>
<p>Navigate to <strong>Control Panel &gt; Device Manager</strong> and Expand “<strong>Microsoft Kinect</strong>” .</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/camera_not_detected.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="Camera_Not_Detected" src="http://abhijitjana.files.wordpress.com/2011/09/camera_not_detected_thumb.png?w=407&#038;h=289" alt="Camera_Not_Detected" width="407" height="289" border="0" /></a></p>
<p>You will find multiple Kinect devices has been detected by your system. But, Check out the<strong> <span style="text-decoration:underline;">“Warning Symbol”</span></strong> with one of Kinect Camera Devices</p>
<p>Right Click on that item and Select <strong>Properties</strong>, below dialog screen will appear. Check out the <em>Device Status</em> section it’s says “<strong>This Device Cannot start. (Code 10)</strong> .</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image59.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb58.png?w=594&#038;h=429" alt="image" width="594" height="429" border="0" /></a></p>
<p>I was just wondering why it is not working ? Is there something wrong with second Kinect Device ?  The result was same after changing the USB ports for Kinect devices with in the different ports that were available with my laptop.</p>
<p>I started investigation and found some answer <a href="http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/4da8c75e-9aad-4dc3-bd83-d77ab4cd2f82" target="_blank">over here</a>. It’s says, There is currently a limitation where Kinect devices might not work reliably when they are connected to the same USB host controller as other USB devices, such as webcams or other Kinect devices.</p>
<p>What I did next is, Changed the device manager view to “<strong>Devices by Connection</strong>”</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image60.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb59.png?w=531&#038;h=419" alt="image" width="531" height="419" border="0" /></a></p>
<p>What I found is , Both of the Kinect are being controlled by Same USB Controller. So, it was looks like I don’t have any chance to work multiple Kinect as I checked with all the USB ports.</p>
<p>Well, <a href="http://twitter.com/#!/jebarson007" target="_blank">Jebarson</a> gave me an idea to plugged into the USB ports which were available with Laptop docking station. I just did that. Well, it worked. Check out the below snaps, both the Kinect Sensors detected properly.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/devicemanager_kinect2.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="DeviceManager_Kinect2" src="http://abhijitjana.files.wordpress.com/2011/09/devicemanager_kinect2_thumb.png?w=269&#038;h=434" alt="DeviceManager_Kinect2" width="269" height="434" border="0" /></a></p>
<p>So, we are done with H/W Configuration stuff . What about accessing them using Application ?</p>
<p>Kinect SDK APIs provides a class “<strong>Device</strong>” which represents a system’s Kinect sensors. It’s has a property “<strong>Count</strong>” which will show the number of Kinect been detected.  So, I wrote following line of code, and check out the result.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/devicedetectioncode.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:right;padding-top:0;border-width:0;" title="DeviceDetectionCode" src="http://abhijitjana.files.wordpress.com/2011/09/devicedetectioncode_thumb.png?w=737&#038;h=206" alt="DeviceDetectionCode" width="737" height="206" align="right" border="0" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>That’s all from here. In next Post we will check how to develop application Multiple Kinect . That will be more interesting.</p>
<p>&nbsp;</p>
<blockquote><p><strong><img class="wlEmoticon wlEmoticon-lightbulb" style="border-style:none;" src="http://abhijitjana.files.wordpress.com/2011/09/wlemoticon-lightbulb.png?w=460" alt="Light bulb" />Other Posts from this series :</strong></p>
<p><a href="http://abhijitjana.net/2011/09/14/development-with-kinect-net-sdk-part-i-installation-and-development-environment-setup/"><span style="font-size:x-small;">Development With Kinect .NET SDK (Part I) – Installation and Development Environment Setup</span></a></p>
<p><a href="http://abhijitjana.net/2011/09/17/development-with-kinect-net-sdk-part-ii-using-nui-apis-with-camera/"><span style="font-size:x-small;">Development With Kinect .NET SDK (Part II) – Using NUI APIs with Camera</span></a></p>
<p><a href="http://abhijitjana.net/2011/09/18/development-with-kinect-net-sdk-part-iii-adjusting-the-kinect-camera-angle/"><span style="font-size:x-small;">Development With Kinect .NET SDK (Part III) – Adjusting the Kinect Camera Angle</span></a></p></blockquote>
<p>Hope this helps !</p>
<p>Cheers !!</p>
<p>Abhijit</p>
<br />Filed under: <a href='http://abhijitjana.net/category/net-4-0/'>.NET 4.0</a>, <a href='http://abhijitjana.net/category/kinect/'>Kinect</a>, <a href='http://abhijitjana.net/category/visual-studio-2010/'>Visual Studio 2010</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abhijitjana.wordpress.com/3208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abhijitjana.wordpress.com/3208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abhijitjana.wordpress.com/3208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abhijitjana.wordpress.com/3208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abhijitjana.wordpress.com/3208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abhijitjana.wordpress.com/3208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abhijitjana.wordpress.com/3208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abhijitjana.wordpress.com/3208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abhijitjana.wordpress.com/3208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abhijitjana.wordpress.com/3208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abhijitjana.wordpress.com/3208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abhijitjana.wordpress.com/3208/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abhijitjana.wordpress.com/3208/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abhijitjana.wordpress.com/3208/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3208&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abhijitjana.net/2011/09/20/development-with-kinect-net-sdk-part-iv-connecting-multiple-kinect-devices-with-system/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2d57d87d3990f59469b6b6bd8f03f490?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Abhijit Jana</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/camera_not_detected_thumb.png" medium="image">
			<media:title type="html">Camera_Not_Detected</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb58.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb59.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/devicemanager_kinect2_thumb.png" medium="image">
			<media:title type="html">DeviceManager_Kinect2</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/devicedetectioncode_thumb.png" medium="image">
			<media:title type="html">DeviceDetectionCode</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/wlemoticon-lightbulb.png" medium="image">
			<media:title type="html">Light bulb</media:title>
		</media:content>
	</item>
		<item>
		<title>Development With Kinect .NET SDK (Part III) &#8211; Adjusting the Kinect Camera Angle</title>
		<link>http://abhijitjana.net/2011/09/18/development-with-kinect-net-sdk-part-iii-adjusting-the-kinect-camera-angle/</link>
		<comments>http://abhijitjana.net/2011/09/18/development-with-kinect-net-sdk-part-iii-adjusting-the-kinect-camera-angle/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 12:00:29 +0000</pubDate>
		<dc:creator>Abhijit Jana</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Kinect]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Kinect Camera]]></category>
		<category><![CDATA[Kinect Camera Angle]]></category>
		<category><![CDATA[Kinect Tutorial]]></category>

		<guid isPermaLink="false">https://abhijitjana.wordpress.com/?p=3185</guid>
		<description><![CDATA[This is the Part III of my Kinect .NET SDK Development series post. In past two posts I have discussed about  Installation of Kinect Devices along with setting up your development environment and Exploring NUI APIs with Camera. In this post I am going to cover some more fundamental stuff of Kinect Camera. Kinect .NET [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3185&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is the Part III of my Kinect .NET SDK Development series post. In past two posts I have discussed about  <a href="http://abhijitjana.net/2011/09/14/development-with-kinect-net-sdk-part-i-installation-and-development-environment-setup/" target="_blank">Installation of Kinect Devices along with setting up your development environment</a> and <a href="http://abhijitjana.net/2011/09/17/development-with-kinect-net-sdk-part-ii-using-nui-apis-with-camera/" target="_blank">Exploring NUI APIs with Camera</a>. In this post I am going to cover some more fundamental stuff of Kinect Camera. Kinect .NET SDK provides some API to interact with motorized tilt ( Check out the device details section of first post for more information )  to enables the camera up (<span style="color:#000080;">+27 Degree</span>)  or down (<span style="color:#000080;">-27 degrees</span>) .  To adjust the motorized tilt  you need to  set the <span style="color:#000080;">NUI</span> Cameras <span style="color:#000080;">ElevationAngle</span> property to a value between –27 and +27.<br />
<span id="more-3185"></span><br />
<a href="http://abhijitjana.files.wordpress.com/2011/09/image53.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb52.png?w=378&#038;h=164" alt="image" width="378" height="164" border="0" /></a><br />
let’s follow the below step to create an application to demonstrate it.</p>
<p><strong>Step 1.</strong> Create a <span style="color:#000080;">New WPF Project</span> in Visual Studio 2010 named it as “<span style="color:#000080;">AdjustingKinectCameraDemo</span>”</p>
<p><strong>Step 2.</strong> Add “<span style="color:#000080;">Microsoft.Research.Kinect.dll</span>” as <span style="color:#000080;">Reference Assembly</span>.</p>
<p><strong>Step 3.</strong> Open the code view of your application and add “<span style="color:#000080;">Microsoft.Research.Kinect.Nui</span>” as <span style="color:#000080;">Namespaces</span>.</p>
<p><strong>Step 4.</strong> The next thing we are going to do is, designing a small UI with one <span style="color:#000080;">Image Control</span>, <span style="color:#000080;">TextBox</span> and a <span style="color:#000080;">Button control</span>.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image54.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb53.png?w=418&#038;h=271" alt="image" width="418" height="271" border="0" /></a></p>
<p>You can use below <span style="color:#000080;">XAML</span> Markup for the above design</p>
<p><pre class="brush: csharp;">
 &lt;Grid&gt;
        &lt;Image Height=&quot;203&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;120,23,0,0&quot;
               Name=&quot;imageControl&quot; Stretch=&quot;Fill&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;268&quot; /&gt;
        &lt;TextBox Height=&quot;34&quot; HorizontalAlignment=&quot;Left&quot;
                 Margin=&quot;158,240,0,0&quot; Name=&quot;textAngel&quot;
                 VerticalAlignment=&quot;Top&quot; Width=&quot;119&quot; /&gt;
        &lt;Button Content=&quot;Ok&quot; Height=&quot;36&quot; HorizontalAlignment=&quot;Left&quot;
                Margin=&quot;287,240,0,0&quot; Name=&quot;buttonAngel&quot;
                VerticalAlignment=&quot;Top&quot; Width=&quot;89&quot; Click=&quot;buttonAngle_Click&quot; /&gt;
    &lt;/Grid&gt;
</pre></p>
<p><strong>Step 5.</strong> The next step is to<span style="color:#000080;"> initialize the Kinect Runtime</span> and <span style="color:#000080;">display the video into image control</span>. We did this exercise in our last post.  So, here I am not explaining how to do that, Just use below code snippet for the same.</p>
<p><pre class="brush: csharp;">
       /// &lt;summary&gt;
        /// Define the Kinect Sensor Runtime
        /// &lt;/summary&gt;
        Runtime kinectRuntime = new Runtime();

        /// &lt;summary&gt;
        /// Initializes a new instance of the &lt;see cref=&quot;MainWindow&quot;/&gt; class.
        /// &lt;/summary&gt;
        public MainWindow()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainWindow_Loaded);
            Unloaded += new RoutedEventHandler(MainWindow_Unloaded);
        }

        /// &lt;summary&gt;
        /// Handles the Unloaded event of the MainWindow control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void MainWindow_Unloaded(object sender, RoutedEventArgs e)
        {
            // Uninitialize the Device when Unload
            this.kinectRuntime.Uninitialize();
        }

        /// &lt;summary&gt;
        /// Handles the Loaded event of the MainWindow control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Initialize the Device when Load
            this.kinectRuntime.Initialize(RuntimeOptions.UseColor);
            this.kinectRuntime.VideoFrameReady += new EventHandler&lt;ImageFrameReadyEventArgs&gt;(kinectRuntime_VideoFrameReady);
            this.kinectRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
        }

        /// &lt;summary&gt;
        /// Handles the VideoFrameReady event of the kinectRuntime control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;Microsoft.Research.Kinect.Nui.ImageFrameReadyEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void kinectRuntime_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
        {
            PlanarImage planarImage = e.ImageFrame.Image;
            imageControl.Source = BitmapSource.Create(planarImage.Width, planarImage.Height, 96, 96, PixelFormats.Bgr32, null, planarImage.Bits, planarImage.Width * planarImage.BytesPerPixel);
        }
</pre></p>
<p><strong>Step 6 :</strong> Change the camera angle on button click as show in below code snippet.</p>
<p><pre class="brush: csharp;">
  /// &lt;summary&gt;
        /// Handles the Click event of the buttonAngle control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonAngle_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Set the ElevationAngle of current runtime camera
                this.kinectRuntime.NuiCamera.ElevationAngle = Convert.ToInt32(this.textAngel.Text);
            }
            catch (ArgumentOutOfRangeException exp)
            {
                MessageBox.Show(exp.Message);
            }
        }

</pre></p>
<p>If the value of Elevation Angel &gt; 27 or &lt; -27  degree application will trow a &#8220;<span style="color:#000080;">ArgumentOutOfRangException</span>&#8221; .</p>
<p>That’s all, just run the application and give the textbox value in between +27 to  -27, you will see the Kinect motorized tilt is changing with the camera angel. Below is the screen shots with Angel 0, +27 and – 27 degrees where as  the position of Kinect device was same.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image55.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb54.png?w=281&#038;h=174" alt="image" width="281" height="174" align="left" border="0" /></a><a href="http://abhijitjana.files.wordpress.com/2011/09/image56.png"><img class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb56.png?w=237&#038;h=169" alt="image" width="237" height="169" align="right" border="0" /></a></p>
<p>Check out the quick Video demo as well.</p>
<div><span style="text-align:center; display: block;"><a href="http://abhijitjana.net/2011/09/18/development-with-kinect-net-sdk-part-iii-adjusting-the-kinect-camera-angle/"><img src="http://img.youtube.com/vi/6nT4X34syvY/2.jpg" alt="" /></a></span></div>
<p>Note, this features is not for frequent uses. Generally this need to setup and track skeleton during the start up of your Application.</p>
<p>Read <a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/guides.aspx">Kinect SDK Documentation</a> for more information.</p>
<h2><strong><strong><a href="https://skydrive.live.com/?cid=6ab190a26079cd46&amp;sc=documents&amp;nl=1&amp;uc=1&amp;id=6AB190A26079CD46%21218">Download Complete Project </a></strong></strong></h2>
<p>Till now whatever we have learned we learned about a single Kinect Device. In my next two post I will discussion about <em><span style="text-decoration:underline;">configuring multiple Kinect Devices and then will develop a application using Multiple devices</span></em>. Then we will bake with Skeleton Tracking and Audio fundamentals.  So lot&#8217;s of interesting stuff on the way !!!</p>
<p>Hope this helps !</p>
<p>Cheers !!</p>
<p>AJ</p>
<br />Filed under: <a href='http://abhijitjana.net/category/net-4-0/'>.NET 4.0</a>, <a href='http://abhijitjana.net/category/kinect/'>Kinect</a>, <a href='http://abhijitjana.net/category/visual-studio-2010/'>Visual Studio 2010</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abhijitjana.wordpress.com/3185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abhijitjana.wordpress.com/3185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abhijitjana.wordpress.com/3185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abhijitjana.wordpress.com/3185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abhijitjana.wordpress.com/3185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abhijitjana.wordpress.com/3185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abhijitjana.wordpress.com/3185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abhijitjana.wordpress.com/3185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abhijitjana.wordpress.com/3185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abhijitjana.wordpress.com/3185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abhijitjana.wordpress.com/3185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abhijitjana.wordpress.com/3185/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abhijitjana.wordpress.com/3185/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abhijitjana.wordpress.com/3185/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3185&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abhijitjana.net/2011/09/18/development-with-kinect-net-sdk-part-iii-adjusting-the-kinect-camera-angle/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2d57d87d3990f59469b6b6bd8f03f490?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Abhijit Jana</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb52.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb53.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb54.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb56.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Development With Kinect .NET SDK (Part II) &#8211; Using NUI APIs with Camera</title>
		<link>http://abhijitjana.net/2011/09/17/development-with-kinect-net-sdk-part-ii-using-nui-apis-with-camera/</link>
		<comments>http://abhijitjana.net/2011/09/17/development-with-kinect-net-sdk-part-ii-using-nui-apis-with-camera/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 04:58:20 +0000</pubDate>
		<dc:creator>Abhijit Jana</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Kinect]]></category>
		<category><![CDATA[Kinect Camera]]></category>
		<category><![CDATA[Kinect Tutorial]]></category>
		<category><![CDATA[NUI APIs]]></category>

		<guid isPermaLink="false">https://abhijitjana.wordpress.com/?p=3145</guid>
		<description><![CDATA[In my previous post Development With Kinect .NET SDK (Part I) – Installation and Development Environment Setup I discussed about  fundamentals of  Kinect sensors and developing application using Kinect .NET SDK. I also explained different types of API that mainly used for interacting with Kinect Device. Natural User interfaces (NUI) and Audio are the core [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3145&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my previous post <a href="http://abhijitjana.net/2011/09/14/development-with-kinect-net-sdk-part-i-installation-and-development-environment-setup/">Development With Kinect .NET SDK (Part I) – Installation and Development Environment Setup</a> I discussed about  fundamentals of  Kinect sensors and developing application using Kinect .NET SDK. I also explained different types of API that mainly used for interacting with Kinect Device.<span style="color:#000080;"><em> Natural User interfaces (NUI)</em></span> and <em>Audio</em> are the core APIs stack for Kinect sensors and  and in the previous article we starts with NUI APIs. By this time you must know how to get start with of NUI API’s by initializing the runtime. Let’s take a inner look of NUI API. In this post I will discuss about <span style="color:#000080;">NUI</span> APIs for Kinect .NET SDK and will see how we can interact with Kinect Camera Sensors using it.</p>
<p><span id="more-3145"></span></p>
<p>As we are going to explore the NUI APIs, first of all I will try to explain about fundamentals of Kinect SDK Library and type of APIs, then we will look inside NUI APIs and in the end we will be developing some application as shown in below.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image49.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb48.png?w=502&#038;h=285" alt="image" width="502" height="285" border="0" /></a></p>
<p>Yeah. Super cool and lots of learning from this article !!</p>
<p>NUI APIs are the set of APIs that retrieves data from Kinect Sensors, camera and control the devices. This enables you to access images and stream data from Kinect Sensors.  So, what it does? For any kind of application your application access the NUI APIs, which interacts with Kinect Sensors and transfer back Image Stream, Depth Stream data to applications and this APIs also allow user to take control of Kinect Motor.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image29.png"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb28.png?w=265&#038;h=331" alt="image" width="265" height="331" border="0" /></a></p>
<p>Why this is called as <span style="color:#000080;"><em>Natural User Interface (NUI )</em></span> ? , because this APIs help developer to use the<em> Kinect for Natural Inputs</em> like skeleton tracking, sensing, depth measuring etc.   As said, NUI APIs interacts with Camera , Sensors and Motors where as you  need a separate set of APIs to take control over Audio Mic Array ( We are not covering Audio array part in this article) . Below picture illustrate overall API Classification for Kinect SDK. <a href="http://abhijitjana.files.wordpress.com/2011/09/image30.png"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb29.png?w=618&#038;h=493" alt="image" width="618" height="493" border="0" /></a></p>
<p>To start with any Kinect application, you have to Add<span style="color:#000080;"> <em>Microsoft.Research.Kinect.dll</em></span> as reference to interact with Kinect and first of all we need to  define a Runtime of Kinect Sensors.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image31.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb30.png?w=333&#038;h=55" alt="image" width="333" height="55" border="0" /></a></p>
<p>This will create an instance of Kinect which represent the current device. <em><span style="font-size:xx-small;">( <em>Well, you can interact with multiple Kinect , will talk about this later )</em></span></em> .  Below diagram representing the overall APIs available for <span style="color:#000080;"> Kinect SDK NUI</span> . Let’s focus on the methods inside <span style="color:#000080;"><em>Runtime</em></span> Class. This contain <span style="color:#000080;">Initialize()</span> and <span style="color:#000080;">Uninitialize()</span> method along with other methods. This two methods user for initializing and Uninitializing the Kinect Runtime.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image32.png"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb31.png?w=561&#038;h=273" alt="image" width="561" height="273" border="0" /></a></p>
<p>In my previous post I talked about initializing and uninitializing of Kinect runtime.  <span style="color:#000080;">Initialize</span>() method Initializes the NUI subsystems that the application requires.  we have initialized the Kinect Runtime with <span style="color:#000080;">RuntimeOptions</span> as shown in below snippet.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image33.png"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb32.png?w=548&#038;h=133" alt="image" width="548" height="133" border="0" /></a></p>
<p><span style="color:#000080;">RuntimeOptions</span> specifies the runtime options for a Kinect sensor.  Kinect process data using Multi-stage channel. So, specifying runtime tell the what are the channel need to start.</p>
<p><span style="color:#000080;">RuntimeOption</span> is a public Enumeration inside the NUI library.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image34.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb33.png?w=425&#038;h=225" alt="image" width="425" height="225" border="0" /></a></p>
<p><span style="color:#000080;">UseColor</span> streams the color image from the Kinect and this is used for color Video. UseDepth option stream the depth image data and UseSkeleatal provides the skeleton positions.</p>
<p>When you are done with all operation, call <span style="color:#000080;">Runtime.Uninitialize()</span> to close the instance.</p>
<p>Well, we learned lot about NUI API. Let’s used some of these API</p>
<h2><span style="color:#000080;">Demo : NUI API’s Video and Depth Image</span></h2>
<p>Start a new <span style="color:#000080;">Visual Studio Instance</span> and Create a New WPF Project Template with Name “<span style="color:#000080;"><em>KinectCameraNUIDemo</em></span>”.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image35.png"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb34.png?w=489&#038;h=337" alt="image" width="489" height="337" border="0" /></a></p>
<p>From Solution Explorer, right click on the project and Add “<span style="color:#000080;">Microsoft.Research.Kinect.dl</span>l” as reference assembly</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image36.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;margin-left:0;margin-right:0;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb35.png?w=214&#038;h=216" alt="image" width="214" height="216" border="0" /></a></p>
<p>you already knows about the initializing the Kinect devices, so I am not discussing on that. Below code snippets shows the basic code blocks which instantiate a Kinect Runtime for the create WPF Application.</p>
<p><pre class="brush: csharp;">
 /// &lt;summary&gt;
    /// Interaction logic for MainWindow.xaml
    /// &lt;/summary&gt;
    public partial class MainWindow : Window
    {
        /// &lt;summary&gt;
        /// Runtime Instance for Device
        /// &lt;/summary&gt;
        Runtime nuiRuntime = new Runtime();

        /// &lt;summary&gt;
        /// Initializes a new instance of the &lt;see cref=&quot;MainWindow&quot;/&gt; class.
        /// &lt;/summary&gt;
        public MainWindow()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainWindow_Loaded);
            Unloaded += new RoutedEventHandler(MainWindow_Unloaded);
        }

        /// &lt;summary&gt;
        /// Handles the Unloaded event of the MainWindow control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void MainWindow_Unloaded(object sender, RoutedEventArgs e)
        {
            // Uninitialize the Kinect
            nuiRuntime.Uninitialize();
        }

        /// &lt;summary&gt;
        /// Handles the Loaded event of the MainWindow control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
           // Initialize the Runtime with Color Channel
            nuiRuntime.Initialize(RuntimeOptions.UseColor);
        }
    }
</pre></p>
<p>We are going to display some video capture from Kinect. So, lets first create the UI. The UI is very simple, put one Image and one button control.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image37.png"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb36.png?w=498&#038;h=369" alt="image" width="498" height="369" border="0" /></a></p>
<p>Below is the XAML markup for the above design.</p>
<p><pre class="brush: xml;">
 &lt;Grid Height=&quot;365&quot;&gt;
        &lt;Image Height=&quot;277&quot; HorizontalAlignment=&quot;Left&quot;
               Margin=&quot;64,12,0,0&quot;
               Name=&quot;videoControl&quot;
               Stretch=&quot;Fill&quot;
               VerticalAlignment=&quot;Top&quot; Width=&quot;385&quot; /&gt;
        &lt;Button Content=&quot;Capture&quot;
                Height=&quot;41&quot; HorizontalAlignment=&quot;Left&quot;
                Margin=&quot;191,295,0,0&quot; Name=&quot;buttonCapture&quot;
                VerticalAlignment=&quot;Top&quot; Width=&quot;143&quot; /&gt;
    &lt;/Grid&gt;
</pre></p>
<p>You have already initialized the Kinect runtime with <span style="color:#000080;">UseColor RuntimeOptions</span>. Which means, Kinect already initialized a channel for the color image streaming.  So in the next step you need to write an event handler for video frame. This Occurs when a video frame is ready. Code snippet for the VideoFrameReady event handler look like this :<a href="http://abhijitjana.files.wordpress.com/2011/09/image38.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb37.png?w=681&#038;h=275" alt="image" width="681" height="275" border="0" /></a></p>
<p>Once you have done with signing the video frame, in next step you have to Open a video Stream channel for the image stream.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image39.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb38.png?w=791&#038;h=26" alt="image" width="791" height="26" border="0" /></a></p>
<p><span style="color:#000080;">ImageStreamType</span> gets the image stream type. It can be Video or Depth depends the type of event handler we have attached with it. Along with the <span style="color:#000080;">ImageStreamType</span> you have specify the pool size , resolution and ImageType which is also an enumeration that specifies an image type .</p>
<p>Let’s have handle the event for <span style="color:#000080;">VideoFrameReady</span>. Kinect  Video returns <span style="color:#000080;">PlanarImage </span> and we just need to create new Bitmap source and display on the Image control.</p>
<p><pre class="brush: csharp;">
        /// &lt;summary&gt;
        /// Handles the VideoFrameReady event of the nuiRuntime control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;Microsoft.Research.Kinect.Nui.ImageFrameReadyEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void nuiRuntime_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
        {
            PlanarImage planarImage = e.ImageFrame.Image;
            videoControl.Source = BitmapSource.Create(planarImage.Width, planarImage.Height, 96, 96,
                PixelFormats.Bgr32, null, planarImage.Bits, planarImage.Width * planarImage.BytesPerPixel);

      }
</pre></p>
<p>That’s all, let run the application. and Click on the “<span style="color:#000080;">Capture Button</span>”, you will find output like below,</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image50.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb49.png?w=384&#038;h=288" alt="image" width="384" height="288" border="0" /></a></p>
<p>of course this should be a video display, not still image !!!</p>
<p>Very easy to capture Video. Want to make more easy , yes you can do it using Coding for <a href="http://c4fkinect.codeplex.com/" target="_blank">Fun Kinect Toolkit</a> . This Toolkit contains some useful extension methods for both WinForm and WPF version which will make things much easier.</p>
<p>As for example, using this Coding for Fun Toolkit, you need to write below code block for VideoStream event handler.</p>
<p><pre class="brush: csharp;">
  /// &lt;summary&gt;
        /// Handles the VideoFrameReady event of the nuiRuntime control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;Microsoft.Research.Kinect.Nui.ImageFrameReadyEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void nuiRuntime_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
        {
            //PlanarImage planarImage = e.ImageFrame.Image;
            //videoControl.Source = BitmapSource.Create(planarImage.Width, planarImage.Height, 96, 96,
            //    PixelFormats.Bgr32, null, planarImage.Bits, planarImage.Width * planarImage.BytesPerPixel);

            videoControl.Source = e.ImageFrame.ToBitmapSource();
      }
</pre></p>
<p>but before using Coding for Fun APIs, you have add the “<em><span style="color:#000080;">Coding4Fun.Kinect.Wpf.dll</span>”</em> ( As this a WPF Application ) as reference and put using <span style="text-decoration:underline;"><span style="color:#000080;text-decoration:underline;">Coding4Fun.Kinect.Wpf</span></span>; as namespaces.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image43.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb42.png?w=608&#038;h=179" alt="image" width="608" height="179" border="0" /></a></p>
<p>Let’s make this demo more interesting, while we are creating a bitmap using <span style="color:#000080;">BitmapSource.Create()</span> , we are passing the <span style="color:#000080;">PixelFormats</span> as one of the argument. Let’s change it do something different (<span style="color:#000080;">Cmyk32</span>) and bind the image to a different Image control.</p>
<p><pre class="brush: csharp;">
/// &lt;summary&gt;
        /// Handles the VideoFrameReady event of the nuiRuntime control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;Microsoft.Research.Kinect.Nui.ImageFrameReadyEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void nuiRuntime_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
        {
            PlanarImage planarImage = e.ImageFrame.Image;
            videoControl.Source = BitmapSource.Create(planarImage.Width, planarImage.Height, 96, 96,
                PixelFormats.Bgr32, null, planarImage.Bits, planarImage.Width * planarImage.BytesPerPixel);

            videoSource2.Source = BitmapSource.Create(planarImage.Width, planarImage.Height, 96, 96,
              PixelFormats.Cmyk32, null, planarImage.Bits, planarImage.Width * planarImage.BytesPerPixel);
         }
</pre></p>
<p>Below is the resulting output :</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image51.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb50.png?w=513&#038;h=353" alt="image" width="513" height="353" border="0" /></a></p>
<p>Till now we covered only about the Video images, let’s have a look what happened for Depth Image.  Handling depth stream image is pretty similar to handling the Video steam, the only change required is the type of images and streams.</p>
<p>The first thing you need to change is initialization of runtime. This time you have to use <span style="color:#000080;">UseDepth</span> as well.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image46.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb45.png?w=693&#038;h=117" alt="image" width="693" height="117" border="0" /></a></p>
<p>Once you are done with initialization, you need to raise an event handler for Depth Stream and need to open a new channel for Depth image where you have to specify the <span style="color:#000080;">ImageStreamType</span> as <span style="color:#000080;">Depth</span> and <span style="color:#000080;">ImageType</span> as <span style="color:#000080;">Depth</span>.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image47.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb46.png?w=687&#038;h=211" alt="image" width="687" height="211" border="0" /></a></p>
<p>That’s all you really do not need to worry about other stuff. You can put multiple image control and bind different types of images to display it. Yes, its all about fun !!</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image52.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb51.png?w=559&#038;h=319" alt="image" width="559" height="319" border="0" /></a></p>
<h2><span style="color:#003366;"><strong>Here is the complete code snippet : </strong></span></h2>
<p><pre class="brush: csharp;">

namespace KinectCameraNUIDemo
{
    using System;
    using System.Windows;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using Coding4Fun.Kinect.Wpf;
    using Microsoft.Research.Kinect.Nui;

    /// &lt;summary&gt;
    /// Interaction logic for MainWindow.xaml
    /// &lt;/summary&gt;
    public partial class MainWindow : Window
    {
        /// &lt;summary&gt;
        /// Runtime Instance for Device
        /// &lt;/summary&gt;
        Runtime nuiRuntime = new Runtime(0);

        /// &lt;summary&gt;
        /// Initializes a new instance of the &lt;see cref=&quot;MainWindow&quot;/&gt; class.
        /// &lt;/summary&gt;
        public MainWindow()
        {

            InitializeComponent();
            Loaded += new RoutedEventHandler(MainWindow_Loaded);
            Unloaded += new RoutedEventHandler(MainWindow_Unloaded);
        }

        /// &lt;summary&gt;
        /// Handles the Unloaded event of the MainWindow control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void MainWindow_Unloaded(object sender, RoutedEventArgs e)
        {
            // Uninitialize the Kinect
            nuiRuntime.Uninitialize();
        }

        /// &lt;summary&gt;
        /// Handles the Loaded event of the MainWindow control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Initialize the Runtime with Color Channel
            nuiRuntime.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseDepth);

        }

        /// &lt;summary&gt;
        /// Handles the Click event of the buttonCapture control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonCapture_Click(object sender, RoutedEventArgs e)
        {

            // Signing the Event for Image frame ready
            nuiRuntime.VideoFrameReady += new EventHandler&lt;ImageFrameReadyEventArgs&gt;(nuiRuntime_VideoFrameReady);
            nuiRuntime.DepthFrameReady += new EventHandler&lt;ImageFrameReadyEventArgs&gt;(nuiRuntime_DepthFrameReady);
            nuiRuntime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
            nuiRuntime.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.Depth);
        }

        void nuiRuntime_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
        {
            depthSourceControl.Source = e.ImageFrame.ToBitmapSource();

        }

        /// &lt;summary&gt;
        /// Handles the VideoFrameReady event of the nuiRuntime control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;Microsoft.Research.Kinect.Nui.ImageFrameReadyEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        void nuiRuntime_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
        {
            PlanarImage planarImage = e.ImageFrame.Image;
            videoControl.Source = BitmapSource.Create(planarImage.Width, planarImage.Height, 96, 96,
                PixelFormats.Bgr32, null, planarImage.Bits, planarImage.Width * planarImage.BytesPerPixel);

            videoSource2.Source = BitmapSource.Create(planarImage.Width, planarImage.Height, 96, 96,
              PixelFormats.Cmyk32, null, planarImage.Bits, planarImage.Width * planarImage.BytesPerPixel);

            videoSource3.Source = BitmapSource.Create(planarImage.Width, planarImage.Height, 96, 96,
              PixelFormats.Bgr24, null, planarImage.Bits, planarImage.Width * planarImage.BytesPerPixel);
        }
    }
}

</pre></p>
<p>Below is the XAML Markup Snippet, I just drag and drop few control .</p>
<p><pre class="brush: xml;">
  &lt;Grid Height=&quot;451&quot; Width=&quot;607&quot;&gt;
         &lt;Image Height=&quot;343&quot; HorizontalAlignment=&quot;Left&quot;
               Margin=&quot;12,12,0,0&quot;
               Name=&quot;videoControl&quot;
               Stretch=&quot;Fill&quot;
               VerticalAlignment=&quot;Top&quot; Width=&quot;385&quot; /&gt;
        &lt;Button Content=&quot;Capture&quot;
                Height=&quot;41&quot; HorizontalAlignment=&quot;Left&quot;
                Margin=&quot;299,376,0,0&quot; Name=&quot;buttonCapture&quot;
                VerticalAlignment=&quot;Top&quot; Width=&quot;143&quot; Click=&quot;buttonCapture_Click&quot; /&gt;
        &lt;Image Height=&quot;150&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;360,23,0,0&quot;
               Name=&quot;videoSource2&quot; Stretch=&quot;Fill&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;200&quot; /&gt;
        &lt;Image Height=&quot;150&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;360,183,0,0&quot;
               Name=&quot;depthSourceControl&quot; Stretch=&quot;Fill&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;200&quot; /&gt;
        &lt;Image Height=&quot;113&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;481,129,0,0&quot;
               Name=&quot;videoSource3&quot; Stretch=&quot;Fill&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;114&quot; /&gt;
    &lt;/Grid&gt;

</pre></p>
<h2><span style="color:#000080;"><strong>References :</strong></span></h2>
<p><a href="http://c4fkinect.codeplex.com/">Coding for Fun</a><br />
<a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/guides.aspx">Kinect Documentation</a></p>
<h2><span style="color:#000080;"><strong><a href="https://skydrive.live.com/?cid=6ab190a26079cd46&amp;sc=documents&amp;nl=1&amp;uc=1&amp;id=6AB190A26079CD46!218"><span style="color:#000080;">Download Complete Project </span></a> </strong></span></h2>
<p>In this post we have learned about NUI API&#8217;s and learned how we can use those APIs to interact with Kinect Camera and sensors. In the next post I will talk about something more on camera and then we will start with skeleton tracking followed by Audio.</p>
<p>Read Out First Part over here <a href="http://abhijitjana.net/2011/09/14/development-with-kinect-net-sdk-part-i-installation-and-development-environment-setup/">Development With Kinect .NET SDK (Part I) – Installation and Development Environment Setup </a><br />
Hope this helps !</p>
<p>Cheers !!</p>
<p>AJ</p>
<br />Filed under: <a href='http://abhijitjana.net/category/net-4-0/'>.NET 4.0</a>, <a href='http://abhijitjana.net/category/kinect/'>Kinect</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abhijitjana.wordpress.com/3145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abhijitjana.wordpress.com/3145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abhijitjana.wordpress.com/3145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abhijitjana.wordpress.com/3145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abhijitjana.wordpress.com/3145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abhijitjana.wordpress.com/3145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abhijitjana.wordpress.com/3145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abhijitjana.wordpress.com/3145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abhijitjana.wordpress.com/3145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abhijitjana.wordpress.com/3145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abhijitjana.wordpress.com/3145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abhijitjana.wordpress.com/3145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abhijitjana.wordpress.com/3145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abhijitjana.wordpress.com/3145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3145&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abhijitjana.net/2011/09/17/development-with-kinect-net-sdk-part-ii-using-nui-apis-with-camera/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2d57d87d3990f59469b6b6bd8f03f490?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Abhijit Jana</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb48.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb28.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb29.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb30.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb31.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb32.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb33.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb34.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb35.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb36.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb37.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb38.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb49.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb42.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb50.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb45.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb46.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb51.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Development With Kinect .NET SDK (Part I) &#8211; Installation and Development Environment Setup</title>
		<link>http://abhijitjana.net/2011/09/14/development-with-kinect-net-sdk-part-i-installation-and-development-environment-setup/</link>
		<comments>http://abhijitjana.net/2011/09/14/development-with-kinect-net-sdk-part-i-installation-and-development-environment-setup/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 19:08:08 +0000</pubDate>
		<dc:creator>Abhijit Jana</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Kinect]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Kinect Tutorial]]></category>
		<category><![CDATA[Setup Kinect SDK Development Environment]]></category>

		<guid isPermaLink="false">https://abhijitjana.wordpress.com/?p=3091</guid>
		<description><![CDATA[The Kinect SDK is a developer toolkit for developing applications. This SDK provides a fantastic interface to interact with Kinect programmatically. The Kinect for Windows SDK beta includes drivers that interact with H/W and provides an interface to interact with device, APIs for  interacting with  Camera, Sensors, microphone and Motor. The SDK provides capabilities to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3091&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The <span style="color:#000080;">Kinect SDK</span> is a developer toolkit for developing applications. This <span style="color:#000080;">SDK</span> provides a fantastic interface to interact with <span style="color:#000080;">Kinect</span> programmatically. The Kinect for Windows SDK beta includes drivers that interact with H/W and provides an interface to interact with device, APIs for  interacting with  Camera, Sensors, microphone and Motor. The SDK provides capabilities to the developers who build applications with  C#, VB or C++  with Visual Studio 2010  which is running on Windows 7. I started developing application with Kinect SDK almost 2 months back, from the day when I received my Kinect Device. I tweeted about my first application over <a href="http://twitter.com/#!/AbhijitJana/status/86311041025327104" target="_blank">here</a>  and I am still learning about the Kinect SDK API’s and how to use them in different ways. Let’s share the learning over here. I will keep posting as step by step to allow you to  understand the API&#8217;s and get inside Kinect development. I will write a series of post where I will discuss about fundamentals of Kinect SDK API and developing Application using it and yes Step by Step and obviously with Demo Project</p>
<p><span id="more-3091"></span></p>
<p>So what are the thing we are going to learn today ? Well, we will learn about the system requirements and the installation of the Kinect device, which will ensure that our device setup properly and we are good to start with development.</p>
<h2><span style="color:#000080;">Get Ready with Your Development Environment</span></h2>
<p>The current version of Kinect for Windows SDK beta 1  needs below requirements to start</p>
<h3>Hardware</h3>
<ul>
<li><a href="http://www.xbox.com/en-US/Xbox360/Accessories/Kinect/kinectforxbox360">Kinect for Xbox 360 sensor</a></li>
<li>Computer with a dual-core, 2.66-GHz or faster processor</li>
<li>Windows 7–compatible graphics card that supports DirectX® 9.0c capabilities</li>
<li>2-GB RAM (4-GB RAM recommended)</li>
</ul>
<h3>Software</h3>
<ul>
<li>Windows 7 (x86 or x64)</li>
<li><a href="http://www.microsoft.com/express/downloads/">Visual Studio 2010 Express</a> (or other 2010 edition)</li>
<li><a href="http://msdn.microsoft.com/en-us/netframework/aa569263">Microsoft .NET Framework 4.0</a></li>
</ul>
<p><a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/download.aspx" target="_blank">Refer ^ for more information</a></p>
<h2><span style="color:#000080;">Download and Install Kinect for Windows SDK beta</span></h2>
<p><a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/download.aspx" target="_blank">Download the SDK Beta</a>, Once you have the development environment setup ready. Please make sure you are downloading the <span style="text-decoration:underline;"><em>SDK Version based on 64bit or 32bit Operating System</em></span>. Once done with download, install it. You really do not need to plugin your Kinect devices during the installation of SDK.</p>
<h2> <span style="color:#000080;">Know your Kinect Device</span></h2>
<p>Before checking out Driver installation, let’s have a quick look into the basic H/W elements of Kinect. This contains 3d Depth Sensors, RGB Camera which is used for Video Capturing , Array of MIC and TILT.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image9.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb9.png?w=482&#038;h=306" alt="image" width="482" height="306" border="0" /></a></p>
<p>Kinect SDK provides some API to interact with motorized tilt to enables the camera up or down 27 degrees  . This API is the part of Kinect Camera.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image10.png"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb10.png?w=279&#038;h=174" alt="image" width="279" height="174" border="0" /></a></p>
<p>I will be talking details about each and everything in my upcoming post while exploring the API’s for each every section.</p>
<h2><span style="color:#000080;">Checkout your Installation of Device Driver</span></h2>
<p>Plug in your Kinect USB cable with Computer. Once Windows detects the devices, you will get the LED Indicator blinking ( Yeah, this one is mine) .</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/wp_000633.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="WP_000633" src="http://abhijitjana.files.wordpress.com/2011/09/wp_000633_thumb.jpg?w=391&#038;h=293" alt="WP_000633" width="391" height="293" border="0" /></a></p>
<p>Wait for Windows to recognize the sponsor&#8217;s.  You can check it out from <strong>Control Panel &gt; Device Manager</strong> for the installed device driver. By default with only USB connection, Windows will detect only the device, as shown in below picture.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image11.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb11.png?w=215&#038;h=385" alt="image" width="215" height="385" border="0" /></a></p>
<p>But, Camera , Sensors and Audio is yet to detect. Here is a point, To detect all  Kinect elements, device need some high power supply. For that you need to plug the power supply to your Kinect Device from external Power Source. This will enables windows to detect all the components of Kinect Devices.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image12.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb12.png?w=218&#038;h=338" alt="image" width="218" height="338" border="0" /></a></p>
<p>Here is the Quick Video for the Device detection.</p>
<div id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:47204f19-b826-406e-90ed-f118af2c5541" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;">
<div><span style="text-align:center; display: block;"><a href="http://abhijitjana.net/2011/09/14/development-with-kinect-net-sdk-part-i-installation-and-development-environment-setup/"><img src="http://img.youtube.com/vi/4rJA0hSYOvs/2.jpg" alt="" /></a></span></div>
<div style="width:448px;clear:both;font-size:.8em;">Kinect Device Detection : A Small Clip Recorded</div>
</div>
<h4></h4>
<h4></h4>
<h4></h4>
<h4></h4>
<h2><span style="color:#000080;"><strong>Test Your Device </strong></span></h2>
<p>You have done with setup and installation. Let have a quick test your device.  Kinect SDK installs few sample application , Sample Skeletal Viewer is one of them. Just run that application, you will able to see your view in Depth View Skeletal View and Camera View.</p>
<h4><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image13.png?w=775&#038;h=295" alt="image" width="775" height="295" border="0" /></h4>
<p>If all of them are coming up. Your are all set to start development.</p>
<h2><span style="color:#000080;">What else Kinect SDK installed for Developers ?</span></h2>
<p>Yes, Kinect SDK also installed a best resource to learn Kinect SDK Development and Explore the APIs. This installation contains, Kinect SDK API Reference file.<em> I learned most of the things from here itself.</em></p>
<h2><span style="color:#000080;"><strong>How Application Interacts with Kinect</strong></span></h2>
<p>You have already installed SDK and Kinect Setup properly . So before start with development, let have a look how Application interacts with Kinect Devices. Kinect SDK Installed set of API to interact with Devices, You application will talk to those APIs and APIs will talk to Devices. Below images shows the same flow.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image14.png"><img style="background-image:none;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb13.png?w=245&#038;h=306" alt="image" width="245" height="306" border="0" /></a></p>
<h2><span style="color:#000080;"><strong>Staring With Application Development</strong>  :</span></h2>
<p>Finally all the setup are done.  Let’s  have start some development with Visual Studio 2010 and create a small application  which will <span style="color:#000000;">Initialize Kinect Sensor and display the Unique device name</span></p>
<p>Fire a new instance of Visual Studio, Select New Project Option from file Menu and Select “WPF Application” Template , Give the name as “MyFirstKinectDemo”</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image15.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb14.png?w=506&#038;h=296" alt="image" width="506" height="296" border="0" /></a></p>
<p>Click on OK, It will create a blank WPF Application for you.  Before going ahead, first lets design the UI as show in below</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image16.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb15.png?w=516&#038;h=314" alt="image" width="516" height="314" border="0" /></a></p>
<p>Below code snippet  is the XAML markup for the above design. Well, its very simple.</p>
<p></p>
<p>Now it’s time to interact with Kinect SDK API’s. To start with, you need to first add the reference of  Kinect SDK assemblies. Navigate to solution explorer, <span style="color:#000000;">Right Click</span> on the Project and Select <span style="color:#000000;">“Add Reference”</span></p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image17.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb16.png?w=318&#038;h=181" alt="image" width="318" height="181" border="0" /></a></p>
<p>The assembly you need to add is “Microsoft.Research.Kinect.dll” ,  You can search for Kinect keyword in the Assembly search text box to get it faster.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image88.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image88_thumb.png?w=652&#038;h=192" alt="image" width="652" height="192" border="0" /></a></p>
<p>This will add Microsoft.Research.Kinect.dll as reference to your project. The top level view of this assembly  in Object Explorer given as below. These two are the different segment of Kinect APIs.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image18.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb17.png?w=315&#038;h=86" alt="image" width="315" height="86" border="0" /></a></p>
<p>If you want to interact with NUI ( Natural User Interface)   API  like camera, sensors, Skeleton viewer  you have to use the below namespaces.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image105.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image105_thumb.png?w=374&#038;h=37" alt="image" width="374" height="37" border="0" /></a></p>
<p>If you want to interact with Kinect Audio Array, you have to include</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image112.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image112_thumb.png?w=376&#038;h=34" alt="image" width="376" height="34" border="0" /></a></p>
<p>For this application, we will be using NUI API hence we will be adding below namespaces with our code.</p>
<p><pre class="brush: csharp;">
using Microsoft.Research.Kinect.Nui;
</pre></p>
<p>First of all you need to define the runtime of Kinect as shown in below,  this represents the instance of Kinect Sensor.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image20.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb19.png?w=333&#038;h=55" alt="image" width="333" height="55" border="0" /></a></p>
<p>After that,  initialize the runtime with the options you want to use. Below are this Runtime options which Kinect Supports</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image21.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb20.png?w=452&#038;h=110" alt="image" width="452" height="110" border="0" /></a></p>
<p>In the next article I will discuss more about the runtime options. For this example,  use RuntimeOptions.UseColor to use the RGB camera.</p>
<p>Below is complete Code snippet for Initialize and Uninitialized the Kinect Device.</p>
<p><pre class="brush: csharp;">

    /// &lt;summary&gt;
    /// Interaction logic for MainWindow.xaml
    /// &lt;/summary&gt;
    public partial class MainWindow : Window
    {
        /// &lt;summary&gt;
        ///
        /// &lt;/summary&gt;
        Runtime nuiRuntime = new Runtime();

        /// &lt;summary&gt;
        /// Initializes a new instance of the &lt;see cref=&quot;MainWindow&quot;/&gt; class.
        /// &lt;/summary&gt;
        public MainWindow()
        {
            InitializeComponent();
        }

        /// &lt;summary&gt;
        /// Handles the Click event of the buttonInitialize control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonInitialize_Click(object sender, RoutedEventArgs e)
        {
           // Intialize Kinect Device with UseColor Runtime Option
            nuiRuntime.Initialize(RuntimeOptions.UseColor);
            MessageBox.Show(&quot;Device Runtime Initialized&quot;);

            //Get the Camera Device Name
            labelDeviceName.Content = nuiRuntime.NuiCamera.UniqueDeviceName;
        }

        /// &lt;summary&gt;
        /// Handles the Click event of the buttonUnInitialize control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        private void buttonUnInitialize_Click(object sender, RoutedEventArgs e)
        {
            // Uninitilize Runtime
            nuiRuntime.Uninitialize();
            MessageBox.Show(&quot;Device Runtime UnInitialized&quot;);
        }
    }
</pre></p>
<p>That’s all, Run the Application and Click on “Initialize Kinect Runtime” , your application will initialize a runtime of Kinect device via SDK APIs and you will get below message as written in code.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image22.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb21.png?w=405&#038;h=56" alt="image" width="405" height="56" border="0" /></a></p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image23.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb22.png?w=413&#038;h=267" alt="image" width="413" height="267" border="0" /></a></p>
<p>After the acceptance of the initialize message, you will get the Unique Camera device name.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image24.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb23.png?w=337&#038;h=36" alt="image" width="337" height="36" border="0" /></a></p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image25.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb24.png?w=379&#038;h=247" alt="image" width="379" height="247" border="0" /></a></p>
<p>Clicking on “Uninitialized Kinect Runtime, button will execute the below code to uninitialized device</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image26.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb25.png?w=337&#038;h=62" alt="image" width="337" height="62" border="0" /></a></p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image27.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb26.png?w=441&#038;h=271" alt="image" width="441" height="271" border="0" /></a></p>
<h2><a href="https://skydrive.live.com/?cid=6ab190a26079cd46&amp;sc=documents&amp;nl=1&amp;uc=1&amp;id=6AB190A26079CD46%21218"><strong><span style="color:#000080;">Download Sample</span></strong></a></h2>
<p>Well, That’s all . To Summarize the stuff what I have discussed till now is, setting up your development environment, installing Kinect SDK, Detecting  the devices and a small application to initialize the  Kinect devices. This is only the beginning, we will talk a lot more about API and will start with something new in my next post.</p>
<p><a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/default.aspx">More Study and Reference</a></p>
<p>Thanks !</p>
<p>Abhijit</p>
<br />Filed under: <a href='http://abhijitjana.net/category/net-4-0/'>.NET 4.0</a>, <a href='http://abhijitjana.net/category/kinect/'>Kinect</a>, <a href='http://abhijitjana.net/category/visual-studio-2010/'>Visual Studio 2010</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abhijitjana.wordpress.com/3091/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abhijitjana.wordpress.com/3091/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abhijitjana.wordpress.com/3091/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abhijitjana.wordpress.com/3091/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abhijitjana.wordpress.com/3091/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abhijitjana.wordpress.com/3091/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abhijitjana.wordpress.com/3091/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abhijitjana.wordpress.com/3091/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abhijitjana.wordpress.com/3091/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abhijitjana.wordpress.com/3091/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abhijitjana.wordpress.com/3091/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abhijitjana.wordpress.com/3091/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abhijitjana.wordpress.com/3091/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abhijitjana.wordpress.com/3091/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3091&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abhijitjana.net/2011/09/14/development-with-kinect-net-sdk-part-i-installation-and-development-environment-setup/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2d57d87d3990f59469b6b6bd8f03f490?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Abhijit Jana</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb9.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb10.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/wp_000633_thumb.jpg" medium="image">
			<media:title type="html">WP_000633</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb11.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb12.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image13.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb13.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb14.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb15.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb16.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image88_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb17.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image105_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image112_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb19.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb20.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb21.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb22.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb23.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb24.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb25.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb26.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Dynamically set control visibility inside ItemTemplate&#8217;s of GridView using Bind Expression</title>
		<link>http://abhijitjana.net/2011/09/01/dynamically-set-control-visibility-inside-itemtemplates-of-gridview-using-bind-expression/</link>
		<comments>http://abhijitjana.net/2011/09/01/dynamically-set-control-visibility-inside-itemtemplates-of-gridview-using-bind-expression/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 12:46:34 +0000</pubDate>
		<dc:creator>Abhijit Jana</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Beginners]]></category>
		<category><![CDATA[Binding]]></category>
		<category><![CDATA[BindingExpression]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[ItemTemplates]]></category>

		<guid isPermaLink="false">https://abhijitjana.wordpress.com/?p=3031</guid>
		<description><![CDATA[GridView TemplateField allow us to specify custom controls, multiple fields and Html using a custom template. TemplateField allows us to define a completely customized template for GridView Column. We can bind the data with in template control using binding expression. ASP.NET provides number of ways to take control over the template control. In this post [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3031&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>GridView <span style="color:#000080;">TemplateField</span> allow us to specify custom controls, multiple fields and Html using a custom template. <span style="color:#000080;">TemplateField</span> allows us to define a completely customized template for GridView Column. We can bind the data with in template control using binding expression. ASP.NET provides number of ways to take control over the template control. In this post I am going to discuss how we can set template control visibility based on certain condition which depends on the data source data. For example, imagine you have a link button within template field. You want to set visibility if that control based on the some value of your data source.</p>
<p><span id="more-3031"></span></p>
<p>Let’s consider we have below class for Customer entity. We will create a list of Customers and based on the value of “<span style="color:#000080;">ShowURL</span>” we are going to display the Web Sites URL.</p>
<p><pre class="brush: csharp;">

    /// &lt;summary&gt;
    /// Customer Class
    /// &lt;/summary&gt;
    internal sealed class Customer
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string WebSite { get; set; }
        public bool ShowURL { get; set; }
    }
</pre></p>
<p>Here’s the code snippet for creating List and binding with <span style="color:#000080;">GridView</span> Control.</p>
<p><pre class="brush: csharp;">
  /// &lt;summary&gt;
        /// Handles the Load event of the Page control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.EventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        protected void Page_Load(object sender, EventArgs e)
        {
            List&lt;Customer&gt; emps = new List&lt;Customer&gt;()
            {
                new Customer{ID=1, Name=&quot;Customer 1&quot;,WebSite=&quot;http://abhijitjana.net&quot;,ShowURL=true},
                new Customer{ID=2, Name=&quot;Customer 2&quot;,WebSite=&quot;http://abhisheksur.com&quot;,ShowURL=false},
                new Customer{ID=3, Name=&quot;Customer 3&quot;,WebSite=&quot;http://jebarson.info&quot; ,ShowURL=true},
                new Customer{ID=4, Name=&quot;Customer 4&quot;, WebSite=&quot;http://atulvarma.com&quot;, ShowURL=false}

                };
            myGrid.DataSource = emps;
            myGrid.DataBind();
        }
</pre></p>
<p>In this example we are going to illustrate the binding with <span style="color:#000080;">TemplateField</span>, so here is the design view of GridView where we have Two column with two different template field. First one is the container of Name and second on is the container of Web Site.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image2.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb2.png?w=619&#038;h=290" alt="image" width="619" height="290" border="0" /></a></p>
<p>Below images shows the output of the above binding.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image3.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb3.png?w=466&#038;h=212" alt="image" width="466" height="212" border="0" /></a></p>
<p>Well, as of now all the site link are getting displayed in the <span style="color:#000080;">GridView</span>. But we have to display the links based on the value of “<span style="color:#000080;">ShowURL</span>”  field.</p>
<p>The most common solution we can find is “set visibility during GridView <span style="color:#000080;">RowDataBound</span> Event” as shown in below</p>
<p><pre class="brush: csharp;">
/// &lt;summary&gt;
        /// Handles the RowDataBound event of the myGrid control.
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;sender&quot;&gt;The source of the event.&lt;/param&gt;
        /// &lt;param name=&quot;e&quot;&gt;The &lt;see cref=&quot;System.Web.UI.WebControls.GridViewRowEventArgs&quot;/&gt; instance containing the event data.&lt;/param&gt;
        protected void myGrid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Customer cust = e.Row.DataItem as Customer;
                if (!cust.ShowURL)
                {
                    LinkButton lnkWebURL = e.Row.FindControl(&quot;lnk&quot;) as LinkButton;
                    if (lnkWebURL != null)
                    {
                        lnkWebURL.Visible = false;
                    }
                }
            }
        }
</pre></p>
<p>Above code will hide the link button from the GridView as shown in below image.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image5.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb5.png?w=425&#038;h=211" alt="image" width="425" height="211" border="0" /></a></p>
<p>Well, do we really need to override <span style="color:#000080;">myGrid_RowDataBound()</span> for this small task ? Can’t we do it using Binding Expression. One similar question <a href="http://www.codeproject.com/Answers/246922/LinkButton-Inside-GridView-Visibility#answer2" target="_blank">had  asked over  at Code Project</a> and I am going to share the answer  which I have provided .</p>
<p>We can use Operator with in Bind Expression. Hence, we can set the visibility of Control using Binding Expression. We really don’t need to write code in <span style="color:#000080;">RowDataBound</span> just set the visibility of <span style="color:#000080;">LinkButton</span> as shown in below</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image6.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb6.png?w=715&#038;h=141" alt="image" width="715" height="141" border="0" /></a></p>
<p><em>How it works ?</em></p>
<p>This will do exactly we did in<span style="color:#000080;"> myGrid_RowDataBound()</span> event. But we followed a different approach.  <span style="color:#000080;">Eval(“ShowURL”)</span> find evaluate the value of ShowURL From the GridView data source and then set the properties of <span style="color:#000080;">LinkButton</span> <span style="color:#000080;">Visibility</span>.  Based on the visible properties of <span style="color:#000080;">LinkButton</span>, controls renders on page.</p>
<p>We can also use any conditional operator with in the  Binding Expression as well as shown in below</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/09/image7.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/09/image_thumb7.png?w=534&#038;h=88" alt="image" width="534" height="88" border="0" /></a></p>
<p>That’s all. Very simple, but this will give you some idea to think on using Binding Expression in different ways as well.</p>
<p>Hope this helps.</p>
<p>Cheers !</p>
<p>Aj</p>
<br />Filed under: <a href='http://abhijitjana.net/category/net-4-0/'>.NET 4.0</a>, <a href='http://abhijitjana.net/category/my-articles/aspnet/'>ASP.NET</a>, <a href='http://abhijitjana.net/category/my-articles/c/'>C#</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abhijitjana.wordpress.com/3031/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abhijitjana.wordpress.com/3031/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abhijitjana.wordpress.com/3031/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abhijitjana.wordpress.com/3031/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abhijitjana.wordpress.com/3031/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abhijitjana.wordpress.com/3031/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abhijitjana.wordpress.com/3031/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abhijitjana.wordpress.com/3031/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abhijitjana.wordpress.com/3031/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abhijitjana.wordpress.com/3031/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abhijitjana.wordpress.com/3031/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abhijitjana.wordpress.com/3031/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abhijitjana.wordpress.com/3031/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abhijitjana.wordpress.com/3031/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3031&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abhijitjana.net/2011/09/01/dynamically-set-control-visibility-inside-itemtemplates-of-gridview-using-bind-expression/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2d57d87d3990f59469b6b6bd8f03f490?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Abhijit Jana</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/09/image_thumb7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>31 Tips on ASP.NET, C#, WPF , MEF, MVC, Visual Studio &#8211; August 2011 Links</title>
		<link>http://abhijitjana.net/2011/08/31/31-tips-on-asp-net-c-wpf-mef-mvc-visual-studio-august-2011-links/</link>
		<comments>http://abhijitjana.net/2011/08/31/31-tips-on-asp-net-c-wpf-mef-mvc-visual-studio-august-2011-links/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 13:29:29 +0000</pubDate>
		<dc:creator>Abhijit Jana</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[ASP.NET 4.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[dailydotnettips]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">https://abhijitjana.wordpress.com/2011/08/31/31-tips-on-asp-net-c-wpf-mef-mvc-visual-studio-august-2011-links/</guid>
		<description><![CDATA[Daily .NET Tips is aiming to sharing useful coding tips and tricks for .NET Developers. This site completely design for sharing Tips and Tricks, useful Code Snippet which anyone use in daily development work and targeted anything related with .NET.&#160;&#160; This month we have wide range of tips including Threading, MEF, WPF and MVC. In [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3014&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://dailydotnettips.com">Daily .NET Tips </a>is aiming to sharing useful coding tips and tricks for .NET Developers. This site completely design for sharing Tips and Tricks, useful Code Snippet which anyone use in daily development work and targeted anything related with .NET.&#160;&#160; This month we have wide range of tips including Threading, MEF, WPF and MVC. In this post I am quickly listing down all the tips which are published over the month August 2011</p>
<p><span id="more-3014"></span>
<ol>
<li><a href="http://dailydotnettips.com/2011/08/31/working-with-aggregatecatalog-in-mef/" target="_blank">Working with AggregateCatalog in MEF</a></li>
<li>&#160;<a href="http://dailydotnettips.com/2011/08/31/working-with-directorycatalog-in-mef/" target="_blank">Working with DirectoryCatalog in MEF</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/30/working-with-assemblycatalog-in-mef/" target="_blank">Working with AssemblyCatalog in MEF</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/29/working-with-typecatalog-in-mef/" target="_blank">Working with TypeCatalog in MEF</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/28/how-to-use-debuggertypeproxy-while-debugging-your-sensitive-type/" target="_blank">How to use DebuggerTypeProxy while debugging your sensitive Type</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/28/asp-net-calendar-control-as-outlook-calendar/" target="_blank">ASP.NET Calendar Control as Outlook Calendar</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/27/initialize-assemblies-using-preapplicationstartmethodattribute-aspnet4-app/" target="_blank">Initialize assemblies using PreApplicationStartMethod for ASP.NET 4.0 Application</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/26/async-lambda-expression/" target="_blank">Async Lambda Expression</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/25/playing-with-list-controls-using-jquery/" target="_blank">Playing with ASP.NET List Controls using jQuery</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/24/how-to-allow-user-to-input-html-in-asp-net-mvc/" target="_blank">How to allow user to input html in ASP.NET MVC?</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/22/using-mutex-to-avoid-deadlocks/" target="_blank">Using Mutex to avoid deadlocks</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/21/writing-inline-code-in-wpf/">Writing inline Code in WPF</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/20/what-is-synchronizationcontext-all-about/" target="_blank">What is SynchronizationContext all about</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/19/threadlocal-storage-a-lazy-implementation/" target="_blank">ThreadLocal storage in .NET</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/18/barrier-in-net-4-0/" target="_blank">Barrier in .NET 4.0</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/17/use-of-interlocked-in-race-condition/" target="_blank">Use of Interlocked in Race Condition</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/16/call-asp-net-page-methods-using-ajax/" target="_blank">Call ASP.NET Page Methods using your own AJAX</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/15/use-of-spinlock-for-threadlocking/" target="_blank">Use of SpinLock for ThreadLocking</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/14/using-readerwriterlock-over-monitor-for-thread-locking/">Using ReaderWriterLock over Monitor for Thread Locking</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/11/1538/" target="_blank">What is the use of IsBackground property of Thread?</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/10/enable-address-level-debugging-in-visual-studio/" target="_blank">Enable Address Level Debugging in Visual Studio</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/09/get-list-of-all-control-types-in-wpf/">Get List of all Control Types in WPF</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/08/how-to-create-simple-faded-transparent-controls-in-wpf/" target="_blank">How to apply simple faded transparent effects on WPF controls ?</a></li>
<li>&#160;<a href="http://dailydotnettips.com/2011/08/07/use-visual-studio-server-explorer-to-add-new-or-existing-sql-server-ce-database/" target="_blank">Use Visual Studio Server Explorer to Add New or Existing SQL Server CE Database</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/06/co-ordinated-thread-shutdown-with-and-without-using-cancellationtokensource/" target="_blank">Co-Ordinated Thread Shutdown with and without using CancellationTokenSource</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/05/generate-thousand-of-request/" target="_blank">Generate thousand of request</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/05/writing-a-stretchable-contentcontrol-in-wpf/" target="_blank">Writing a Stretchable ContentControl in WPF</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/04/how-to-retrieve-wpf-visual-tree-programmatically/" target="_blank">How to Retrieve WPF Visual Tree Programmatically ?</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/03/what-is-visual-tree-and-logical-tree-in-wpf/" target="_blank">What is Visual Tree and Logical Tree in WPF?</a></li>
<li>&#160;<a href="http://dailydotnettips.com/2011/08/02/dealing-with-hwnd-in-wpf/" target="_blank">Dealing with HWND in WPF</a> </li>
<li><a href="http://dailydotnettips.com/2011/08/01/hosting-a-wpf-control-inside-a-windows-form/" target="_blank">Hosting a WPF control inside a Windows Form</a></li>
</ol>
<p>To get regular updates visit <a href="http://dailydotnettips.com">http://dailydotnettips.com</a> and follow <a href="http://twitter.com/dailydotnettips">@dailydotnettips</a> at Twitter </p>
<br />Filed under: <a href='http://abhijitjana.net/category/net-4-0/'>.NET 4.0</a>, <a href='http://abhijitjana.net/category/asp-net-4-0/'>ASP.NET 4.0</a>, <a href='http://abhijitjana.net/category/my-articles/c/'>C#</a>, <a href='http://abhijitjana.net/category/tips-and-tricks/'>Tips and Tricks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abhijitjana.wordpress.com/3014/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abhijitjana.wordpress.com/3014/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abhijitjana.wordpress.com/3014/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abhijitjana.wordpress.com/3014/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abhijitjana.wordpress.com/3014/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abhijitjana.wordpress.com/3014/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abhijitjana.wordpress.com/3014/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abhijitjana.wordpress.com/3014/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abhijitjana.wordpress.com/3014/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abhijitjana.wordpress.com/3014/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abhijitjana.wordpress.com/3014/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abhijitjana.wordpress.com/3014/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abhijitjana.wordpress.com/3014/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abhijitjana.wordpress.com/3014/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3014&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abhijitjana.net/2011/08/31/31-tips-on-asp-net-c-wpf-mef-mvc-visual-studio-august-2011-links/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2d57d87d3990f59469b6b6bd8f03f490?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Abhijit Jana</media:title>
		</media:content>
	</item>
		<item>
		<title>Install a shared Assembly to the GAC as post build event from Visual Studio</title>
		<link>http://abhijitjana.net/2011/08/25/install-a-shared-assembly-to-the-gac-as-post-build-event-from-visual-studio/</link>
		<comments>http://abhijitjana.net/2011/08/25/install-a-shared-assembly-to-the-gac-as-post-build-event-from-visual-studio/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 20:09:01 +0000</pubDate>
		<dc:creator>Abhijit Jana</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Assembly]]></category>
		<category><![CDATA[GAC]]></category>
		<category><![CDATA[Gacutil]]></category>
		<category><![CDATA[install Assembly into GAC from Visual Studio]]></category>

		<guid isPermaLink="false">https://abhijitjana.wordpress.com/?p=3002</guid>
		<description><![CDATA[The Global Assembly Cache (GAC) is a Cache for globally available Assemblies. Most of the shared assemblies are installed inside GAC to shared across different applications. The Global Assembly Cache tool (Gacutil.exe) allow us to manipulate the contents of the global assembly cache along with install and un-install Assembly. During the development, we generally  take [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3002&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://msdn.microsoft.com/en-us/library/yf1d93sz.aspx" target="_blank"><em>Global Assembly Cache</em> (GAC)</a> is a Cache for globally available Assemblies. Most of the <a href="http://msdn.microsoft.com/en-us/library/aa371839%28v=vs.85%29.aspx" target="_blank"><em>shared assemblies</em></a> are installed inside GAC to shared across different applications. The <a href="http://msdn.microsoft.com/en-us/library/ex0ss12c.aspx" target="_blank">Global Assembly Cache tool</a> (Gacutil.exe) allow us to manipulate the contents of the global assembly cache along with install and un-install Assembly. During the development, we generally  take help of <em>gacutil</em> from command prompt to install or uninstall assemblies into or from GAC. This is a repetitive process, every time you made some changes in your library you might need to deploy it into the GAC. Visual Studio has a nice feature called Pre-Build and Post-Build events. Using these events we execute some specific  commands before or after the build. In this post I am going to show you how we can configure the post build event to deploy an Assembly to GAC.</p>
<p><span id="more-3002"></span></p>
<p>Installing Assembly to the  GAC requires admin privileges. Visual Studio must be started with elevated rights.  From the <em>Project Properties Window  Page</em> of the class library ( which you want to put into GAC) , Navigate to “<em>Build Events”</em> Tab.  Build Events tab having two command line option for both Pre-Build and Post-Build event.  We will be configuring the Post Build Event to install the dll into GAC because we want to put the dll into GAC after the successful build.</p>
<p>Below is the  typical syntax for installing Assembly into GAC  from command prompt which we used generally</p>
<p><pre class="brush: csharp;">
gacutil [options] [assemblyName | assemblyPath | assemblyListFile]
</pre></p>
<p><em>Visual Studio Build Events</em> also use the same syntax. But, the interesting part is the Location of GAC.  Yes, the GAC was split into two. We all knows, .NET 4.0 introduced CLR 4.0. NET Framework 2.0 and .NET Framework 3.5 targeted to  CLR 2.0  and  .NET Framework 4.0 is targeted to CLR 4.0. The GAC is now split into private GAC’s for each runtime that targeted differently to CLR 2.0 and CLR 4.0 . I will recommend you read the article  “<a href="http://msdn.microsoft.com/en-us/magazine/dd727509.aspx" target="_blank">Understanding the CLR Binding”</a> for more details.</p>
<p>Let’s assume, the Assembly is targeted to .NET 4.0 . To Add this Assembly, we have to specify the below Pre-Build Command.</p>
<p><pre class="brush: csharp;">
&quot;%ProgramFiles%\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\gacutil.exe&quot;  /i &quot;$(TargetPath)&quot;
</pre></p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/08/image32.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/08/image_thumb32.png?w=580&#038;h=417" alt="image" width="580" height="417" border="0" /></a></p>
<p><em>$(TargetPath)</em> is a pre defined macros that returns the dll full path.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/08/image33.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/08/image_thumb33.png?w=494&#038;h=322" alt="image" width="494" height="322" border="0" /></a></p>
<p>Ok, that’s all. <em>Save</em> the file and build  your class library.  You are expecting the assembly to be installed into GAC.  But after build  you will get below error indicates something went wrong.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/08/image34.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/08/image_thumb34.png?w=643&#038;h=124" alt="image" width="643" height="124" border="0" /></a></p>
<p>From the error message it is difficult to understand what’s went wrong. In this situation <em>Output window</em> is very useful. Below is the captured details by out put window.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/08/image35.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/08/image_thumb35.png?w=697&#038;h=136" alt="image" width="697" height="136" border="0" /></a></p>
<p>Well, if you know what is assembly and what is shared assembly, you must be knowing about  Strong name.  A Shared Assembly must have a strong name to uniquely identify.  <a href="http://msdn.microsoft.com/en-us/library/wd40t7ad.aspx" target="_blank">Read more about strong name</a></p>
<p>So, let’s quickly create a strong name using  Strong Name tool . Open Visual Studio Command Prompt and type the below command.</p>
<p><pre class="brush: csharp;">sn –k  &gt; c:\mytestkey.snk </pre></p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/08/image36.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/08/image_thumb36.png?w=703&#038;h=172" alt="image" width="703" height="172" align="left" border="0" /></a></p>
<p>This will generates and writes the public and private key pair in C:\mytestkey.snk file. If you are interested, you can read <a href="http://msdn.microsoft.com/en-us/library/k5b5tt23%28v=vs.80%29.aspx" target="_blank">Strong Name Tool (Sn.exe)</a> for further details on Strong Name Tool.</p>
<p>Once you have done with the snk file generation, go back to<em> visual studio &gt;  Properties Pages &gt; Signing </em>Tab.  Enabled the “Sing the assembly” option. This will allow you to choose the “snk” file.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/08/image37.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/08/image_thumb37.png?w=670&#038;h=177" alt="image" width="670" height="177" border="0" /></a></p>
<p>From the “<em>Choose a strong name key file”</em> dropdown, browse the newly generated snk (<em>mytestkey.snk</em>) file.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/08/image38.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/08/image_thumb38.png?w=564&#038;h=86" alt="image" width="564" height="86" border="0" /></a></p>
<p>That all, now you can build the application and check the “Output window” as well for details.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/08/image39.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/08/image_thumb39.png?w=441&#038;h=99" alt="image" width="441" height="99" border="0" /></a></p>
<p>Check for your GAC, you will find your assembly installed there.</p>
<p><a href="http://abhijitjana.files.wordpress.com/2011/08/image40.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://abhijitjana.files.wordpress.com/2011/08/image_thumb40.png?w=408&#038;h=300" alt="image" width="408" height="300" border="0" /></a></p>
<p>For .NET Framework 3.5, if you have use below command as post build event</p>
<p><pre class="brush: csharp;">
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe&quot;  /i &quot;$(TargetPath)&quot;
</pre></p>
<p>So you really don’t not need to run gacutil command from command prompt ever time after successful build. Visual Studio will take care of each and every thing automatically. For this type of scenarios, Output window is very important, because you can get details of the execution from here only. Similarly like Post-Build event, you can use Pre-Build event to remove some assemblies from GAC.</p>
<p>That’s all.</p>
<p>Hope this will help !</p>
<p>Cheers !</p>
<p>Aj.</p>
<blockquote class='twitter-tweet'><p>[New Blog Post]  Install a shared Assembly to the GAC as post build event from Visual Studio wp.me/ppvPE-Mq <a href="http://twitter.com/search?q=%23vstudio" title="#vstudio">#vstudio</a> <a href="http://twitter.com/search?q=%23gac" title="#gac">#gac</a> <a href="http://twitter.com/search?q=%23assembly" title="#assembly">#assembly</a>&mdash; <br />Abhijit Jana (@AbhijitJana) <a href='http://twitter.com/#!/AbhijitJana/status/106461017319555073' data-datetime='2011-08-24T20:20:59+00:00'>August 24, 2011</a></p></blockquote>
<br />Filed under: <a href='http://abhijitjana.net/category/net-4-0/'>.NET 4.0</a>, <a href='http://abhijitjana.net/category/visual-studio/'>Visual Studio</a>, <a href='http://abhijitjana.net/category/visual-studio-2010/'>Visual Studio 2010</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abhijitjana.wordpress.com/3002/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abhijitjana.wordpress.com/3002/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abhijitjana.wordpress.com/3002/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abhijitjana.wordpress.com/3002/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abhijitjana.wordpress.com/3002/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abhijitjana.wordpress.com/3002/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abhijitjana.wordpress.com/3002/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abhijitjana.wordpress.com/3002/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abhijitjana.wordpress.com/3002/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abhijitjana.wordpress.com/3002/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abhijitjana.wordpress.com/3002/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abhijitjana.wordpress.com/3002/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abhijitjana.wordpress.com/3002/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abhijitjana.wordpress.com/3002/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abhijitjana.net&amp;blog=6080566&amp;post=3002&amp;subd=abhijitjana&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abhijitjana.net/2011/08/25/install-a-shared-assembly-to-the-gac-as-post-build-event-from-visual-studio/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2d57d87d3990f59469b6b6bd8f03f490?s=96&#38;d=wavatar&#38;r=G" medium="image">
			<media:title type="html">Abhijit Jana</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/08/image_thumb32.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/08/image_thumb33.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/08/image_thumb34.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/08/image_thumb35.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/08/image_thumb36.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/08/image_thumb37.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/08/image_thumb38.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/08/image_thumb39.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://abhijitjana.files.wordpress.com/2011/08/image_thumb40.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
	</channel>
</rss>
