🚧 ColorImageStream setup attempt

ui-window
Nicolas FRANCO 1 year ago
parent 7c0db8cd7e
commit f3f6456d1f

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Kinect;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace KinectConnection
{
@ -11,14 +9,84 @@ namespace KinectConnection
/// </summary>
public class ColorImageStream : KinectStream
{
/// <summary>
/// The writeable bitmap.
/// </summary>
private WriteableBitmap bitmap = null;
/// <summary>
/// The color frame reader.
/// </summary>
private ColorFrameReader reader;
public override void Start()
{
throw new NotImplementedException();
// create the colorFrameDescription from the ColorFrameSource using rgba format
// the dimensions of the bitmap => match the dimensions of the color frame from the Kinect sensor.
FrameDescription colorFrameDescription = this.KinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
this.bitmap = this.bitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);
// open the reader for the color frames
this.reader = this.KinectSensor.ColorFrameSource.OpenReader();
// subscribe to the event
this.reader.FrameArrived += this.Reader_ColorFrameArrived;
}
public override void Stop()
{
throw new NotImplementedException();
if (this.reader != null)
{
this.reader.FrameArrived -= this.Reader_ColorFrameArrived;
// Dispose the reader to free resources.
// If we don't dispose manualy, the gc will do it for us, but we don't know when.
this.reader.Dispose();
this.reader = null;
}
}
/// <summary>
/// METHOD FROM THE SAMPLE
/// Handles the color frame data arriving from the sensor.
/// </summary>
/// <param name="sender">object sending the event</param>
/// <param name="e">event arguments</param>
private void Reader_ColorFrameArrived(object sender, ColorFrameArrivedEventArgs e)
{
bool colorFrameProcessed = false;
// ColorFrame is IDisposable
using (ColorFrame colorFrame = e.FrameReference.AcquireFrame())
{
if (colorFrame != null)
{
FrameDescription colorFrameDescription = colorFrame.FrameDescription;
// verify data and write the new color frame data to the Writeable bitmap
if ((colorFrameDescription.Width == this.bitmap.PixelWidth) && (colorFrameDescription.Height == this.bitmap.PixelHeight))
{
if (colorFrame.RawColorImageFormat == ColorImageFormat.Bgra)
{
// ! Method not found
//colorFrame.CopyRawFrameDataToBuffer(this.bitmap.PixelBuffer);
}
else
{
// ! Method not found
//colorFrame.CopyConvertedFrameDataToBuffer(this.bitmap.PixelBuffer, ColorImageFormat.Bgra);
}
colorFrameProcessed = true;
}
}
}
// we got a frame, render
if (colorFrameProcessed)
{
// ! Method not found
//this.bitmap.Invalidate();
}
}
}
}

@ -40,8 +40,10 @@
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Kinect, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Kinect.2.0.1410.19000\lib\net45\Microsoft.Kinect.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Assemblies\Microsoft.Kinect.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<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>
@ -70,12 +72,18 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="ColorImageStream.cs" />
<Compile Include="DepthImageStream.cs" />
<Compile Include="InfraredImgaeStream.cs" />
<Compile Include="KinectManager.cs" />
<Compile Include="KinectStream.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

@ -2,7 +2,6 @@
<packages>
<package id="CommunityToolkit.Mvvm" version="8.2.2" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net48" />
<package id="Microsoft.Kinect" version="2.0.1410.19000" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />

@ -12,7 +12,6 @@
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Kinect" Version="2.0.1410.19000" />
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save