<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>The Blog of Sho</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/the_blog_of_sho/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/feed.xml</link>
    <description>News about Sho, an interactive environment for data analysis and scientific computing in .NET</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:33:35 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Sho 2.0.5, IronPython 2.7, and Python Tools for Visual Studio</title>
      <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/sho-2-0-5-ironpython-2-7-and-python-tools-for-visual-studio</link>
      <pubDate>Mon, 29 Aug 2011 11:30:00 GMT</pubDate>
      <dc:creator><![CDATA[Sho Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/the_blog_of_sho/2011/08/29/sho-2-0-5-ironpython-2-7-and-python-tools-for-visual-studio/</guid>
      <description><![CDATA[Today is a big day for Sho &ndash; we&rsquo;re releasing an update to Sho containing some minor...]]></description>
      <content:encoded><![CDATA[<p>Today is a big day for Sho &ndash; we&rsquo;re releasing an update to Sho containing some minor features and bugfixes (version 2.0.5), but the bigger news is that we now have a version that works with IronPython 2.7. This is something our users have been wanting for some time, and we appreciate your requests and feedback about it.&nbsp; You can now get versions of Sho 2.0.5 for both IronPython 2.7 and IronPython 2.6 &ndash; the details and the differences between the versions (and why you might want one or the other) are explained in our new <a href="http://research.microsoft.com/en-us/projects/sho/installers.aspx">Installers page</a>.&nbsp; Note that since IronPython 2.7 comes under a different license, you&rsquo;ll have to install that first, and the IP 2.7 version of Sho will then find and use the appropriate libraries.</p>
<p>In addition, we&rsquo;re very excited to see the release of <a href="http://pytools.codeplex.com/">Python Tools for Visual Studio (PTVS)</a> 1.0 by our friends on the Python Tools team, which works as a plug-in for Visual Studio 2010; even if you don&rsquo;t have Visual Studio you can get the free VS shell and use PTVS with that (details are on the PTVS install page).&nbsp; For years, users have been asking us for a great IDE for Sho, and we&rsquo;re glad to finally have an answer for them. PTVS makes for a fantastic IDE for Python in general (standard Python as well as IronPython), including powerful debugging capabilities, an editor with syntax highlighting, intellisense, find all references, find definition, and other such great utilities, as well as a very nice interactive window (REPL).&nbsp; In addition, we&rsquo;ve done some work to make Sho work smoothly with PTVS, and our <a href="http://research.microsoft.com/en-us/projects/sho/ptvs.aspx">new IDE page</a> explains how to install and set it all up.&nbsp;</p>
<p>You can get the latest bits and find links to the Sho pages mentioned above at <a href="http://research.microsoft.com/sho">http://research.microsoft.com/sho</a></p>
<h4>Sho 2.0.5 changelist:</h4>
<ul>
<li>IronPython 2.7 and 2.6 versions</li>
<li>Smooth animations in Sho plots via Double Buffering (via the ShoChart.Freeze command)</li>
<li>Upgraded MKL to version 10.3.4</li>
<li>New ArrayMathInPlace class: implements the same elementwise operations as ArrayMath, but does them in-place on the input array</li>
<li>ShoPlotHelper.Grid() now returns a ShoChartGrid object instead of just a Control</li>
<li>Fixed Sho.py so scripts run from ipy.exe that import Sho work properly (they used to run twice)</li>
<li>Fixed a bug in the slicing of multidimensional arrays</li>
<li>Fixed a bug in Multiply Into</li>
<li>Fixed console crash when tab-completing certain types</li>
<li>Fixed doc() crash when called on certain types</li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>Connecting to Kinect from Sho</title>
      <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/connecting-to-kinect-from-sho</link>
      <pubDate>Thu, 16 Jun 2011 13:14:33 GMT</pubDate>
      <dc:creator><![CDATA[Sho Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/the_blog_of_sho/2011/06/16/connecting-to-kinect-from-sho/</guid>
      <description><![CDATA[By now you’ve certainly heard of the Kinect sensor, and very likely about the freshly-released...]]></description>
      <content:encoded><![CDATA[<p>By now you’ve certainly heard of the <a href="http://www.xbox.com/en-US/Kinect/healthyfun">Kinect sensor</a>, and very likely about the freshly-released <a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/">Kinect SDK</a> developed by some of our colleagues here at Microsoft Research. We wanted <a href="http://research.microsoft.com/sho">Sho</a> users to be able to get in on the fun too, so we’ve worked out a bit of glue code (kinect.py, included at the end of this article) to make it easy for you to get at Kinect data from Sho. In the usual Sho way, you won’t need to compile any code; just a few lines of script will get you going. With only 70 or so lines of code you can create the sorts of fun animations you’ll see below!</p>  <p>As you may know, the Kinect is a pretty complex sensor, and the SDK adds even more layers of sophistication. The hardware itself is comprised of a depth sensor and a microphone array; the SDK extracts skeletons of multiple people in the scene, high-quality audio output, and sound source localization (estimates of where the sound is coming from). In this post, we’re only going to work with the skeleton data; if there’s demand (i.e., if we hear from you!), we can add more posts to get the other sorts of data as well.</p>  <h3>What Can It Do?</h3>  <p>It’s often best to start with a demo. Let’s start with something basic: let’s use Sho’s built-in plotting functionality to just plot all the available skeletons and label all the individual joints. Kinect.py has a KinectTracker class which uses a polling model to get skeleton information. The class’ skeletonFrame member will contain the most recent set of skeletons (or None if no skeleton has been found yet), and skeletonUpdateTime will be set to the last time the skeletons were updated. To make it a bit more fun, we’ll have the skeletons update in real time within the plot (<a href="http://research.microsoft.com/en-us/UM/redmond/projects/Sho/videos/shokinect_labeled.wmv">see the video</a>). The video shows Sho’s new double buffering feature for plots, which will appear in Sho 2.0.5 (to be released in the next few weeks); in the current version of Sho you’ll see some “flashing” when updating the plot.</p>  <p><a href="http://research.microsoft.com/en-us/UM/redmond/projects/Sho/videos/shokinect_labeled.wmv"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/22/metablogapi/8737.clip_image002_1708AB22.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-22-metablogapi/8737.clip_5F00_image002_5F00_1708AB22.jpg" width="244" height="204" /></a></p>  <p>The next question, of course, is how we did that and how much code it took. Fortunately it’s quite simple and not very much code at all:</p>  <div style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 1pt; mso-element: para-border-div; mso-border-alt: solid windowtext .5pt">   <p class="CodeBox"><font face="Courier New"><span class="SpellE"><span class="GramE">def</span></span> <span class="SpellE">bodyplot</span>(<span class="SpellE">kinecttracker</span>):</font></p>    <p class="CodeBox"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">def</span></span> <span class="SpellE">plotjointseq</span>(<span class="SpellE">jointlist</span>):         <br /><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></font><span style="color: green"><font face="Courier New"># <span class="GramE">helper</span> <span class="SpellE">func</span> to plot a set of lines through a series of </font><span class="SpellE"><font face="Courier New">jointnames            <br /></font></span></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>x = [<span class="SpellE"><span class="GramE">jointhash</span></span><span class="GramE">[</span><span class="SpellE">jointname</span>][0] for <span class="SpellE">jointname</span> in <span class="SpellE">jointlist</span>]         <br /><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>y = [<span class="SpellE"><span class="GramE">jointhash</span></span><span class="GramE">[</span><span class="SpellE">jointname</span>][1] for <span class="SpellE">jointname</span> in <span class="SpellE">jointlist</span>]         <br /><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">plot(</span><span class="SpellE">x,y,<span style="color: #a31515">'k</span></span><span style="color: #a31515">-'</span>)</font></p>    <p class="CodeBox"><font face="Courier New"><span style="color: #4f6228; mso-themecolor: accent3; mso-themeshade: 128"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"># set up plot          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">clearplot</span></span><span class="GramE">()          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>p = <span class="GramE">plot(</span>[1],[1])         <br /></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span># <span class="GramE">double</span> buffering mode - uncomment the below for <span class="SpellE">Sho</span> 2.0.5+           <br /></font></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="color: #77933c; mso-themecolor: accent3; mso-themeshade: 191; mso-style-textfill-fill-color: #77933c; mso-style-textfill-fill-themecolor: accent3; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=75000"># <span class="SpellE">p.Freeze</span> = True           <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">lastplottime</span></span> = <span class="SpellE">System.DateTime.Now          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">jointhash</span></span> = <span class="SpellE">System.Collections.Hashtable</span>()         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="GramE">hold(</span>True)</font><font face="Courier New">&#160;</o:p></font></p>    <p class="CodeBox"><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span># <span class="GramE">keep</span> doing this until the user hits Ctrl-Shift-C in the console           <br /></font></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="GramE">while(</span>True):         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">System.Threading.Thread.Sleep</span></span><span class="GramE">(</span>0)         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">if</span> <span class="SpellE">kinecttracker.skeletonFrame</span>:         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">clearplot</span></span><span class="GramE">()          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">p.HorizontalMajorGridlinesVisible</span> = False         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">axisranges</span></span><span class="GramE">(</span>-.8,.8,-.8,.8)</font><font face="Courier New">&#160;</o:p></font></p>    <p class="CodeBox"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green"># iterate through all found skeletons          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">for</span> skeleton in <span class="SpellE">kinecttracker.skeletonFrame.Skeletons</span>:         <br /></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span># only <span class="GramE">draw</span> valid skeletons           <br /></font></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">if</span> <span class="SpellE">skeleton.TrackingState</span> == <span class="SpellE">SkeletonTrackingState.Tracked</span>:         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>x = []         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>y = []         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">labels</span> = []</font><font face="Courier New">&#160;</o:p></font></p>    <p class="CodeBox"><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span># <span class="GramE">iterate</span> through joints and store their           <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; # location in <span class="SpellE">jointhash            <br /></span></font></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">for</span> joint in <span class="SpellE">skeleton.Joints</span>:         <br /></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span># <span class="GramE">extract</span> the <span class="SpellE">jointname</span> from the id, where the id is&#160; <br /></font></span><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span># <span class="GramE">something</span> like:           <br /></font></span><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span># <span class="SpellE">Microsoft.Research.Kinect.Nui.JointID.FootRight            <br />&#160;&#160;&#160;&#160;&#160;&#160; </span></font></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">jointname</span></span> = <span class="SpellE">joint.ID.ToString</span>().split(&quot;.&quot;)[-1]         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>z = <span class="SpellE">joint.Position.Z</span> + 1e-10         <br /></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160; </span># <span class="GramE">project</span> x location into <span class="SpellE">viewplane</span> using z           <br /></font></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">currx</span></span> = <span class="SpellE">joint.Position.X</span>/z         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">x.Add</span></span><span class="GramE">(</span><span class="SpellE">currx</span>)         <br /></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160; </span># <span class="GramE">project</span> y location into <span class="SpellE">viewplane</span> using z           <br /></font></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">curry</span> = <span class="SpellE">joint.Position.Y</span>/z         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">y.Add</span></span><span class="GramE">(</span>curry)         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">labels.Add</span></span><span class="GramE">(</span><span class="SpellE">jointname</span>)         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"># store the projected locations and the original <span class="SpellE">x<span class="GramE">,y,z              <br /></span></span></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">jointhash</span></span><span class="GramE">[</span><span class="SpellE">jointname</span>] = (<span class="SpellE">currx,curry</span>,\         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#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; </span><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">joint.Position.X</span>,\         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#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; </span><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">joint.Position.Y</span>, z)         <br /></font><font face="Courier New"><span style="mso-spacerun: yes"></span></font></p>    <p class="CodeBox"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green"># <span class="GramE">draw</span> joints with joint labels           <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">plot(</span><span class="SpellE">x,y,<span style="color: #a31515">'b.'</span>,size</span>=10, labels=labels)</font></p>    <p class="CodeBox"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green"># <span class="GramE">draw</span> lines connecting joints           <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">plotjointseq</span></span><span class="GramE">(</span>[<span style="color: #a31515">&quot;<span class="SpellE">HipCenter</span>&quot;</span>,<span style="color: #a31515">&quot;Spine&quot;</span>,\         <br />&#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; <span style="color: #a31515">&quot;<span class="SpellE">ShoulderCenter</span>&quot;</span>,<span style="color: #a31515">&quot;Head&quot;</span>])         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">plotjointseq</span></span><span class="GramE">(</span>[<font color="#c0504d">&quot;<span class="SpellE">ShoulderCenter</span>&quot;</font>,<font color="#c0504d">&quot;<span class="SpellE">ShoulderLeft</span>&quot;</font>,\         <br /></font><font face="Courier New"><span style="color: #a31515"><span style="mso-spacerun: yes">&#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; </span>&quot;<span class="SpellE">ElbowLeft</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">WristLeft</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">HandLeft</span>&quot;</span>])         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">plotjointseq</span></span><span class="GramE">(</span>[<span style="color: #a31515">&quot;<span class="SpellE">ShoulderCenter</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">ShoulderRight</span>&quot;</span>,\         <br /></font><font face="Courier New"><span style="color: #a31515"><span style="mso-spacerun: yes">&#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; </span>&quot;<span class="SpellE">ElbowRight</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">WristRight</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">HandRight</span>&quot;</span>])         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">plotjointseq</span></span><span class="GramE">(</span>[<span style="color: #a31515">&quot;<span class="SpellE">HipCenter</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">HipLeft</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">KneeLeft</span>&quot;</span>,\         <br /></font><font face="Courier New"><span style="color: #a31515"><span style="mso-spacerun: yes">&#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; </span>&quot;<span class="SpellE">AnkleLeft</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">FootLeft</span>&quot;</span>])         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">plotjointseq</span></span><span class="GramE">(</span>[<span style="color: #a31515">&quot;<span class="SpellE">HipCenter</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">HipRight</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">KneeRight</span>&quot;</span>,\         <br /></font><font face="Courier New"><span style="color: #a31515"><span style="mso-spacerun: yes">&#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; </span>&quot;<span class="SpellE">AnkleRight</span>&quot;</span>,<span style="color: #a31515">&quot;<span class="SpellE">FootRight</span>&quot;</span>])</font></p>    <p class="CodeBox"><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span># <span class="GramE">compute</span> the <span class="SpellE">framerate</span> and use a label to display it           <br /></font></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">framerate</span></span> = 1000.0/\         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#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; </span>((<span class="SpellE">System.DateTime.Now\          <br />&#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; -lastplottime</span>).Milliseconds)         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">plot(</span>[-.7],[.7],labels=[<span class="SpellE">str</span>(round(<span class="SpellE">framerate</span>))+<span style="color: #a31515">&quot; fps&quot;</span>])         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">lastplottime</span></span> = <span class="SpellE">System.DateTime.Now</span></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New">&#160;</o:p></font></span></p>    <p class="CodeBox"><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span># set the <span class="GramE">size<span style="mso-spacerun: yes">&#160; </span>of</span> the graph           <br /></font></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">axisranges</span></span><span class="GramE">(</span>-.8,.8,-.8,.8)</font><font face="Courier New">&#160;</o:p></font></p>    <p class="CodeBox"><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span># in double buffering mode, update the view           <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; # (uncomment below for <span class="SpellE">Sho</span> 2.0.5+)           <br /></font></span><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #77933c; mso-themecolor: accent3; mso-themeshade: 191; mso-style-textfill-fill-color: #77933c; mso-style-textfill-fill-themecolor: accent3; mso-style-textfill-fill-alpha: 100.0%; mso-style-textfill-fill-colortransforms: lumm=75000"># <span class="SpellE"><span class="GramE">p.Render</span></span><span class="GramE">()</span></span></font></p> </div>  <p>That example demonstrates all the important stuff: how to get at individual joints and their 3D locations, as well as how the joints are connected together. From there, it’s easy to add a few more lines of code and create simple virtual 3D objects. In the example below, I’ve created a simple staff object with a fixed 3D length that’s centered between the two hands. The code below can be inserted right before the “draw joints” section in the bodyplot() function above:</p>  <div style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 1pt; mso-element: para-border-div; mso-border-alt: solid windowtext .5pt">   <br />    <p class="CodeBox"><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"># <span class="GramE">draw</span> red staff           <br /></font></span><font face="Courier New"><span class="SpellE"><span class="GramE">handleftpt</span></span> = <span class="SpellE">DoubleArray<span style="color: blue">.</span>From</span>(<span class="SpellE">jointhash</span>[<span style="color: #a31515">&quot;<span class="SpellE">HandLeft</span>&quot;</span>])         <br /></font><font face="Courier New"><span class="SpellE"><span class="GramE">handrightpt</span></span> = <span class="SpellE">DoubleArray<span style="color: blue">.</span>From</span>(<span class="SpellE">jointhash</span>[<span style="color: #a31515">&quot;<span class="SpellE">HandRight</span>&quot;</span>])         <br /></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"># <span class="GramE">compute</span> center point between hands           <br /></font></span><font face="Courier New"><span class="SpellE"><span class="GramE">handcenterpt</span></span> = (<span class="SpellE">handleftpt+handrightpt</span>)/2.0         <br /></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"># compute vector along staff direction          <br /></font></span><font face="Courier New"><span class="SpellE"><span class="GramE">staffvec</span></span> = <span class="SpellE">handrightpt-handleftpt          <br /></span></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"># normalize it to unit length          <br /></font></span><font face="Courier New"><span class="SpellE"><span class="GramE">staffvec</span></span> = <span class="SpellE">staffvec</span>/(norm(<span class="SpellE">staffvec</span>)+1e-10)         <br /></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"># <span class="GramE">compute</span> the left and right end of the staff           <br /></font></span><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"># <span class="GramE">it's</span> two units long and .05 units wide, centered between the hands           <br /></font></span><font face="Courier New"><span class="SpellE"><span class="GramE">staffleftpt</span></span> = <span class="SpellE">handcenterpt</span> -<span class="SpellE">staffvec</span>*1.0         <br /></font><font face="Courier New"><span class="SpellE"><span class="GramE">staffrightpt</span></span> = <span class="SpellE">handcenterpt</span><span style="mso-spacerun: yes">&#160; </span>+ <span class="SpellE">staffvec</span>*1.0         <br /></font><span style="color: #76923c; mso-themecolor: accent3; mso-themeshade: 191"><font face="Courier New"># <span class="GramE">if</span> the hands are close enough to each other, draw the staff           <br /></font></span><font face="Courier New"><span class="GramE"><span style="color: blue">if</span></span> norm(<span class="SpellE">handrightpt</span>[2:]-<span class="SpellE">handleftpt</span>[2:]) &lt; 0.7:         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="GramE">plot(</span>[staffleftpt[2]/staffleftpt[4],staffrightpt[2]/staffrightpt[4]],\         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160; </span>[<span class="GramE">staffleftpt[</span>3]/staffleftpt[4],staffrightpt[3]/staffrightpt[4]],<span style="color: #a31515">'r-'</span>)         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="GramE">plot(</span>[staffrightpt[2]/staffrightpt[4],staffrightpt[2]/staffrightpt[4]],\         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160; </span>[<span class="GramE">staffrightpt[</span>3]/staffrightpt[4],(staffrightpt[3]+0.05)/staffrightpt[4]],<span style="color: #a31515">'r-'</span>)         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="GramE">plot(</span>[staffleftpt[2]/staffleftpt[4],staffleftpt[2]/staffleftpt[4]],\         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160; </span>[<span class="GramE">staffleftpt[</span>3]/staffleftpt[4],(staffleftpt[3]+.05)/staffleftpt[4]],<span style="color: #a31515">'r-'</span>)         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="GramE">plot(</span>[staffleftpt[2]/staffleftpt[4],staffrightpt[2]/staffrightpt[4]],\         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;</span>[(<span class="GramE">staffleftpt[</span>3]+.05)/staffleftpt[4],(staffrightpt[3]+.05)/staffrightpt[4]],<span style="color: #a31515">'r-'</span>)</font></p> </div>  <p>When the hands get within a certain distance of each other, the staff (magically) appears, and our little stick figure friend can do some fancy tricks. A screenshot is below, but you’ll want to <a href="http://research.microsoft.com/en-us/UM/redmond/projects/Sho/videos/shokinect_redstaff.wmv">click here to see the video</a>.</p>  <p><a href="http://research.microsoft.com/en-us/UM/redmond/projects/Sho/videos/shokinect_redstaff.wmv"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="clip_image003" border="0" alt="clip_image003" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/22/metablogapi/2870.clip_image003_1DBBB4A5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-22-metablogapi/2870.clip_5F00_image003_5F00_1DBBB4A5.png" width="244" height="215" /></a></p>  <h3>How It Works</h3>  <p>The glue code that gets the SDK working in Sho, kinect.py, is also quite short, but what it does is a little complicated. Since the managed layer of the Kinect SDK depends on the WPF threading model and message pump, we have to create a shim WPF application and window that will get the events. That application has a callback that’s called every time it gets new skeleton data; inside that callback we save the skeletonFrame information and the skeletonUpdateTime in the KinectTracker object, which we can access outside of the shim application’s thread. The entirety of kinect.py is below; note you may need to update the paths to point to wherever you installed the SDK:</p>  <div style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 1pt; mso-element: para-border-div; mso-border-alt: solid windowtext .5pt">   <br />    <p class="testbox"><font color="#008000" face="Courier New"># kinect.py</font><font face="Courier New">&#160;</o:p></font></p>    <p class="testbox"><font face="Courier New"><span class="GramE">from</span> <span class="SpellE">sho</span> import *         <br /></font><font face="Courier New"><span class="GramE">import</span> System, <span class="SpellE">clr          <br /></span></font><font face="Courier New"><span class="SpellE"><span class="GramE">clr.AddReference</span></span><span class="GramE">(</span><span style="color: #a31515">&quot;<span class="SpellE">PresentationFramework</span>&quot;</span>)         <br /></font><font face="Courier New"><span class="SpellE"><span class="GramE">clr.AddReference</span></span><span class="GramE">(</span><span style="color: #a31515">&quot;<span class="SpellE">PresentationCore</span>&quot;</span>)         <br /></font><font face="Courier New"><span class="SpellE"><span class="GramE">clr.AddReference</span></span><span class="GramE">(</span><span style="color: #a31515">&quot;<span class="SpellE">WindowsBase</span>&quot;</span>)         <br /></font><font face="Courier New"><span class="SpellE"><span class="GramE">clr.AddReference</span></span><span class="GramE">(</span><span style="color: #a31515">&quot;<span class="SpellE">System.Xaml</span>&quot;</span>)         <br /></font><font face="Courier New"><span class="SpellE"><span class="GramE">addpath</span></span><span class="GramE">(</span><span style="color: #a31515">&quot;C:\Program Files (x86)\Microsoft Research <span class="SpellE">KinectSDK</span>&quot;</span>)         <br /></font><font face="Courier New"><span class="SpellE"><span class="GramE">ShoLoadAssembly</span></span><span class="GramE">(</span><span style="color: #a31515">&quot;Microsoft.Research.Kinect.dll&quot;</span>)         <br /></font><font face="Courier New"><span class="GramE">from</span> <span class="SpellE">Microsoft.Research.Kinect.Nui</span> import *</font><font face="Courier New">&#160;</o:p></font></p>    <p class="testbox"><font face="Courier New"><span class="GramE">class</span> <span class="SpellE">KinectHelperWindow</span>(<span class="SpellE">System.Windows.Window</span>):         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">def</span></span> __<span class="SpellE">init</span>__(self):         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.nui</span> = <span class="GramE">None          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.Width</span> = 1         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.Height</span> = 1         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.Visibility</span> = <span class="SpellE">System.Windows.Visibility.Hidden          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.Loaded</span> += <span class="SpellE"><span class="GramE">System.Windows.RoutedEventHandler</span></span><span class="GramE">(</span><span class="SpellE">self.Init</span>)</font></p>    <p class="testbox"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">def</span></span> <span class="SpellE">SkeletonFrameReady</span>(self, <span class="SpellE">obj</span>, <span class="SpellE">skeletoneventargs</span>):         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.kinectinfo.skeletonUpdateTime</span> = <span class="SpellE">System.DateTime.Now          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.kinectinfo.skeletonFrame</span> = <span class="SpellE">skeletoneventargs.SkeletonFrame</span></font><font face="Courier New">&#160;</o:p></font></p>    <p class="testbox"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">def</span></span> <span class="SpellE">Init</span>(self, <span class="SpellE">obj</span>, <span class="SpellE">rea</span>):         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.nui</span> = <span class="GramE">Runtime()          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">self.nui.Initialize</span></span><span class="GramE">(</span><span class="SpellE">RuntimeOptions.UseDepthAndPlayerIndex</span> |\         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">RuntimeOptions.UseSkeletalTracking</span> |\         <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font><font face="Courier New">&#160;<span class="SpellE">RuntimeOptions.UseColor</span>);         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">self.nui.VideoStream.Open</span></span><span class="GramE">(</span><span class="SpellE">ImageStreamType.Video</span>, 2,\         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>ImageResolution.Resolution640x480, <span class="SpellE">ImageType.Color</span>);         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">self.nui.DepthStream.Open</span></span><span class="GramE">(</span><span class="SpellE">ImageStreamType.Depth</span>, 2, \         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>ImageResolution.Resolution320x240, \         <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font><font face="Courier New"><span class="SpellE">ImageType.DepthAndPlayerIndex</span>);         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.nui.SkeletonFrameReady</span> += \         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">System.EventHandler[</span>SkeletonFrameReadyEventArgs]\         <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </font><font face="Courier New">(self.SkeletonFrameReady)</font></p>    <p class="testbox"><font face="Courier New"><span class="GramE">class</span> <span class="SpellE">KinectTracker</span>:         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">def</span></span> __<span class="SpellE">init</span>__(self):         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.skeletonFrame</span> = <span class="GramE">None          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.skeletonUpdateTime</span> = <span class="GramE">None          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">pass</span></font></p>    <p class="testbox"><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">def</span></span> <span class="SpellE">StartKinect</span>(self):         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.app</span> = <span class="SpellE"><span class="GramE">System.Windows.Application</span></span><span class="GramE">()          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">khw</span></span> = <span class="SpellE">KinectHelperWindow</span>()         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">khw.kinectinfo</span> = self         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">self.helperwindow</span> = <span class="SpellE">khw          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">self.app.Run</span></span><span class="GramE">(</span><span class="SpellE">khw</span>)</font></p>    <p class="testbox"><font face="Courier New"><span class="SpellE"><span class="GramE">def</span></span> <span class="SpellE">startKinectTracker</span>():         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">kt</span></span> = <span class="SpellE">KinectTracker</span>()         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">kt.shothread</span> = <span class="SpellE"><span class="GramE">ShoThread</span></span><span class="GramE">(</span><span class="SpellE">kt.StartKinect</span>, <span style="color: #a31515">&quot;<span class="SpellE">kinectapp</span>&quot;</span>, \         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">System.Threading.ApartmentState.STA</span>)         <br /></font><font face="Courier New"><span style="mso-spacerun: yes">&#160; </span><span style="mso-spacerun: yes">&#160; </span><span class="SpellE"><span class="GramE">kt.shothread.Start</span></span><span class="GramE">()          <br /></span></font><font face="Courier New"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="GramE">return</span> <span class="SpellE">kt</span></font></p> </div>  <p>&#160;</p>  <h3>How To Get Started with Your Own Code</h3>  <p>To develop your own Kinect demos, you’ll have to start by getting yourself a Kinect sensor. I’d recommend the <a href="http://www.amazon.com/gp/product/B002BSA298">standalone sensor</a>, since it comes with a power supply; if you get the package with an xbox 360 you’ll need to buy a separate power supply as it only comes with a cable to connect to the 360 console. Once you have the device, you’ll need to install the <a href="http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/">Kinect SDK</a>. Once you’ve done that, reboot your machine, plug in your kinect, and you should be ready to go.</p>  <p>In order to use the sensor from Sho, you’ll have to use the 32-bit console, shoconsole32, even on a 64-bit machine, as although the drivers work on both 32-bit and 64-bit machines, the managed SDK only supports calls from 32-bit contexts. You’ll also want to save the glue code above as kinect.py. Once in the console, import it and create a KinectTracker object with startKinectTracker:</p>  <p><font face="Courier New">&gt;&gt;&gt; import kinect      <br />&gt;&gt;&gt; kt = kinect.startKinectTracker()</font></p>  <p>Once a skeleton is found in the sensor’s range, its data will be copied to kt.skeletonFrame and you can use it as in the demos above.</p>  <h3>And You’re Off!</h3>  <p>So there you have it; you now know how to talk to the Kinect SDK from Sho using the wrapper in kinect.py above. I’m sure you’ll do far more creative things than adding a red staff to a stick figure, and we’d love to hear about it. Please send us links to your own demo videos in the comments!</p>]]></content:encoded>
    </item>
    <item>
      <title>Analyzing Stock Price Data with Sho, Part I</title>
      <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/analyzing-stock-price-data-with-sho-part-i</link>
      <pubDate>Thu, 26 May 2011 18:54:57 GMT</pubDate>
      <dc:creator><![CDATA[Sho Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/the_blog_of_sho/2011/05/26/analyzing-stock-price-data-with-sho-part-i/</guid>
      <description><![CDATA[One fun arena for doing data analysis and visualization is the stock market.&#160; Fortunately, a...]]></description>
      <content:encoded><![CDATA[<p>One fun arena for doing data analysis and visualization is the stock market.&#160; Fortunately, a lot of stock market data is now available publicly,&#160; and Sho makes it easy and fun to do various kinds of analysis on it. We’ll look at data from the stocks in the S&amp;P 500 index, since that data is readily available – you can get the last year of daily prices from various locations, including <a title="http://pages.swcp.com/stocks/#Daily%20update" href="http://pages.swcp.com/stocks/#Daily%20update">http://pages.swcp.com/stocks/#Daily%20update</a>.</p>  <p>Start by downloading the data – pick the “Historical” option and click “Get Full Set;” this will give you a zip file which will contain a single file, sp500hst.txt.&#160; Save that to some handy directory.&#160; If we open up that file in a text editor, we’ll see a bunch of lines like the below:</p>  <p><font face="Courier New">20100310,CBS,14.45,14.75,14.39,14.75,81612      <br />20100311,CBS,14.63,14.8,14.4,14.8,65851       <br />20100312,CBS,14.79,14.85,14.42,14.6,66466       <br />20100315,CBS,14.52,14.535,14.22,14.44,68313       <br />20100316,CBS,14.44,14.78,14.31,14.78,103030       <br />20100317,CBS,14.83,14.945,14.46,14.5,80747       <br />20100318,CBS,14.51,14.655,14.24,14.37,55267       <br />20100319,CBS,14.42,14.63,13.98,13.98,99261       <br />20100322,CBS,13.96,14.14,13.7,14.07,58456       <br />20100323,CBS,14.14,14.28,14.06,14.26,66844       <br />20100324,CBS,14.13,14.43,14.03,14.24,84188       <br />20100325,CBS,14.42,14.44,13.85,13.87,108878       <br /></font></p>  <p>In other words, the date, followed by the symbol, followed by open, high, low, close, and the volume for that day.&#160; We’re interested in grabbing the closing value for each day for a given stock so that we can plot it, compute running averages, make predictions, etc.&#160; Let’s write a function that will extract this from the file:</p>  <p><font face="Courier New">def getseries(symbol, filename):     <br /></font><font face="Courier New">&#160;&#160;&#160; data = csvreadArray(filename)     <br />&#160;&#160;&#160; dates = []       <br />&#160;&#160;&#160; prices = []       <br />&#160;&#160;&#160; for line in data.Rows:       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if line[1] == symbol:       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; dates.Add(line[0]) # date       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; prices.Add(float(line[5])) # closing price       <br />&#160;&#160;&#160; return(dates,DoubleArray.From(prices))</font>&#160;&#160;&#160; </p>  <p>This will get us the dates and closing price for a given symbol.&#160; Note that we convert the list of prices to a DoubleArray for ease of later manipulations. Let’s retrieve the prices for symbol “CBS” and plot the result:</p>  <p><font face="Courier New">&gt;&gt;&gt; dates, prices = getseries(&quot;CBS&quot;, &quot;c:/mypath/sp500hst.txt&quot;)      <br />&gt;&gt;&gt; plot(prices)</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/22/metablogapi/8117.rawseries_61BF0C37.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-22-metablogapi/8117.rawseries_5F00_61BF0C37.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="rawseries" border="0" alt="rawseries" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/22/metablogapi/1106.rawseries_thumb_211CBFC8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-22-metablogapi/1106.rawseries_5F00_thumb_5F00_211CBFC8.png" width="448" height="321" /></a></p>  <p>That gives us a first look at the raw data.&#160; Note that the x axis labels are just the index number of each element; we’d rather see the appropriate date labels for the x axis, but since they’re strings and not numeric values, we can’t just pass them in via plot(x,y).&#160; We can instead modify the x-axis labels with the xlabels command – we just need to tell it which locations to label and what the respective values would be, so we’ll create a series of numbers spaced by 10 and then pick out the appropriate labels with a list comprehension:   <br /><font face="Courier New">     <br />&gt;&gt;&gt; sd = range(0,len(dates),10)       <br />&gt;&gt;&gt; xlabels(sd, [dates[ind] for ind in sd], orientation=90) # create date labels on x axis and turn them 90 degrees</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/22/metablogapi/6557.prices_5CDC587B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-22-metablogapi/6557.prices_5F00_5CDC587B.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="prices" border="0" alt="prices" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/22/metablogapi/4403.prices_thumb_40CB9990.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-22-metablogapi/4403.prices_5F00_thumb_5F00_40CB9990.png" width="447" height="320" /></a></p>  <p>Now we’d like to see the moving averages over different windows for the stock in addition to its daily value.&#160; We can use the signal processing tools in Sho to easily compute a moving average by convolving the time series with a box filter, which we can represent via <font face="Courier New">ones(N,1)/N</font> where N is the length of the filter.&#160; We divide by N to normalize the sum of the filter to 1.&#160; We’ll compute a 10-day and a 30-day moving average.</p>  <p><font face="Courier New">&gt;&gt;&gt; smooth10 = SignalProc.conv(DoubleArray.From(prices).T, ones(10,1)/10.0, CompMode.Auto, BoundaryMode.Reflect)     <br />&gt;&gt;&gt; smooth30 = SignalProc.conv(DoubleArray.From(prices).T, ones(30,1)/30.0, CompMode.Auto, BoundaryMode.Reflect)</font></p>  <p>We’ll now plot these smoothed signals on top of the original prices by using the hold() command to hold the previous plot.&#160; Finally, we’ll add a legend to label the separate time series; we’ll also add a title for good measure.</p>  <p><font face="Courier New">&gt;&gt;&gt; hold()     <br />&gt;&gt;&gt; plot(smooth10)      <br />&gt;&gt;&gt; plot(smooth30)      <br />&gt;&gt;&gt; legend('daily prices','10-day average','30-day average')      <br />&gt;&gt;&gt; plottitle('Daily Prices for CBS')</font></p>  <p><font face="Courier New"><font face="Segoe UI">That gets us to the plot below:</font></font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/22/metablogapi/3733.allseries_3535DC51.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-22-metablogapi/3733.allseries_5F00_3535DC51.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="allseries" border="0" alt="allseries" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/22/metablogapi/6471.allseries_thumb_2E169FD9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-22-metablogapi/6471.allseries_5F00_thumb_5F00_2E169FD9.png" width="582" height="451" /></a></p>  <p><font face="Courier New"><font face="Segoe UI">In the next post, we’ll show how build a simple autoregressive model for predicting future prices (though not with particularly high accuracy).</font></font></p>]]></content:encoded>
    </item>
    <item>
      <title>Speech Synthesis from Sho</title>
      <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/speech-synthesis-from-sho</link>
      <pubDate>Fri, 08 Apr 2011 18:25:10 GMT</pubDate>
      <dc:creator><![CDATA[Sho Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/the_blog_of_sho/2011/04/08/speech-synthesis-from-sho/</guid>
      <description><![CDATA[Last time, we looked at how we could do speech recognition from Sho.&#160; Well, what about the...]]></description>
      <content:encoded><![CDATA[<p>Last time, we looked at how we could do speech recognition from Sho.&#160; Well, what about the other direction, speech synthesis (or text-to-speech)?&#160; It turns out that’s even easier to do:</p>  <p><font face="Courier New">&gt;&gt;&gt; clr.AddReference(&quot;System.Speech&quot;)     <br />&gt;&gt;&gt; from System.Speech.Synthesis import SpeechSynthesizer      <br />&gt;&gt;&gt; synth = SpeechSynthesizer()      <br />&gt;&gt;&gt; synth.Speak(&quot;Hello all and welcome to the Blog of Sho&quot;)</font></p>  <p>That’s all it takes to get Sho talking back to you.&#160; If nothing else, this is a fun way to get Sho to tell you when it’s finished with a long optimization run :).</p>]]></content:encoded>
    </item>
    <item>
      <title>Using Speech Recognition from Sho</title>
      <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/using-speech-recognition-from-sho</link>
      <pubDate>Fri, 18 Mar 2011 17:15:00 GMT</pubDate>
      <dc:creator><![CDATA[Sho Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/the_blog_of_sho/2011/03/18/using-speech-recognition-from-sho/</guid>
      <description><![CDATA[One of the great things about Sho is that a broad variety of powerful libraries is available at your...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal"><span style="font-size: small"><span style="font-family: calibri">One of the great things about Sho is that a broad variety of powerful libraries is available at your fingertips.<span style="mso-spacerun: yes">&#160; </span>Today I’ll give an introduction to using Windows’ speech recognition engine, which is surprisingly easy and fun to use.</span></span></p>  <p class="MsoNormal"><span style="font-size: small"><span style="font-family: calibri">To get started, you’ll need to have some kind of microphone.<span style="mso-spacerun: yes">&#160; </span>Headsets work best, but webcam mics, built-in laptop mics, or analog mics will work as well.<span style="mso-spacerun: yes">&#160; </span>Once you’ve got that plugged in, you need to do a little bit of setup:<o:p></o:p></span></span></p>  <p class="MsoNormal"><span style="font-size: small"><span style="font-family: courier new,courier"></span></span></p>  <p><span style="font-size: small"><span style="font-family: courier new,courier">&gt;&gt;&gt; clr.AddReference(&quot;System.Speech&quot;)       <br />&gt;&gt;&gt; from System.Speech.Recognition import *</span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">Now we’ll instantiate a speech recognition engine.<span style="mso-spacerun: yes">&#160; </span>We’ll set it up with the default dictation grammar – you can custom design a grammar as well, but the default works pretty well for general use.<o:p></o:p></span></span></p>  <p class="MsoNormal"><span style="font-size: small"><span style="font-family: courier new,courier"></span></span></p>  <p><span style="font-size: small"><span style="font-family: courier new,courier">&gt;&gt;&gt; sre = SpeechRecognitionEngine()       <br />&gt;&gt;&gt; sre.SetInputToDefaultAudioDevice()        <br />&gt;&gt;&gt; sre.LoadGrammar(DictationGrammar())<o:p></o:p></span></span></p>  <p class="MsoNormal"><span style="font-size: small"><span style="font-family: calibri"></span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">Now we can tell the recognizer to listen for speech.<span style="mso-spacerun: yes">&#160; </span>Type in the following line and say something into the mic, like “a family of ducks can create a traffic jam:”<o:p></o:p></span></span></p>  <p><span style="font-size: small"><span style="font-family: courier new,courier">&gt;&gt;&gt; res = sre.Recognize()<o:p></o:p></span></span></p>  <p class="MsoNormal"><span style="font-size: small"><span style="font-family: calibri"></span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">This call will block until it gets an utterance from the microphone.<span style="mso-spacerun: yes">&#160; </span>Once it returns, you can print the resulting text:<o:p></o:p></span></span></p>  <p><span style="font-size: small"><span style="font-family: courier new,courier">&gt;&gt;&gt; print res.Text<o:p></o:p></span></span></p>  <p class="MsoNormal"><span style="font-size: small"><span style="font-family: calibri"></span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">You can also use the recognizer in an asynchronous mode, where each speech event will trigger a callback.<span style="mso-spacerun: yes">&#160; </span>To do this, first define a function and hook it to the recognizer’s SpeechRecognized event:<o:p></o:p></span></span></p>  <p class="MsoNormal"><span style="font-size: small"><span style="font-family: courier new,courier"></span></span></p>  <p><span style="font-size: small"><span style="font-family: courier new,courier">&gt;&gt;&gt; def printspeech(sender, event):       <br /><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>txt = e.Result.Text        <br /><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>print txt        <br /></span></span><span style="font-size: small"><span style="font-family: courier new,courier">&gt;&gt;&gt; sre.SpeechRecognized += printspeech<o:p></o:p></span></span></p>  <p class="MsoNormal"><span style="font-size: small"><span style="font-family: calibri"></span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">Then start up the recognizer in asynchronous mode; the call below will return immediately:<o:p></o:p></span></span></p>  <p><span style="font-size: small"><span style="font-family: courier new,courier">&gt;&gt;&gt; sre.RecognizeAsync(RecognizeMode.Multiple)<o:p></o:p></span></span></p>  <p><span style="line-height: 115%; font-family: &#39;Calibri&#39;,&#39;sans-serif&#39;; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: &#39;Times New Roman&#39;; mso-bidi-theme-font: minor-bidi; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: ar-sa"><span style="font-size: small">The printspeech() function will be called after each speech utterance. If you leave out the RecognizeMode.Multiple, the recognizer will stop listening after the first event.<span style="mso-spacerun: yes">&#160; </span>Note that the callback can be a method in an object, which will allow you to keep some state.<span style="mso-spacerun: yes">&#160; </span>In this way, you can create all kinds of speech-enabled applications: a voice-controlled chess game, a drawing program that lets you change pens by voice, etc.<span style="mso-spacerun: yes">&#160; </span>Give it a shot and let us know what you build with it!</span></span></p>]]></content:encoded>
    </item>
    <item>
      <title>Calling Sho from F#</title>
      <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/calling-sho-from-f</link>
      <pubDate>Thu, 03 Mar 2011 11:45:15 GMT</pubDate>
      <dc:creator><![CDATA[Sho Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/the_blog_of_sho/2011/03/03/calling-sho-from-f/</guid>
      <description><![CDATA[Yin Zhu at the Hong Kong University of Science and Technology has some sample code for calling Sho...]]></description>
      <content:encoded><![CDATA[<p><a target="_blank" href="http://www.blogger.com/profile/14892386755350244000">Yin Zhu</a> at the Hong Kong University of Science and Technology has some <a href="http://fdatamining.blogspot.com/2011/02/introducing-sho-and-using-its-libraries.html">sample code for calling Sho libraries from F#</a>. It looks quite simple: hopefully the F# community will find the Sho libraries useful.</p>]]></content:encoded>
    </item>
    <item>
      <title>BioInformatics in Sho: Using the Microsoft Biology Foundation</title>
      <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/bioinformatics-in-sho-using-the-microsoft-biology-foundation</link>
      <pubDate>Fri, 18 Feb 2011 16:33:50 GMT</pubDate>
      <dc:creator><![CDATA[Sho Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/the_blog_of_sho/2011/02/18/bioinformatics-in-sho-using-the-microsoft-biology-foundation/</guid>
      <description><![CDATA[Beatriz, from the Microsoft Biology&nbsp;Initiative team, recently put up a great post on how to use...]]></description>
      <content:encoded><![CDATA[<p>Beatriz, from the Microsoft Biology&nbsp;Initiative team, recently put up <a href="http://blogs.msdn.com/b/mbi/archive/2011/02/10/the-microsoft-biology-foundation-and-sho-the-net-playground-for-data.aspx">a great post on how to use their Microsoft Biology Foundation (MBF) library from Sho</a>.&nbsp; Her post gives&nbsp;many more details, but to give you a quick teaser of how easy it is, here is all you have to do to import the library and load up some gene sequences from a FASTA file:</p>
<p style="padding-left: 60px;"><span style="font-family: courier new,courier;">&gt;&gt;&gt; ShoLoadAssembly("c:/Program Files/Microsoft Biology Initiative/1.0/MBF/MBF.dll")<br /></span><span style="font-family: courier new,courier;">&gt;&gt;&gt; import MBF<br /></span><span style="font-family: courier new,courier;">&gt;&gt;&gt; filename = "c:\\path\\to\\your\\file.fa"<br /></span><span style="font-family: courier new,courier;">&gt;&gt;&gt; parser = MBF.IO.SequenceParsers.FindParserByFile(filename)<br /></span><span style="font-family: courier new,courier;">&gt;&gt;&gt; sequences = parser.Parse(filename)<br /></span><span style="font-family: courier new,courier;">&gt;&gt;&gt; for x in sequences: print x<br /><br />CCAGGCTTTAGGTATCACCACTAAAATCTCCAGGGGCAC<br />TTTCCAGGCTTTAGGTATCACCACTAAAATCTCAAG<br />GGTATCACCACTAAAATCTCCAGGGGCACCATTGAA<br />...</span></p>
<p>&nbsp;There's of course much more you can do with the MBF tools than just read sequences from files - you can parse sequences, make visualizations, do sequence alignment, multi-sequence alignment, fragment assembly, transcription, translation, pattern matching against sequences, and more (see their <a href="http://research.microsoft.com/en-US/projects/bio/training.aspx">MBF training page</a> for more information), all from the .NET language of your choice.&nbsp;&nbsp;All this functionality is thus available in Sho; using the code is as simple as the small example above.</p>]]></content:encoded>
    </item>
    <item>
      <title>Using Sho Visualization in WinForms from C#</title>
      <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/using-sho-visualization-in-winforms-from-c</link>
      <pubDate>Tue, 15 Feb 2011 13:35:00 GMT</pubDate>
      <dc:creator><![CDATA[Sho Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/the_blog_of_sho/2011/02/15/using-sho-visualization-in-winforms-from-c/</guid>
      <description><![CDATA[Over on the Forum of Sho drobertson asked how to create a Contour Chart from C# within a form. I...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: small;"><span style="font-family: arial,helvetica,sans-serif;">Over on the <a target="_blank" title="http://social.msdn.microsoft.com/Forums/en-US/theforumofsho/threads" href="http://social.msdn.microsoft.com/Forums/en-US/theforumofsho/threads">Forum of Sho </a>drobertson asked how to create a Contour Chart from C# within a form. I thought that would make good example code, so here it is:</span></span>
</p>
<pre class="scroll"><code class="cplusplus">using System;<br />using System.Collections.Generic;<br />using System.Drawing;<br />using System.Linq;<br />using System.Text;<br />using System.Windows.Forms;<br />using ShoNS.Visualization;<br />using ShoNS.Array;<br />using ShoNS.MathFunc;<br /><br />namespace testForm<br />{<br />    // Create a composite visualization by deriving from System.Windows.Forms.Form<br />    public class testForm : Form<br />    {<br />        private ShoChart ch;     // this will hold a Sho contour chart<br />        private Button button1;  // a button to update the contour chart<br />        private Label label1;    // a label to show how many times the button has been clicked<br />        private int num;         // a counter<br /><br /><br />        public testForm()<br />        {<br />            num = 0;<br />            InitializeComponent();<br />        }<br /><br />        // code to generate (slightly random) data and create a contour chart from it<br />        // this method shows examples of calling into the Sho math libraries and the Sho viz libraries<br />        private ShoChart GenChart()<br />        {<br />            // first, create a range object that spans from 0 to pi, with 100 elements<br />            DoubleRange b = new DoubleRange(0.0, Math.PI);<br />            b.Count = 100;<br />            // now, create a row vector and fill it with random numbers<br />            DoubleArray x = new DoubleArray(1, 100);<br />            ArrayRandom.FillRandom&lt;double&gt;(x);<br />            // shift and scale the random numbers, and add sin(b) to it, to make a noisy sinusoid<br />            x = (x-0.5) * 0.1 + ArrayMath.Sin(b);<br />            // analogously, we'll make a noisy cosine row vector, 100 long<br />            DoubleArray y = new DoubleArray(1, 100);<br />            ArrayRandom.FillRandom&lt;double&gt;(y);<br />            y = (y-0.5) * 0.1 + ArrayMath.Cos(b);<br />            // now, make a matrix from the outer product of x and y.<br />            DoubleArray arr = x.T * y;<br />            // from the matrix, create a contour plot. Second argument says automatically choose the contours<br />            ShoChart ch = new ShoContourChart(arr, null);<br />            // all of the Sho viz classes inherit from control, so we can set WinForms control parameters<br />            // to size the contour plot and place it within the parent form.<br />            ch.AutoSize = true;<br />            ch.Location = new Point(25, 75);<br />            ch.Name = "ContourChart";<br />            ch.Size = new Size(375, 225);<br />            return ch;<br />        }<br /><br />        // a button click will create a new contour chart with slightly randomized data<br />        private void buttonClick(object sender, EventArgs e)<br />        {<br />            SuspendLayout();<br />            // take the old contour plot out of the form<br />            Controls.Remove(ch);<br />            // generate a new one, and put it into the form<br />            ch = GenChart();<br />            Controls.Add(ch);<br />            // increment the label<br />            label1.Text = num.ToString();<br />            num++;<br />            // relayout and refresh the form<br />            ResumeLayout(false);<br />            PerformLayout();<br />            Refresh();<br />        }<br /><br />        private void InitializeComponent()<br />        {<br />            // code derived from form wizard: create a button and label<br />            button1 = new Button();<br />            label1 = new Label();<br /><br />            SuspendLayout();<br /><br />            // position and parameterize the button<br />            button1.Location = new Point(175, 50);<br />            button1.Name = "button1";<br />            button1.Size = new Size(100, 20);<br />            button1.TabIndex = 0;<br />            button1.Text = "click me";<br />            button1.UseVisualStyleBackColor = true;<br />            button1.Click += new EventHandler(buttonClick); // hook up button click handler<br /><br />            // position and parameterize the label<br />            label1.AutoSize = true;<br />            label1.Location = new Point(215, 25);<br />            label1.Name = "label1";<br />            label1.Size = new Size(50, 20);<br />            label1.Text = num.ToString();<br />            label1.TextAlign = ContentAlignment.MiddleCenter;<br />            num++;<br /><br />            // create a new contour plot<br />            ch = GenChart();<br /><br />            AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);<br />            AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;<br />            ClientSize = new System.Drawing.Size(425, 325);<br />            Controls.Add(label1);<br />            Controls.Add(button1);<br />            Controls.Add(ch);<br />            Name = "Form1";<br />            Text = "Example showing ShoChart embedded in WinForm using C#";<br /><br />            // layout the controls: now we're ready to start the message pump<br />            ResumeLayout(false);<br />            PerformLayout();<br />        }<br />    }<br />}<br /><br /></code></pre>
<p>&nbsp;</p>
<p><code class="cplusplus"><span style="font-family: arial,helvetica,sans-serif; font-size: small;">From inside of Sho, you can test this by dynamically loading the dll, and running the form in its own thread (made easy with ShoThread):<br /></span></code></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="font-family: courier new,courier;"></span></span></p>
<pre class="scroll"><code class="js">&gt;&gt;&gt; load('testForm.dll')<br />&lt;Assembly testForm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...&gt;<br />&gt;&gt;&gt; from testForm import *<br />&gt;&gt;&gt; t = ShoThread(lambda : System.Windows.Forms.Application.Run(testForm()))<br />&gt;&gt;&gt; t.Start()<br /><br /><br /><br /><br /><br /></code></pre>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="font-family: courier new,courier;"><br /></span></span></p>
<p><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><span style="font-family: courier new,courier;"><br /></span></span></p>
<p><code class="cplusplus"><span style="font-family: arial,helvetica,sans-serif; font-size: small;"></span></code></p>
<p>&nbsp;</p>
<pre class="scroll"><code class="cplusplus"><span style="font-family: arial,helvetica,sans-serif; font-size: small;"><br /></span></code></pre>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Editing and Debugging Sho Code with Visual Studio 2010 and IronPython Tools</title>
      <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/editing-and-debugging-sho-code-with-visual-studio-2010-and-ironpython-tools</link>
      <pubDate>Wed, 02 Feb 2011 10:31:23 GMT</pubDate>
      <dc:creator><![CDATA[Sho Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/the_blog_of_sho/2011/02/02/editing-and-debugging-sho-code-with-visual-studio-2010-and-ironpython-tools/</guid>
      <description><![CDATA[If you're writing substantial amounts of Sho code, and especially if you're doing GUI programming,...]]></description>
      <content:encoded><![CDATA[<p>If you're writing substantial amounts of Sho code, and especially if you're doing GUI programming, you'll find that print statements just don't cut it after some point for debugging.&nbsp; If you want to set breakpoints, inspect variables, walk the stack, etc., <a href="http://www.ironpython.net/tools/">IronPython Tools</a> for Visual Studio 2010 provides a great solution.&nbsp; It's also good for editing Sho code, with syntax highlighting, basic type inference (it will guess at the types for your code even when you're not running it), and more.&nbsp; Note that if you want to use it as an editor, I'd strongly suggest going into Tools-&gt;Options-&gt;Text Editor-&gt;IronPython-&gt;Tabs and select "Insert Spaces" instead of "Keep Tabs" - tabs make it <em>extremely</em> difficult to debug indent/dedent errors in Python.&nbsp; Of course, you don't have to use Visual Studio for editing Python - Emacs, Vim, and a variety of other tools have excellent Python support - but if you're already using Visual Studio for C#, you may find it handy to deal with all the files for a project in one enviornment.</p>
<p>To debug your code, you can still use the Sho Console - just attach the debugger to the shoconsole.exe process, set your breakpoints, and continue as normal.&nbsp; When your breakpoints are hit, execution will stop and you can step through code, inspect variables, and all the rest.&nbsp; You can see a <a href="http://research.microsoft.com/en-us/UM/redmond/projects/Sho/videos/DebuggingShoWithVS2010_640x480.wmv">walkthrough of the debugging process in this video</a> I put up on the <a href="http://research.microsoft.com/en-us/projects/sho/videos.aspx">Sho Videos page</a>.&nbsp; </p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Using Sho for Optimization Tasks</title>
      <link>https://docs.microsoft.com/archive/blogs/the_blog_of_sho/using-sho-for-optimization-tasks</link>
      <pubDate>Fri, 28 Jan 2011 11:38:40 GMT</pubDate>
      <dc:creator><![CDATA[Sho Team]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/the_blog_of_sho/2011/01/28/using-sho-for-optimization-tasks/</guid>
      <description><![CDATA[Our colleague Nathan Brixius just wrote a great blog post about how to do some pretty cool tricks...]]></description>
      <content:encoded><![CDATA[<p>Our colleague Nathan Brixius <a href="http://blogs.msdn.com/b/natbr/archive/2011/01/28/optimization-modeling-using-solver-foundation-and-sho.aspx">just wrote a great blog post</a> about how to do some pretty cool tricks with the Optimization package that ships with Sho (including solving the classic <a href="http://en.wikipedia.org/wiki/Eight_queens_puzzle">N-Queens problem</a>), which is just a thin&nbsp;wrapper of&nbsp;his team's <a href="http://www.solverfoundation.com/">Solver Foundation</a>.&nbsp; My personal favorite in the package is&nbsp;Optimizer.QuasiNewton, which&nbsp;implements <a href="http://en.wikipedia.org/wiki/L-BFGS">L-BFGS</a>&nbsp;for fast, unconstrained optimization.&nbsp; I use that all the time for machine learning techniques that involve minimizing some (ideally convex) loss function, like Logistic Regression, which is just a few dozen lines of code when you have QuasiNewton at your disposal.&nbsp; </p>]]></content:encoded>
    </item>
  </channel>
</rss>