diff --git a/Sources/ConsoleApp/ConsoleApp.csproj b/Sources/ConsoleApp/ConsoleApp.csproj
index e0bb9e2..11b775b 100644
--- a/Sources/ConsoleApp/ConsoleApp.csproj
+++ b/Sources/ConsoleApp/ConsoleApp.csproj
@@ -54,10 +54,6 @@
-
- {2496dfb1-eb55-47a1-a780-211e079b289d}
- LibMyGesturesBank
-
{0751c83e-7845-4e5f-a5d3-e11aba393aca}
Lib
diff --git a/Sources/ConsoleApp/Program.cs b/Sources/ConsoleApp/Program.cs
index b02defb..fb7ff8d 100644
--- a/Sources/ConsoleApp/Program.cs
+++ b/Sources/ConsoleApp/Program.cs
@@ -1,5 +1,4 @@
using Lib;
-using LibMyGesturesBank;
using Microsoft.Kinect;
using System;
using System.Collections.Generic;
diff --git a/Sources/KinectSolution.sln b/Sources/KinectSolution.sln
index 9911da0..84d68a1 100644
--- a/Sources/KinectSolution.sln
+++ b/Sources/KinectSolution.sln
@@ -7,10 +7,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfApp", "WpfApp\WpfApp.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib", "Lib\Lib.csproj", "{0751C83E-7845-4E5F-A5D3-E11ABA393ACA}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibMyGesturesBank", "LibMyGesturesBank\LibMyGesturesBank.csproj", "{2496DFB1-EB55-47A1-A780-211E079B289D}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyGesturesBank", "LibMyGesturesBank\MyGesturesBank.csproj", "{2496DFB1-EB55-47A1-A780-211E079B289D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{27D9C879-52BB-4BD7-B08D-63A534AC6D7E}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KinectUtils", "KinectUtils\KinectUtils.csproj", "{2D44487E-F514-4063-9494-2AF1E8C9E9C8}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +35,10 @@ Global
{27D9C879-52BB-4BD7-B08D-63A534AC6D7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27D9C879-52BB-4BD7-B08D-63A534AC6D7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27D9C879-52BB-4BD7-B08D-63A534AC6D7E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2D44487E-F514-4063-9494-2AF1E8C9E9C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2D44487E-F514-4063-9494-2AF1E8C9E9C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2D44487E-F514-4063-9494-2AF1E8C9E9C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2D44487E-F514-4063-9494-2AF1E8C9E9C8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Sources/KinectUtils/AllGesturesFactory.cs b/Sources/KinectUtils/AllGesturesFactory.cs
new file mode 100644
index 0000000..970478a
--- /dev/null
+++ b/Sources/KinectUtils/AllGesturesFactory.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace KinectUtils
+{
+ public class AllGesturesFactory : IGestureFactory
+ {
+ public IEnumerable CreateGestures()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Sources/LibMyGesturesBank/BaseGesture.cs b/Sources/KinectUtils/BaseGesture.cs
similarity index 83%
rename from Sources/LibMyGesturesBank/BaseGesture.cs
rename to Sources/KinectUtils/BaseGesture.cs
index 0750ecd..c12223a 100644
--- a/Sources/LibMyGesturesBank/BaseGesture.cs
+++ b/Sources/KinectUtils/BaseGesture.cs
@@ -1,11 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using Microsoft.Kinect;
-namespace LibMyGesturesBank
+namespace KinectUtils
{
public abstract class BaseGesture
{
diff --git a/Sources/KinectUtils/BaseMapping.cs b/Sources/KinectUtils/BaseMapping.cs
new file mode 100644
index 0000000..8d16076
--- /dev/null
+++ b/Sources/KinectUtils/BaseMapping.cs
@@ -0,0 +1,33 @@
+using Microsoft.Kinect;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace KinectUtils
+{
+ class BaseMapping
+ {
+ public void SubscribeToStartGesture(BaseGesture gesture)
+ {
+ throw new NotImplementedException();
+ }
+ public void SubscribeToEndGesture(BaseGesture gesture)
+ {
+ throw new NotImplementedException();
+ }
+ public void SubscribeToToggleGesture(BaseGesture gesture)
+ {
+ throw new NotImplementedException();
+ }
+ protected T Mapping(Body body)
+ {
+ throw new NotImplementedException();
+ }
+ public bool TestMapping(Body body, out T output)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Sources/KinectUtils/Gesture.cs b/Sources/KinectUtils/Gesture.cs
new file mode 100644
index 0000000..f1140b3
--- /dev/null
+++ b/Sources/KinectUtils/Gesture.cs
@@ -0,0 +1,34 @@
+using Microsoft.Kinect;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace KinectUtils
+{
+ abstract class Gesture : BaseGesture
+ {
+ protected int _maxNbOfFrames;
+ protected int _minNbOfFrames;
+ private int currentFrameCount;
+ public bool isRecognitionRunning { get; set; }
+ public int MinNbOfFrames {
+ get { return _minNbOfFrames; }
+ private set { _minNbOfFrames = value; }
+ }
+ public int MaxNbOfFrames
+ {
+ get { return _maxNbOfFrames; }
+ private set { _maxNbOfFrames = value; }
+ }
+ public override void TestGesture(Body body)
+ {
+
+ }
+ abstract protected bool TestInitialConditions(Body body);
+ abstract protected bool TestPosture(Body body);
+ abstract protected bool TestRunningGesture(Body body);
+ abstract protected bool TestEndConditions(Body body);
+ }
+}
diff --git a/Sources/KinectUtils/GestureManager.cs b/Sources/KinectUtils/GestureManager.cs
new file mode 100644
index 0000000..d9e08a5
--- /dev/null
+++ b/Sources/KinectUtils/GestureManager.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Lib;
+
+namespace KinectUtils
+{
+ static class GestureManager
+ {
+ static event EventHandler GestureRecognized;
+ static KinectManager KinectManager { get; set; }
+ static List KnownGestures { get; set; }
+
+ static public void AddGestures(IGestureFactory factory)
+ {
+ KnownGestures = (List)factory.CreateGestures();
+ }
+ static public void AddGestures(params BaseGesture[] gestures)
+ {
+ foreach (var gesture in gestures)
+ {
+ KnownGestures.Add(gesture);
+ }
+ }
+ static public void RemoveGesture(BaseGesture gesture)
+ {
+ KnownGestures.Remove(gesture);
+ }
+ static public void StartAcquiringFrames(KinectManager kinectManager)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Sources/KinectUtils/IGestureFactory.cs b/Sources/KinectUtils/IGestureFactory.cs
new file mode 100644
index 0000000..f78c453
--- /dev/null
+++ b/Sources/KinectUtils/IGestureFactory.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace KinectUtils
+{
+ interface IGestureFactory
+ {
+ IEnumerable CreateGestures();
+ }
+}
diff --git a/Sources/KinectUtils/KinectUtils.csproj b/Sources/KinectUtils/KinectUtils.csproj
new file mode 100644
index 0000000..c64f282
--- /dev/null
+++ b/Sources/KinectUtils/KinectUtils.csproj
@@ -0,0 +1,61 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {2D44487E-F514-4063-9494-2AF1E8C9E9C8}
+ Library
+ Properties
+ KinectUtils
+ KinectUtils
+ v4.7.2
+ 512
+ true
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {0751c83e-7845-4e5f-a5d3-e11aba393aca}
+ Lib
+
+
+
+
\ No newline at end of file
diff --git a/Sources/LibMyGesturesBank/Posture.cs b/Sources/KinectUtils/Posture.cs
similarity index 75%
rename from Sources/LibMyGesturesBank/Posture.cs
rename to Sources/KinectUtils/Posture.cs
index de00509..a95b2c6 100644
--- a/Sources/LibMyGesturesBank/Posture.cs
+++ b/Sources/KinectUtils/Posture.cs
@@ -1,13 +1,12 @@
-using System;
+using Microsoft.Kinect;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Microsoft.Kinect;
using System.Threading.Tasks;
-namespace LibMyGesturesBank
+namespace KinectUtils
{
-
public abstract class Posture : BaseGesture
{
protected abstract bool TestPosture(Body body);
@@ -21,7 +20,5 @@ namespace LibMyGesturesBank
}
}
- // Ajoutez ici d'autres méthodes ou propriétés nécessaires
}
-
}
diff --git a/Sources/KinectUtils/Properties/AssemblyInfo.cs b/Sources/KinectUtils/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..08c12d2
--- /dev/null
+++ b/Sources/KinectUtils/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Les informations générales relatives à un assembly dépendent de
+// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
+// associées à un assembly.
+[assembly: AssemblyTitle("KinectUtils")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("KinectUtils")]
+[assembly: AssemblyCopyright("Copyright © 2024")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
+// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
+// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
+[assembly: ComVisible(false)]
+
+// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
+[assembly: Guid("2d44487e-f514-4063-9494-2af1e8c9e9c8")]
+
+// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
+//
+// Version principale
+// Version secondaire
+// Numéro de build
+// Révision
+//
+// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
+// en utilisant '*', comme indiqué ci-dessous :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Sources/Lib/BodyImageStream.cs b/Sources/Lib/BodyImageStream.cs
index bcebacb..8b7b9bc 100644
--- a/Sources/Lib/BodyImageStream.cs
+++ b/Sources/Lib/BodyImageStream.cs
@@ -44,6 +44,7 @@ namespace Lib
Bitmap = new WriteableBitmap(framedescription.Width, framedescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);
reader = kinectmanager.Sensor.BodyFrameSource.OpenReader();
reader.FrameArrived += Reader_BodyFrameArrived;
+
// initialiser le tableau des corps
this.bodies = new Body[kinectmanager.Sensor.BodyFrameSource.BodyCount];
Canvas = skeletonCanvas;
diff --git a/Sources/Lib/ColorAndBodyImageStream.cs b/Sources/Lib/ColorAndBodyImageStream.cs
index 9ea035f..f410334 100644
--- a/Sources/Lib/ColorAndBodyImageStream.cs
+++ b/Sources/Lib/ColorAndBodyImageStream.cs
@@ -18,10 +18,14 @@ namespace Lib
public BodyFrameReader Reader
{
get { return reader; }
- set { reader = value; }
+ private set { reader = value; }
}
- //private ColorFrameReader colorReader;
+ private ColorFrameReader _colorReader;
+ public ColorFrameReader ColorReader {
+ get { return _colorReader; }
+ private set { _colorReader = value; }
+ }
private Body[] bodies;
public Body[] Bodies
@@ -36,6 +40,11 @@ namespace Lib
Reader.Dispose();
Reader = null;
}
+ if(ColorReader != null)
+ {
+ ColorReader.Dispose();
+ ColorReader = null;
+ }
}
@@ -45,6 +54,8 @@ namespace Lib
Bitmap = new WriteableBitmap(framedescription.Width, framedescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);
reader = kinectmanager.Sensor.BodyFrameSource.OpenReader();
reader.FrameArrived += Reader_BodyFrameArrived;
+ ColorReader = KinectManager.Sensor.ColorFrameSource.OpenReader();
+ ColorReader.FrameArrived += Reader_ColorFrameArrived;
// initialiser le tableau des corps
this.bodies = new Body[kinectmanager.Sensor.BodyFrameSource.BodyCount];
Canvas = skeletonCanvas;
@@ -167,5 +178,36 @@ namespace Lib
}
}
}
+ private void Reader_ColorFrameArrived(object sender, ColorFrameArrivedEventArgs e)
+ {
+ using (ColorFrame 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/KinectStreams.cs b/Sources/Lib/KinectStreams.cs
index 5744db3..7909557 100644
--- a/Sources/Lib/KinectStreams.cs
+++ b/Sources/Lib/KinectStreams.cs
@@ -12,6 +12,7 @@ namespace Lib
Color,
Depth,
IR,
+ Body,
ColorAndBody
}
}
diff --git a/Sources/Lib/KinectStreamsFactory.cs b/Sources/Lib/KinectStreamsFactory.cs
index ce211e9..1571530 100644
--- a/Sources/Lib/KinectStreamsFactory.cs
+++ b/Sources/Lib/KinectStreamsFactory.cs
@@ -31,7 +31,8 @@ namespace Lib
{ KinectStreams.Color, () => new ColorImageStream(KinectManager) },
{ KinectStreams.Depth, () => new DepthImageStream(KinectManager) },
{ KinectStreams.IR, () => new InfraredImageStream(KinectManager) },
- { KinectStreams.ColorAndBody, () => new BodyImageStream(KinectManager,SkeletonCanvas) }
+ { KinectStreams.Body, () => new BodyImageStream(KinectManager,SkeletonCanvas) },
+ { KinectStreams.ColorAndBody, () => new ColorAndBodyImageStream(KinectManager,SkeletonCanvas) }
};
}
diff --git a/Sources/LibMyGesturesBank/LibMyGesturesBank.csproj b/Sources/LibMyGesturesBank/MyGesturesBank.csproj
similarity index 89%
rename from Sources/LibMyGesturesBank/LibMyGesturesBank.csproj
rename to Sources/LibMyGesturesBank/MyGesturesBank.csproj
index 805bf1d..7a43ab1 100644
--- a/Sources/LibMyGesturesBank/LibMyGesturesBank.csproj
+++ b/Sources/LibMyGesturesBank/MyGesturesBank.csproj
@@ -8,7 +8,7 @@
Library
Properties
LibMyGesturesBank
- LibMyGesturesBank
+ MyGesturesBank
v4.7.2
512
true
@@ -44,13 +44,17 @@
-
-
+
+
+
+ {2d44487e-f514-4063-9494-2af1e8c9e9c8}
+ KinectUtils
+
{0751c83e-7845-4e5f-a5d3-e11aba393aca}
Lib
diff --git a/Sources/LibMyGesturesBank/PostureHandUp.cs b/Sources/LibMyGesturesBank/PostureHandUp.cs
index 970f01e..54b1a6e 100644
--- a/Sources/LibMyGesturesBank/PostureHandUp.cs
+++ b/Sources/LibMyGesturesBank/PostureHandUp.cs
@@ -1,11 +1,7 @@
using Microsoft.Kinect;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using KinectUtils;
-namespace LibMyGesturesBank
+namespace MyGesturesBank
{
public class PostureHandUp : Posture
{
diff --git a/Sources/LibMyGesturesBank/PostureHandsOnHead .cs b/Sources/LibMyGesturesBank/PostureHandsOnHead .cs
index 34ea5b1..7ad19b9 100644
--- a/Sources/LibMyGesturesBank/PostureHandsOnHead .cs
+++ b/Sources/LibMyGesturesBank/PostureHandsOnHead .cs
@@ -1,11 +1,8 @@
using Microsoft.Kinect;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using KinectUtils;
-namespace LibMyGesturesBank
+namespace MyGesturesBank
{
public class PostureHandsOnHead : Posture
{
diff --git a/Sources/LibMyGesturesBank/Properties/AssemblyInfo.cs b/Sources/LibMyGesturesBank/Properties/AssemblyInfo.cs
index 4138d3e..ab22671 100644
--- a/Sources/LibMyGesturesBank/Properties/AssemblyInfo.cs
+++ b/Sources/LibMyGesturesBank/Properties/AssemblyInfo.cs
@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
-[assembly: AssemblyTitle("LibMyGesturesBank")]
+[assembly: AssemblyTitle("MyGesturesBank")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("LibMyGesturesBank")]
+[assembly: AssemblyProduct("MyGesturesBank")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/Sources/LibMyGesturesBank/RightHandUp.cs b/Sources/LibMyGesturesBank/RightHandUp.cs
new file mode 100644
index 0000000..259d3a5
--- /dev/null
+++ b/Sources/LibMyGesturesBank/RightHandUp.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LibMyGesturesBank
+{
+ internal class RightHandUp
+ {
+ }
+}
diff --git a/Sources/LibMyGesturesBank/TwoHandsDragon.cs b/Sources/LibMyGesturesBank/TwoHandsDragon.cs
new file mode 100644
index 0000000..a5e9d5f
--- /dev/null
+++ b/Sources/LibMyGesturesBank/TwoHandsDragon.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LibMyGesturesBank
+{
+ internal class TwoHandsDragon
+ {
+ }
+}
diff --git a/Sources/WpfApp/MainWindow.xaml b/Sources/WpfApp/MainWindow.xaml
index 08613ef..dd3f6fb 100644
--- a/Sources/WpfApp/MainWindow.xaml
+++ b/Sources/WpfApp/MainWindow.xaml
@@ -22,12 +22,15 @@
-
-
+
+
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Sources/WpfApp/MainWindow.xaml.cs b/Sources/WpfApp/MainWindow.xaml.cs
index 181a008..823fe81 100644
--- a/Sources/WpfApp/MainWindow.xaml.cs
+++ b/Sources/WpfApp/MainWindow.xaml.cs
@@ -97,6 +97,13 @@ namespace WpfApp
CurrentKinectStream.Start();
}
+ private void ToBodyImageStream(object sender, RoutedEventArgs e)
+ {
+ CurrentKinectStream.Stop();
+ CurrentKinectStream = Factory[KinectStreams.Body];
+ Debug.WriteLine(CurrentKinectStream.GetType().Name);
+ CurrentKinectStream.Start();
+ }
private void ToColorAndBodyImageStream(object sender, RoutedEventArgs e)
{
CurrentKinectStream.Stop();