diff --git a/KinectConnection/ColorImageStream.cs b/KinectConnection/ColorImageStream.cs
index ab14316..b757dea 100644
--- a/KinectConnection/ColorImageStream.cs
+++ b/KinectConnection/ColorImageStream.cs
@@ -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
///
public class ColorImageStream : KinectStream
{
+ ///
+ /// The writeable bitmap.
+ ///
+ private WriteableBitmap bitmap = null;
+
+ ///
+ /// The color frame reader.
+ ///
+ 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;
+ }
+ }
+
+ ///
+ /// METHOD FROM THE SAMPLE
+ /// Handles the color frame data arriving from the sensor.
+ ///
+ /// object sending the event
+ /// event arguments
+ 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();
+ }
}
}
}
diff --git a/KinectConnection/KinectConnection.csproj b/KinectConnection/KinectConnection.csproj
index 50fb200..0697207 100644
--- a/KinectConnection/KinectConnection.csproj
+++ b/KinectConnection/KinectConnection.csproj
@@ -40,8 +40,10 @@
..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
- ..\packages\Microsoft.Kinect.2.0.1410.19000\lib\net45\Microsoft.Kinect.dll
+ False
+ ..\..\..\..\..\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Assemblies\Microsoft.Kinect.dll
+
..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
@@ -70,12 +72,18 @@
+
+
+
+
+
+
diff --git a/KinectConnection/app.config b/KinectConnection/app.config
new file mode 100644
index 0000000..688b079
--- /dev/null
+++ b/KinectConnection/app.config
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/KinectConnection/packages.config b/KinectConnection/packages.config
index 7fc340b..8965839 100644
--- a/KinectConnection/packages.config
+++ b/KinectConnection/packages.config
@@ -2,7 +2,6 @@
-
diff --git a/KinectSensorStreams/KinectSensorStreams.csproj b/KinectSensorStreams/KinectSensorStreams.csproj
index 37e7391..c63f408 100644
--- a/KinectSensorStreams/KinectSensorStreams.csproj
+++ b/KinectSensorStreams/KinectSensorStreams.csproj
@@ -12,7 +12,6 @@
-