diff --git a/GestureTestApp/App.config b/GestureTestApp/App.config new file mode 100644 index 0000000..ad63fbc --- /dev/null +++ b/GestureTestApp/App.config @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GestureTestApp/App.xaml b/GestureTestApp/App.xaml new file mode 100644 index 0000000..43f10b0 --- /dev/null +++ b/GestureTestApp/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/GestureTestApp/App.xaml.cs b/GestureTestApp/App.xaml.cs new file mode 100644 index 0000000..43bf3d0 --- /dev/null +++ b/GestureTestApp/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace GestureTestApp +{ + /// + /// Logique d'interaction pour App.xaml + /// + public partial class App : Application + { + } +} diff --git a/GestureTestApp/Converter/KinectStatusToColorConverter.cs b/GestureTestApp/Converter/KinectStatusToColorConverter.cs new file mode 100644 index 0000000..d14ffa7 --- /dev/null +++ b/GestureTestApp/Converter/KinectStatusToColorConverter.cs @@ -0,0 +1,45 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media; + +namespace KinectSensorStreams.Converter +{ + /// + /// Converter permettant de convertir un bool (état du Kinect) en une couleur (Ellipse de la page principale) + /// + public class KinectStatusToColorConverter : IValueConverter + { + /// + /// Méthode pour convertir la valeur reçue + /// + /// Valeur à convertir (boolean) + /// Type de la valeur à retourner (BrushColor) + /// Paramètre (non utilisé ici) + /// Culture (non utilisée ici) + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is bool status && targetType == typeof(Brush)) + { + return status ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red); + } + + return new SolidColorBrush(Colors.Transparent); + } + + /// + /// Méthode pour convertir à l'inverse + /// + /// + /// + /// + /// + /// + /// + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/GestureTestApp/GestureTestApp.csproj b/GestureTestApp/GestureTestApp.csproj new file mode 100644 index 0000000..d20522f --- /dev/null +++ b/GestureTestApp/GestureTestApp.csproj @@ -0,0 +1,144 @@ + + + + + Debug + AnyCPU + {E44C939A-B8C8-418B-BB98-CDBCACDD5074} + WinExe + GestureTestApp + GestureTestApp + v4.7.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\CommunityToolkit.Mvvm.8.2.2\lib\netstandard2.0\CommunityToolkit.Mvvm.dll + + + ..\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 + + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll + + + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + MainWindow.xaml + + + App.xaml + Code + + + MSBuild:Compile + Designer + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + {e527438a-dfa2-4ec6-9891-d4956152b093} + KinectConnection + + + + + + + Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}. + + + + \ No newline at end of file diff --git a/GestureTestApp/Properties/AssemblyInfo.cs b/GestureTestApp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3635747 --- /dev/null +++ b/GestureTestApp/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// Les informations générales relatives à un assembly dépendent de +// l'ensemble d'attributs suivant. Pour modifier les informations +// associées à un assembly. +[assembly: AssemblyTitle("GestureTestApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("workgroup")] +[assembly: AssemblyProduct("GestureTestApp")] +[assembly: AssemblyCopyright("Copyright © workgroup 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)] + +//Pour commencer à générer des applications localisables, définissez +//CultureUtiliséePourCoder dans votre fichier .csproj +//dans . Par exemple, si vous utilisez le français +//dans vos fichiers sources, définissez à fr-FR. Puis, supprimez les marques de commentaire de +//l'attribut NeutralResourceLanguage ci-dessous. Mettez à jour "fr-FR" dans +//la ligne ci-après pour qu'elle corresponde au paramètre UICulture du fichier projet. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //où se trouvent les dictionnaires de ressources spécifiques à un thème + //(utilisé si une ressource est introuvable dans la page, + // ou dictionnaires de ressources de l'application) + ResourceDictionaryLocation.SourceAssembly //où se trouve le dictionnaire de ressources générique + //(utilisé si une ressource est introuvable dans la page, + // dans l'application ou dans l'un des dictionnaires de ressources spécifiques à un thème) +)] + + +// 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/GestureTestApp/Properties/Resources.Designer.cs b/GestureTestApp/Properties/Resources.Designer.cs new file mode 100644 index 0000000..b2ed66d --- /dev/null +++ b/GestureTestApp/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 +// +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. +// +//------------------------------------------------------------------------------ + +namespace GestureTestApp.Properties +{ + + + /// + /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. + /// + // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder + // à l'aide d'un outil, tel que ResGen ou Visual Studio. + // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen + // avec l'option /str ou régénérez votre projet VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GestureTestApp.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Remplace la propriété CurrentUICulture du thread actuel pour toutes + /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/GestureTestApp/Properties/Resources.resx b/GestureTestApp/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/GestureTestApp/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GestureTestApp/Properties/Settings.Designer.cs b/GestureTestApp/Properties/Settings.Designer.cs new file mode 100644 index 0000000..df6ae79 --- /dev/null +++ b/GestureTestApp/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace GestureTestApp.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/GestureTestApp/Properties/Settings.settings b/GestureTestApp/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/GestureTestApp/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/GestureTestApp/View/MainWindow.xaml b/GestureTestApp/View/MainWindow.xaml new file mode 100644 index 0000000..520322a --- /dev/null +++ b/GestureTestApp/View/MainWindow.xaml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GestureTestApp/View/MainWindow.xaml.cs b/GestureTestApp/View/MainWindow.xaml.cs new file mode 100644 index 0000000..9c3285e --- /dev/null +++ b/GestureTestApp/View/MainWindow.xaml.cs @@ -0,0 +1,34 @@ +using KinectSensorStreams.ViewModel; +using System.Windows; + +namespace KinectSensorStreams.View +{ + /// + /// Logique d'interaction pour MainWindow.xaml + /// + public partial class MainWindow : Window + { + #region Properties + + public MainWindowVM MainWindowVM { get; set; } + + #endregion + + #region Constructor + + public MainWindow() + { + MainWindowVM = new MainWindowVM(); + InitializeComponent(); + DataContext = MainWindowVM; + } + + public override void BeginInit() + { + base.BeginInit(); + MainWindowVM.StartCommand.Execute(null); + } + + #endregion + } +} diff --git a/GestureTestApp/ViewModel/MainWindowVM.cs b/GestureTestApp/ViewModel/MainWindowVM.cs new file mode 100644 index 0000000..8806d1c --- /dev/null +++ b/GestureTestApp/ViewModel/MainWindowVM.cs @@ -0,0 +1,168 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using KinectConnection; +using KinectConnection.enums; +using KinectUtils; +using System.Linq; +using System.Net.NetworkInformation; +using System.Windows.Input; + +namespace KinectSensorStreams.ViewModel +{ + public class MainWindowVM : ObservableObject + { + private KinectStream kinectStream; + + #region Properties + + /// + /// Propriété liée à la commande appelée au démarrage de la page principale + /// + public ICommand StartCommand { get; set; } + + public ICommand ColorCommand { get; set; } + public ICommand BodyCommand { get; set; } + public ICommand IRCommand { get; set; } + public ICommand DepthCommand { get; set; } + public ICommand BodyColorCommand { get; set; } + + /// + /// The Kinect streams factory. + /// + public KinectStreamsFactory KinectStreamsFactory { get; set; } + + /// + /// The Kinect stream property. + /// + public KinectStream KinectStream + { + get { return kinectStream; } + set { SetProperty(ref kinectStream, value); } + } + + /// + /// The Secondary Kinect stream property. + /// + public KinectStream KinectStream2 + { + get { return kinectStream; } + set { SetProperty(ref kinectStream, value); } + } + + #endregion + + #region Constructor + + /// + /// Constructeur du ViewModel de la page principale + /// + public MainWindowVM() + { + // eventuellement a enlever : + GestureManager = new GestureManager(); + + // factory + KinectStreamsFactory = new KinectStreamsFactory(new KinectManager()); + + StartCommand = new RelayCommand(Start); + // [Question] : StartCommand ici peut être mieux que BeginInit() dans MainWindow.xaml.cs ? + ColorCommand = new RelayCommand(Color); + BodyCommand = new RelayCommand(Body); + IRCommand = new RelayCommand(IR); + DepthCommand = new RelayCommand(Depth); + BodyColorCommand = new RelayCommand(BodyColor); + } + + #endregion + + #region Methods + + /// + /// Méthode initialisée au lancement de la page principale pour savoir si le Kinect est disponible ou non + /// + private void Start() + { + GestureManager.KinectManager.StartSensor(); + // Start the kinect sensor + //KinectStream.KinectManager.StartSensor(); + // Start the color stream reader + //KinectStream.Start(); + } + + private void Color() + { + if(KinectStream != null) + { + KinectStream.Stop(); + } + if (KinectStream2 != null) + { + KinectStream2.Stop(); + } + KinectStream = KinectStreamsFactory[KinectStreams.Color]; + KinectStream.Start(); + } + + private void Body() + { + if (KinectStream != null) + { + KinectStream.Stop(); + } + if (KinectStream2 != null) + { + KinectStream2.Stop(); + } + KinectStream = KinectStreamsFactory[KinectStreams.Body]; + KinectStream.Start(); + GestureManager.GestureRecognized += GestureManager.KnownGestures.FirstOrDefault().TestGesture(BodyImageStream.); + + } + + private void IR() + { + if (KinectStream != null) + { + KinectStream.Stop(); + } + if (KinectStream2 != null) + { + KinectStream2.Stop(); + } + KinectStream = KinectStreamsFactory[KinectStreams.IR]; + KinectStream.Start(); + } + + private void Depth() + { + if (KinectStream != null) + { + KinectStream.Stop(); + } + if (KinectStream2 != null) + { + KinectStream2.Stop(); + } + KinectStream = KinectStreamsFactory[KinectStreams.Depth]; + KinectStream.Start(); + } + + private void BodyColor() + { + if (KinectStream != null) + { + KinectStream.Stop(); + } + if (KinectStream2 != null) + { + KinectStream2.Stop(); + } + KinectStream = KinectStreamsFactory[KinectStreams.Color]; + KinectStream.Start(); + KinectStream2 = KinectStreamsFactory[KinectStreams.Body]; + KinectStream2.Start(); + } + + #endregion + } +} diff --git a/GestureTestApp/packages.config b/GestureTestApp/packages.config new file mode 100644 index 0000000..5a79abb --- /dev/null +++ b/GestureTestApp/packages.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/KinectConnection/BodyImageStream.cs b/KinectConnection/BodyImageStream.cs index b2be032..f348bf4 100644 --- a/KinectConnection/BodyImageStream.cs +++ b/KinectConnection/BodyImageStream.cs @@ -18,6 +18,11 @@ namespace KinectConnection /// public class BodyImageStream : KinectStream { + /// + /// Propriété liée à l'objet GestureManager + /// + //public GestureManager GestureManager { get; set; } + // Le lecteur pour les données enoyées par le Kinect private BodyFrameReader bodyFrameReader = null; diff --git a/KinectSensorStreams.sln b/KinectSensorStreams.sln index 0c0398e..783afed 100644 --- a/KinectSensorStreams.sln +++ b/KinectSensorStreams.sln @@ -13,6 +13,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyGestureBank", "MyGestureB EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PostureTester", "PostureTester\PostureTester.csproj", "{7C427E13-E012-4C29-97ED-1792BA40F063}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GestureTestApp", "GestureTestApp\GestureTestApp.csproj", "{E44C939A-B8C8-418B-BB98-CDBCACDD5074}" + ProjectSection(ProjectDependencies) = postProject + {D70B7357-6FF8-4F35-A283-8DB4217C0C85} = {D70B7357-6FF8-4F35-A283-8DB4217C0C85} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,6 +44,10 @@ Global {7C427E13-E012-4C29-97ED-1792BA40F063}.Debug|Any CPU.Build.0 = Debug|Any CPU {7C427E13-E012-4C29-97ED-1792BA40F063}.Release|Any CPU.ActiveCfg = Release|Any CPU {7C427E13-E012-4C29-97ED-1792BA40F063}.Release|Any CPU.Build.0 = Release|Any CPU + {E44C939A-B8C8-418B-BB98-CDBCACDD5074}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E44C939A-B8C8-418B-BB98-CDBCACDD5074}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E44C939A-B8C8-418B-BB98-CDBCACDD5074}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E44C939A-B8C8-418B-BB98-CDBCACDD5074}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE