├── Docs
└── Joint+Mapping.xlsx
├── 3rd Party
├── VrpnNet
│ ├── x64
│ │ ├── Debug
│ │ │ └── VrpnNet.dll
│ │ └── Release
│ │ │ └── VrpnNet.dll
│ └── x86
│ │ ├── Debug
│ │ └── VrpnNet.dll
│ │ └── Release
│ │ └── VrpnNet.dll
└── EigenWrapper
│ ├── x64
│ ├── Debug
│ │ ├── EigenWrapper.dll
│ │ └── NativeEigenWrapper.dll
│ └── Release
│ │ ├── EigenWrapper.dll
│ │ └── NativeEigenWrapper.dll
│ └── x86
│ ├── Debug
│ ├── EigenWrapper.dll
│ └── NativeEigenWrapper.dll
│ └── Release
│ ├── EigenWrapper.dll
│ └── NativeEigenWrapper.dll
├── KinectWithVRServer
├── Joint Mapping.xlsx
├── Shaders
│ ├── NoScalingEffect
│ │ ├── NoScalingEffect.ps
│ │ ├── NoScalingEffect.fx
│ │ └── NoScalingEffectWrapper.cs
│ ├── ColorDepthEffect
│ │ ├── ColorDepthEffect.ps
│ │ ├── ColorDepthEffect.fx
│ │ └── ColorDepthEffectWrapper.cs
│ ├── ColorScaleEffect
│ │ ├── ColorScaleEffect.ps
│ │ ├── ColorScaleEffect.fx
│ │ └── ColorScaleEffectWrapper.cs
│ └── DepthScalingEffect
│ │ ├── DepthScalingEffect.ps
│ │ ├── DepthScalingEffect.fx
│ │ └── DepthScalingEffectWrapper.cs
├── app.config
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── KinectV1Wrapper
│ ├── KV1SettingsControl.xaml
│ ├── KV1SdkTest.cs
│ ├── KV1StatusHelper.cs
│ ├── KV1SettingsControl.xaml.cs
│ └── KV1Core.cs
├── KinectV2Wrapper
│ ├── KV2SettingsControl.xaml
│ ├── KV2SdkTest.cs
│ ├── KV2StatusHelper.cs
│ ├── KV2SettingsControl.xaml.cs
│ ├── KV2Core.cs
│ └── KV2Settings.cs
├── NetworkKinectWrapper
│ ├── NKSettingsControl.xaml
│ ├── NKAddDialog.xaml
│ ├── NKSettingsControl.xaml.cs
│ ├── NKAddDialog.xaml.cs
│ ├── NKSettings.cs
│ └── NKCore.cs
├── App.xaml
├── NativeInterop.cs
├── VerifyDLLs.cs
├── ConcurrentSkeletonCollection.cs
├── FeedbackCore.cs
├── ConsoleUI.cs
├── App.xaml.cs
└── GestureRecognition
│ ├── KMeans.cs
│ └── GestureSettingsUserControl.xaml
├── KinectBase
├── IKinectSkeletonControl.cs
├── IKinectSettings.cs
├── Properties
│ └── AssemblyInfo.cs
├── IKinectSettingsControl.cs
├── IKinectCore.cs
├── Enums.cs
└── KinectBase.csproj
├── KinectV1Core
├── Properties
│ └── AssemblyInfo.cs
├── KinectV1SkeletonControl.xaml.cs
├── KinectV1SkeletonControl.xaml
├── KinectV1StatusHelper.cs
├── AdvancedColorWindow.xaml
└── KinectV1Core.csproj
├── KinectV2Core
├── Properties
│ └── AssemblyInfo.cs
├── KinectV2SkeletonControl.xaml.cs
├── KinectV2SkeletonControl.xaml
├── KinectV2Settings.cs
├── KinectV2Core.csproj
└── KinectV2StatusHelper.cs
├── NetworkKinectCore
├── Properties
│ └── AssemblyInfo.cs
├── NetworkKinectCore.csproj
├── NetworkKinectSettings.cs
└── NetworkKinectSettingsControl.xaml
├── Readme.md
├── .gitignore
└── KinectWithVRServer.sln
/Docs/Joint+Mapping.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/Docs/Joint+Mapping.xlsx
--------------------------------------------------------------------------------
/3rd Party/VrpnNet/x64/Debug/VrpnNet.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/VrpnNet/x64/Debug/VrpnNet.dll
--------------------------------------------------------------------------------
/3rd Party/VrpnNet/x86/Debug/VrpnNet.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/VrpnNet/x86/Debug/VrpnNet.dll
--------------------------------------------------------------------------------
/KinectWithVRServer/Joint Mapping.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/KinectWithVRServer/Joint Mapping.xlsx
--------------------------------------------------------------------------------
/3rd Party/VrpnNet/x64/Release/VrpnNet.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/VrpnNet/x64/Release/VrpnNet.dll
--------------------------------------------------------------------------------
/3rd Party/VrpnNet/x86/Release/VrpnNet.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/VrpnNet/x86/Release/VrpnNet.dll
--------------------------------------------------------------------------------
/3rd Party/EigenWrapper/x64/Debug/EigenWrapper.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/EigenWrapper/x64/Debug/EigenWrapper.dll
--------------------------------------------------------------------------------
/3rd Party/EigenWrapper/x86/Debug/EigenWrapper.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/EigenWrapper/x86/Debug/EigenWrapper.dll
--------------------------------------------------------------------------------
/3rd Party/EigenWrapper/x64/Release/EigenWrapper.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/EigenWrapper/x64/Release/EigenWrapper.dll
--------------------------------------------------------------------------------
/3rd Party/EigenWrapper/x86/Release/EigenWrapper.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/EigenWrapper/x86/Release/EigenWrapper.dll
--------------------------------------------------------------------------------
/3rd Party/EigenWrapper/x64/Debug/NativeEigenWrapper.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/EigenWrapper/x64/Debug/NativeEigenWrapper.dll
--------------------------------------------------------------------------------
/3rd Party/EigenWrapper/x86/Debug/NativeEigenWrapper.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/EigenWrapper/x86/Debug/NativeEigenWrapper.dll
--------------------------------------------------------------------------------
/3rd Party/EigenWrapper/x64/Release/NativeEigenWrapper.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/EigenWrapper/x64/Release/NativeEigenWrapper.dll
--------------------------------------------------------------------------------
/3rd Party/EigenWrapper/x86/Release/NativeEigenWrapper.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/3rd Party/EigenWrapper/x86/Release/NativeEigenWrapper.dll
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/NoScalingEffect/NoScalingEffect.ps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/KinectWithVRServer/Shaders/NoScalingEffect/NoScalingEffect.ps
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/ColorDepthEffect/ColorDepthEffect.ps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/KinectWithVRServer/Shaders/ColorDepthEffect/ColorDepthEffect.ps
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/ColorScaleEffect/ColorScaleEffect.ps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/KinectWithVRServer/Shaders/ColorScaleEffect/ColorScaleEffect.ps
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/DepthScalingEffect/DepthScalingEffect.ps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vancegroup/KVR/HEAD/KinectWithVRServer/Shaders/DepthScalingEffect/DepthScalingEffect.ps
--------------------------------------------------------------------------------
/KinectWithVRServer/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/KinectBase/IKinectSkeletonControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace KinectBase
8 | {
9 | public interface IKinectSkeletonControl
10 | {
11 | int? kinectID { get; }
12 | KinectVersion version { get; }
13 | string uniqueKinectID { get; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/NoScalingEffect/NoScalingEffect.fx:
--------------------------------------------------------------------------------
1 | sampler2D input : register(s0);
2 |
3 | float4 main(float2 uv : TEXCOORD) : COLOR
4 | {
5 | //Get the original pixel color
6 | float4 inColor = tex2D(input, uv);
7 |
8 | //Unpack the data and convert to 16-bit grayscale
9 | float temp = (inColor.g * 255.0 + inColor.b) / 256.0;
10 | temp = clamp(temp, 0, 1);
11 |
12 | //We aren't doing any shading in this case, so just return the original image color
13 | return float4(temp, temp, temp, 1.0);
14 | }
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/DepthScalingEffect/DepthScalingEffect.fx:
--------------------------------------------------------------------------------
1 | sampler2D input : register(s0);
2 | float minimum : register(c0);
3 | float maximum : register(c1);
4 |
5 | float4 main(float2 uv : TEXCOORD) : COLOR
6 | {
7 | float4 inColor = tex2D(input, uv);
8 |
9 | //Unpack the data and convert to 16-bit grayscale
10 | float temp = (inColor.g * 255.0 + inColor.b) / 256.0;
11 |
12 | //Scale the image so it fills the full range
13 | float range = maximum - minimum;
14 | float temp2 = clamp((temp - minimum) / range, 0, 1);
15 |
16 | return float4(temp2, temp2, temp2, 1.0);
17 | }
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV1Wrapper/KV1SettingsControl.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV2Wrapper/KV2SettingsControl.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/KinectWithVRServer/NetworkKinectWrapper/NKSettingsControl.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV2Wrapper/KV2SdkTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using KinectV2Core;
7 |
8 | namespace KinectWithVRServer.KinectV2Wrapper
9 | {
10 | internal class KV2SdkTest
11 | {
12 | internal static bool IsSDKWorking()
13 | {
14 | bool SDKWorks = false;
15 |
16 | try
17 | {
18 | KinectV2StatusHelper.TestKinectSDK();
19 | SDKWorks = true;
20 | }
21 | catch { }
22 |
23 | return SDKWorks;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/KinectWithVRServer/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV1Wrapper/KV1SdkTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using KinectV1Core;
7 |
8 | namespace KinectWithVRServer.KinectV1Wrapper
9 | {
10 | internal class KV1SdkTest
11 | {
12 | internal static bool IsSDKWorking()
13 | {
14 | bool SDKWorks = false;
15 |
16 | try
17 | {
18 | KinectV1StatusEventArgs[] statuses = KinectV1StatusHelper.GetAllKinectsStatus();
19 | SDKWorks = true;
20 | }
21 | catch { }
22 |
23 | return SDKWorks;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/KinectBase/IKinectSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace KinectBase
8 | {
9 | public interface IKinectSettings
10 | {
11 | //All the Kinect cores need these properties so we can figure out what's what
12 | int kinectID { get; set; }
13 | KinectVersion version { get; }
14 | string uniqueKinectID { get; set; }
15 | bool mergeSkeletons { get; set; }
16 | }
17 |
18 | public class KinectSettingsComparer : IComparer
19 | {
20 | public int Compare(IKinectSettings x, IKinectSettings y)
21 | {
22 | return x.kinectID.CompareTo(y.kinectID);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/KinectWithVRServer/NetworkKinectWrapper/NKAddDialog.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34209
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace KinectWithVRServer.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/NoScalingEffect/NoScalingEffectWrapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Media.Effects;
6 | using System.Windows.Media;
7 | using System.Windows;
8 |
9 | namespace KinectWithVRServer.Shaders
10 | {
11 | public class NoScalingEffect : ShaderEffect
12 | {
13 | private static PixelShader noScalingPixelShader = new PixelShader() { UriSource = new Uri(@"pack://application:,,,/KinectWithVRServer;component/Shaders/NoScalingEffect/NoScalingEffect.ps") };
14 |
15 | public NoScalingEffect()
16 | {
17 | PixelShader = noScalingPixelShader;
18 | UpdateShaderValue(InputProperty);
19 | }
20 |
21 | //Set the input property (this will be used as a sampler2D in the shader to get the original image color)
22 | public Brush Input
23 | {
24 | get { return (Brush)GetValue(InputProperty); }
25 | set { SetValue(InputProperty, value); }
26 | }
27 | public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(NoScalingEffect), 0);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/KinectWithVRServer/NativeInterop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace KinectWithVRServer
5 | {
6 | //WARNING: These may break the ability to compile to 64-bit
7 | static internal class NativeInterop
8 | {
9 | [DllImport("kernel32.dll", SetLastError=true)]
10 | static internal extern bool AttachConsole(int processID);
11 |
12 | [DllImport("kernel32.dll", SetLastError=true)]
13 | static internal extern bool FreeConsole();
14 |
15 | [DllImport("kernel32.dll", SetLastError=true)]
16 | static internal extern bool AllocConsole();
17 |
18 | [DllImport("kernel32.dll", SetLastError=true)]
19 | static internal extern int GetLastError();
20 |
21 | [DllImport("kernel32.dll", SetLastError = true)]
22 | static internal extern bool SetConsoleMode(IntPtr consoleHandle, uint mode);
23 |
24 | [DllImport("kernel32.dll", SetLastError = true)]
25 | static internal extern bool GetConsoleMode(IntPtr consoleHandle, out uint mode);
26 |
27 | [DllImport("kernel32.dll", SetLastError = true)]
28 | static internal extern IntPtr GetStdHandle(int handleType); //-10, -11, or -12 (input, output, and error respectively)
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/KinectBase/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("KinectBase")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("KinectBase")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("62f8b5b8-cbd9-44ca-a4b2-9ebe97fb1ecf")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/KinectV1Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("KinectV1Core")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("KinectV1Core")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("3ccfecea-7ba2-44d7-b5f0-ff54bf0a5ac2")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/KinectV2Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("KinectV2Core")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("KinectV2Core")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("61a2e934-69ad-4cf9-9d57-28a9e70657a3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/NetworkKinectCore/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("NetworkKinectCore")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("NetworkKinectCore")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("398c764c-b42e-4524-a7f7-159db651c6a8")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/ColorScaleEffect/ColorScaleEffect.fx:
--------------------------------------------------------------------------------
1 | sampler2D input : register(s0);
2 | float minimum : register(c0);
3 | float maximum : register(c1);
4 |
5 | float4 main(float2 uv : TEXCOORD) : COLOR
6 | {
7 | float4 inColor = tex2D(input, uv);
8 | float4 outColor = float4(0.0, 0.0, 0.0, 1.0);
9 |
10 | //Unpack the data and convert to 16-bit grayscale
11 | float temp = (inColor.g * 255.0 + inColor.b) / 256.0;
12 |
13 | //Scale the image so it fills the full range
14 | float range = maximum - minimum;
15 | float qtr = 0.25 * range;
16 | [flatten] if (temp < minimum)
17 | {
18 | outColor.rgb = float3(0.0, 0.0, 0.0);
19 | }
20 | else if (temp < minimum + 0.25 * range)
21 | {
22 | float interpol = (temp - minimum) / qtr;
23 | outColor.rgb = lerp(float3(0.0, 0.0, 1.0), float3(0.0, 1.0, 1.0), float3(interpol, interpol, interpol));
24 | }
25 | else if (temp < minimum + 0.5 * range)
26 | {
27 | float interpol = (temp - minimum - qtr) / qtr;
28 | outColor.rgb = lerp(float3(0.0, 1.0, 1.0), float3(0.0, 1.0, 0.0), float3(interpol, interpol, interpol));
29 | }
30 | else if (temp < minimum + 0.75 * range)
31 | {
32 | float interpol = (temp - minimum - 2 * qtr) / qtr;
33 | outColor.rgb = lerp(float3(0.0, 1.0, 0.0), float3(1.0, 1.0, 0.0), float3(interpol, interpol, interpol));
34 | }
35 | else if (temp < maximum)
36 | {
37 | float interpol = (temp - minimum - 3 * qtr) / qtr;
38 | outColor.rgb = lerp(float3(1.0, 1.0, 0.0), float3(1.0, 0.0, 0.0), float3(interpol, interpol, interpol));
39 | }
40 | else
41 | {
42 | outColor.rgb = float3(1.0, 0.0, 0.0);
43 | }
44 |
45 | return outColor;
46 | }
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/ColorDepthEffect/ColorDepthEffect.fx:
--------------------------------------------------------------------------------
1 | sampler2D input : register(s0);
2 | float minimum : register(c0);
3 | float maximum : register(c1);
4 |
5 | float4 main(float2 uv : TEXCOORD) : COLOR
6 | {
7 | float4 inColor = tex2D(input, uv);
8 | float4 outColor = float4(0.0, 0.0, 0.0, 1.0);
9 |
10 | //Unpack the data and convert to 16-bit grayscale
11 | float temp = (inColor.g * 255.0 + inColor.b) / 256.0;
12 |
13 | //Scale the image so it fills the full range
14 | float range = maximum - minimum;
15 | float qtr = 0.25 * range;
16 | [flatten] if (temp < minimum)
17 | {
18 | float interpol = temp / minimum;
19 | outColor.rgb = lerp(float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 1.0), float3(interpol, interpol, interpol));
20 | }
21 | else if (temp < minimum + 0.25 * range)
22 | {
23 | float interpol = (temp - minimum) / qtr;
24 | outColor.rgb = lerp(float3(0.0, 0.0, 1.0), float3(0.0, 1.0, 1.0), float3(interpol, interpol, interpol));
25 | }
26 | else if (temp < minimum + 0.5 * range)
27 | {
28 | float interpol = (temp - minimum - qtr) / qtr;
29 | outColor.rgb = lerp(float3(0.0, 1.0, 1.0), float3(0.0, 1.0, 0.0), float3(interpol, interpol, interpol));
30 | }
31 | else if (temp < minimum + 0.75 * range)
32 | {
33 | float interpol = (temp - minimum - 2 * qtr) / qtr;
34 | outColor.rgb = lerp(float3(0.0, 1.0, 0.0), float3(1.0, 1.0, 0.0), float3(interpol, interpol, interpol));
35 | }
36 | else if (temp < maximum)
37 | {
38 | float interpol = (temp - minimum - 3 * qtr) / qtr;
39 | outColor.rgb = lerp(float3(1.0, 1.0, 0.0), float3(1.0, 0.0, 0.0), float3(interpol, interpol, interpol));
40 | }
41 | else
42 | {
43 | float interpol = (temp - maximum) / (1.0 - maximum);
44 | outColor.rgb = lerp(float3(1.0, 0.0, 0.0), float3(1.0, 0.0, 1.0), float3(interpol, interpol, interpol));
45 | }
46 |
47 | return outColor;
48 | }
--------------------------------------------------------------------------------
/KinectBase/IKinectSettingsControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace KinectBase
8 | {
9 | public interface IKinectSettingsControl
10 | {
11 | int? kinectID { get; set; }
12 | KinectVersion version { get; }
13 | string uniqueKinectID { get; set; }
14 |
15 | //A function to update all the GUI settings based on the server settings
16 | void UpdateGUI(MasterSettings newSettings);
17 | }
18 |
19 | public class KinectSettingsControlComparer : IComparer
20 | {
21 | //Sorts the Kinect settings GUI controls by kinectID with null IDs having the HIGHEST value
22 | //This is so the index in the array of the pages will match the Kinect number, with the unused ones at the end
23 | public int Compare(IKinectSettingsControl x, IKinectSettingsControl y)
24 | {
25 | if (x.kinectID.HasValue)
26 | {
27 | if (y.kinectID.HasValue)
28 | {
29 | int tempX = x.kinectID.Value;
30 | int tempY = y.kinectID.Value;
31 | return tempX.CompareTo(tempY);
32 | }
33 | else
34 | {
35 | return -1; //If x has a value but y is null, then y is greater
36 | }
37 | }
38 | else
39 | {
40 | if (y.kinectID.HasValue)
41 | {
42 | return 1; //If x is null amd y isn't, then x is greater
43 | }
44 | else
45 | {
46 | return 0; //If both are null, then they are equal
47 | }
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/KinectV2Core/KinectV2SkeletonControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using KinectBase;
16 |
17 | namespace KinectV2Core
18 | {
19 | ///
20 | /// Interaction logic for KinectV2SkeletonControl.xaml
21 | ///
22 | public partial class KinectV2SkeletonControl : UserControl, IKinectSkeletonControl
23 | {
24 | private KinectV2SettingsControl parent;
25 | public int? kinectID
26 | {
27 | get { return parent.kinectID; }
28 | }
29 | public KinectVersion version
30 | {
31 | get { return KinectVersion.KinectV2; }
32 | }
33 | public string uniqueKinectID
34 | {
35 | get { return parent.uniqueKinectID; }
36 | }
37 |
38 | public KinectV2SkeletonControl(KinectV2SettingsControl thisParent)
39 | {
40 | parent = thisParent;
41 |
42 | InitializeComponent();
43 |
44 | SkelSortModeComboBox.SelectedIndex = 0;
45 | SkeletonSettingsDataGrid.ItemsSource = parent.kinectSettings.rawSkeletonSettings.individualSkeletons;
46 | SkeletonSettingsDataGrid.Items.Refresh();
47 | }
48 |
49 | //Controls which skeleton sorting mode is used
50 | private void SkelSortModeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
51 | {
52 | parent.kinectSettings.rawSkeletonSettings.skeletonSortMode = (SkeletonSortMethod)SkelSortModeComboBox.SelectedIndex;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/ColorDepthEffect/ColorDepthEffectWrapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Media.Effects;
6 | using System.Windows.Media;
7 | using System.Windows;
8 |
9 | namespace KinectWithVRServer.Shaders
10 | {
11 | public class ColorDepthEffect : ShaderEffect
12 | {
13 | private static PixelShader colorizePixelShader = new PixelShader() { UriSource = new Uri(@"pack://application:,,,/KinectWithVRServer;component/Shaders/ColorDepthEffect/ColorDepthEffect.ps") };
14 |
15 | public ColorDepthEffect()
16 | {
17 | PixelShader = colorizePixelShader;
18 | UpdateShaderValue(InputProperty);
19 | UpdateShaderValue(MinimumProperty);
20 | UpdateShaderValue(MaximumProperty);
21 | }
22 |
23 | //Set the input property (this will be used as a sampler2D in the shader to get the original image color)
24 | public Brush Input
25 | {
26 | get { return (Brush)GetValue(InputProperty); }
27 | set { SetValue(InputProperty, value); }
28 | }
29 | public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ColorDepthEffect), 0);
30 |
31 | //Set the minimum value property
32 | public float Minimum
33 | {
34 | get { return (float)GetValue(MinimumProperty); }
35 | set { SetValue(MinimumProperty, (double)value); }
36 | }
37 | public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register("Minimum", typeof(double), typeof(ColorDepthEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(0)));
38 |
39 | //Set the maximum value property
40 | public float Maximum
41 | {
42 | get { return (float)GetValue(MaximumProperty); }
43 | set { SetValue(MaximumProperty, (double)value); }
44 | }
45 | public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum", typeof(double), typeof(ColorDepthEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(1)));
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/ColorScaleEffect/ColorScaleEffectWrapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Media.Effects;
6 | using System.Windows.Media;
7 | using System.Windows;
8 |
9 | namespace KinectWithVRServer.Shaders
10 | {
11 | public class ColorScaleEffect : ShaderEffect
12 | {
13 | private static PixelShader colorScalePixelShader = new PixelShader() { UriSource = new Uri(@"pack://application:,,,/KinectWithVRServer;component/Shaders/ColorScaleEffect/ColorScaleEffect.ps") };
14 |
15 | public ColorScaleEffect()
16 | {
17 | PixelShader = colorScalePixelShader;
18 | UpdateShaderValue(InputProperty);
19 | UpdateShaderValue(MinimumProperty);
20 | UpdateShaderValue(MaximumProperty);
21 | }
22 |
23 | //Set the input property (this will be used as a sampler2D in the shader to get the original image color)
24 | public Brush Input
25 | {
26 | get { return (Brush)GetValue(InputProperty); }
27 | set { SetValue(InputProperty, value); }
28 | }
29 | public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(ColorScaleEffect), 0);
30 |
31 | //Set the minimum value property
32 | public float Minimum
33 | {
34 | get { return (float)GetValue(MinimumProperty); }
35 | set { SetValue(MinimumProperty, (double)value); }
36 | }
37 | public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register("Minimum", typeof(double), typeof(ColorScaleEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(0)));
38 |
39 | //Set the maximum value property
40 | public float Maximum
41 | {
42 | get { return (float)GetValue(MaximumProperty); }
43 | set { SetValue(MaximumProperty, (double)value); }
44 | }
45 | public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum", typeof(double), typeof(ColorScaleEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(1)));
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/KinectV1Core/KinectV1SkeletonControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using KinectBase;
16 |
17 | namespace KinectV1Core
18 | {
19 | ///
20 | /// Interaction logic for KinectV1SkeletonControl.xaml
21 | ///
22 | public partial class KinectV1SkeletonControl : UserControl, IKinectSkeletonControl
23 | {
24 | private KinectV1SettingsControl parent;
25 | public int? kinectID
26 | {
27 | get { return parent.kinectID; }
28 | }
29 | public KinectVersion version
30 | {
31 | get { return KinectVersion.KinectV1; }
32 | }
33 | public string uniqueKinectID
34 | {
35 | get { return parent.uniqueKinectID; }
36 | }
37 |
38 | public KinectV1SkeletonControl(KinectV1SettingsControl thisParent)
39 | {
40 | parent = thisParent;
41 |
42 | InitializeComponent();
43 |
44 | SkelSortModeComboBox.SelectedIndex = 0;
45 | SkeletonSettingsDataGrid.ItemsSource = parent.kinectSettings.rawSkeletonSettings.individualSkeletons;
46 | SkeletonSettingsDataGrid.Items.Refresh();
47 | }
48 |
49 | //Changes if the skeleton tracking is in seated mode
50 | private void ChooseSeatedCheckBox_CheckChanged(object sender, RoutedEventArgs e)
51 | {
52 | parent.kinectSettings.rawSkeletonSettings.isSeatedMode = (bool)ChooseSeatedCheckBox.IsChecked;
53 | }
54 | //Controls which skeleton sorting mode is used
55 | private void SkelSortModeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
56 | {
57 | parent.kinectSettings.rawSkeletonSettings.skeletonSortMode = (SkeletonSortMethod)SkelSortModeComboBox.SelectedIndex;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # Kinect With VR Server - KVR
2 |
3 | https://github.com/vancegroup/KVR
4 |
5 | This software manages and runs VRPN servers for one or more Microsoft Kinect sensors and enables voice recognition, gesture recognition, and skeleton merging.
6 |
7 |
8 | ## Requirements:
9 |
10 | * [Microsoft .NET Framework](http://www.microsoft.com/en-us/download/details.aspx?id=30653) (currently tested against 4.5)
11 | * [Microsoft Kinect v1 SDK along with the Toolkit](http://www.microsoft.com/en-us/kinectforwindows/) (currently tested against 1.8)
12 | * [Microsoft Kinect v2 SDK](http://www.microsoft.com/en-us/download/details.aspx?id=44561) (currently tested against 2.0.1410.19000)
13 | * [Microsoft Speech Platform SDK](http://www.microsoft.com/en-us/download/details.aspx?id=27226) (currently tested against version 11)
14 | * VRPN .NET Bindings
15 | 1. [VRPN](http://www.cs.unc.edu/Research/vrpn/)
16 | Our research group using [this fork](https://github.com/rpavlik/vrpn) of VRPN.
17 | 2. [VrpnNet](http://wwwx.cs.unc.edu/~chrisv/vrpnnet)
18 | Our research group using [this fork](https://github.com/vancegroup/VrpnNet) of VrpnNet.
19 | * [Eigen .NET Bindings](https://github.com/vancegroup/EigenNet) (precompiled binaries included)
20 |
21 |
22 | ## Compiling Hints:
23 |
24 | * Make sure the references in the Visual Studio project point to the correct DLL location.
25 | 1. Microsoft.Kinect (Microsoft.Kinect.dll)
26 | 2. Microsoft.Speech (Microsoft.Speech.dll)
27 | 3. VrpnNet (VrpnNet.dll)
28 | * Both the Kinect v1 and Kinect v2 use the Microsoft.Kinect namespace and a library called Microsof.Kinect.dll, but the two are not compatible. Make sure you reference the correct version in the correct project.
29 | * The project can be compiled and run on a Windows 7 computer without the Kinect v2 SDK installed, provided a precompiled version of the KinectV2Core is available and the KinectV2Core project is set to not build. KVR will run without Kinect v2 support in this case.
30 | * The debug versions of VrpnNet require Visual Studio 2010 to be installed. If VS 2010 is not installed, link KVR to the release version of VrpnNet for the appropriate CPU architecture.
31 | * Matrix calculations in the Eigen .NET bindings will be extremely slow if the project is using a debug version of the Eigen .NET bindings.
32 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Shaders/DepthScalingEffect/DepthScalingEffectWrapper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Media.Effects;
6 | using System.Windows.Media;
7 | using System.Windows;
8 |
9 | namespace KinectWithVRServer.Shaders
10 | {
11 | public class DepthScalingEffect : ShaderEffect
12 | {
13 | private static PixelShader scalingPixelShader = new PixelShader() { UriSource = new Uri(@"pack://application:,,,/KinectWithVRServer;component/Shaders/DepthScalingEffect/DepthScalingEffect.ps") };
14 |
15 | public DepthScalingEffect()
16 | {
17 | PixelShader = scalingPixelShader;
18 | UpdateShaderValue(InputProperty);
19 | UpdateShaderValue(MinimumProperty);
20 | UpdateShaderValue(MaximumProperty);
21 | }
22 |
23 | //Set the input property (this will be used as a sampler2D in the shader to get the original image color)
24 | public Brush Input
25 | {
26 | get { return (Brush)GetValue(InputProperty); }
27 | set { SetValue(InputProperty, value); }
28 | }
29 | public static readonly DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(DepthScalingEffect), 0);
30 |
31 | //Set the minimum value property
32 | public float Minimum
33 | {
34 | get { return (float)GetValue(MinimumProperty); }
35 | set { SetValue(MinimumProperty, (double)value); }
36 | }
37 | public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register("Minimum", typeof(double), typeof(DepthScalingEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(0)));
38 |
39 | //Set the maximum value property
40 | public float Maximum
41 | {
42 | get { return (float)GetValue(MaximumProperty); }
43 | set { SetValue(MaximumProperty, (double)value); }
44 | }
45 | public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum", typeof(double), typeof(DepthScalingEffect), new UIPropertyMetadata(0.0, PixelShaderConstantCallback(1)));
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("KinectWithVRServer")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("KinectWithVRServer")]
15 | [assembly: AssemblyCopyright("Copyright © 2013")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/KinectWithVRServer/NetworkKinectWrapper/NKSettingsControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using KinectBase;
16 | using NetworkKinectCore;
17 |
18 | namespace KinectWithVRServer.NetworkKinectWrapper
19 | {
20 | public partial class SettingsControl : UserControl, IKinectSettingsControl
21 | {
22 | //Private variable to manage the wrapped settings control
23 | private NetworkKinectSettingsControl realControl;
24 |
25 | //Public properties required by the IKinectSettingsControl interface
26 | public int? kinectID
27 | {
28 | get { return realControl.kinectID; }
29 | set { realControl.kinectID = value; }
30 | }
31 | public KinectVersion version
32 | {
33 | get { return realControl.version; }
34 | }
35 | public string uniqueKinectID
36 | {
37 | get { return realControl.uniqueKinectID; }
38 | set { realControl.uniqueKinectID = value; }
39 | }
40 |
41 | //Public properties specific to the network Kinect
42 |
43 | //Public methods required by the IKinectSettingsControl interface
44 | public void UpdateGUI(MasterSettings newSettings)
45 | {
46 | realControl.UpdateGUI(newSettings);
47 | }
48 |
49 | //Constructor to setup the real NetworkKinectSettingsControl
50 | public SettingsControl(int kinectNumber, ref MasterSettings settings, IKinectCore kinect)
51 | {
52 | InitializeComponent();
53 | Grid.SetColumn(this, 2);
54 | this.Visibility = System.Windows.Visibility.Collapsed;
55 |
56 | Core coreWrapper = (Core)kinect;
57 | NetworkKinectCore.NetworkKinectCore kinectCore = (NetworkKinectCore.NetworkKinectCore)coreWrapper;
58 | realControl = new NetworkKinectSettingsControl(kinectNumber, ref settings, kinectCore);
59 | realControl.Visibility = System.Windows.Visibility.Visible;
60 | this.MasterGrid.Children.Add((UserControl)realControl);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/KinectWithVRServer/NetworkKinectWrapper/NKAddDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace KinectWithVRServer.NetworkKinectWrapper
16 | {
17 | //This class is a dialog window which prompts for a unique name for the network Kinect when it is added
18 | //This isn't a wrapper like the rest of the stuff in this sub-namespace, as wrapping in this case would be superfluous
19 | public partial class NKAddDialog : Window
20 | {
21 | MainWindow parent;
22 | private string id = null;
23 | internal string UniqueID
24 | {
25 | get { return id; }
26 | }
27 |
28 | public NKAddDialog(MainWindow thisParent)
29 | {
30 | InitializeComponent();
31 |
32 | parent = thisParent;
33 |
34 | //This causes the cursor to be in the textbox automatically when the dialog is opened so the user can start typing without having to select the textbox first
35 | UniqueNameTextBox.Focus();
36 | }
37 |
38 | private void OkButton_Click(object sender, RoutedEventArgs e)
39 | {
40 | bool uniqueName = false;
41 | string name = UniqueNameTextBox.Text;
42 |
43 | if (name.Length > 0)
44 | {
45 | bool found = false;
46 | for (int i = 0; i < parent.availableKinects.Count; i++)
47 | {
48 | if (name == parent.availableKinects[i].UniqueID)
49 | {
50 | found = true;
51 | break;
52 | }
53 | }
54 | uniqueName = !found;
55 | }
56 |
57 | if (uniqueName)
58 | {
59 | id = name;
60 | this.DialogResult = true;
61 | }
62 | else
63 | {
64 | MessageBox.Show("Error: The provided name for the network Kinect sensor is not unique. Please enter a different name.", "Error: Invalid Name.", MessageBoxButton.OK, MessageBoxImage.Error);
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV1Wrapper/KV1StatusHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using KinectV1Core;
7 |
8 | namespace KinectWithVRServer.KinectV1Wrapper
9 | {
10 | //This class wraps the KinectV1StatusHelper class to delay the DLL loading and prevent a crash in the event that the KinectV1 dll is missing
11 | public class StatusHelper
12 | {
13 | public event StatusEventHandler StatusChanged;
14 | private KinectV1StatusHelper realHelper;
15 |
16 | public StatusHelper()
17 | {
18 | realHelper = new KinectV1StatusHelper();
19 | realHelper.KinectV1StatusChanged += realHelper_KinectV1StatusChanged;
20 | }
21 |
22 | public static StatusEventArgs[] GetAllKinectsStatus()
23 | {
24 | KinectV1StatusEventArgs[] statusArray = KinectV1StatusHelper.GetAllKinectsStatus();
25 | StatusEventArgs[] statuses = new StatusEventArgs[statusArray.Length];
26 |
27 | for (int i = 0; i < statusArray.Length; i++)
28 | {
29 | statuses[i] = new StatusEventArgs();
30 | statuses[i].isXBox360Kinect = statusArray[i].isXBox360Kinect;
31 | statuses[i].KinectNumber = statusArray[i].KinectNumber;
32 | statuses[i].Status = statusArray[i].Status;
33 | statuses[i].UniqueKinectID = statusArray[i].UniqueKinectID;
34 | }
35 |
36 | return statuses;
37 | }
38 |
39 | private void realHelper_KinectV1StatusChanged(object sender, KinectV1StatusEventArgs e)
40 | {
41 | if (StatusChanged != null)
42 | {
43 | StatusEventArgs args = new StatusEventArgs();
44 | args.isXBox360Kinect = e.isXBox360Kinect;
45 | args.KinectNumber = e.KinectNumber;
46 | args.Status = e.Status;
47 | args.UniqueKinectID = e.UniqueKinectID;
48 |
49 | StatusChanged(this, args);
50 | }
51 | }
52 | }
53 |
54 | public delegate void StatusEventHandler(object sender, StatusEventArgs e);
55 |
56 | public class StatusEventArgs : EventArgs
57 | {
58 | public KinectBase.KinectStatus Status;
59 | //public string ConnectionID;
60 | public string UniqueKinectID;
61 | public int KinectNumber; //This is the number in the SDKs list of kinects
62 | public bool isXBox360Kinect;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV1Wrapper/KV1SettingsControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using KinectBase;
16 | using KinectV1Core;
17 |
18 | namespace KinectWithVRServer.KinectV1Wrapper
19 | {
20 | public partial class SettingsControl : UserControl, IKinectSettingsControl
21 | {
22 | //Private variable to manage the wrapping
23 | private KinectV1SettingsControl realControl;
24 |
25 | //Public properties required by the IKinectSettingsControl interface
26 | public int? kinectID
27 | {
28 | get { return realControl.kinectID; }
29 | set { realControl.kinectID = value; }
30 | }
31 | public KinectVersion version
32 | {
33 | get { return realControl.version; }
34 | }
35 | public string uniqueKinectID
36 | {
37 | get { return realControl.uniqueKinectID; }
38 | set { realControl.uniqueKinectID = value; }
39 | }
40 |
41 | //Public properties specific to the Kinect v1
42 | public UserControl skeletonUserControl
43 | {
44 | get { return realControl.skeletonUserControl; }
45 | set { realControl.skeletonUserControl = value; }
46 | }
47 |
48 | //Public methods required by the IKinectSettingsControl interface
49 | public void UpdateGUI(MasterSettings newSettings)
50 | {
51 | realControl.UpdateGUI(newSettings);
52 | }
53 |
54 | //Constructor to setup the real KinectV1SettingsControl
55 | public SettingsControl(int kinectNumber, ref MasterSettings settings, IKinectCore kinect)
56 | {
57 | InitializeComponent();
58 | Grid.SetColumn(this, 2);
59 | this.Visibility = System.Windows.Visibility.Collapsed;
60 |
61 | Core coreWrapper = (Core)kinect;
62 | KinectCoreV1 kinectCore = (KinectCoreV1)coreWrapper;
63 | realControl = new KinectV1SettingsControl(kinectNumber, ref settings, kinectCore);
64 | realControl.Visibility = System.Windows.Visibility.Visible;
65 | this.MasterGrid.Children.Add((UserControl)realControl);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV2Wrapper/KV2StatusHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using KinectV2Core;
7 |
8 | namespace KinectWithVRServer.KinectV2Wrapper
9 | {
10 | //This class wraps the KinectV2StatusHelper class to delay the DLL loading and prevent a crash in the event that the KinectV2 DLL is missing
11 | public class StatusHelper
12 | {
13 | public event StatusEventHandler StatusChanged;
14 | private KinectV2StatusHelper realHelper;
15 |
16 | public StatusHelper()
17 | {
18 | realHelper = new KinectV2StatusHelper();
19 | realHelper.KinectV2StatusChanged += realHelper_KinectV2StatusChanged;
20 | }
21 |
22 | public static StatusEventArgs[] GetAllKinectsStatus()
23 | {
24 | KinectV2StatusEventArgs[] statusArray = KinectV2StatusHelper.GetAllKinectsStatus();
25 | StatusEventArgs[] statuses = new StatusEventArgs[statusArray.Length];
26 |
27 | for (int i = 0; i < statusArray.Length; i++)
28 | {
29 | statuses[i] = new StatusEventArgs();
30 | statuses[i].KinectNumber = statusArray[i].KinectNumber;
31 | statuses[i].Status = statusArray[i].Status;
32 | statuses[i].UniqueKinectID = statusArray[i].UniqueKinectID;
33 | }
34 |
35 | return statuses;
36 | }
37 | public static void StartKinectV2Service()
38 | {
39 | KinectV2StatusHelper.StartKinectV2Service();
40 | }
41 | public static void StopKinectV2Service()
42 | {
43 | KinectV2StatusHelper.StopKinectV2Service();
44 | }
45 |
46 | private void realHelper_KinectV2StatusChanged(object sender, KinectV2StatusEventArgs e)
47 | {
48 | if (StatusChanged != null)
49 | {
50 | StatusEventArgs args = new StatusEventArgs();
51 | args.KinectNumber = e.KinectNumber;
52 | args.Status = e.Status;
53 | args.UniqueKinectID = e.UniqueKinectID;
54 |
55 | StatusChanged(this, args);
56 | }
57 | }
58 | }
59 |
60 | public delegate void StatusEventHandler(object sender, StatusEventArgs e);
61 |
62 | public class StatusEventArgs : EventArgs
63 | {
64 | public KinectBase.KinectStatus Status;
65 | public string UniqueKinectID;
66 | public int KinectNumber; //This is the number in the SDK's list of Kinects
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV2Wrapper/KV2SettingsControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using KinectBase;
16 | using KinectV2Core;
17 |
18 | namespace KinectWithVRServer.KinectV2Wrapper
19 | {
20 | ///
21 | /// Interaction logic for KV2SettingsControl.xaml
22 | ///
23 | public partial class SettingsControl : UserControl, IKinectSettingsControl
24 | {
25 | //Private variable to manage the wrapping
26 | private KinectV2SettingsControl realControl;
27 |
28 | //Public properties required by the IKinectSettingsControl interface
29 | public int? kinectID
30 | {
31 | get { return realControl.kinectID; }
32 | set { realControl.kinectID = value; }
33 | }
34 | public KinectVersion version
35 | {
36 | get { return realControl.version; }
37 | }
38 | public string uniqueKinectID
39 | {
40 | get { return realControl.uniqueKinectID; }
41 | set { realControl.uniqueKinectID = value; }
42 | }
43 |
44 | //Public properties specific to the Kinect v2
45 | public UserControl skeletonUserControl
46 | {
47 | get { return realControl.skeletonUserControl; }
48 | set { realControl.skeletonUserControl = value; }
49 | }
50 |
51 | //Public methods required by the IKinectSettingsControl interface
52 | public void UpdateGUI(MasterSettings newSettings)
53 | {
54 | realControl.UpdateGUI(newSettings);
55 | }
56 |
57 | //Constructor to setup the real KinectV2SettingsControl
58 | public SettingsControl(int kinectNumber, ref MasterSettings settings, IKinectCore kinect)
59 | {
60 | InitializeComponent();
61 | Grid.SetColumn(this, 2);
62 | this.Visibility = System.Windows.Visibility.Collapsed;
63 |
64 | Core coreWrapper = (Core)kinect;
65 | KinectCoreV2 kinectCore = (KinectCoreV2)coreWrapper;
66 | realControl = new KinectV2SettingsControl(kinectNumber, ref settings, kinectCore);
67 | realControl.Visibility = System.Windows.Visibility.Visible;
68 | this.MasterGrid.Children.Add((UserControl)realControl);
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # https://github.com/github/gitignore
2 |
3 | ## Ignore Visual Studio temporary files, build results, and
4 | ## files generated by popular Visual Studio add-ons.
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.sln.docstates
10 |
11 | # Build results
12 |
13 | [Dd]ebug/
14 | [Rr]elease/
15 | x64/
16 | build/
17 | [Bb]in/
18 | [Oo]bj/
19 |
20 | # MSTest test Results
21 | [Tt]est[Rr]esult*/
22 | [Bb]uild[Ll]og.*
23 |
24 | *_i.c
25 | *_p.c
26 | *.ilk
27 | *.meta
28 | *.obj
29 | *.pch
30 | *.pdb
31 | *.pgc
32 | *.pgd
33 | *.rsp
34 | *.sbr
35 | *.tlb
36 | *.tli
37 | *.tlh
38 | *.tmp
39 | *.tmp_proj
40 | *.log
41 | *.vspscc
42 | *.vssscc
43 | .builds
44 | *.pidb
45 | *.log
46 | *.scc
47 |
48 | # Visual C++ cache files
49 | ipch/
50 | *.aps
51 | *.ncb
52 | *.opensdf
53 | *.sdf
54 | *.cachefile
55 |
56 | # Visual Studio profiler
57 | *.psess
58 | *.vsp
59 | *.vspx
60 |
61 | # Guidance Automation Toolkit
62 | *.gpState
63 |
64 | # ReSharper is a .NET coding add-in
65 | _ReSharper*/
66 | *.[Rr]e[Ss]harper
67 |
68 | # TeamCity is a build add-in
69 | _TeamCity*
70 |
71 | # DotCover is a Code Coverage Tool
72 | *.dotCover
73 |
74 | # NCrunch
75 | *.ncrunch*
76 | .*crunch*.local.xml
77 |
78 | # Installshield output folder
79 | [Ee]xpress/
80 |
81 | # DocProject is a documentation generator add-in
82 | DocProject/buildhelp/
83 | DocProject/Help/*.HxT
84 | DocProject/Help/*.HxC
85 | DocProject/Help/*.hhc
86 | DocProject/Help/*.hhk
87 | DocProject/Help/*.hhp
88 | DocProject/Help/Html2
89 | DocProject/Help/html
90 |
91 | # Click-Once directory
92 | publish/
93 |
94 | # Publish Web Output
95 | *.Publish.xml
96 | *.pubxml
97 |
98 | # NuGet Packages Directory
99 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
100 | #packages/
101 |
102 | # Windows Azure Build Output
103 | csx
104 | *.build.csdef
105 |
106 | # Windows Store app package directory
107 | AppPackages/
108 |
109 | # Others
110 | sql/
111 | *.Cache
112 | ClientBin/
113 | [Ss]tyle[Cc]op.*
114 | ~$*
115 | *~
116 | *.dbmdl
117 | *.[Pp]ublish.xml
118 | *.pfx
119 | *.publishsettings
120 |
121 | # RIA/Silverlight projects
122 | Generated_Code/
123 |
124 | # Backup & report files from converting an old project file to a newer
125 | # Visual Studio version. Backup files are not needed, because we have git ;-)
126 | _UpgradeReport_Files/
127 | Backup*/
128 | UpgradeLog*.XML
129 | UpgradeLog*.htm
130 |
131 | # SQL Server files
132 | App_Data/*.mdf
133 | App_Data/*.ldf
134 |
135 | # =========================
136 | # Windows detritus
137 | # =========================
138 |
139 | # Windows image file caches
140 | Thumbs.db
141 | ehthumbs.db
142 |
143 | # Folder config file
144 | Desktop.ini
145 |
146 | # Recycle Bin used on file shares
147 | $RECYCLE.BIN/
148 |
149 | # Mac crap
150 | .DS_Store
151 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34209
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace KinectWithVRServer.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("KinectWithVRServer.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/KinectWithVRServer/VerifyDLLs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Reflection;
7 |
8 | using System.Diagnostics;
9 |
10 | namespace KinectWithVRServer
11 | {
12 | internal class VerifyDLLs
13 | {
14 | internal static bool Kinect1Avaliable()
15 | {
16 | bool isAvaliable = false;
17 |
18 | Assembly thisAssm = Assembly.GetExecutingAssembly();
19 |
20 | //Check to see if KinectV1Core.dll exists
21 | AssemblyName[] refs = thisAssm.GetReferencedAssemblies();
22 | for (int i = 0; i < refs.Length; i++)
23 | {
24 | if (refs[i].Name == "KinectV1Core")
25 | {
26 | try
27 | {
28 | Assembly.Load(refs[i]);
29 | isAvaliable = true;
30 | }
31 | catch { }
32 | }
33 | }
34 |
35 | //Secondary check to see if the DLL actually functions
36 | if (isAvaliable)
37 | {
38 | isAvaliable = KinectV1Wrapper.KV1SdkTest.IsSDKWorking();
39 | }
40 | return isAvaliable;
41 | }
42 |
43 | internal static bool Kinect2Avaliable()
44 | {
45 | bool isAvaliable = false;
46 |
47 | Assembly thisAssm = Assembly.GetExecutingAssembly();
48 |
49 | //Check to see if KinectV1Core.dll exists
50 | AssemblyName[] refs = thisAssm.GetReferencedAssemblies();
51 | for (int i = 0; i < refs.Length; i++)
52 | {
53 | if (refs[i].Name == "KinectV2Core")
54 | {
55 | try
56 | {
57 | Assembly.Load(refs[i]);
58 | isAvaliable = true;
59 | }
60 | catch { }
61 | }
62 | }
63 |
64 | //Secondary check to see if the DLL actually functions
65 | if (isAvaliable)
66 | {
67 | isAvaliable = KinectV2Wrapper.KV2SdkTest.IsSDKWorking();
68 | }
69 |
70 | return isAvaliable;
71 | }
72 |
73 | internal static bool NetworkedKinectAvaliable()
74 | {
75 | bool isAvaliable = false;
76 |
77 | Assembly thisAssm = Assembly.GetExecutingAssembly();
78 |
79 | //Check to see if KinectV1Core.dll exists
80 | AssemblyName[] refs = thisAssm.GetReferencedAssemblies();
81 | for (int i = 0; i < refs.Length; i++)
82 | {
83 | if (refs[i].Name == "NetworkKinectCore")
84 | {
85 | try
86 | {
87 | Assembly.Load(refs[i]);
88 | isAvaliable = true;
89 | }
90 | catch { }
91 | }
92 | }
93 |
94 | return isAvaliable;
95 | }
96 | }
97 |
98 | public class AvaliableDLLs
99 | {
100 | internal AvaliableDLLs() { }
101 |
102 | internal bool HasKinectV1 = false;
103 | internal bool HasKinectV2 = false;
104 | internal bool HasNetworkedKinect = false;
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/KinectWithVRServer/ConcurrentSkeletonCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.Concurrent;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace KinectWithVRServer
9 | {
10 | //TODO: FIX THIS!!!
11 | //This works in principle, but it isn't being agressive enough in getting rid of old skeletons
12 | //Somehow, when the system gets backed up, we need to clear it
13 | class ConcurrentSkeletonCollection
14 | {
15 | private List mainList = new List();
16 | private List addCache = new List();
17 | private List removeList = new List();
18 | object lockObj = new object();
19 | int refCount = 0;
20 |
21 | public void Add(FilteredSkeleton skeleton)
22 | {
23 | lock (lockObj)
24 | {
25 | if (refCount == 0)
26 | {
27 | mainList.Add(skeleton);
28 | }
29 | else
30 | {
31 | addCache.Add(skeleton);
32 | }
33 | }
34 | }
35 | public void HoldUpdates()
36 | {
37 | lock (lockObj)
38 | {
39 | refCount++;
40 | }
41 | }
42 | public void ReleaseForUpdates()
43 | {
44 | lock (lockObj)
45 | {
46 | refCount--;
47 | System.Diagnostics.Debug.WriteLine("There are {0} references.", refCount);
48 |
49 | if (refCount == 0)
50 | {
51 | //Remove the requested skeletons
52 | removeList.Sort(); //Sort the indices
53 | for (int i = 0; i < removeList.Count; i++) //Remove any duplicates
54 | {
55 | while (i + 1 < removeList.Count && removeList[i] == removeList[i + 1])
56 | {
57 | removeList.RemoveAt(i + 1);
58 | }
59 | }
60 |
61 | for (int j = removeList.Count - 1; j >= 0; j--) //Go through and do the removals in reverse order so we don't mess up the indexing
62 | {
63 | mainList.RemoveAt(removeList[j]);
64 | }
65 | removeList.Clear();
66 |
67 | //Copy all the data from the cache to the main list
68 | for (int i = 0; i < addCache.Count; i++)
69 | {
70 | mainList.Add(addCache[i]);
71 | }
72 | addCache.Clear();
73 | }
74 | else if (refCount < 0)
75 | {
76 | throw new Exception("The ref count should never be less than 0!");
77 | }
78 | }
79 | }
80 | public void RemoveAt(int idx)
81 | {
82 | lock (lockObj)
83 | {
84 | if (refCount == 0)
85 | {
86 | mainList.RemoveAt(idx);
87 | }
88 | else
89 | {
90 | removeList.Add(idx);
91 | }
92 | }
93 | }
94 | public int Count
95 | {
96 | get { return mainList.Count; }
97 | }
98 | public FilteredSkeleton this[int index]
99 | {
100 | get
101 | {
102 | return mainList[index];
103 | }
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/KinectBase/IKinectCore.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace KinectBase
8 | {
9 | public interface IKinectCore
10 | {
11 | string uniqueKinectID
12 | {
13 | get;
14 | }
15 | int kinectID { get; set; }
16 | KinectVersion version { get; }
17 |
18 | bool ColorStreamEnabled { get; }
19 | bool DepthStreamEnabled { get; }
20 |
21 | void ShutdownSensor();
22 | KinectSkeleton TransformSkeleton(KinectSkeleton skeleton);
23 | Joint TransformJoint(Joint joint);
24 | System.Windows.Point MapJointToColor(Joint joint, bool undoTransform);
25 | System.Windows.Point MapJointToDepth(Joint joint, bool undoTransform);
26 |
27 | //All versions of the Kinect core need to implement these events to pass the data up to the GUI
28 | event SkeletonEventHandler SkeletonChanged;
29 | event DepthFrameEventHandler DepthFrameReceived;
30 | event ColorFrameEventHandler ColorFrameReceived;
31 | event AccelerationEventHandler AccelerationChanged;
32 | event AudioPositionEventHandler AudioPositionChanged;
33 | event LogMessageEventHandler LogMessageGenerated;
34 | }
35 |
36 | public class KinectCoreComparer : IComparer
37 | {
38 | public int Compare(IKinectCore x, IKinectCore y)
39 | {
40 | return x.kinectID.CompareTo(y.kinectID);
41 | }
42 | }
43 |
44 | public delegate void SkeletonEventHandler(object sender, SkeletonEventArgs e);
45 | public delegate void DepthFrameEventHandler(object sender, DepthFrameEventArgs e);
46 | public delegate void ColorFrameEventHandler(object sender, ColorFrameEventArgs e);
47 | public delegate void AccelerationEventHandler(object sender, AccelerationEventArgs e);
48 | public delegate void AudioPositionEventHandler(object sender, AudioPositionEventArgs e);
49 | public delegate void LogMessageEventHandler(object sender, LogMessageEventArgs e);
50 |
51 | public class SkeletonEventArgs : EventArgs
52 | {
53 | public KinectSkeleton[] skeletons;
54 | public int kinectID;
55 | }
56 | public class DepthFrameEventArgs : EventArgs
57 | {
58 | public byte[] image;
59 | public int perPixelExtra;
60 | //public System.Windows.Media.PixelFormat pixelFormat;
61 | public int width;
62 | public int height;
63 | public int bytesPerPixel;
64 | public TimeSpan timeStamp;
65 | public int kinectID;
66 | public float reliableMin; //This should be from 0 to 1
67 | public float reliableMax; //This hsould be from 0 to 1
68 | }
69 | public class ColorFrameEventArgs : EventArgs
70 | {
71 | public byte[] image;
72 | public System.Windows.Media.PixelFormat pixelFormat;
73 | public bool isIR;
74 | public int width;
75 | public int height;
76 | public int bytesPerPixel;
77 | public TimeSpan timeStamp;
78 | public int kinectID;
79 | }
80 | public class AccelerationEventArgs : EventArgs
81 | {
82 | public System.Windows.Media.Media3D.Vector3D? acceleration;
83 | public int? elevationAngle;
84 | public int kinectID;
85 | }
86 | public class AudioPositionEventArgs : EventArgs
87 | {
88 | public double audioAngle;
89 | public double confidence;
90 | public int kinectID;
91 | }
92 | public class LogMessageEventArgs : EventArgs
93 | {
94 | public string errorMessage;
95 | public bool verboseMessage; //If this is true, the message should only be displayed when the system is in verbose mode
96 | public int kinectID;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/KinectV2Core/KinectV2SkeletonControl.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/KinectBase/Enums.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace KinectBase
8 | {
9 | //Many of the enumerators from the Kinect namespace have to be replicated here so we have a base set we can use with both versions of the sensor
10 | //The enum values have been set so, as best as possible, they can be directly cast from the KinectBase version to the Microsoft version
11 | //public enum JointType {HipCenter = 0, Spine = 1, ShoulderCenter = 2, Head = 3, ShoulderLeft = 4,
12 | // ElbowLeft = 5, WristLeft = 6, HandLeft = 7, ShoulderRight = 8, ElbowRight = 9,
13 | // WristRight = 10, HandRight = 11, HipLeft = 12, KneeLeft = 13, AnkleLeft = 14,
14 | // FootLeft = 15, HipRight = 16, KneeRight = 17, AnkleRight = 18, FootRight = 19,
15 | // SpineShoulder = 20, HandTipLeft = 21, ThumbLeft = 22, HandTipRight = 23, ThumbRight = 24,
16 | // SpineBase = 25, SpineMid = 26, Neck = 27}
17 |
18 | //Joints that have been renamed in Kinect 2 are double mapped to the same number as the old name
19 | public enum JointType { HipCenter = 0, Spine = 1, ShoulderCenter = 2, Head = 3,
20 | ShoulderLeft = 4, ElbowLeft = 5, WristLeft = 6, HandLeft = 7,
21 | ShoulderRight = 8, ElbowRight = 9, WristRight = 10, HandRight = 11,
22 | HipLeft = 12, KneeLeft = 13, AnkleLeft = 14, FootLeft = 15,
23 | HipRight = 16, KneeRight = 17, AnkleRight = 18, FootRight = 19,
24 | HandTipLeft = 21, ThumbLeft = 22, HandTipRight = 23, ThumbRight = 24,
25 | SpineShoulder = 2, SpineBase = 0, SpineMid = 1, Neck = 20 }
26 |
27 | public enum AudioTrackingMode { Loudest, Feedback, MergedSkeletonX, LocalSkeletonX }
28 | public enum EchoCancellationMode {None = 0, CancellationOnly = 1, CancellationAndSuppression = 2}
29 | public enum TrackingState { NotTracked = 0, Inferred = 1, Tracked = 2, PositionOnly = 3 }
30 | public enum TrackingConfidence { Low = 0, High = 1, Unknown = 2}
31 | public enum KinectVersion { NetworkKinect = 0, KinectV1 = 1, KinectV2 = 2, }
32 | public enum KinectStatus { Undefined = 0, Disconnected = 1, Connected = 2, Initializing = 3, Error = 4, NotPowered = 5, NotReady = 6, DeviceNotGenuine = 7, DeviceNotSupported = 8, InsufficientBandwidth = 9 };
33 | public enum ColorImageFormat { Undefined = 0, RgbResolution640x480Fps30 = 1, RgbResolution1280x960Fps12 = 2, YuvResolution640x480Fps15 = 3, RawYuvResolution640x480Fps15 = 4, InfraredResolution640x480Fps30 = 5, RawBayerResolution640x480Fps30 = 6, RawBayerResolution1280x960Fps12 = 7 };
34 | public enum PowerLineFrequency { Disabled = 0, FiftyHertz = 1, SixtyHertz = 2 };
35 | public enum BacklightCompensationMode { AverageBrightness = 0, CenterPriority = 1, LowlightsPriority = 2, CenterOnly = 4 };
36 | public enum DepthImageFormat { Undefined = 0, Resolution640x480Fps30 = 1, Resolution320x240Fps30 = 2, Resolution80x60Fps30 = 3 };
37 |
38 | public enum CommandType { Voice, Gesture/*, Analog */}
39 | public enum ServerType { Button, Analog, Tracker, Text, Imager }
40 | public enum ButtonType { Setter, Toggle, Momentary }
41 | public enum SkeletonSortMethod
42 | {
43 | NoSort = 0, OriginXClosest = 1, OriginXFarthest = 2, OriginYClosest = 3, OriginYFarthest = 4, OriginZClosest = 5, OriginZFarthest = 6, OriginEuclidClosest = 7, OriginEuclidFarthest = 8,
44 | FeedbackXClosest = 9, FeedbackXFarthest = 10, FeedbackYClosest = 11, FeedbackYFarthest = 12, FeedbackZClosest = 13, FeedbackZFarthest = 14, FeedbackEuclidClosest = 15, FeedbackEuclidFarthest = 16
45 | }
46 | //public enum GestureType { Recorded }
47 | public enum PressState { Pressed, Released }
48 | public enum HMMModel { LeftToRight, LeftToRight2, Ergodic, LeftToRight2Loop, LeftToRightAll }
49 | }
50 |
--------------------------------------------------------------------------------
/KinectV1Core/KinectV1SkeletonControl.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/KinectWithVRServer/NetworkKinectWrapper/NKSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using KinectBase;
8 | using NetworkKinectCore;
9 |
10 | namespace KinectWithVRServer.NetworkKinectWrapper
11 | {
12 | public class Settings : IKinectSettings
13 | {
14 | //Private variable to manage the wrapped class
15 | private NetworkKinectSettings realSettings;
16 |
17 | //Public properties required by the interface
18 | public int kinectID
19 | {
20 | get { return realSettings.kinectID; }
21 | set { realSettings.kinectID = value; }
22 | }
23 | public KinectVersion version
24 | {
25 | get { return realSettings.version; }
26 | }
27 | public string uniqueKinectID
28 | {
29 | get { return realSettings.uniqueKinectID; }
30 | set { realSettings.uniqueKinectID = value; }
31 | }
32 | public bool mergeSkeletons
33 | {
34 | get { return realSettings.mergeSkeletons; }
35 | set { realSettings.mergeSkeletons = value; }
36 | }
37 |
38 | //Constructor to setup the real KinectV1Settings object
39 | public Settings(string uniqueID, int kinectNumber)
40 | {
41 | realSettings = new NetworkKinectSettings(uniqueID, kinectNumber);
42 | }
43 | public Settings() //Needed for serialization
44 | {
45 | realSettings = new NetworkKinectSettings();
46 | }
47 |
48 | //Public properties specific to the network Kinect
49 | public string serverName
50 | {
51 | get { return realSettings.serverName; }
52 | set { realSettings.serverName = value; }
53 | }
54 | #region Skeleton and Physical Settings
55 | public System.Windows.Media.Media3D.Point3D kinectPosition
56 | {
57 | get { return realSettings.kinectPosition; }
58 | set { realSettings.kinectPosition = value; }
59 | }
60 | public double kinectYaw
61 | {
62 | get { return realSettings.kinectYaw; }
63 | set { realSettings.kinectYaw = value; }
64 | }
65 | public double kinectPitch
66 | {
67 | get { return realSettings.kinectPitch; }
68 | set { realSettings.kinectPitch = value; }
69 | }
70 | public double kinectRoll
71 | {
72 | get { return realSettings.kinectRoll; }
73 | set { realSettings.kinectRoll = value; }
74 | }
75 | #endregion
76 | #region Joint Mapping
77 | public ObservableCollection jointMappings
78 | {
79 | get { return realSettings.jointMappings; }
80 | set { realSettings.jointMappings = value; }
81 | }
82 | public string lhServerName
83 | {
84 | get { return realSettings.lhServerName; }
85 | set { realSettings.lhServerName = value; }
86 | }
87 | public int lhChannel
88 | {
89 | get { return realSettings.lhChannel; }
90 | set { realSettings.lhChannel = value; }
91 | }
92 | public string rhServerName
93 | {
94 | get { return realSettings.rhServerName; }
95 | set { realSettings.rhServerName = value; }
96 | }
97 | public int rhChannel
98 | {
99 | get { return realSettings.rhChannel; }
100 | set { realSettings.rhChannel = value; }
101 | }
102 | #endregion
103 |
104 | //Custom conversion operator so this class can be cast as a KinectV1Settings class
105 | public static explicit operator NetworkKinectSettings(Settings settings)
106 | {
107 | return settings.realSettings;
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/KinectV2Core/KinectV2Settings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Media;
7 | using System.Windows.Media.Media3D;
8 | using KinectBase;
9 |
10 | namespace KinectV2Core
11 | {
12 | public class KinectV2Settings : IKinectSettings
13 | {
14 | public KinectV2Settings() { } //Needed for serialization
15 | public KinectV2Settings(string deviceUniqueID, int kinectNumber)
16 | {
17 | uniqueKinectID = deviceUniqueID;
18 | kinectID = kinectNumber;
19 |
20 | //Set the default values
21 | mergeSkeletons = true;
22 | sendRawSkeletons = false;
23 | transformRawSkeletons = false;
24 | kinectPosition = new Point3D(0, 0, 0);
25 | scaleDepthToReliableRange = true;
26 | colorizeDepth = false;
27 | sendAudioAngle = false;
28 | audioTrackMode = AudioTrackingMode.Loudest;
29 | sendColorImage = false;
30 | sendDepthImage = false;
31 | sendIRImage = false;
32 |
33 | //Setup the options for the raw skeleton, irrespective of use
34 | rawSkeletonSettings = new SkeletonSettings();
35 | }
36 |
37 | public string uniqueKinectID { get; set; }
38 | public int kinectID { get; set; }
39 | public KinectVersion version
40 | {
41 | get { return KinectVersion.KinectV2; }
42 | }
43 |
44 | #region Color Settings
45 | private bool isColorPreview = true;
46 | public bool useColorPreview
47 | {
48 | get
49 | {
50 | return isColorPreview;
51 | }
52 | set
53 | {
54 | isColorPreview = value;
55 | }
56 | }
57 | public bool useIRPreview
58 | {
59 | get
60 | {
61 | return !isColorPreview;
62 | }
63 | set
64 | {
65 | isColorPreview = !value;
66 | }
67 | }
68 | public bool sendColorImage { get; set; }
69 | public string colorServerName { get; set; }
70 | public bool sendIRImage { get; set; }
71 | public string irServerName { get; set; }
72 | #endregion
73 |
74 | #region Depth Settings
75 | public bool scaleDepthToReliableRange { get; set; }
76 | public bool colorizeDepth { get; set; }
77 | public bool sendDepthImage { get; set; }
78 | public string depthServerName { get; set; }
79 | #endregion
80 |
81 | #region Skeleton and Physical Settings
82 | public bool mergeSkeletons { get; set; }
83 | public bool sendRawSkeletons { get; set; }
84 | public bool transformRawSkeletons { get; set; }
85 | public SkeletonSettings rawSkeletonSettings { get; set; }
86 | public Point3D kinectPosition { get; set; }
87 | private double yaw = 0;
88 | private double pitch = 0;
89 | private double roll = 0;
90 | public double kinectYaw
91 | {
92 | get { return yaw; }
93 | set { yaw = value; }
94 | }
95 | public double kinectPitch
96 | {
97 | get { return pitch; }
98 | set { pitch = value; }
99 | }
100 | public double kinectRoll
101 | {
102 | get { return roll; }
103 | set { roll = value; }
104 | }
105 | //public Quaternion kinectOrientation
106 | //{
107 | // get
108 | // {
109 | // //TODO: Calculate the orientation quaternion from the Euler angles
110 | // return Quaternion.Identity;
111 | // }
112 | //}
113 | #endregion
114 |
115 | #region Audio Settings
116 | public bool sendAudioAngle { get; set; }
117 | public AudioTrackingMode audioTrackMode { get; set; }
118 | public int audioBeamTrackSkeletonNumber { get; set; }
119 | public string audioAngleServerName { get; set; }
120 | public int audioAngleChannel { get; set; }
121 | #endregion
122 | }
123 | }
--------------------------------------------------------------------------------
/KinectWithVRServer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KinectWithVRServer", "KinectWithVRServer\KinectWithVRServer.csproj", "{DF4941C5-2949-40B4-B4DB-4FEC3D345C19}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KinectV1Core", "KinectV1Core\KinectV1Core.csproj", "{1C1B1857-A092-41FA-9875-89ACF0D9710D}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KinectBase", "KinectBase\KinectBase.csproj", "{E212EA42-C987-4D89-996F-C9DA49878CFD}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KinectV2Core", "KinectV2Core\KinectV2Core.csproj", "{BA6C3333-EE04-4238-8B0B-EEEF5951F51A}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkKinectCore", "NetworkKinectCore\NetworkKinectCore.csproj", "{FEA65975-74FA-4E87-B571-A53591CE0C42}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|x64 = Debug|x64
17 | Debug|x86 = Debug|x86
18 | Release|x64 = Release|x64
19 | Release|x86 = Release|x86
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {DF4941C5-2949-40B4-B4DB-4FEC3D345C19}.Debug|x64.ActiveCfg = Debug|x64
23 | {DF4941C5-2949-40B4-B4DB-4FEC3D345C19}.Debug|x64.Build.0 = Debug|x64
24 | {DF4941C5-2949-40B4-B4DB-4FEC3D345C19}.Debug|x86.ActiveCfg = Debug|x86
25 | {DF4941C5-2949-40B4-B4DB-4FEC3D345C19}.Debug|x86.Build.0 = Debug|x86
26 | {DF4941C5-2949-40B4-B4DB-4FEC3D345C19}.Release|x64.ActiveCfg = Release|x64
27 | {DF4941C5-2949-40B4-B4DB-4FEC3D345C19}.Release|x64.Build.0 = Release|x64
28 | {DF4941C5-2949-40B4-B4DB-4FEC3D345C19}.Release|x86.ActiveCfg = Release|x86
29 | {DF4941C5-2949-40B4-B4DB-4FEC3D345C19}.Release|x86.Build.0 = Release|x86
30 | {1C1B1857-A092-41FA-9875-89ACF0D9710D}.Debug|x64.ActiveCfg = Debug|x64
31 | {1C1B1857-A092-41FA-9875-89ACF0D9710D}.Debug|x64.Build.0 = Debug|x64
32 | {1C1B1857-A092-41FA-9875-89ACF0D9710D}.Debug|x86.ActiveCfg = Debug|x86
33 | {1C1B1857-A092-41FA-9875-89ACF0D9710D}.Debug|x86.Build.0 = Debug|x86
34 | {1C1B1857-A092-41FA-9875-89ACF0D9710D}.Release|x64.ActiveCfg = Release|x64
35 | {1C1B1857-A092-41FA-9875-89ACF0D9710D}.Release|x64.Build.0 = Release|x64
36 | {1C1B1857-A092-41FA-9875-89ACF0D9710D}.Release|x86.ActiveCfg = Release|x86
37 | {1C1B1857-A092-41FA-9875-89ACF0D9710D}.Release|x86.Build.0 = Release|x86
38 | {E212EA42-C987-4D89-996F-C9DA49878CFD}.Debug|x64.ActiveCfg = Debug|x64
39 | {E212EA42-C987-4D89-996F-C9DA49878CFD}.Debug|x64.Build.0 = Debug|x64
40 | {E212EA42-C987-4D89-996F-C9DA49878CFD}.Debug|x86.ActiveCfg = Debug|x86
41 | {E212EA42-C987-4D89-996F-C9DA49878CFD}.Debug|x86.Build.0 = Debug|x86
42 | {E212EA42-C987-4D89-996F-C9DA49878CFD}.Release|x64.ActiveCfg = Release|x64
43 | {E212EA42-C987-4D89-996F-C9DA49878CFD}.Release|x64.Build.0 = Release|x64
44 | {E212EA42-C987-4D89-996F-C9DA49878CFD}.Release|x86.ActiveCfg = Release|x86
45 | {E212EA42-C987-4D89-996F-C9DA49878CFD}.Release|x86.Build.0 = Release|x86
46 | {BA6C3333-EE04-4238-8B0B-EEEF5951F51A}.Debug|x64.ActiveCfg = Debug|x64
47 | {BA6C3333-EE04-4238-8B0B-EEEF5951F51A}.Debug|x64.Build.0 = Debug|x64
48 | {BA6C3333-EE04-4238-8B0B-EEEF5951F51A}.Debug|x86.ActiveCfg = Debug|x86
49 | {BA6C3333-EE04-4238-8B0B-EEEF5951F51A}.Debug|x86.Build.0 = Debug|x86
50 | {BA6C3333-EE04-4238-8B0B-EEEF5951F51A}.Release|x64.ActiveCfg = Release|x64
51 | {BA6C3333-EE04-4238-8B0B-EEEF5951F51A}.Release|x64.Build.0 = Release|x64
52 | {BA6C3333-EE04-4238-8B0B-EEEF5951F51A}.Release|x86.ActiveCfg = Release|x86
53 | {BA6C3333-EE04-4238-8B0B-EEEF5951F51A}.Release|x86.Build.0 = Release|x86
54 | {FEA65975-74FA-4E87-B571-A53591CE0C42}.Debug|x64.ActiveCfg = Debug|x64
55 | {FEA65975-74FA-4E87-B571-A53591CE0C42}.Debug|x64.Build.0 = Debug|x64
56 | {FEA65975-74FA-4E87-B571-A53591CE0C42}.Debug|x86.ActiveCfg = Debug|x86
57 | {FEA65975-74FA-4E87-B571-A53591CE0C42}.Debug|x86.Build.0 = Debug|x86
58 | {FEA65975-74FA-4E87-B571-A53591CE0C42}.Release|x64.ActiveCfg = Release|x64
59 | {FEA65975-74FA-4E87-B571-A53591CE0C42}.Release|x64.Build.0 = Release|x64
60 | {FEA65975-74FA-4E87-B571-A53591CE0C42}.Release|x86.ActiveCfg = Release|x86
61 | {FEA65975-74FA-4E87-B571-A53591CE0C42}.Release|x86.Build.0 = Release|x86
62 | EndGlobalSection
63 | GlobalSection(SolutionProperties) = preSolution
64 | HideSolutionNode = FALSE
65 | EndGlobalSection
66 | EndGlobal
67 |
--------------------------------------------------------------------------------
/KinectBase/KinectBase.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E212EA42-C987-4D89-996F-C9DA49878CFD}
8 | Library
9 | Properties
10 | KinectBase
11 | KinectBase
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | bin\x64\Debug\
18 | DEBUG;TRACE
19 | full
20 | x64
21 | prompt
22 | MinimumRecommendedRules.ruleset
23 | ..\3rd Party\EigenWrapper\x64\Debug\EigenWrapper.dll
24 |
25 |
26 | bin\x64\Release\
27 | TRACE
28 | true
29 | pdbonly
30 | x64
31 | prompt
32 | MinimumRecommendedRules.ruleset
33 | ..\3rd Party\EigenWrapper\x64\Release\EigenWrapper.dll
34 |
35 |
36 | true
37 | bin\x86\Debug\
38 | DEBUG;TRACE
39 | full
40 | x86
41 | prompt
42 | MinimumRecommendedRules.ruleset
43 | ..\3rd Party\EigenWrapper\x86\Debug\EigenWrapper.dll
44 |
45 |
46 | bin\x86\Release\
47 | TRACE
48 | true
49 | pdbonly
50 | x86
51 | prompt
52 | MinimumRecommendedRules.ruleset
53 | ..\3rd Party\EigenWrapper\x86\Release\EigenWrapper.dll
54 |
55 |
56 |
57 | $(EigenPath)
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
90 |
--------------------------------------------------------------------------------
/KinectV1Core/KinectV1StatusHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.Kinect;
7 |
8 | namespace KinectV1Core
9 | {
10 | public class KinectV1StatusHelper
11 | {
12 | public event KinectV1StatusEventHandler KinectV1StatusChanged;
13 |
14 | public KinectV1StatusHelper()
15 | {
16 | KinectSensor.KinectSensors.StatusChanged += KinectSensors_StatusChanged;
17 | }
18 |
19 | public static KinectV1StatusEventArgs[] GetAllKinectsStatus()
20 | {
21 | KinectV1StatusEventArgs[] statusArray = new KinectV1StatusEventArgs[KinectSensor.KinectSensors.Count];
22 |
23 | for (int i = 0; i < KinectSensor.KinectSensors.Count; i++)
24 | {
25 | KinectV1StatusEventArgs temp = new KinectV1StatusEventArgs();
26 | temp.KinectNumber = i;
27 | //temp.ConnectionID = KinectSensor.KinectSensors[i].DeviceConnectionId;
28 | //temp.UniqueKinectID = KinectSensor.KinectSensors[i].UniqueKinectId;
29 | temp.UniqueKinectID = KinectSensor.KinectSensors[i].DeviceConnectionId;
30 | temp.Status = (KinectBase.KinectStatus)KinectSensor.KinectSensors[i].Status;
31 |
32 | //Test each Kinect to see if it is an XBox 360 Kinect
33 | bool isXbox360Kinect = false;
34 | try
35 | {
36 | ColorCameraSettings test = KinectSensor.KinectSensors[i].ColorStream.CameraSettings;
37 | test = null;
38 | isXbox360Kinect = false;
39 | }
40 | catch
41 | {
42 | isXbox360Kinect = true;
43 | }
44 | temp.isXBox360Kinect = isXbox360Kinect;
45 |
46 | statusArray[i] = temp;
47 | }
48 |
49 | return statusArray;
50 | }
51 |
52 | private void KinectSensors_StatusChanged(object sender, StatusChangedEventArgs e)
53 | {
54 | if (KinectV1StatusChanged != null) //Okay, maybe it isn't that much work, but we may as well not do it if we don't have to
55 | {
56 | KinectV1StatusEventArgs args = new KinectV1StatusEventArgs();
57 | args.Status = (KinectBase.KinectStatus)e.Status; //This case SHOULD work because the numbers in the enum are assigned the same
58 | int sensorNumber = -1;
59 | bool isXbox360Kinect = false;
60 | for (int i = 0; i < KinectSensor.KinectSensors.Count; i++)
61 | {
62 | if (e.Sensor.UniqueKinectId == KinectSensor.KinectSensors[i].UniqueKinectId)
63 | {
64 | sensorNumber = i;
65 | try
66 | {
67 | ColorCameraSettings test = KinectSensor.KinectSensors[i].ColorStream.CameraSettings;
68 | test = null;
69 | isXbox360Kinect = false;
70 | }
71 | catch
72 | {
73 | isXbox360Kinect = true;
74 | }
75 | }
76 | }
77 | args.KinectNumber = sensorNumber;
78 | //args.ConnectionID = e.Sensor.DeviceConnectionId;
79 | //args.UniqueKinectID = e.Sensor.UniqueKinectId;
80 | args.UniqueKinectID = e.Sensor.DeviceConnectionId;
81 | args.isXBox360Kinect = isXbox360Kinect;
82 |
83 | OnKinectV1StatusChanged(args);
84 | }
85 | }
86 |
87 | protected virtual void OnKinectV1StatusChanged(KinectV1StatusEventArgs e)
88 | {
89 | if (KinectV1StatusChanged != null)
90 | {
91 | KinectV1StatusChanged(this, e);
92 | }
93 | }
94 | }
95 |
96 | public delegate void KinectV1StatusEventHandler(object sender, KinectV1StatusEventArgs e);
97 |
98 | public class KinectV1StatusEventArgs : EventArgs
99 | {
100 | public KinectBase.KinectStatus Status;
101 | //public string ConnectionID;
102 | public string UniqueKinectID;
103 | public int KinectNumber; //This is the number in the SDKs list of kinects
104 | public bool isXBox360Kinect;
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/NetworkKinectCore/NetworkKinectCore.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {FEA65975-74FA-4E87-B571-A53591CE0C42}
8 | Library
9 | Properties
10 | NetworkKinectCore
11 | NetworkKinectCore
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | bin\x86\Debug\
18 | DEBUG;TRACE
19 | full
20 | x86
21 | prompt
22 | MinimumRecommendedRules.ruleset
23 | ..\3rd Party\VrpnNet\x86\Debug\VrpnNet.dll
24 |
25 |
26 | bin\x86\Release\
27 | TRACE
28 | true
29 | pdbonly
30 | x86
31 | prompt
32 | MinimumRecommendedRules.ruleset
33 | ..\3rd Party\VrpnNet\x86\Release\VrpnNet.dll
34 |
35 |
36 | true
37 | bin\x64\Debug\
38 | DEBUG;TRACE
39 | full
40 | x64
41 | prompt
42 | MinimumRecommendedRules.ruleset
43 | ..\3rd Party\VrpnNet\x64\Debug\VrpnNet.dll
44 |
45 |
46 | bin\x64\Release\
47 | TRACE
48 | true
49 | pdbonly
50 | x64
51 | prompt
52 | MinimumRecommendedRules.ruleset
53 | ..\3rd Party\VrpnNet\x64\Release\VrpnNet.dll
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | False
68 | $(VRPNPath)
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | NetworkKinectSettingsControl.xaml
77 |
78 |
79 |
80 |
81 |
82 | {e212ea42-c987-4d89-996f-c9da49878cfd}
83 | KinectBase
84 |
85 |
86 |
87 |
88 | Designer
89 | MSBuild:Compile
90 |
91 |
92 |
93 |
100 |
--------------------------------------------------------------------------------
/KinectWithVRServer/FeedbackCore.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using Vrpn;
7 |
8 | namespace KinectWithVRServer
9 | {
10 | class FeedbackCore
11 | {
12 | private volatile bool forceStop = false;
13 | private volatile ServerRunState clientState = ServerRunState.Stopped;
14 | public ServerRunState ClientState
15 | {
16 | get { return clientState; }
17 | }
18 | public bool isRunning
19 | {
20 | get { return (clientState == ServerRunState.Running); }
21 | }
22 | private string serverName = "";
23 | private ServerCore server;
24 | private MainWindow parent;
25 | //private bool isGUI = false;
26 | internal bool isVerbose = false;
27 | private int watchedSensor;
28 |
29 | public FeedbackCore(bool verboseOutput, ServerCore serverCore, MainWindow thisParent = null)
30 | {
31 | isVerbose = verboseOutput;
32 | server = serverCore;
33 |
34 | if (thisParent != null)
35 | {
36 | //isGUI = true;
37 | parent = thisParent;
38 | }
39 | }
40 |
41 | public void StartFeedbackCore(string trackerName, int sensorNumber)
42 | {
43 | serverName = trackerName;
44 | watchedSensor = sensorNumber;
45 |
46 | forceStop = false;
47 | clientState = ServerRunState.Starting;
48 | RunFeedbackCoreDelegate feedbackDelegate = RunFeedbackCore;
49 | feedbackDelegate.BeginInvoke(null, null);
50 | }
51 |
52 | public void StopFeedbackCore()
53 | {
54 | forceStop = true;
55 | int count = 0;
56 | int maxCount = 50;
57 | while (count < maxCount) //Wait for the core to stop
58 | {
59 | if (clientState == ServerRunState.Stopped)
60 | {
61 | break;
62 | }
63 | Thread.Sleep(10);
64 | }
65 | if (count >= maxCount && clientState != ServerRunState.Stopped)
66 | {
67 | throw new Exception("Could not stop feedback core!");
68 | }
69 | }
70 |
71 | private void RunFeedbackCore()
72 | {
73 | //Connection clientConnection = Connection.GetConnectionByName(serverName);
74 | using (TrackerRemote client = new TrackerRemote(serverName))
75 | {
76 | client.PositionChanged += client_PositionChanged;
77 | clientState = ServerRunState.Running;
78 |
79 | while (!forceStop)
80 | {
81 | //clientConnection.Update();
82 | client.Update();
83 | Thread.Yield();
84 | }
85 |
86 | clientState = ServerRunState.Stopping;
87 | client.PositionChanged -= client_PositionChanged;
88 | //client.Dispose();
89 | //clientConnection.Dispose();
90 | }
91 | clientState = ServerRunState.Stopped;
92 | }
93 |
94 | private void client_PositionChanged(object sender, TrackerChangeEventArgs e)
95 | {
96 | if (e.Sensor == watchedSensor)
97 | {
98 | server.feedbackPosition = (System.Windows.Media.Media3D.Point3D)e.Position;
99 | updateAudioBeamAngles(server.feedbackPosition.Value);
100 | System.Diagnostics.Debug.WriteLine("Position: " + server.feedbackPosition.Value.X + ", " + server.feedbackPosition.Value.Y + ", " + server.feedbackPosition.Value.Z);
101 | }
102 | }
103 |
104 | private void updateAudioBeamAngles(System.Windows.Media.Media3D.Point3D feedbackPosition)
105 | {
106 | for (int i = 0; i < server.kinects.Count; i++)
107 | {
108 | if (server.kinects[i].version == KinectBase.KinectVersion.KinectV1)
109 | {
110 | if (((KinectV1Wrapper.Settings)server.serverMasterOptions.kinectOptionsList[i]).audioTrackMode == KinectBase.AudioTrackingMode.Feedback)
111 | {
112 | ((KinectV1Wrapper.Core)server.kinects[i]).UpdateAudioAngle(feedbackPosition);
113 | }
114 | }
115 | else if (server.kinects[i].version == KinectBase.KinectVersion.KinectV2)
116 | {
117 | if (((KinectV2Wrapper.Settings)server.serverMasterOptions.kinectOptionsList[i]).audioTrackMode == KinectBase.AudioTrackingMode.Feedback)
118 | {
119 | ((KinectV2Wrapper.Core)server.kinects[i]).UpdateAudioAngle(feedbackPosition);
120 | }
121 | }
122 | }
123 | }
124 |
125 | private delegate void RunFeedbackCoreDelegate();
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/KinectWithVRServer/ConsoleUI.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 |
4 | namespace KinectWithVRServer
5 | {
6 | static class ConsoleUI
7 | {
8 | internal static void RunServerInConsole(bool isVerbose, bool autoStart, string startupFile, AvaliableDLLs dlls)
9 | {
10 | Console.Clear();
11 | Console.WriteLine("Welcome to the Kinect With VR (KVR) Server!");
12 | Console.WriteLine("Press the \"E\" key at any time to exit.");
13 |
14 | //Notify the user if DLLs are missing
15 | if (!dlls.HasKinectV1)
16 | {
17 | Console.WriteLine("Warning: Kinect v1 support is unavaliable due to missing DLLs");
18 | }
19 | if (!dlls.HasKinectV2)
20 | {
21 | Console.WriteLine("Warning: Kinect v2 support is unavaliable due to missing DLLs");
22 | }
23 | if (!dlls.HasNetworkedKinect)
24 | {
25 | Console.WriteLine("Warning: Networked Kinect support is unavaliable due to missing DLLs");
26 | }
27 |
28 | KinectBase.MasterSettings settings = new KinectBase.MasterSettings();
29 |
30 | try
31 | {
32 | settings = HelperMethods.LoadSettings(startupFile);
33 | }
34 | catch
35 | {
36 | HelperMethods.WriteToLog("Cannot open settings file!");
37 | }
38 |
39 | ServerCore server = new ServerCore(isVerbose, settings);
40 | for (int i = 0; i < server.serverMasterOptions.kinectOptionsList.Count; i++) //Launch the Kinects
41 | {
42 | if (server.serverMasterOptions.kinectOptionsList[i].version == KinectBase.KinectVersion.KinectV1)
43 | {
44 | if (dlls.HasKinectV1)
45 | {
46 | //server.kinects.Add(new KinectV1Core.KinectCoreV1(ref server.serverMasterOptions, false, server.serverMasterOptions.kinectOptionsList[i].kinectID));
47 | server.kinects.Add(new KinectV1Wrapper.Core(ref server.serverMasterOptions, false, server.serverMasterOptions.kinectOptionsList[i].kinectID));
48 | }
49 | else
50 | {
51 | Console.WriteLine("Cannot load Kinect v1 with ID: {0} due to missing DLLs.", server.serverMasterOptions.kinectOptionsList[i].kinectID);
52 | }
53 | }
54 | else if (server.serverMasterOptions.kinectOptionsList[i].version == KinectBase.KinectVersion.KinectV2)
55 | {
56 | if (dlls.HasKinectV2)
57 | {
58 | server.kinects.Add(new KinectV2Wrapper.Core(ref server.serverMasterOptions, false, server.serverMasterOptions.kinectOptionsList[i].kinectID));
59 | }
60 | else
61 | {
62 | Console.WriteLine("Cannot load Kinect v2 with ID: {0} due to missing DLLs.", server.serverMasterOptions.kinectOptionsList[i].kinectID);
63 | }
64 | }
65 | else if (server.serverMasterOptions.kinectOptionsList[i].version == KinectBase.KinectVersion.NetworkKinect)
66 | {
67 | if (dlls.HasNetworkedKinect)
68 | {
69 | server.kinects.Add(new NetworkKinectWrapper.Core(ref server.serverMasterOptions, false, server.serverMasterOptions.kinectOptionsList[i].kinectID, server.serverMasterOptions.kinectOptionsList[i].uniqueKinectID));
70 | }
71 | else
72 | {
73 | Console.WriteLine("Cannot load network Kinect with ID: {0} due to missing DLLs.", server.serverMasterOptions.kinectOptionsList[i].kinectID);
74 | }
75 | }
76 | else
77 | {
78 | Console.WriteLine("Kinect number {0} was of an unknown version and could not be opened.", i);
79 | }
80 | }
81 | server.launchServer(); //This will still try to launch with default settings even if the settings load fails
82 |
83 | bool running = true;
84 | while (running)
85 | {
86 | Thread.Sleep(100);
87 | if (Console.KeyAvailable)
88 | {
89 | ConsoleKeyInfo key = Console.ReadKey(false);
90 | if (key.Key == ConsoleKey.E || (key.Key == ConsoleKey.C && key.Modifiers == ConsoleModifiers.Control))
91 | {
92 | running = false;
93 | }
94 | }
95 | }
96 |
97 | Console.WriteLine(); //Write a blank so the next statement has its own line
98 | Console.WriteLine("Shutting down the server. Please wait...");
99 | server.stopServer();
100 |
101 | NativeInterop.FreeConsole();
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/KinectV2Core/KinectV2Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {BA6C3333-EE04-4238-8B0B-EEEF5951F51A}
8 | Library
9 | Properties
10 | KinectV2Core
11 | KinectV2Core
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | bin\x86\Debug\
18 | DEBUG;TRACE
19 | full
20 | x86
21 | prompt
22 | MinimumRecommendedRules.ruleset
23 | true
24 |
25 |
26 | bin\x86\Release\
27 | TRACE
28 | true
29 | pdbonly
30 | x86
31 | prompt
32 | MinimumRecommendedRules.ruleset
33 | true
34 |
35 |
36 | true
37 | bin\x64\Debug\
38 | DEBUG;TRACE
39 | full
40 | x64
41 | prompt
42 | MinimumRecommendedRules.ruleset
43 | true
44 |
45 |
46 | bin\x64\Release\
47 | TRACE
48 | true
49 | pdbonly
50 | x64
51 | prompt
52 | MinimumRecommendedRules.ruleset
53 | true
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | KinectV2SettingsControl.xaml
74 |
75 |
76 | KinectV2SkeletonControl.xaml
77 |
78 |
79 |
80 |
81 |
82 |
83 | Designer
84 | MSBuild:Compile
85 |
86 |
87 | Designer
88 | MSBuild:Compile
89 |
90 |
91 |
92 |
93 | {e212ea42-c987-4d89-996f-c9da49878cfd}
94 | KinectBase
95 |
96 |
97 |
98 |
105 |
--------------------------------------------------------------------------------
/KinectWithVRServer/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Windows;
7 | using System.Diagnostics;
8 | using System.IO;
9 | using System.Threading;
10 | using System.Runtime.InteropServices;
11 |
12 | namespace KinectWithVRServer
13 | {
14 | ///
15 | /// Interaction logic for App.xaml
16 | ///
17 | public partial class App : Application
18 | {
19 | private void Application_Startup(object sender, StartupEventArgs e)
20 | {
21 | //Argument booleans
22 | bool parentCommandLine = false;
23 | bool newCommandLine = false;
24 | bool help = false;
25 | bool connected = false;
26 | bool verbose = false;
27 | bool autoStart = false;
28 | string startupFile = "";
29 |
30 | string[] args = e.Args;
31 |
32 | //Parse command line arguments
33 | for (int i = 0; i < args.Length; i++)
34 | {
35 | if((args[i].ToLower() == "-c" || args[i].ToLower() == "/c") && !newCommandLine)
36 | {
37 | parentCommandLine = true;
38 | }
39 | else if (args[i].ToLower() == "-nc" || args[i].ToLower() == "/nc")
40 | {
41 | parentCommandLine = false;
42 | newCommandLine = true;
43 | }
44 | else if (args[i].ToLower() == "-v" || args[i].ToLower() == "/v")
45 | {
46 | verbose = true;
47 | }
48 | else if (args[i].ToLower() == "-s" || args[i].ToLower() == "/s")
49 | {
50 | autoStart = true;
51 | }
52 | else if(args[i].ToLower() == "-h" || args[i].ToLower() == "/h" || args[i].ToLower() == "-?" || args[i].ToLower() == "/?")
53 | {
54 | help = true;
55 | connected = NativeInterop.AttachConsole(-1);
56 | if (connected)
57 | {
58 | Console.WriteLine();
59 | Console.WriteLine();
60 | Console.WriteLine("Usage: KinectWithVRServer [filename] [/c] [/nc] [/s] [/v]");
61 | Console.WriteLine();
62 | Console.WriteLine("Options:");
63 | Console.WriteLine("\t/c\tLaunches the program in the pre-existing command line.");
64 | Console.WriteLine("\t/nc\tLaunches the program in a new command line window.");
65 | Console.WriteLine("\t/?\tShows this help message.");
66 | Console.WriteLine("\t/h\tShows this help message.");
67 | Console.WriteLine("\t/s\tStarts the server immediately upon program launch.\r\n\t\tThis is implied when launched in console mode.");
68 | Console.WriteLine("\t/v\tVerbose output mode.");
69 | NativeInterop.FreeConsole();
70 | }
71 | }
72 | else if (i == 0)
73 | {
74 | startupFile = args[i];
75 | }
76 | }
77 |
78 | if (!help)
79 | {
80 | //For Testing
81 | AvaliableDLLs dlls = new AvaliableDLLs();
82 | dlls.HasKinectV1 = VerifyDLLs.Kinect1Avaliable();
83 | dlls.HasKinectV2 = VerifyDLLs.Kinect2Avaliable();
84 | dlls.HasNetworkedKinect = VerifyDLLs.NetworkedKinectAvaliable();
85 |
86 | if (newCommandLine || parentCommandLine)
87 | {
88 | if (newCommandLine)
89 | {
90 | connected = NativeInterop.AllocConsole();
91 |
92 | }
93 | else if (parentCommandLine)
94 | {
95 | connected = NativeInterop.AttachConsole(-1);
96 |
97 | IntPtr consoleHandle = NativeInterop.GetStdHandle(-10);
98 | uint consoleMode = 0;
99 | NativeInterop.GetConsoleMode(consoleHandle, out consoleMode);
100 | NativeInterop.SetConsoleMode(consoleHandle, (uint)(consoleMode & (~0x0002)));
101 | }
102 |
103 | if (connected)
104 | {
105 | ConsoleUI.RunServerInConsole(verbose, autoStart, startupFile, dlls);
106 | }
107 | }
108 | else
109 | {
110 | //Note: You can't put the Try/Catch here to handle if there are no Kinects because the GUI will try to launch on a different thread, and thus it can't pass the error down
111 | MainWindow gui = new MainWindow(verbose, autoStart, dlls, startupFile);
112 | gui.ShowDialog();
113 | }
114 | }
115 |
116 | this.Shutdown();
117 | }
118 | }
119 | }
--------------------------------------------------------------------------------
/KinectWithVRServer/NetworkKinectWrapper/NKCore.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using KinectBase;
7 |
8 | namespace KinectWithVRServer.NetworkKinectWrapper
9 | {
10 | //This class wraps the NetworkKinectCore class to delay the DLL loading and prevent a crash in the event that the NetworkKinectCore DLL doesn't exist
11 | class Core : IKinectCore
12 | {
13 | //Private variable to hold the wrapped class
14 | private NetworkKinectCore.NetworkKinectCore realCore;
15 |
16 | //Public properties required by the interface
17 | public string uniqueKinectID
18 | {
19 | get { return realCore.uniqueKinectID; }
20 | }
21 | public int kinectID
22 | {
23 | get { return realCore.kinectID; }
24 | set { realCore.kinectID = value; }
25 | }
26 | public KinectVersion version
27 | {
28 | get { return realCore.version; }
29 | }
30 | public bool ColorStreamEnabled
31 | {
32 | get { return realCore.ColorStreamEnabled; }
33 | }
34 | public bool DepthStreamEnabled
35 | {
36 | get { return realCore.DepthStreamEnabled; }
37 | }
38 |
39 | //Public methods required by the interface
40 | public void ShutdownSensor()
41 | {
42 | realCore.ShutdownSensor();
43 | }
44 | public KinectSkeleton TransformSkeleton(KinectSkeleton skeleton)
45 | {
46 | return realCore.TransformSkeleton(skeleton);
47 | }
48 | public Joint TransformJoint(Joint joint)
49 | {
50 | return realCore.TransformJoint(joint);
51 | }
52 | public System.Windows.Point MapJointToColor(Joint joint, bool undoTransform)
53 | {
54 | return realCore.MapJointToColor(joint, undoTransform);
55 | }
56 | public System.Windows.Point MapJointToDepth(Joint joint, bool undoTransform)
57 | {
58 | return realCore.MapJointToDepth(joint, undoTransform);
59 | }
60 |
61 | //Events required by the interface
62 | public event SkeletonEventHandler SkeletonChanged;
63 | public event DepthFrameEventHandler DepthFrameReceived;
64 | public event ColorFrameEventHandler ColorFrameReceived;
65 | public event AccelerationEventHandler AccelerationChanged;
66 | public event AudioPositionEventHandler AudioPositionChanged;
67 | public event LogMessageEventHandler LogMessageGenerated;
68 |
69 | //Constructor to setup the real KinectV1Core object
70 | public Core(ref MasterSettings settings, bool isGUILaunched, int kinectNumber, string name)
71 | {
72 | realCore = new NetworkKinectCore.NetworkKinectCore(ref settings, isGUILaunched, kinectNumber, name);
73 |
74 | //Subscribe to the events so they can be forwarded
75 | realCore.SkeletonChanged += realCore_SkeletonChanged;
76 | realCore.DepthFrameReceived += realCore_DepthFrameReceived;
77 | realCore.ColorFrameReceived += realCore_ColorFrameReceived;
78 | realCore.AccelerationChanged += realCore_AccelerationChanged;
79 | realCore.AudioPositionChanged += realCore_AudioPositionChanged;
80 | realCore.LogMessageGenerated += realCore_LogMessageGenerated;
81 | }
82 |
83 | //Forward all the events
84 | private void realCore_SkeletonChanged(object sender, SkeletonEventArgs e)
85 | {
86 | if (SkeletonChanged != null)
87 | {
88 | SkeletonChanged(this, e);
89 | }
90 | }
91 | private void realCore_DepthFrameReceived(object sender, DepthFrameEventArgs e)
92 | {
93 | if (DepthFrameReceived != null)
94 | {
95 | DepthFrameReceived(this, e);
96 | }
97 | }
98 | private void realCore_ColorFrameReceived(object sender, ColorFrameEventArgs e)
99 | {
100 | if (ColorFrameReceived != null)
101 | {
102 | ColorFrameReceived(this, e);
103 | }
104 | }
105 | private void realCore_AccelerationChanged(object sender, AccelerationEventArgs e)
106 | {
107 | if (AccelerationChanged != null)
108 | {
109 | AccelerationChanged(this, e);
110 | }
111 | }
112 | private void realCore_AudioPositionChanged(object sender, AudioPositionEventArgs e)
113 | {
114 | if (AudioPositionChanged != null)
115 | {
116 | AudioPositionChanged(this, e);
117 | }
118 | }
119 | private void realCore_LogMessageGenerated(object sender, LogMessageEventArgs e)
120 | {
121 | if (LogMessageGenerated != null)
122 | {
123 | LogMessageGenerated(this, e);
124 | }
125 | }
126 |
127 | //Network Kinect specific methods
128 | public void StartNetworkKinect()
129 | {
130 | realCore.StartNetworkKinect();
131 | }
132 |
133 | //Custom conversion operator so this class can be cast as a NetworkKinectCore class
134 | public static explicit operator NetworkKinectCore.NetworkKinectCore(Core kinectCore)
135 | {
136 | return kinectCore.realCore;
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/KinectV2Core/KinectV2StatusHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Microsoft.Kinect;
7 |
8 | namespace KinectV2Core
9 | {
10 | public class KinectV2StatusHelper
11 | {
12 | public event KinectV2StatusEventHandler KinectV2StatusChanged;
13 |
14 | public KinectV2StatusHelper()
15 | {
16 | KinectSensor.GetDefault().IsAvailableChanged += KinectV2StatusHelper_IsAvailableChanged;
17 | }
18 |
19 | public static void TestKinectSDK()
20 | {
21 | KinectSensor tempSensor = KinectSensor.GetDefault();
22 | }
23 |
24 | //This is really goofy, but apparently the Kinect needs to be open before it can be avaliable
25 | public static bool StartKinectV2Service()
26 | {
27 | KinectSensor tempKinect = KinectSensor.GetDefault();
28 | tempKinect.Open();
29 |
30 | bool started = false;
31 | int timeoutCount = 0;
32 | while (!started && timeoutCount < 20)
33 | {
34 | if (tempKinect.IsAvailable)
35 | {
36 | started = true;
37 | }
38 | System.Threading.Thread.Sleep(50);
39 | timeoutCount++;
40 | }
41 |
42 |
43 | return started;
44 | }
45 |
46 | public static void StopKinectV2Service()
47 | {
48 | KinectSensor tempKinect = KinectSensor.GetDefault();
49 | tempKinect.Close();
50 | }
51 |
52 | public static KinectV2StatusEventArgs[] GetAllKinectsStatus()
53 | {
54 | //For the time being, this will always be an array with one element because of the one Kinect v2 per computer limit
55 | KinectV2StatusEventArgs[] statusArray = new KinectV2StatusEventArgs[1];
56 |
57 | for (int i = 0; i < 1; i++)
58 | {
59 | KinectV2StatusEventArgs temp = new KinectV2StatusEventArgs();
60 | temp.KinectNumber = i;
61 | KinectSensor tempKinect = KinectSensor.GetDefault();
62 |
63 | //It looks like the service can be opened at any time, and only becomes available if there is actually a Kinect attached to the computer
64 | temp.UniqueKinectID = tempKinect.UniqueKinectId;
65 | if (tempKinect.IsAvailable)
66 | {
67 | temp.Status = KinectBase.KinectStatus.Connected;
68 | System.Diagnostics.Debug.WriteLine("Kinect 2 connected (static method).");
69 | }
70 | else
71 | {
72 | if (tempKinect.IsOpen)
73 | {
74 | temp.Status = KinectBase.KinectStatus.NotReady;
75 | System.Diagnostics.Debug.WriteLine("Kinect 2 not ready (static method).");
76 | }
77 | else
78 | {
79 | temp.Status = KinectBase.KinectStatus.Disconnected;
80 | System.Diagnostics.Debug.WriteLine("Kinect 2 disconnected (static method).");
81 | }
82 | }
83 | statusArray[i] = temp;
84 | }
85 |
86 | return statusArray;
87 | }
88 |
89 | void KinectV2StatusHelper_IsAvailableChanged(object sender, IsAvailableChangedEventArgs e)
90 | {
91 | if (KinectV2StatusChanged != null) //Only do this is there are subscribers to the event
92 | {
93 | KinectV2StatusEventArgs args = new KinectV2StatusEventArgs();
94 | if (e.IsAvailable)
95 | {
96 | args.Status = KinectBase.KinectStatus.Connected;
97 | System.Diagnostics.Debug.WriteLine("Kinect 2 connected (event).");
98 | }
99 | else
100 | {
101 | if (KinectSensor.GetDefault().IsOpen)
102 | {
103 | args.Status = KinectBase.KinectStatus.NotReady;
104 | System.Diagnostics.Debug.WriteLine("Kinect 2 not ready (event).");
105 | }
106 | else
107 | {
108 | args.Status = KinectBase.KinectStatus.Disconnected;
109 | System.Diagnostics.Debug.WriteLine("Kinect 2 disconnected (event).");
110 | }
111 | }
112 | args.KinectNumber = 0; //This is always 0 because the Kinect v2 only supports 1 Kinect
113 | args.UniqueKinectID = KinectSensor.GetDefault().UniqueKinectId;
114 |
115 | OnKinectV2StatusChanged(args);
116 | }
117 | }
118 |
119 | protected virtual void OnKinectV2StatusChanged(KinectV2StatusEventArgs e)
120 | {
121 | if (KinectV2StatusChanged != null)
122 | {
123 | KinectV2StatusChanged(this, e);
124 | }
125 | }
126 | }
127 |
128 | public delegate void KinectV2StatusEventHandler(object sender, KinectV2StatusEventArgs e);
129 |
130 | public class KinectV2StatusEventArgs : EventArgs
131 | {
132 | public KinectBase.KinectStatus Status;
133 | public string UniqueKinectID;
134 | public int KinectNumber; //This is the number in the SDKs list of kinects
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV2Wrapper/KV2Core.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using KinectBase;
7 | using KinectV2Core;
8 |
9 | namespace KinectWithVRServer.KinectV2Wrapper
10 | {
11 | //This class wraps the KinectV2Core class to delay the DLL loading and prevent a crash in the event that the KinectV2Core DLL doesn't exist
12 | class Core : IKinectCore
13 | {
14 | //Private variables to manage the wrapping
15 | private KinectCoreV2 realCore;
16 |
17 | //Public properties required by the interface
18 | public string uniqueKinectID
19 | {
20 | get { return realCore.uniqueKinectID; }
21 | }
22 | public int kinectID
23 | {
24 | get { return realCore.kinectID; }
25 | set { realCore.kinectID = value; }
26 | }
27 | public KinectVersion version
28 | {
29 | get { return realCore.version; }
30 | }
31 | public bool ColorStreamEnabled
32 | {
33 | get { return realCore.ColorStreamEnabled; }
34 | }
35 | public bool DepthStreamEnabled
36 | {
37 | get { return realCore.DepthStreamEnabled; }
38 | }
39 |
40 | //Public methods required by the interface
41 | public void ShutdownSensor()
42 | {
43 | realCore.ShutdownSensor();
44 | }
45 | public KinectSkeleton TransformSkeleton(KinectSkeleton skeleton)
46 | {
47 | return realCore.TransformSkeleton(skeleton);
48 | }
49 | public Joint TransformJoint(Joint joint)
50 | {
51 | return realCore.TransformJoint(joint);
52 | }
53 | public System.Windows.Point MapJointToColor(Joint joint, bool undoTransform)
54 | {
55 | return realCore.MapJointToColor(joint, undoTransform);
56 | }
57 | public System.Windows.Point MapJointToDepth(Joint joint, bool undoTransform)
58 | {
59 | return realCore.MapJointToDepth(joint, undoTransform);
60 | }
61 |
62 | //Events required by the interface
63 | public event SkeletonEventHandler SkeletonChanged;
64 | public event DepthFrameEventHandler DepthFrameReceived;
65 | public event ColorFrameEventHandler ColorFrameReceived;
66 | public event AccelerationEventHandler AccelerationChanged;
67 | public event AudioPositionEventHandler AudioPositionChanged;
68 | public event LogMessageEventHandler LogMessageGenerated;
69 |
70 | //Constructor to setup the real KinectV2Core object
71 | public Core(ref MasterSettings settings, bool isGUILaunched, int kinectNumber)
72 | {
73 | realCore = new KinectCoreV2(ref settings, isGUILaunched, kinectNumber);
74 |
75 | //Subscribe to the events so they can be forwarded
76 | realCore.SkeletonChanged += realCore_SkeletonChanged;
77 | realCore.DepthFrameReceived += realCore_DepthFrameReceived;
78 | realCore.ColorFrameReceived += realCore_ColorFrameReceived;
79 | realCore.AccelerationChanged += realCore_AccelerationChanged;
80 | realCore.AudioPositionChanged += realCore_AudioPositionChanged;
81 | realCore.LogMessageGenerated += realCore_LogMessageGenerated;
82 | }
83 |
84 | //Forward all the events
85 | private void realCore_SkeletonChanged(object sender, SkeletonEventArgs e)
86 | {
87 | if (SkeletonChanged != null)
88 | {
89 | SkeletonChanged(this, e);
90 | }
91 | }
92 | private void realCore_DepthFrameReceived(object sender, DepthFrameEventArgs e)
93 | {
94 | if (DepthFrameReceived != null)
95 | {
96 | DepthFrameReceived(this, e);
97 | }
98 | }
99 | private void realCore_ColorFrameReceived(object sender, ColorFrameEventArgs e)
100 | {
101 | if (ColorFrameReceived != null)
102 | {
103 | ColorFrameReceived(this, e);
104 | }
105 | }
106 | private void realCore_AccelerationChanged(object sender, AccelerationEventArgs e)
107 | {
108 | if (AccelerationChanged != null)
109 | {
110 | AccelerationChanged(this, e);
111 | }
112 | }
113 | private void realCore_AudioPositionChanged(object sender, AudioPositionEventArgs e)
114 | {
115 | if (AudioPositionChanged != null)
116 | {
117 | AudioPositionChanged(this, e);
118 | }
119 | }
120 | private void realCore_LogMessageGenerated(object sender, LogMessageEventArgs e)
121 | {
122 | if (LogMessageGenerated != null)
123 | {
124 | LogMessageGenerated(this, e);
125 | }
126 | }
127 |
128 | //Kinect v2 specific methods
129 | public void StartKinectAudio()
130 | {
131 | realCore.StartKinectAudio();
132 | }
133 | public void UpdateAudioAngle(System.Windows.Media.Media3D.Point3D position)
134 | {
135 | realCore.UpdateAudioAngle(position);
136 | }
137 | public System.IO.Stream GetKinectAudioStream()
138 | {
139 | return realCore.GetKinectAudioStream();
140 | }
141 |
142 | //Custom conversion operator so this class can be cast as a KinectV2Core class
143 | public static explicit operator KinectCoreV2(Core kinectCore)
144 | {
145 | return kinectCore.realCore;
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV1Wrapper/KV1Core.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using KinectBase;
7 | using KinectV1Core;
8 |
9 | namespace KinectWithVRServer.KinectV1Wrapper
10 | {
11 | //This class wraps the KinectV1Core class to delay the DLL loading and prevent a crash in the event that the KinectV1 dll is missing
12 | class Core : IKinectCore
13 | {
14 | //Private variables to manage the wrapping
15 | private KinectCoreV1 realCore;
16 |
17 | //Public properties required by the interface
18 | public string uniqueKinectID
19 | {
20 | get { return realCore.uniqueKinectID; }
21 | }
22 | public int kinectID
23 | {
24 | get { return realCore.kinectID; }
25 | set { realCore.kinectID = value; }
26 | }
27 | public KinectVersion version
28 | {
29 | get { return realCore.version; }
30 | }
31 | public bool ColorStreamEnabled
32 | {
33 | get { return realCore.ColorStreamEnabled; }
34 | }
35 | public bool DepthStreamEnabled
36 | {
37 | get { return realCore.DepthStreamEnabled; }
38 | }
39 |
40 | //Public methods required by the interface
41 | public void ShutdownSensor()
42 | {
43 | realCore.ShutdownSensor();
44 | }
45 | public KinectSkeleton TransformSkeleton(KinectSkeleton skeleton)
46 | {
47 | return realCore.TransformSkeleton(skeleton);
48 | }
49 | public Joint TransformJoint(Joint joint)
50 | {
51 | return realCore.TransformJoint(joint);
52 | }
53 | public System.Windows.Point MapJointToColor(Joint joint, bool undoTransform)
54 | {
55 | return realCore.MapJointToColor(joint, undoTransform);
56 | }
57 | public System.Windows.Point MapJointToDepth(Joint joint, bool undoTransform)
58 | {
59 | return realCore.MapJointToDepth(joint, undoTransform);
60 | }
61 |
62 | //Events required by the interface
63 | public event SkeletonEventHandler SkeletonChanged;
64 | public event DepthFrameEventHandler DepthFrameReceived;
65 | public event ColorFrameEventHandler ColorFrameReceived;
66 | public event AccelerationEventHandler AccelerationChanged;
67 | public event AudioPositionEventHandler AudioPositionChanged;
68 | public event LogMessageEventHandler LogMessageGenerated;
69 |
70 | //Constructor to setup the real KinectV1Core object
71 | public Core(ref MasterSettings settings, bool isGUILaunched, int? kinectNumber = null)
72 | {
73 | realCore = new KinectCoreV1(ref settings, isGUILaunched, kinectNumber);
74 |
75 | //Subscribe to the events so they can be forwarded
76 | realCore.SkeletonChanged += realCore_SkeletonChanged;
77 | realCore.DepthFrameReceived += realCore_DepthFrameReceived;
78 | realCore.ColorFrameReceived += realCore_ColorFrameReceived;
79 | realCore.AccelerationChanged += realCore_AccelerationChanged;
80 | realCore.AudioPositionChanged += realCore_AudioPositionChanged;
81 | realCore.LogMessageGenerated += realCore_LogMessageGenerated;
82 | }
83 |
84 | //Forward all the events
85 | private void realCore_SkeletonChanged(object sender, SkeletonEventArgs e)
86 | {
87 | if (SkeletonChanged != null)
88 | {
89 | SkeletonChanged(this, e);
90 | }
91 | }
92 | private void realCore_DepthFrameReceived(object sender, DepthFrameEventArgs e)
93 | {
94 | if (DepthFrameReceived != null)
95 | {
96 | DepthFrameReceived(this, e);
97 | }
98 | }
99 | private void realCore_ColorFrameReceived(object sender, ColorFrameEventArgs e)
100 | {
101 | if (ColorFrameReceived != null)
102 | {
103 | ColorFrameReceived(this, e);
104 | }
105 | }
106 | private void realCore_AccelerationChanged(object sender, AccelerationEventArgs e)
107 | {
108 | if (AccelerationChanged != null)
109 | {
110 | AccelerationChanged(this, e);
111 | }
112 | }
113 | private void realCore_AudioPositionChanged(object sender, AudioPositionEventArgs e)
114 | {
115 | if (AudioPositionChanged != null)
116 | {
117 | AudioPositionChanged(this, e);
118 | }
119 | }
120 | private void realCore_LogMessageGenerated(object sender, LogMessageEventArgs e)
121 | {
122 | if (LogMessageGenerated != null)
123 | {
124 | LogMessageGenerated(this, e);
125 | }
126 | }
127 |
128 | //Kinect v1 specific methods
129 | public void StartKinectAudio()
130 | {
131 | realCore.StartKinectAudio();
132 | }
133 | public System.IO.Stream GetKinectAudioStream()
134 | {
135 | return realCore.GetKinectAudioStream();
136 | }
137 | public void UpdateAudioAngle(System.Windows.Media.Media3D.Point3D position)
138 | {
139 | realCore.UpdateAudioAngle(position);
140 | }
141 |
142 | //Custom conversion operator so this class can be cast as a KinectV1Core class
143 | public static explicit operator KinectCoreV1(Core kinectCore)
144 | {
145 | return kinectCore.realCore;
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/KinectWithVRServer/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/KinectV1Core/AdvancedColorWindow.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | White Balance
15 |
16 |
17 | Saturation
18 |
19 | Gamma
20 |
21 | Hue
22 |
23 |
24 |
25 |
26 | Sharpness
27 |
28 | Contrast
29 |
30 | Powerline Frequency
31 |
32 |
33 |
34 |
35 |
36 | Backlight Compensation
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | Brightness
47 |
48 | Gain
49 |
50 | Frame Delay (ms)
51 |
52 | Exposure (ms)
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/NetworkKinectCore/NetworkKinectSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.ObjectModel;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Media.Media3D;
8 | using KinectBase;
9 |
10 | namespace NetworkKinectCore
11 | {
12 | public class NetworkKinectSettings : KinectBase.IKinectSettings
13 | {
14 | //Constructors
15 | public NetworkKinectSettings() { } //Needed for serialization, do not use otherwise!
16 | public NetworkKinectSettings(string uniqueID, int kinectNumber)
17 | {
18 | uniqueKinectID = uniqueID;
19 | kinectID = kinectNumber;
20 |
21 | //Set any necessary default values here
22 | mergeSkeletons = true; //this will always be true, as a networked kinects only job is to pull in skeletons to merge
23 | kinectPosition = new Point3D(0.0, 0.0, 0.0);
24 | kinectYaw = 0.0;
25 | kinectRoll = 0.0;
26 | kinectPitch = 0.0;
27 | lhChannel = 1;
28 | rhChannel = 0;
29 |
30 | //Initialize the joint mappings
31 | jointMappings = new ObservableCollection();
32 | for (int i = 0; i <= 26; i++)
33 | {
34 | JointType? tempJoint = mapChannelNumberToJoint(i);
35 | if (tempJoint.HasValue)
36 | {
37 | JointMapping temp = new JointMapping(tempJoint.Value, i, 0.01);
38 | jointMappings.Add(temp);
39 | }
40 | }
41 | }
42 |
43 | //Properties required by the IKinectSettings interface
44 | public string uniqueKinectID { get; set; }
45 | public int kinectID { get; set; }
46 | public KinectVersion version
47 | {
48 | get { return KinectVersion.NetworkKinect; }
49 | }
50 | public bool mergeSkeletons { get; set; }
51 |
52 | //Name of VRPN skeleton server
53 | public string serverName { get; set; }
54 |
55 | #region Physical Settings
56 | public Point3D kinectPosition { get; set; }
57 | public double kinectYaw { get; set; }
58 | public double kinectPitch { get; set; }
59 | public double kinectRoll { get; set; }
60 | #endregion
61 |
62 | #region Joint Mapping
63 | public ObservableCollection jointMappings { get; set; }
64 | public string lhServerName { get; set; }
65 | public int lhChannel { get; set; }
66 | public string rhServerName { get; set; }
67 | public int rhChannel { get; set; }
68 | #endregion
69 |
70 | //Private method to help create the initial joint mappings
71 | private JointType? mapChannelNumberToJoint(int channelNumber)
72 | {
73 | switch (channelNumber)
74 | {
75 | case 0:
76 | return JointType.Head;
77 | case 1:
78 | return JointType.ShoulderCenter;
79 | case 2:
80 | return JointType.Spine;
81 | case 3:
82 | return JointType.HipCenter;
83 | case 4:
84 | return null;
85 | case 5:
86 | return JointType.ShoulderLeft;
87 | case 6:
88 | return JointType.ElbowLeft;
89 | case 7:
90 | return JointType.WristLeft;
91 | case 8:
92 | return JointType.HandLeft;
93 | case 9:
94 | return JointType.HandTipLeft;
95 | case 10:
96 | return null;
97 | case 11:
98 | return JointType.ShoulderRight;
99 | case 12:
100 | return JointType.ElbowRight;
101 | case 13:
102 | return JointType.WristRight;
103 | case 14:
104 | return JointType.HandRight;
105 | case 15:
106 | return JointType.HandTipRight;
107 | case 16:
108 | return JointType.HipLeft;
109 | case 17:
110 | return JointType.KneeLeft;
111 | case 18:
112 | return JointType.AnkleLeft;
113 | case 19:
114 | return JointType.FootLeft;
115 | case 20:
116 | return JointType.HipRight;
117 | case 21:
118 | return JointType.KneeRight;
119 | case 22:
120 | return JointType.AnkleRight;
121 | case 23:
122 | return JointType.FootRight;
123 | case 24:
124 | return JointType.Neck;
125 | case 25:
126 | return JointType.ThumbLeft;
127 | case 26:
128 | return JointType.ThumbRight;
129 | default:
130 | return null;
131 | }
132 | }
133 | }
134 |
135 | public class JointMapping
136 | {
137 | public JointMapping(JointType jointType, int channelNumber, double positionAccuracy, bool jointEnabled = true)
138 | {
139 | joint = jointType;
140 | channel = channelNumber;
141 | accuracy = positionAccuracy;
142 | useJoint = jointEnabled;
143 | lastPosition = null;
144 | }
145 |
146 | public JointType joint { get; set; }
147 | public string jointName
148 | {
149 | get
150 | {
151 | return joint.ToString();
152 | }
153 | }
154 | public int channel { get; set; }
155 | public double accuracy { get; set; }
156 | public bool useJoint { get; set; }
157 | public Point3D? lastPosition { get; set; }
158 | public string lastPositionString
159 | {
160 | get
161 | {
162 | string temp = "N/A";
163 | if (lastPosition.HasValue)
164 | {
165 | temp = "(" + lastPosition.Value.X.ToString() + ", " + lastPosition.Value.Y.ToString() + ", " + lastPosition.Value.Z.ToString() + ")";
166 | }
167 | return temp;
168 | }
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/KinectWithVRServer/KinectV2Wrapper/KV2Settings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using KinectBase;
7 | using KinectV2Core;
8 |
9 | namespace KinectWithVRServer.KinectV2Wrapper
10 | {
11 | public class Settings : IKinectSettings
12 | {
13 | //Private variables to manage the wrapping
14 | private KinectV2Settings realSettings;
15 |
16 | //Public properties required by the interface
17 | public int kinectID
18 | {
19 | get { return realSettings.kinectID; }
20 | set { realSettings.kinectID = value; }
21 | }
22 | public KinectVersion version
23 | {
24 | get { return realSettings.version; }
25 | }
26 | public string uniqueKinectID
27 | {
28 | get { return realSettings.uniqueKinectID; }
29 | set { realSettings.uniqueKinectID = value; }
30 | }
31 | public bool mergeSkeletons
32 | {
33 | get { return realSettings.mergeSkeletons; }
34 | set { realSettings.mergeSkeletons = value; }
35 | }
36 |
37 | //Constructor to setup the real KinectV1Settings object
38 | public Settings(string uniqueID, int kinectNumber)
39 | {
40 | realSettings = new KinectV2Settings(uniqueID, kinectNumber);
41 | }
42 | public Settings() //Needed for serialization
43 | {
44 | realSettings = new KinectV2Settings();
45 | }
46 |
47 | //Public properties specific to the Kinect v2
48 | #region Color Settings
49 | public bool useColorPreview
50 | {
51 | get { return realSettings.useColorPreview; }
52 | set { realSettings.useColorPreview = value; }
53 | }
54 | public bool useIRPreview
55 | {
56 | get { return realSettings.useIRPreview; }
57 | set { realSettings.useIRPreview = value; }
58 | }
59 | public bool sendColorImage
60 | {
61 | get { return realSettings.sendColorImage; }
62 | set { realSettings.sendColorImage = value; }
63 | }
64 | public string colorServerName
65 | {
66 | get { return realSettings.colorServerName; }
67 | set { realSettings.colorServerName = value; }
68 | }
69 | public bool sendIRImage
70 | {
71 | get { return realSettings.sendIRImage; }
72 | set { realSettings.sendIRImage = value; }
73 | }
74 | public string irServerName
75 | {
76 | get { return realSettings.irServerName; }
77 | set { realSettings.irServerName = value; }
78 | }
79 | #endregion
80 |
81 | #region Depth Settings
82 | public bool scaleDepthToReliableRange
83 | {
84 | get { return realSettings.scaleDepthToReliableRange; }
85 | set { realSettings.scaleDepthToReliableRange = value; }
86 | }
87 | public bool colorizeDepth
88 | {
89 | get { return realSettings.colorizeDepth; }
90 | set { realSettings.colorizeDepth = value; }
91 | }
92 | public bool sendDepthImage
93 | {
94 | get { return realSettings.sendDepthImage; }
95 | set { realSettings.sendDepthImage = value; }
96 | }
97 | public string depthServerName
98 | {
99 | get { return realSettings.depthServerName; }
100 | set { realSettings.depthServerName = value; }
101 | }
102 | #endregion
103 |
104 | #region Skeleton and Physical Settings
105 | //Note, mergeSkeleton is up above because it is required by the interface (it doesn't have to be up there, that's just how I sorted things)
106 | public bool sendRawSkeletons
107 | {
108 | get { return realSettings.sendRawSkeletons; }
109 | set { realSettings.sendRawSkeletons = value; }
110 | }
111 | public bool transformRawSkeletons
112 | {
113 | get { return realSettings.transformRawSkeletons; }
114 | set { realSettings.transformRawSkeletons = value; }
115 | }
116 | public SkeletonSettings rawSkeletonSettings
117 | {
118 | get { return realSettings.rawSkeletonSettings; }
119 | set { realSettings.rawSkeletonSettings = value; }
120 | }
121 | public System.Windows.Media.Media3D.Point3D kinectPosition
122 | {
123 | get { return realSettings.kinectPosition; }
124 | set { realSettings.kinectPosition = value; }
125 | }
126 | public double kinectYaw
127 | {
128 | get { return realSettings.kinectYaw; }
129 | set { realSettings.kinectYaw = value; }
130 | }
131 | public double kinectPitch
132 | {
133 | get { return realSettings.kinectPitch; }
134 | set { realSettings.kinectPitch = value; }
135 | }
136 | public double kinectRoll
137 | {
138 | get { return realSettings.kinectRoll; }
139 | set { realSettings.kinectRoll = value; }
140 | }
141 | //public System.Windows.Media.Media3D.Quaternion kinectOrientation
142 | //{
143 | // get { return realSettings.kinectOrientation; }
144 | // set { realSettings.kinectOrientation = value; }
145 | //}
146 | #endregion
147 |
148 | #region Audio Settings
149 | public bool sendAudioAngle
150 | {
151 | get { return realSettings.sendAudioAngle; }
152 | set { realSettings.sendAudioAngle = value; }
153 | }
154 | public AudioTrackingMode audioTrackMode
155 | {
156 | get { return realSettings.audioTrackMode; }
157 | set { realSettings.audioTrackMode = value; }
158 | }
159 | public int audioBeamTrackSkeletonNumber
160 | {
161 | get { return realSettings.audioBeamTrackSkeletonNumber; }
162 | set { realSettings.audioBeamTrackSkeletonNumber = value; }
163 | }
164 | public string audioAngleServerName
165 | {
166 | get { return realSettings.audioAngleServerName; }
167 | set { realSettings.audioAngleServerName = value; }
168 | }
169 | public int audioAngleChannel
170 | {
171 | get { return realSettings.audioAngleChannel; }
172 | set { realSettings.audioAngleChannel = value; }
173 | }
174 | #endregion
175 |
176 | //Custom conversion operator so this class can be cast as a KinectV2Settings class
177 | public static explicit operator KinectV2Settings(Settings settings)
178 | {
179 | return settings.realSettings;
180 | }
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/KinectV1Core/KinectV1Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {1C1B1857-A092-41FA-9875-89ACF0D9710D}
8 | Library
9 | Properties
10 | KinectV1Core
11 | KinectV1Core
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | bin\x64\Debug\
18 | DEBUG;TRACE
19 | full
20 | x64
21 | prompt
22 | MinimumRecommendedRules.ruleset
23 | true
24 | ..\3rd Party\EigenWrapper\x64\Debug\EigenWrapper.dll
25 |
26 |
27 | bin\x64\Release\
28 | TRACE
29 | true
30 | pdbonly
31 | x64
32 | prompt
33 | MinimumRecommendedRules.ruleset
34 | true
35 | ..\3rd Party\EigenWrapper\x64\Release\EigenWrapper.dll
36 |
37 |
38 | true
39 | bin\x86\Debug\
40 | DEBUG;TRACE
41 | full
42 | x86
43 | prompt
44 | MinimumRecommendedRules.ruleset
45 | true
46 | ..\3rd Party\EigenWrapper\x86\Debug\EigenWrapper.dll
47 |
48 |
49 | bin\x86\Release\
50 | TRACE
51 | true
52 | pdbonly
53 | x86
54 | prompt
55 | MinimumRecommendedRules.ruleset
56 | true
57 | ..\3rd Party\EigenWrapper\x86\Release\EigenWrapper.dll
58 |
59 |
60 |
61 | $(EigenPath)
62 |
63 |
64 |
65 | C:\Program Files\Microsoft SDKs\Kinect\Developer Toolkit v1.8.0\Assemblies\Microsoft.Kinect.Toolkit.dll
66 |
67 |
68 | C:\Program Files\Microsoft SDKs\Kinect\Developer Toolkit v1.8.0\Assemblies\Microsoft.Kinect.Toolkit.Interaction.dll
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | AdvancedColorWindow.xaml
85 |
86 |
87 |
88 |
89 | KinectV1SettingsControl.xaml
90 |
91 |
92 | KinectV1SkeletonControl.xaml
93 |
94 |
95 |
96 |
97 |
98 |
99 | MSBuild:Compile
100 | Designer
101 |
102 |
103 | Designer
104 | MSBuild:Compile
105 |
106 |
107 | Designer
108 | MSBuild:Compile
109 |
110 |
111 |
112 |
113 | KinectInteraction180_32.dll
114 | PreserveNewest
115 |
116 |
117 |
118 |
119 | KinectInteraction180_64.dll
120 | PreserveNewest
121 |
122 |
123 |
124 |
125 | {e212ea42-c987-4d89-996f-c9da49878cfd}
126 | KinectBase
127 |
128 |
129 |
130 |
137 |
--------------------------------------------------------------------------------
/KinectWithVRServer/GestureRecognition/KMeans.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Media.Media3D;
7 |
8 | namespace KinectWithVRServer
9 | {
10 | class KMeans
11 | {
12 | public static List FindKMeanCentroids(List data, int clusters)
13 | {
14 | #region Initialize the centroids semi-randomly
15 | //Initialize variables
16 | Point3D mins = new Point3D(double.MaxValue, double.MaxValue, double.MaxValue);
17 | Point3D maxes = new Point3D(double.MinValue, double.MinValue, double.MinValue);
18 | Random rand = new Random();
19 |
20 | //Find the extents of the data
21 | for (int i = 0; i < data.Count; i++)
22 | {
23 | //Check the X values
24 | if (mins.X > data[i].X)
25 | {
26 | mins.X = data[i].X;
27 | }
28 | if (maxes.X < data[i].X)
29 | {
30 | maxes.X = data[i].X;
31 | }
32 |
33 | //Check the Y values
34 | if (mins.Y > data[i].Y)
35 | {
36 | mins.Y = data[i].Y;
37 | }
38 | if (maxes.Y < data[i].Y)
39 | {
40 | maxes.Y = data[i].Y;
41 | }
42 |
43 | //Check the Z values
44 | if (mins.Z > data[i].Z)
45 | {
46 | mins.Z = data[i].Z;
47 | }
48 | if (maxes.Z < data[i].Z)
49 | {
50 | maxes.Z = data[i].Z;
51 | }
52 | }
53 |
54 | List centroids = new List(clusters);
55 | for (int i = 0; i < clusters; i++)
56 | {
57 | Point3D temp = new Point3D();
58 | temp.X = rand.NextDouble() * (maxes.X - mins.X) + mins.X;
59 | temp.Y = rand.NextDouble() * (maxes.Y - mins.Y) + mins.Y;
60 | temp.Z = rand.NextDouble() * (maxes.Z - mins.Z) + mins.Z;
61 |
62 | centroids.Add(temp);
63 |
64 | //Verify that no cluster centers are the same
65 | for (int k = i - 1; k >= 0; k--)
66 | {
67 | bool same = true;
68 |
69 | if (centroids[k].X != centroids[i].X)
70 | {
71 | same = false;
72 | }
73 | else if (centroids[k].Y != centroids[i].Y)
74 | {
75 | same = false;
76 | }
77 | else if (centroids[k].Z != centroids[i].Z)
78 | {
79 | same = false;
80 | }
81 |
82 | if (same)
83 | {
84 | centroids.RemoveAt(i);
85 | i--;
86 | break;
87 | }
88 | }
89 | }
90 | #endregion
91 |
92 | List> clusterPoints = new List>();
93 | for (int i = 0; i < clusters; i++)
94 | {
95 | clusterPoints.Add(new List());
96 | }
97 |
98 |
99 | double posDiff = 1;
100 | while (posDiff > 0)
101 | {
102 | //Clear the old cluster points
103 | for (int i = 0; i < clusters; i++)
104 | {
105 | clusterPoints[i].Clear();
106 | }
107 |
108 | //Assign the points to their clusters
109 | for (int i = 0; i < data.Count; i++)
110 | {
111 | int index = FindNearestCluster(centroids, data[i]);
112 | clusterPoints[index].Add(data[i]);
113 | }
114 |
115 | //Check that all clusters have at least 1 point, if not, take 2 random points and put them in the cluster
116 | for (int i = 0; i < clusters; i++)
117 | {
118 | if (clusterPoints[i].Count < 1)
119 | {
120 | for (int j = 0; j < 3; j++)
121 | {
122 | int randCluster = rand.Next(0, clusters);
123 | if (clusterPoints[randCluster].Count > 1 && randCluster != i)
124 | {
125 | int randPoint = rand.Next(0, clusterPoints[randCluster].Count);
126 | clusterPoints[i].Add(clusterPoints[randCluster][randPoint]);
127 | clusterPoints[randCluster].RemoveAt(randPoint);
128 | }
129 | else
130 | {
131 | j--;
132 | }
133 | }
134 | }
135 | }
136 |
137 | //Check that all clusters have at least one point and recalculate the centroids
138 | posDiff = 0;
139 | for (int i = 0; i < clusters; i++)
140 | {
141 | Point3D newCentroid = FindCentroid(clusterPoints[i]);
142 | posDiff += FindDistance(newCentroid, centroids[i]);
143 | centroids[i] = newCentroid;
144 | }
145 | }
146 |
147 | return centroids;
148 | }
149 |
150 | public static int FindNearestCluster(List clusterCentroids, Point3D point)
151 | {
152 | int nearest = 0;
153 | double nearestDistance = double.MaxValue;
154 |
155 | for (int i = 0; i < clusterCentroids.Count; i++)
156 | {
157 | double newDistance = FindDistance(clusterCentroids[i], point);
158 |
159 | if (nearestDistance > newDistance)
160 | {
161 | nearestDistance = newDistance;
162 | nearest = i;
163 | }
164 | }
165 |
166 | return nearest;
167 | }
168 |
169 | public static double FindDistance(Point3D vecA, Point3D vecB)
170 | {
171 | Vector3D vec = vecB - vecA;
172 | return vec.Length;
173 | }
174 |
175 | public static Point3D FindCentroid(List clusterPoints)
176 | {
177 | Point3D centroid = new Point3D();
178 |
179 | double averageX = 0.0;
180 | double averageY = 0.0;
181 | double averageZ = 0.0;
182 | for (int j = 0; j < clusterPoints.Count; j++)
183 | {
184 | averageX += (clusterPoints[j].X - averageX) / (j + 1);
185 | averageY += (clusterPoints[j].Y - averageY) / (j + 1);
186 | averageZ += (clusterPoints[j].Z - averageZ) / (j + 1);
187 | }
188 |
189 | centroid.X = averageX;
190 | centroid.Y = averageY;
191 | centroid.Z = averageZ;
192 | return centroid;
193 | }
194 | }
195 | }
196 |
--------------------------------------------------------------------------------
/NetworkKinectCore/NetworkKinectSettingsControl.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/KinectWithVRServer/GestureRecognition/GestureSettingsUserControl.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------