init
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo1", "Demo1\Demo1.csproj", "{1D0066B4-E5EE-4F76-97E4-0372F1EFAE1E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1D0066B4-E5EE-4F76-97E4-0372F1EFAE1E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{1D0066B4-E5EE-4F76-97E4-0372F1EFAE1E}.Debug|x86.Build.0 = Debug|x86
|
||||
{1D0066B4-E5EE-4F76-97E4-0372F1EFAE1E}.Release|x86.ActiveCfg = Release|x86
|
||||
{1D0066B4-E5EE-4F76-97E4-0372F1EFAE1E}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,8 @@
|
||||
<Application x:Class="Demo1.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace Demo1
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für "App.xaml"
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{1D0066B4-E5EE-4F76-97E4-0372F1EFAE1E}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Demo1</RootNamespace>
|
||||
<AssemblyName>Demo1</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Kinect, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>C:\Program Files\Microsoft SDKs\Kinect\v1.7\Assemblies\Microsoft.Kinect.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="SkeletalCommonExtensions.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DepthFrameConverter.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,137 @@
|
||||
using Microsoft.Kinect;
|
||||
using System.Drawing;
|
||||
|
||||
namespace KinectWorkshop
|
||||
{
|
||||
/*public class DepthFrameConverter
|
||||
{
|
||||
const int RED_IDX = 2;
|
||||
const int GREEN_IDX = 1;
|
||||
const int BLUE_IDX = 0;
|
||||
byte[] depthFrame32 = new byte[320 * 240 * 4];
|
||||
|
||||
// Converts a 16-bit grayscale depth frame which includes player indexes into a 32-bit frame
|
||||
// that displays different players in different colors
|
||||
public byte[] ConvertDepthFrameWithUser(DepthImagePixel[] depthFrame, int width, int height)
|
||||
{
|
||||
Color c = Color.Empty;
|
||||
byte[] ret = new byte[width * height * 4];
|
||||
for (int x = 1; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
int i = ((y * width) + x) * 4;
|
||||
short depth = (depthFrame[x + y * width]).Depth;
|
||||
c = Color.Empty;
|
||||
if(depth > 0 && depth <= 4000)
|
||||
{
|
||||
int depthdist = (int)((depth / 4090f) * 255f);
|
||||
c = System.Drawing.Color.FromArgb((int)(depthdist / 2f), depthdist, (int)(depthdist * 0.7f));
|
||||
}
|
||||
ret[i] = c.B;
|
||||
ret[i] = c.G;
|
||||
ret[i] = c.R;
|
||||
ret[i] = 255;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* for (int i16 = 0, i32 = 0; i16 < depthFrame16.Length && i32 < depthFrame32.Length; i16 += 2, i32 += 4)
|
||||
{
|
||||
int player = depthFrame16[i16] & 0x07;
|
||||
//if ((y - 1) * 320 + x * 4 == i16)
|
||||
//{
|
||||
// player = 8;
|
||||
//}
|
||||
int realDepth = (depthFrame16[i16 + 1] << 5) | (depthFrame16[i16] >> 3);
|
||||
// transform 13-bit depth information into an 8-bit intensity appropriate
|
||||
// for display (we disregard information in most significant bit)
|
||||
byte intensity = (byte)(255 - (255 * realDepth / 0x0fff));
|
||||
|
||||
depthFrame32[i32 + RED_IDX] = 0;
|
||||
depthFrame32[i32 + GREEN_IDX] = 0;
|
||||
depthFrame32[i32 + BLUE_IDX] = 0;
|
||||
|
||||
// choose different display colors based on player
|
||||
switch (player)
|
||||
{
|
||||
case 0:
|
||||
depthFrame32[i32 + RED_IDX] = (byte)(intensity / 2);
|
||||
depthFrame32[i32 + GREEN_IDX] = (byte)(intensity / 2);
|
||||
depthFrame32[i32 + BLUE_IDX] = (byte)(intensity / 2);
|
||||
break;
|
||||
case 1:
|
||||
depthFrame32[i32 + RED_IDX] = intensity;
|
||||
break;
|
||||
case 2:
|
||||
depthFrame32[i32 + GREEN_IDX] = intensity;
|
||||
break;
|
||||
case 3:
|
||||
depthFrame32[i32 + RED_IDX] = (byte)(intensity / 4);
|
||||
depthFrame32[i32 + GREEN_IDX] = (byte)(intensity);
|
||||
depthFrame32[i32 + BLUE_IDX] = (byte)(intensity);
|
||||
break;
|
||||
case 4:
|
||||
depthFrame32[i32 + RED_IDX] = (byte)(intensity);
|
||||
depthFrame32[i32 + GREEN_IDX] = (byte)(intensity);
|
||||
depthFrame32[i32 + BLUE_IDX] = (byte)(intensity / 4);
|
||||
break;
|
||||
case 5:
|
||||
depthFrame32[i32 + RED_IDX] = (byte)(intensity);
|
||||
depthFrame32[i32 + GREEN_IDX] = (byte)(intensity / 4);
|
||||
depthFrame32[i32 + BLUE_IDX] = (byte)(intensity);
|
||||
break;
|
||||
case 6:
|
||||
depthFrame32[i32 + RED_IDX] = (byte)(intensity / 2);
|
||||
depthFrame32[i32 + GREEN_IDX] = (byte)(intensity / 2);
|
||||
depthFrame32[i32 + BLUE_IDX] = (byte)(intensity);
|
||||
break;
|
||||
case 7:
|
||||
depthFrame32[i32 + RED_IDX] = (byte)(255 - intensity);
|
||||
depthFrame32[i32 + GREEN_IDX] = (byte)(255 - intensity);
|
||||
depthFrame32[i32 + BLUE_IDX] = (byte)(255 - intensity);
|
||||
break;
|
||||
case 8:
|
||||
depthFrame32[i32 + RED_IDX] = 255;
|
||||
depthFrame32[i32 + GREEN_IDX] = 0;
|
||||
depthFrame32[i32 + BLUE_IDX] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return depthFrame32;*
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal byte[] ConvertDepthFrame(byte[] depthFrame16)
|
||||
{
|
||||
for (int i16 = 0, i32 = 0; i16 < depthFrame16.Length && i32 < depthFrame32.Length; i16 += 2, i32 += 4)
|
||||
{
|
||||
int realDepth = (depthFrame16[i16+1] << 8)|(depthFrame16[i16]);
|
||||
//byte r = (byte)(realDepth >> 8);
|
||||
//byte b = (byte)realDepth;
|
||||
byte intensity = (byte)(255 - (255 * realDepth / 0x0fff));
|
||||
depthFrame32[i32 + RED_IDX] = (byte)((intensity * -1) + 255);// (byte)(intensity / 2);
|
||||
depthFrame32[i32 + GREEN_IDX] = (byte)((intensity * -1) + 255);// (byte)(intensity / 2);
|
||||
depthFrame32[i32 + BLUE_IDX] = (byte)((intensity * -1) + 255);// (byte)(intensity / 2);
|
||||
|
||||
}
|
||||
return depthFrame32;
|
||||
}
|
||||
|
||||
internal byte[] ConvertDepthFrameHiddenPlayer(byte[] depthFrame16)
|
||||
{
|
||||
for (int i16 = 0, i32 = 0; i16 < depthFrame16.Length && i32 < depthFrame32.Length; i16 += 2, i32 += 4)
|
||||
{
|
||||
int realDepth = (depthFrame16[i16 + 1] << 5) | (depthFrame16[i16] >> 3);
|
||||
//byte r = (byte)(realDepth >> 8);
|
||||
//byte b = (byte)realDepth;
|
||||
byte intensity = (byte)(255 - (255 * realDepth / 0x0fff));
|
||||
depthFrame32[i32 + RED_IDX] = (byte)((intensity * -1) + 255);// (byte)(intensity / 2);
|
||||
depthFrame32[i32 + GREEN_IDX] = (byte)((intensity * -1) + 255);// (byte)(intensity / 2);
|
||||
depthFrame32[i32 + BLUE_IDX] = (byte)((intensity * -1) + 255);// (byte)(intensity / 2);
|
||||
|
||||
}
|
||||
return depthFrame32;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<Window x:Class="Demo1.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="MainWindow" Height="520" Width="660" Loaded="Window_Loaded" KeyUp="Window_KeyUp">
|
||||
<Grid>
|
||||
<Image Name="imgDepth" Width="640" Height="480" />
|
||||
<!-- <StackPanel Orientation="Vertical">
|
||||
<Image Name="imgRgb" Width="320" Height="240" />
|
||||
<Image Name="imgDepthPlayer" Width="320" Height="240" />
|
||||
</StackPanel> -->
|
||||
|
||||
<Canvas Name="MainCanvas"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,257 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Microsoft.Kinect;
|
||||
|
||||
namespace Demo1
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private KinectWorkshop.DepthFrameConverter cv = new KinectWorkshop.DepthFrameConverter();
|
||||
private KinectSensor r;
|
||||
//private DepthImagePixel[] depthPixels;
|
||||
//private byte[] colorPixels;
|
||||
//private DepthImageFormat DepthFormat = DepthImageFormat.Resolution320x240Fps30;
|
||||
//private ColorImageFormat ColorFormat = ColorImageFormat.RgbResolution640x480Fps30;
|
||||
//private ColorImagePoint[] colorCoordinates;
|
||||
//private bool init = false;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (KinectSensor.KinectSensors.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Keine Kinect");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
r = KinectSensor.KinectSensors[0];
|
||||
r.Start();
|
||||
//r.Initialize(RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseDepthAndPlayerIndex);
|
||||
|
||||
//r.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(r_VideoFrameReady);
|
||||
//r.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
|
||||
//r.DepthFrameReady += r_DepthFrameReady;
|
||||
//r.DepthStream.Enable();
|
||||
//r.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);
|
||||
//r.SkeletonFrameReady += r_SkeletonFrameReady;
|
||||
r.SkeletonStream.Enable(new TransformSmoothParameters() { Smoothing = 0.1f });
|
||||
//r.SkeletonEngine.TransformSmooth = true;
|
||||
//r.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(r_SkeletonFrameReady);
|
||||
//_cam = r.NuiCamera;
|
||||
//r.AllFramesReady += R_AllFramesReady;
|
||||
r.SkeletonFrameReady += this.r_SkeletonFrameReady;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/*private void R_AllFramesReady(object sender, AllFramesReadyEventArgs e)
|
||||
{
|
||||
if(r == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool depthReceived = false;
|
||||
bool colorReceived = false;
|
||||
|
||||
using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
|
||||
{
|
||||
if (null != depthFrame)
|
||||
{
|
||||
// Copy the pixel data from the image to a temporary array
|
||||
depthFrame.CopyDepthImagePixelDataTo(this.depthPixels);
|
||||
|
||||
depthReceived = true;
|
||||
if(!init) {
|
||||
this.colorCoordinates = new ColorImagePoint[r.DepthStream.FramePixelDataLength];
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
|
||||
{
|
||||
if (null != colorFrame)
|
||||
{
|
||||
// Copy the pixel data from the image to a temporary array
|
||||
colorFrame.CopyPixelDataTo(this.colorPixels);
|
||||
|
||||
colorReceived = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (true == depthReceived)
|
||||
{
|
||||
r.CoordinateMapper.MapDepthFrameToColorFrame(
|
||||
DepthFormat,
|
||||
this.depthPixels,
|
||||
ColorFormat,
|
||||
this.colorCoordinates);
|
||||
|
||||
// ...
|
||||
|
||||
int depthIndex = x + (y * this.depthWidth);
|
||||
DepthImagePixel depthPixel = this.depthPixels[depthIndex];
|
||||
|
||||
// scale color coordinates to depth resolution
|
||||
int X = colorImagePoint.X / this.colorToDepthDivisor;
|
||||
int Y = colorImagePoint.Y / this.colorToDepthDivisor;
|
||||
|
||||
// depthPixel is the depth for the (X,Y) pixel in the color frame
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
void r_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
|
||||
{
|
||||
SkeletonFrame skf = e.OpenSkeletonFrame();
|
||||
if(skf == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Skeleton[] sks = new Skeleton[skf.SkeletonArrayLength];
|
||||
skf.CopySkeletonDataTo(sks);
|
||||
this.MainCanvas.Children.Clear();
|
||||
foreach (Skeleton sk in sks)
|
||||
{
|
||||
if (sk.TrackingState == SkeletonTrackingState.Tracked)
|
||||
{
|
||||
this.drawPlayer(sk);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawPlayer(Skeleton sk)
|
||||
{
|
||||
this.SetPoints(sk);
|
||||
this.SetLines(sk);
|
||||
}
|
||||
|
||||
private void SetLines(Skeleton sk)
|
||||
{
|
||||
JointType[,] id = {
|
||||
{ JointType.Head, JointType.ShoulderCenter },
|
||||
{ JointType.ShoulderCenter, JointType.ShoulderLeft },
|
||||
{ JointType.ShoulderCenter, JointType.ShoulderRight },
|
||||
{ JointType.ShoulderLeft, JointType.ElbowLeft },
|
||||
{ JointType.ShoulderRight, JointType.ElbowRight },
|
||||
{ JointType.ElbowLeft, JointType.WristLeft },
|
||||
{ JointType.ElbowRight, JointType.WristRight },
|
||||
{ JointType.WristLeft, JointType.HandLeft },
|
||||
{ JointType.WristRight, JointType.HandRight },
|
||||
{ JointType.ShoulderCenter, JointType.Spine },
|
||||
{ JointType.Spine, JointType.HipCenter },
|
||||
{ JointType.HipCenter, JointType.HipLeft },
|
||||
{ JointType.HipCenter, JointType.HipRight },
|
||||
{ JointType.HipLeft, JointType.KneeLeft },
|
||||
{ JointType.HipRight, JointType.KneeRight },
|
||||
{ JointType.KneeLeft, JointType.AnkleLeft },
|
||||
{ JointType.KneeRight, JointType.AnkleRight },
|
||||
{ JointType.AnkleLeft, JointType.FootLeft },
|
||||
{ JointType.AnkleRight, JointType.FootRight }
|
||||
};
|
||||
for (int i = 0; i < id.Length / 2; i++)
|
||||
{
|
||||
Joint r1 = sk.Joints[id[i, 0]].ScaleTo(640, 480);
|
||||
Joint r2 = sk.Joints[id[i, 1]].ScaleTo(640, 480);
|
||||
|
||||
/**** */
|
||||
Line l = new Line();
|
||||
l.Stroke = Brushes.Blue;
|
||||
l.StrokeThickness = 5.0;
|
||||
l.Y1 = r1.Position.Y;
|
||||
l.X1 = r1.Position.X;
|
||||
l.Y2 = r2.Position.Y;
|
||||
l.X2 = r2.Position.X;
|
||||
/**** */
|
||||
|
||||
this.MainCanvas.Children.Add(l);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPoints(Skeleton sk)
|
||||
{
|
||||
foreach (Joint joint in sk.Joints)
|
||||
{
|
||||
Joint p = joint.ScaleTo(640, 480);
|
||||
Ellipse e = new Ellipse();
|
||||
e.Fill = Brushes.Red;
|
||||
e.Stroke = Brushes.Black;
|
||||
e.Height = 10;
|
||||
e.Width = 10;
|
||||
Canvas.SetLeft(e, p.Position.X - e.Width / 2);
|
||||
Canvas.SetTop(e, p.Position.Y - e.Height / 2);
|
||||
this.MainCanvas.Children.Add(e);
|
||||
}
|
||||
}
|
||||
|
||||
/*void r_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
|
||||
{
|
||||
//PlanarImage img = e.ImageFrame.Image;
|
||||
DepthImageFrame img = e.OpenDepthImageFrame();
|
||||
if(img == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DepthImagePixel[] bs = new DepthImagePixel[img.PixelDataLength];
|
||||
img.CopyDepthImagePixelDataTo(bs);
|
||||
byte[] bh = cv.ConvertDepthFrameWithUser(bs, img.Width, img.Height);
|
||||
imgDepth.Source = BitmapSource.Create(img.Width, img.Height, 96, 96, PixelFormats.Bgr32, null, bh, img.Width * 4);
|
||||
//bh = cv.ConvertDepthFrameHiddenPlayer(img.Bits);
|
||||
//byte[] bh = cv.ConvertDepthFrame(img.Bits);
|
||||
//imgDepthPlayer.Source = BitmapSource.Create(img.Width, img.Height,
|
||||
// 96, 96, PixelFormats.Bgr32, null,
|
||||
// bh, img.Width * 4);
|
||||
}*/
|
||||
|
||||
private void Window_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.Key == Key.Up)
|
||||
{
|
||||
int k = r.ElevationAngle;
|
||||
k++;
|
||||
r.ElevationAngle = k;
|
||||
}
|
||||
if (e.Key == Key.Down)
|
||||
r.ElevationAngle -= 1;
|
||||
}
|
||||
catch (ArgumentOutOfRangeException outOfRangeException)
|
||||
{
|
||||
MessageBox.Show(outOfRangeException.Message);
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
/*void r_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
|
||||
{
|
||||
PlanarImage img = e.ImageFrame.Image;
|
||||
imgRgb.Source = BitmapSource.Create(img.Width, img.Height,
|
||||
96, 96, PixelFormats.Bgr32, null,
|
||||
img.Bits, img.Width * img.BytesPerPixel);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die mit einer Assembly verknüpft sind.
|
||||
[assembly: AssemblyTitle("Demo1")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Demo1")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2011")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
|
||||
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
|
||||
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//Um mit dem Erstellen lokalisierbarer Anwendungen zu beginnen, legen Sie
|
||||
//<UICulture>ImCodeVerwendeteKultur</UICulture> in der .csproj-Datei
|
||||
//in einer <PropertyGroup> fest. Wenn Sie in den Quelldateien beispielsweise Deutsch
|
||||
//(Deutschland) verwenden, legen Sie <UICulture> auf \"de-DE\" fest. Heben Sie dann die Auskommentierung
|
||||
//des nachstehenden NeutralResourceLanguage-Attributs auf. Aktualisieren Sie "en-US" in der nachstehenden Zeile,
|
||||
//sodass es mit der UICulture-Einstellung in der Projektdatei übereinstimmt.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //Speicherort der designspezifischen Ressourcenwörterbücher
|
||||
//(wird verwendet, wenn eine Ressource auf der Seite
|
||||
// oder in den Anwendungsressourcen-Wörterbüchern nicht gefunden werden kann.)
|
||||
ResourceDictionaryLocation.SourceAssembly //Speicherort des generischen Ressourcenwörterbuchs
|
||||
//(wird verwendet, wenn eine Ressource auf der Seite, in der Anwendung oder einem
|
||||
// designspezifischen Ressourcenwörterbuch nicht gefunden werden kann.)
|
||||
)]
|
||||
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Dieser Code wurde von einem Tool generiert.
|
||||
// Laufzeitversion:4.0.30319.239
|
||||
//
|
||||
// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
|
||||
// der Code neu generiert wird.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Demo1.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
/// </summary>
|
||||
// Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
|
||||
// über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
// mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Demo1.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
/// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.239
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Demo1.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,41 @@
|
||||
using Microsoft.Kinect;
|
||||
using System.Windows;
|
||||
|
||||
namespace Demo1
|
||||
{
|
||||
internal static class SkeletalCommonExtensions
|
||||
{
|
||||
public static Joint ScaleTo(this Joint joint, int width, int height, float skeletonMaxX, float skeletonMaxY)
|
||||
{
|
||||
SkeletonPoint pos = new SkeletonPoint()
|
||||
{
|
||||
X = Scale(width, skeletonMaxX, joint.Position.X),
|
||||
Y = Scale(height, skeletonMaxY, -joint.Position.Y),
|
||||
Z = joint.Position.Z
|
||||
};
|
||||
|
||||
Joint j = new Joint()
|
||||
{
|
||||
TrackingState = joint.TrackingState,
|
||||
Position = pos
|
||||
};
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
public static Joint ScaleTo(this Joint joint, int width, int height)
|
||||
{
|
||||
return ScaleTo(joint, width, height, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
private static float Scale(int maxPixel, float maxSkeleton, float position)
|
||||
{
|
||||
float value = ((((maxPixel / maxSkeleton) / 2) * position) + (maxPixel / 2));
|
||||
if (value > maxPixel)
|
||||
return maxPixel;
|
||||
if (value < 0)
|
||||
return 0;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user