diff --git a/Sources/Lib/Class1.cs b/Sources/Lib/Class1.cs
deleted file mode 100644
index dfbc46b..0000000
--- a/Sources/Lib/Class1.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Lib
-{
- public class Class1
- {
- }
-}
diff --git a/Sources/Lib/ColorImageStream.cs b/Sources/Lib/ColorImageStream.cs
new file mode 100644
index 0000000..8bdd2a2
--- /dev/null
+++ b/Sources/Lib/ColorImageStream.cs
@@ -0,0 +1,61 @@
+using Microsoft.Kinect;
+using System.ComponentModel;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+
+namespace Lib
+{
+ public class ColorImageStream : KinectStream
+ {
+ private ColorFrameReader reader;
+ public ColorFrameReader Reader {
+ get {
+ return reader;
+ }
+ set
+ {
+ reader = value;
+ }
+ }
+ public ColorImageStream() : base()
+ {
+ var frameDescription = KinectManager.Sensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra);
+ this.Bitmap = new WriteableBitmap(frameDescription.Width, frameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);
+ reader = KinectManager.Sensor.ColorFrameSource.OpenReader();
+ reader.FrameArrived += Reader_FrameArrived;
+ }
+
+ private void Reader_FrameArrived(object sender, ColorFrameArrivedEventArgs e)
+ {
+ using (var colorFrame = e.FrameReference.AcquireFrame())
+ {
+ if (colorFrame != null)
+ {
+ // ... Logique existante pour traiter la frame
+ //Debug.WriteLine("Traitement de la frame de couleur.");
+ FrameDescription colorFrameDescription = colorFrame.FrameDescription;
+
+ using (KinectBuffer colorBuffer = colorFrame.LockRawImageBuffer())
+ {
+ this.Bitmap.Lock();
+
+ // Vérifier si la taille de l'image a changé
+ if ((colorFrameDescription.Width == this.Bitmap.PixelWidth) && (colorFrameDescription.Height == this.Bitmap.PixelHeight))
+ {
+ colorFrame.CopyConvertedFrameDataToIntPtr(
+ this.Bitmap.BackBuffer,
+ (uint)(colorFrameDescription.Width * colorFrameDescription.Height * 4),
+ ColorImageFormat.Bgra);
+
+ this.Bitmap.AddDirtyRect(new Int32Rect(0, 0, this.Bitmap.PixelWidth, this.Bitmap.PixelHeight));
+ }
+
+ this.Bitmap.Unlock();
+ }
+ //Debug.WriteLine("Frame de couleur traitée.");
+ }
+ }
+ }
+ }
+}
diff --git a/Sources/Lib/KinectManager.cs b/Sources/Lib/KinectManager.cs
new file mode 100644
index 0000000..bf9ce2b
--- /dev/null
+++ b/Sources/Lib/KinectManager.cs
@@ -0,0 +1,75 @@
+using Microsoft.Kinect;
+using System.ComponentModel;
+using System.Diagnostics;
+
+namespace Lib
+{
+ public class KinectManager : INotifyPropertyChanged
+ {
+ private KinectSensor sensor;
+ public KinectSensor Sensor {
+ get {
+ return sensor;
+ }
+ set
+ {
+ sensor = value;
+ OnPropertyChanged(nameof(Sensor));
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ protected virtual void OnPropertyChanged(string propertyName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ public KinectManager()
+ {
+ sensor = KinectSensor.GetDefault();
+ }
+ public void StartSensor()
+ {
+ if (sensor != null) {
+ sensor.Open();
+ }
+ }
+ public void StopSensor()
+ {
+ if (sensor != null)
+ {
+ sensor.Close();
+ }
+ }
+ public bool Status
+ {
+ get { return Sensor != null && Sensor.IsAvailable; }
+ }
+ public string StatusText
+ {
+ get
+ {
+ if (Sensor == null)
+ {
+ return "Kinect n'est pas connecté";
+ }
+ else if (!Sensor.IsOpen)
+ {
+ return "Kinect n'est pas ouvert";
+ }
+ else if (Sensor.IsAvailable)
+ {
+ return "Kinect est disponible";
+ }
+ else
+ {
+ return "Kinect n'est pas disponible";
+ }
+ }
+ }
+ private void KinectSensor_IsAvailableChanged(object sender, IsAvailableChangedEventArgs args)
+ {
+ // Vous pouvez ajouter ici une logique supplémentaire si nécessaire
+ }
+ }
+}
diff --git a/Sources/Lib/KinectStream.cs b/Sources/Lib/KinectStream.cs
new file mode 100644
index 0000000..61d2fdf
--- /dev/null
+++ b/Sources/Lib/KinectStream.cs
@@ -0,0 +1,51 @@
+using Microsoft.Kinect;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+
+namespace Lib
+{
+ public abstract class KinectStream : INotifyPropertyChanged
+ {
+ public KinectManager KinectManager { get; private set; }
+ private WriteableBitmap bitmap;
+ public WriteableBitmap Bitmap
+ {
+ get { return bitmap; }
+ protected set
+ {
+ if (bitmap != value)
+ {
+ bitmap = value;
+ OnPropertyChanged(nameof(bitmap));
+ }
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ public void OnPropertyChanged(string propertyName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ public KinectStream()
+ {
+ KinectManager = new KinectManager();
+ }
+
+ public virtual void Start()
+ {
+ KinectManager.StartSensor();
+ }
+
+ public virtual void Stop()
+ {
+ KinectManager.StopSensor();
+ }
+ }
+}
diff --git a/Sources/Lib/Lib.csproj b/Sources/Lib/Lib.csproj
index 12682ba..dd258d7 100644
--- a/Sources/Lib/Lib.csproj
+++ b/Sources/Lib/Lib.csproj
@@ -1,10 +1,10 @@
-
+
Debug
AnyCPU
- 0751c83e-7845-4e5f-a5d3-e11aba393aca
+ {0751C83E-7845-4E5F-A5D3-E11ABA393ACA}
Library
Properties
Lib
@@ -31,24 +31,28 @@
4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ ..\packages\Microsoft.Kinect.2.0.1410.19000\lib\net45\Microsoft.Kinect.dll
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/Sources/Lib/packages.config b/Sources/Lib/packages.config
new file mode 100644
index 0000000..f7f19c3
--- /dev/null
+++ b/Sources/Lib/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/Sources/WpfApp/MainWindow.xaml.cs b/Sources/WpfApp/MainWindow.xaml.cs
index b23f2d9..4e07a65 100644
--- a/Sources/WpfApp/MainWindow.xaml.cs
+++ b/Sources/WpfApp/MainWindow.xaml.cs
@@ -1,6 +1,8 @@
-using Microsoft.Kinect;
+using Lib;
+using Microsoft.Kinect;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -62,8 +64,6 @@ namespace WpfApp
public MainWindow()
{
InitializeComponent();
-
- // Définir le DataContext pour le binding
this.DataContext = this;
// Initialiser la Kinect
diff --git a/Sources/WpfApp/WpfApp.csproj b/Sources/WpfApp/WpfApp.csproj
index 950c7f9..766b946 100644
--- a/Sources/WpfApp/WpfApp.csproj
+++ b/Sources/WpfApp/WpfApp.csproj
@@ -98,5 +98,11 @@
+
+
+ {0751c83e-7845-4e5f-a5d3-e11aba393aca}
+ Lib
+
+
\ No newline at end of file