Permalink
Browse files

Merge pull request #21 from mrvux/todomap

Todomap and new nodes
  • Loading branch information...
2 parents 5a801c0 + 4c7e99f commit 549c70fd07f7a13932d4ba9f1446b93894691f02 @joreg joreg committed Dec 31, 2011
Showing with 1,346 additions and 2 deletions.
  1. BIN common/src/thirdparty/Sanford.Collections.dll
  2. BIN common/src/thirdparty/Sanford.Multimedia.Timers.dll
  3. BIN common/src/thirdparty/Sanford.Threading.dll
  4. BIN vvvv45/addonpack/src/nodes/plugins/Devices/MSKinect/Dependencies/Microsoft.Research.Kinect.dll
  5. +147 −0 vvvv45/addonpack/src/nodes/plugins/Devices/MSKinect/Lib/KinectRuntime.cs
  6. +89 −0 vvvv45/addonpack/src/nodes/plugins/Devices/MSKinect/MSKinect.csproj
  7. +137 −0 vvvv45/addonpack/src/nodes/plugins/Devices/MSKinect/Nodes/KinectColorTextureNode.cs
  8. +146 −0 vvvv45/addonpack/src/nodes/plugins/Devices/MSKinect/Nodes/KinectDepthTextureNode.cs
  9. +94 −0 vvvv45/addonpack/src/nodes/plugins/Devices/MSKinect/Nodes/KinectRuntimeNode.cs
  10. +149 −0 vvvv45/addonpack/src/nodes/plugins/Devices/MSKinect/Nodes/KinectSkeletonNode.cs
  11. +36 −0 vvvv45/addonpack/src/nodes/plugins/Devices/MSKinect/Properties/AssemblyInfo.cs
  12. +2 −1 vvvv45/addonpack/src/nodes/plugins/Devices/TodoMap/Lib/Modules/Midi/TodoMidiDevice.cs
  13. +1 −1 vvvv45/addonpack/src/nodes/plugins/Devices/TodoMap/Nodes/Variables/TodoDeleteVariableNode.cs
  14. +36 −0 vvvv45/addonpack/src/nodes/plugins/File/UGRReader/UGRReader/Properties/AssemblyInfo.cs
  15. +72 −0 vvvv45/addonpack/src/nodes/plugins/File/UGRReader/UGRReader/UGRReader.csproj
  16. +164 −0 vvvv45/addonpack/src/nodes/plugins/File/UGRReader/UGRReader/UGRReaderNode.cs
  17. +58 −0 vvvv45/addonpack/src/nodes/plugins/Generics/NearestNeighbour/BaseNearestNeighbourNode.cs
  18. +110 −0 vvvv45/addonpack/src/nodes/plugins/Generics/NearestNeighbour/NearestNeighbour.csproj
  19. +20 −0 vvvv45/addonpack/src/nodes/plugins/Generics/NearestNeighbour/NearestNeighbour.sln
  20. +50 −0 vvvv45/addonpack/src/nodes/plugins/Generics/NearestNeighbour/NearestNeighbourNodes.cs
  21. +35 −0 vvvv45/addonpack/src/nodes/plugins/Generics/NearestNeighbour/Properties/AssemblyInfo.cs
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,147 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Research.Kinect.Nui;
+using System.Runtime.InteropServices;
+
+namespace VVVV.MSKinect.Lib
+{
+ public enum eDepthMode { Disabled, DepthOnly, DepthAndPlayer }
+
+ public class KinectRuntime
+ {
+ public Runtime Runtime { get; private set; }
+
+ public bool IsStarted { get; private set; }
+
+ public event EventHandler<SkeletonFrameReadyEventArgs> SkeletonFrameReady;
+ public event EventHandler<ImageFrameReadyEventArgs> ColorFrameReady;
+ public event EventHandler<ImageFrameReadyEventArgs> DepthFrameReady;
+
+ public KinectStatus LastStatus { get; private set; }
+
+ public eDepthMode DepthMode { get; private set; }
+
+
+ public KinectRuntime()
+ {
+
+ }
+
+ public void Assign(int idx)
+ {
+ if (this.Runtime != null)
+ {
+ this.Runtime.SkeletonFrameReady -= Runtime_SkeletonFrameReady;
+ this.Runtime.VideoFrameReady -= Runtime_VideoFrameReady;
+ this.Runtime.DepthFrameReady -= Runtime_DepthFrameReady;
+ this.Runtime = null;
+ }
+
+ if (this.IsStarted)
+ {
+ this.Stop();
+ }
+
+ if (Runtime.Kinects.Count > 0)
+ {
+ this.Runtime = Runtime.Kinects[idx % Runtime.Kinects.Count];
+ this.Runtime.SkeletonFrameReady += Runtime_SkeletonFrameReady;
+ this.Runtime.VideoFrameReady += Runtime_VideoFrameReady;
+ this.Runtime.DepthFrameReady += Runtime_DepthFrameReady;
+ }
+ }
+
+ void Runtime_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
+ {
+ if (this.DepthFrameReady != null)
+ {
+ this.DepthFrameReady(sender, e);
+ }
+ }
+
+ void Runtime_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
+ {
+ if (this.ColorFrameReady != null)
+ {
+ this.ColorFrameReady(sender, e);
+ }
+ }
+
+ private void Runtime_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
+ {
+ if (this.SkeletonFrameReady != null)
+ {
+ this.SkeletonFrameReady(sender, e);
+ }
+ }
+
+ #region Start
+ public void Start(bool color, bool skeleton, eDepthMode depthmode)
+ {
+ if (this.Runtime != null)
+ {
+ if (this.IsStarted)
+ {
+ this.Stop();
+ }
+
+ if (!this.IsStarted)
+ {
+ try
+ {
+ RuntimeOptions options = (RuntimeOptions)0;
+ if (color) { options |= RuntimeOptions.UseColor; }
+ if (skeleton) { options |= RuntimeOptions.UseSkeletalTracking; }
+
+ if (depthmode == eDepthMode.DepthOnly) { options |= RuntimeOptions.UseDepth; }
+ if (depthmode == eDepthMode.DepthAndPlayer) { options |= RuntimeOptions.UseDepthAndPlayerIndex; }
+
+
+ this.Runtime.Initialize(options);
+ this.Runtime.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
+
+ if (depthmode != eDepthMode.Disabled)
+ {
+ ImageType it = ImageType.Depth;
+ if (depthmode == eDepthMode.DepthAndPlayer) { it = ImageType.DepthAndPlayerIndex; }
+ this.Runtime.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, it);
+ }
+
+ this.IsStarted = true;
+ }
+ catch
+ {
+ this.IsStarted = false;
+ }
+ }
+
+ this.DepthMode = depthmode;
+ }
+ }
+ #endregion
+
+ #region Stop
+ public void Stop()
+ {
+ if (this.Runtime != null)
+ {
+ if (this.IsStarted)
+ {
+ try
+ {
+ this.Runtime.Uninitialize();
+ }
+ catch
+ {
+
+ }
+ }
+
+ this.IsStarted = false;
+ }
+ }
+ #endregion
+ }
+}
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{3AAA18CE-CC3A-40F1-A875-E0249B2AA6EA}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>MSKinect</RootNamespace>
+ <AssemblyName>VVVV.Nodes.MSKinect</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.Research.Kinect, Version=1.0.0.45, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>Dependencies\Microsoft.Research.Kinect.dll</HintPath>
+ </Reference>
+ <Reference Include="SlimDX, Version=4.0.12.43, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\..\..\..\lib\core\SlimDX.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.ComponentModel.Composition.Codeplex, Version=4.1.2.0, Culture=neutral, PublicKeyToken=13e5ffd4e05db186, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\..\..\..\lib\core\System.ComponentModel.Composition.Codeplex.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Lib\KinectRuntime.cs" />
+ <Compile Include="Nodes\KinectColorTextureNode.cs" />
+ <Compile Include="Nodes\KinectDepthTextureNode.cs" />
+ <Compile Include="Nodes\KinectRuntimeNode.cs" />
+ <Compile Include="Nodes\KinectSkeletonNode.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\..\core\Hosting\Hosting.csproj">
+ <Project>{F9A754A6-EEA5-4761-9446-C2AAF9CF8B31}</Project>
+ <Name>Hosting</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\..\core\PluginInterfaces\PluginInterfaces.csproj">
+ <Project>{837C740A-485C-424C-8C38-086ED3DC73CB}</Project>
+ <Name>PluginInterfaces</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\..\core\Utils3rdParty\Utils3rdParty.csproj">
+ <Project>{87863121-C124-4585-B3BB-7706F03ECC64}</Project>
+ <Name>Utils3rdParty</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\..\core\Utils\Utils.csproj">
+ <Project>{C3773330-81FA-4253-823E-1BDE1529AA99}</Project>
+ <Name>Utils</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,137 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using VVVV.PluginInterfaces.V2;
+using VVVV.PluginInterfaces.V1;
+using System.Runtime.InteropServices;
+using Microsoft.Research.Kinect.Nui;
+using VVVV.MSKinect.Lib;
+using System.ComponentModel.Composition;
+using SlimDX.Direct3D9;
+using SlimDX;
+
+namespace VVVV.MSKinect.Nodes
+{
+ [PluginInfo(Name = "RGB", Category = "Kinect",Version="Microsoft", Author = "vux",Tags="directx,texture")]
+ public class KinectColorTextureNode : IPluginEvaluate, IPluginConnections, IPluginDXTexture
+ {
+ [Input("Kinect Runtime")]
+ private Pin<KinectRuntime> FInRuntime;
+
+ [Output("Frame Index",IsSingle=true, Order=10)]
+ private ISpread<int> FOutFrameIndex;
+
+ private int frameindex = -1;
+
+ private IDXTextureOut FOutTexture;
+
+ private bool FInvalidateConnect = false;
+ private bool FInvalidate = true;
+
+ private KinectRuntime runtime;
+
+ private IntPtr colorimage;
+ private object m_colorlock = new object();
+
+
+
+ private Dictionary<int, Texture> FColorTex = new Dictionary<int, Texture>();
+
+
+ [ImportingConstructor()]
+ public KinectColorTextureNode(IPluginHost host)
+ {
+ this.colorimage = Marshal.AllocCoTaskMem(640 * 480 * 4);
+ host.CreateTextureOutput("Texture Out", TSliceMode.Single, TPinVisibility.True, out this.FOutTexture);
+ }
+
+ public void Evaluate(int SpreadMax)
+ {
+ if (this.FInvalidateConnect)
+ {
+ if (runtime != null)
+ {
+ this.runtime.ColorFrameReady -= ColorFrameReady;
+ }
+
+ if (this.FInRuntime.PluginIO.IsConnected)
+ {
+ //Cache runtime node
+ this.runtime = this.FInRuntime[0];
+ this.FInRuntime[0].ColorFrameReady += ColorFrameReady;
+ }
+
+ this.FInvalidateConnect = false;
+ }
+
+ this.FOutFrameIndex[0] = this.frameindex;
+ }
+
+ public void ConnectPin(IPluginIO pin)
+ {
+ if (pin == this.FInRuntime.PluginIO)
+ {
+ this.FInvalidateConnect = true;
+ }
+ }
+
+ public void DisconnectPin(IPluginIO pin)
+ {
+ if (pin == this.FInRuntime.PluginIO)
+ {
+ this.FInvalidateConnect = true;
+ }
+ }
+
+ public void GetTexture(IDXTextureOut ForPin, int OnDevice, out int tex)
+ {
+ tex = 0;
+ if (this.FColorTex.ContainsKey(OnDevice)) { tex = this.FColorTex[OnDevice].ComPointer.ToInt32(); }
+ }
+
+ public void UpdateResource(IPluginOut ForPin, int OnDevice)
+ {
+ if (!this.FColorTex.ContainsKey(OnDevice))
+ {
+ Texture t = new Texture(Device.FromPointer(new IntPtr(OnDevice)), 640, 480, 1, Usage.None, Format.X8R8G8B8, Pool.Managed);
+ this.FColorTex.Add(OnDevice, t);
+ }
+
+ if (this.FInvalidate)
+ {
+ Texture tx = this.FColorTex[OnDevice];
+ Surface srf = tx.GetSurfaceLevel(0);
+ DataRectangle rect = srf.LockRectangle(LockFlags.Discard);
+
+ lock (this.m_colorlock)
+ {
+ rect.Data.WriteRange(this.colorimage, 640 * 480 * 4);
+ }
+ srf.UnlockRectangle();
+
+
+ this.FInvalidate = false;
+ }
+ }
+
+ public void DestroyResource(IPluginOut ForPin, int OnDevice, bool OnlyUnManaged)
+ {
+ if (this.FColorTex.ContainsKey(OnDevice))
+ {
+ this.FColorTex[OnDevice].Dispose();
+ this.FColorTex.Remove(OnDevice);
+ }
+ }
+
+ private void ColorFrameReady(object sender, ImageFrameReadyEventArgs e)
+ {
+ lock (m_colorlock)
+ {
+ Marshal.Copy(e.ImageFrame.Image.Bits, 0, this.colorimage, 640 * 480 * 4);
+ }
+ this.FInvalidate = true;
+ this.frameindex = e.ImageFrame.FrameNumber;
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 549c70f

Please sign in to comment.