From 3f50afff4c484b8fba6630844c4a1059b0d32f30 Mon Sep 17 00:00:00 2001 From: "louis.dufour" Date: Thu, 11 Jan 2024 12:01:05 +0100 Subject: [PATCH 1/5] =?UTF-8?q?Add(SqueletteCaptor):=20Une=20petit=20d?= =?UTF-8?q?=C3=A9but?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/WpfApp/MainWindow.xaml | 2 + Sources/WpfApp/MainWindow.xaml.cs | 70 ++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/Sources/WpfApp/MainWindow.xaml b/Sources/WpfApp/MainWindow.xaml index 4ebe115..5e4a5e2 100644 --- a/Sources/WpfApp/MainWindow.xaml +++ b/Sources/WpfApp/MainWindow.xaml @@ -27,5 +27,7 @@ + + \ No newline at end of file diff --git a/Sources/WpfApp/MainWindow.xaml.cs b/Sources/WpfApp/MainWindow.xaml.cs index cf2c5a6..c3a4a84 100644 --- a/Sources/WpfApp/MainWindow.xaml.cs +++ b/Sources/WpfApp/MainWindow.xaml.cs @@ -24,7 +24,10 @@ namespace WpfApp private KinectSensor kinectSensor = null; private ColorFrameReader colorFrameReader = null; private WriteableBitmap colorBitmap = null; - + + private BodyFrameReader bodyFrameReader = null; + private Body[] bodies = null; + // Propriété publique pour le binding public WriteableBitmap ColorBitmap { @@ -53,6 +56,13 @@ namespace WpfApp // Gérer l'événement FrameArrived pour le flux de couleur this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived; + // Initialisation du BodyFrameReader + this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader(); + this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived; + + // Initialiser le tableau des corps + this.bodies = new Body[this.kinectSensor.BodyFrameSource.BodyCount]; + // Ouvrir la Kinect this.kinectSensor.Open(); } @@ -101,5 +111,63 @@ namespace WpfApp this.kinectSensor = null; } } + + private void Reader_BodyFrameArrived(object sender, BodyFrameArrivedEventArgs e) + { + using (var bodyFrame = e.FrameReference.AcquireFrame()) + { + if (bodyFrame != null) + { + bodyFrame.GetAndRefreshBodyData(this.bodies); + + skeletonCanvas.Children.Clear(); // Nettoyer le canvas avant de dessiner + + foreach (var body in this.bodies) + { + if (body.IsTracked) + { + // Dessiner le squelette + DrawSkeleton(body); + } + } + } + } + } + + private void DrawSkeleton(Body body) + { + foreach (JointType jointType in body.Joints.Keys) + { + Joint joint = body.Joints[jointType]; + if (joint.TrackingState == TrackingState.Tracked) + { + // Convertir les coordonnées du joint en coordonnées de l'écran + Point point = new Point(); + ColorSpacePoint colorPoint = this.kinectSensor.CoordinateMapper.MapCameraPointToColorSpace(joint.Position); + point.X = float.IsInfinity(colorPoint.X) ? 0 : colorPoint.X; + point.Y = float.IsInfinity(colorPoint.Y) ? 0 : colorPoint.Y; + + // Dessiner le joint + DrawJoint(point); + } + } + + // Dessinez les os ici si nécessaire + } + + private void DrawJoint(Point point) + { + Ellipse ellipse = new Ellipse + { + Width = 10, + Height = 10, + Fill = new SolidColorBrush(Colors.Red) + }; + + Canvas.SetLeft(ellipse, point.X - ellipse.Width / 2); + Canvas.SetTop(ellipse, point.Y - ellipse.Height / 2); + + skeletonCanvas.Children.Add(ellipse); + } } } From ca3b37a6e13f1629570d3c0af428f1340a9808bf Mon Sep 17 00:00:00 2001 From: Louis DUFOUR Date: Thu, 11 Jan 2024 12:12:53 +0100 Subject: [PATCH 2/5] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 134 ++++++++++-------------------------------------------- 1 file changed, 25 insertions(+), 109 deletions(-) diff --git a/README.md b/README.md index 61876ea..fb30da3 100644 --- a/README.md +++ b/README.md @@ -1,117 +1,33 @@ -**Home** -| [Exercise 1 - Kinect Streams](./exo1_subject.md) -| [Exercise 2 - Introduction](./exo2_subject.md) -| [Exercise 2 part 1 - Postures](./exo2_1_subject.md) -| [Exercise 2 part 2 - Gestures](./exo2_2_subject.md) -| [Exercise 2 part 3 - Mapping](./exo2_3_subject.md) -| [Exercise 3 - Free App](./exo3_subject.md) +# Projet Kinect -# Kinect Exercises +## Introduction +Ce projet a pour objectif de développer une application de bureau qui exploite les différents capteurs de la Kinect. Il vise à montrer comment la Kinect peut être utilisée dans des applications interactives et immersives. -- [Kinect Exercises](#kinect-exercises) -- [Kinect sensor](#kinect-sensor) - - [What's inside the Kinect sensor?](#whats-inside-the-kinect-sensor) - - [Software and SDK](#software-and-sdk) -- [Course of the practical work](#course-of-the-practical-work) -- [Subjects](#subjects) -- [Evaluation](#evaluation) +## Équipe +- Louis DUFOUR +- Johan LACHENAL +## Technologies Utilisées +- **Langage de Programmation**: C# +- **Framework**: Windows Presentation Foundation (WPF) -The goal of this resource is to go deeper into *Object Oriented Programming* through the use of an (formerly) innovative device (**KinecT**) and simple gesture detection algorithms. -It is made of three exercises: -- the first one aims at retrieving information from the **Kinect** (4 hours) -- the second one aims at writing a gesture detection algorithm (4 hours) -- and the last one is a free subject exercise where you are asked to develop a simple app using the former two exercises. +## Prérequis +- **Matériel**: Une Kinect est nécessaire pour tester le projet. +- **Logiciel**: Visual Studio pour exécuter et développer le projet WPF. -This document is a quick introduction to the **Kinect** sensor. +## Installation et Configuration +1. **Cloner le Répertoire**: Clonez le dépôt GitHub à l'aide de `git clone [url-du-dépôt]`. +2. **Ouvrir avec Visual Studio**: Lancez Visual Studio et ouvrez le projet cloné. +3. **Installer les Dépendances**: Assurez-vous que toutes les bibliothèques nécessaires sont installées. +4. **Connecter la Kinect**: Branchez votre Kinect à votre ordinateur. -# Kinect sensor +## Utilisation +- **Démarrage**: Pour démarrer l'application, exécutez le projet via Visual Studio. +- **Interaction avec la Kinect**: Suivez les instructions à l'écran pour interagir avec l'application en utilisant les capteurs de la Kinect. -**Kinect** is a device designed by Microsoft, initially for the **Xbox360** and **Windows**, and then also for **Xbox One**. -Its purpose is to allow controlling applications (mainly games) without any physical device, with your own body. It is then a **Natural User Interface**. +## Notre avancement +- Body Stream **OK** +- Color Steam **OK** -It has first been sold in late 2010 (v1), and later in february 2012 (v2), and the windows version in july 2014. The production has ended in 2017. -But since 2019, the new **Azure Kinect** has been released. I do not have tested it yet. - -> Tip 💡 -> The word **Kinect** is a puzzle between *kinetic* (movement) and *connect*. - -## What's inside the Kinect sensor? -The **Kinect** sensor owns various sensors. -It is an horizontal bar with: -- an infrared projector, -- cameras (RGB camera, time of flight camera), -- depth sensor, -- a special microchip generating a grid to allow position calculation -- a motorized pivot to position automatically the bar towards the users -- microphones - -It allows: -- full body 3D motion capture (skeleton tracking) -- facial recognition -- voice recognition - -## Software and SDK -If you want to use the **Kinect** sensor v2, you need to use the [**Kinect for Windows SDK 2.0**](https://www.microsoft.com/en-us/download/details.aspx?id=44561). You can then use C# (XAML), C++ or VB.NET. -However, due to its released date, it is not possible to use it with .NET Core or MAUI. You have to use a **.NET Framework** project to develop for the **Kinect**. - -# Course of the practical work -You have only 1 hour of introduction in theater, and then 14 hours of practical work. This can be done only in the **C21** room where the **Kinect SDK** is installed. -> ⚠️ Available material ⚠️ -> Due to the small number of **Kinect** sensors owned by IUT Clermont Auvergne, it is not possible to borrow one for the period, a weekend, or a night. If you want to work with the sensor outside of the practical work, you can borrow one during the day, if it is not used by another group. But all sensors should be returned at the end of the day. - -You have three exercises to realize. It is advised to use: -- 4 to 6 hours for the first one, -- 4 to 6 hours for the second one, -- 2 to 6 hours for the third one. - -Some parts of the exercises are mandatory to access the next exercise, some are not. - -It is advised to organized yourself: -- before practical work: - - study the advised themes via resources given in the subjects, - - prepare your questions if you have some -- during the practical work: - - realize the different tasks - - validate your new skills acquisition with your teacher -- after the practical work: - - update and analyze your *to do list* - - check the skills that have not been vaidated yet with your teacher. - -# Subjects - -- [Exercise 1 - Kinect Streams](./exo1_subject.md) -- [Exercise 2 - Introduction](./exo2_subject.md) -- [Exercise 2 part 1 - Postures](./exo2_1_subject.md) -- [Exercise 2 part 2 - Gestures](./exo2_2_subject.md) -- [Exercise 2 part 3 - Mapping](./exo2_3_subject.md) -- [Exercise 3 - Free App](./exo3_subject.md) - -# Evaluation - -You will be evaluated three times (one for each exercise). It will be done during the practical works. -In order to help you, we deliver you a *skill list* that you will have to fill by validating skills with your teacher. -To obtain a validation, you will have to prove your skill knowledge to your teacher through an oral interview or a test. -The final note will be composed of all the validated skills by the teacher at the end of the last minute of the last practical work hour. - -Exercise | Subject | Coefficient ---- | --- | --- -1 | Kinect Streams | 7 -2.1 | Gesture Recognition (Bases & Postures) | 3 -2.2 | Gesture Recognition (Dynamic Gestures) | 2 -2.3 | Gesture Recognition (Mapping) | 2 -3 | Free App | 7 - ---- - -**Home** -| [Exercise 1 - Kinect Streams](./exo1_subject.md) -| [Exercise 2 - Introduction](./exo2_subject.md) -| [Exercise 2 part 1 - Postures](./exo2_1_subject.md) -| [Exercise 2 part 2 - Gestures](./exo2_2_subject.md) -| [Exercise 2 part 3 - Mapping](./exo2_3_subject.md) -| [Exercise 3 - Free App](./exo3_subject.md) - ---- - -Copyright © 2023-2024 Marc Chevaldonné \ No newline at end of file +## Problèmes Connus et Solutions +Aucun problème rencontré pour le moment From 33e8783e1d40dc3118590d8a3f009412228a9c5f Mon Sep 17 00:00:00 2001 From: "louis.dufour" Date: Thu, 11 Jan 2024 13:39:35 +0100 Subject: [PATCH 3/5] Update(master): orga file --- exo1_subject.md => Sujets/exo1_subject.md | 0 exo2_1_subject.md => Sujets/exo2_1_subject.md | 0 exo2_2_subject.md => Sujets/exo2_2_subject.md | 0 exo2_3_subject.md => Sujets/exo2_3_subject.md | 0 exo2_subject.md => Sujets/exo2_subject.md | 0 exo3_subject.md => Sujets/exo3_subject.md | 0 subject_intro.md => Sujets/subject_intro.md | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename exo1_subject.md => Sujets/exo1_subject.md (100%) rename exo2_1_subject.md => Sujets/exo2_1_subject.md (100%) rename exo2_2_subject.md => Sujets/exo2_2_subject.md (100%) rename exo2_3_subject.md => Sujets/exo2_3_subject.md (100%) rename exo2_subject.md => Sujets/exo2_subject.md (100%) rename exo3_subject.md => Sujets/exo3_subject.md (100%) rename subject_intro.md => Sujets/subject_intro.md (100%) diff --git a/exo1_subject.md b/Sujets/exo1_subject.md similarity index 100% rename from exo1_subject.md rename to Sujets/exo1_subject.md diff --git a/exo2_1_subject.md b/Sujets/exo2_1_subject.md similarity index 100% rename from exo2_1_subject.md rename to Sujets/exo2_1_subject.md diff --git a/exo2_2_subject.md b/Sujets/exo2_2_subject.md similarity index 100% rename from exo2_2_subject.md rename to Sujets/exo2_2_subject.md diff --git a/exo2_3_subject.md b/Sujets/exo2_3_subject.md similarity index 100% rename from exo2_3_subject.md rename to Sujets/exo2_3_subject.md diff --git a/exo2_subject.md b/Sujets/exo2_subject.md similarity index 100% rename from exo2_subject.md rename to Sujets/exo2_subject.md diff --git a/exo3_subject.md b/Sujets/exo3_subject.md similarity index 100% rename from exo3_subject.md rename to Sujets/exo3_subject.md diff --git a/subject_intro.md b/Sujets/subject_intro.md similarity index 100% rename from subject_intro.md rename to Sujets/subject_intro.md From e61a5fb2336c407ad594562779808472a0a57091 Mon Sep 17 00:00:00 2001 From: "louis.dufour" Date: Wed, 17 Jan 2024 08:55:58 +0100 Subject: [PATCH 4/5] Add(dev): Capteur de profondeur --- Sources/WpfApp/MainWindow.xaml | 2 +- Sources/WpfApp/MainWindow.xaml.cs | 65 ++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/Sources/WpfApp/MainWindow.xaml b/Sources/WpfApp/MainWindow.xaml index 5e4a5e2..b0e21ad 100644 --- a/Sources/WpfApp/MainWindow.xaml +++ b/Sources/WpfApp/MainWindow.xaml @@ -26,7 +26,7 @@