added latest master + fixed binding

colorStream
nico-dev 1 year ago
commit 80d8612e48

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace KinectConnection
{
public class BodyImageStream : KinectStream
{
public override void Start()
{
throw new NotImplementedException();
}
public override void Stop()
{
throw new NotImplementedException();
}
}
}

@ -1,4 +1,5 @@
using Microsoft.Kinect; using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.Kinect;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
@ -26,6 +27,13 @@ namespace KinectConnection
/// </summary> /// </summary>
private ColorFrameReader reader; private ColorFrameReader reader;
public WriteableBitmap Bitmap { get { return bitmap; } set { SetProperty(ref bitmap, value); } }
public ColorImageStream() : base()
{
}
public override void Start() public override void Start()
{ {
// create the colorFrameDescription from the ColorFrameSource using rgba format // create the colorFrameDescription from the ColorFrameSource using rgba format

@ -44,6 +44,7 @@
<HintPath>..\..\..\..\..\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Assemblies\Microsoft.Kinect.dll</HintPath> <HintPath>..\..\..\..\..\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Assemblies\Microsoft.Kinect.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath> <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
@ -75,6 +76,7 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BodyImageStream.cs" />
<Compile Include="ColorImageStream.cs" /> <Compile Include="ColorImageStream.cs" />
<Compile Include="DepthImageStream.cs" /> <Compile Include="DepthImageStream.cs" />
<Compile Include="InfraredImageStream.cs" /> <Compile Include="InfraredImageStream.cs" />

@ -12,6 +12,8 @@ namespace KinectConnection
private bool status; private bool status;
private string statusText; private string statusText;
public KinectSensor KinectSensor { get { return kinectSensor; } }
/// <summary> /// <summary>
/// Initializes a new instance of the KinectManager class. /// Initializes a new instance of the KinectManager class.
/// </summary> /// </summary>

@ -1,11 +1,12 @@
using Microsoft.Kinect; using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.Kinect;
namespace KinectConnection namespace KinectConnection
{ {
/// <summary> /// <summary>
/// Abstract class for Kinect streams. /// Abstract class for Kinect streams.
/// </summary> /// </summary>
public abstract class KinectStream public abstract class KinectStream : ObservableObject
{ {
// Redondant d'avoir KinectSensor et KinectManager ici ? (car sensor dans manager) // Redondant d'avoir KinectSensor et KinectManager ici ? (car sensor dans manager)
protected KinectSensor KinectSensor { get; set; } protected KinectSensor KinectSensor { get; set; }
@ -14,5 +15,11 @@ namespace KinectConnection
public abstract void Start(); public abstract void Start();
public abstract void Stop(); public abstract void Stop();
public KinectStream()
{
KinectSensor = KinectSensor.GetDefault();
KinectManager = new KinectManager();
}
} }
} }

@ -16,9 +16,9 @@
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="10"/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="10"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
@ -59,7 +59,8 @@
<Button Content="Color" <Button Content="Color"
Width="100" Width="100"
Height="30" Height="30"
Grid.Column="1"> Grid.Column="1"
Command="{Binding ColorCommand}">
<Button.Resources> <Button.Resources>
<Style TargetType="Border"> <Style TargetType="Border">
<Setter Property="CornerRadius" Value="5"/> <Setter Property="CornerRadius" Value="5"/>
@ -107,5 +108,11 @@
</Button.Resources> </Button.Resources>
</Button> </Button>
</Grid> </Grid>
<Grid Grid.Row="4">
<Viewbox Grid.Row="1" HorizontalAlignment="Center">
<Image Source="{Binding KinectStream.Bitmap}"/>
</Viewbox>
</Grid>
</Grid> </Grid>
</Window> </Window>

@ -13,8 +13,11 @@ namespace KinectSensorStreams.ViewModel
/// </summary> /// </summary>
public ICommand StartCommand { get; set; } public ICommand StartCommand { get; set; }
public ICommand ColorCommand { get; set; }
/// <summary> /// <summary>
/// Propriété liée à l'objet KinectManager /// Propriété liée à l'objet KinectManager
/// Maybe to remove now that we have the KinectStream attribute
/// </summary> /// </summary>
public KinectManager KinectManager { get; set; } public KinectManager KinectManager { get; set; }
@ -68,6 +71,11 @@ namespace KinectSensorStreams.ViewModel
KinectStream.Start(); KinectStream.Start();
} }
private void Color()
{
ColorImageStream.Start();
}
#endregion #endregion
} }
} }

Loading…
Cancel
Save