[Home](./README.md)
| [Exercise 1 - Kinect Streams](./exo1_subject.md)
| [Exercise 2 - Introduction](./exo2_subject.md) 
| **Exercise 2 part 1 - Postures**
| [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)

# Exercise 2: Gesture Recognition part1 (Postures)

# Prerequisites
- the ```KinectManager``` from exercise 1
- inheritance in C# and abstract classes and methods
- polymorphism
- static methods and classes
- event in C# and Event Standard Pattern

# Resources
- 🔜 event and Event Standard Pattern
- 🔜 inheritance in C#
  
# Requested Work
As indicating in the introduction, the goal is to prepare the base classes of the gesture recognition system, and to develop and test postures.  
```mermaid  
classDiagram
class BaseGesture {
    +TestGesture(Body body)*
    +GestureRecognized : EventHandler~GestureRecognizedEventArgs~
    #OnGestureRecognized()
    +GestureName : string
}
class Posture {
    +TestGesture(Body body)*
    #TestPosture(Body body)* bool
}
class GestureManager {
    <<static>>
    +EventHandler~GestureRecognizedEventArgs~ GestureRecognized$ 
    +AddGestures(IGestureFactory: factory)$
    +AddGestures(params BaseGesture[])$
    +RemoveGesture(BaseGesture)$
    +StartAcquiringFrames(KinectManager)$
    +StopAcquiringFrame()$
}
BaseGesture <|-- Posture
Posture <|-- PostureRightHandUp
Posture <|-- PostureTwoHandsDragon
BaseGesture "*" <-- GestureManager : +KnownGestures
GestureManager --> "1" KinectManager : KinectManager

```  

# Steps to reproduce
This part is given as a set of advises to realize your application.  
I use some symbols in it:  
symbol | signification  
--- | --- 
💡 | be smart: this can obviously be done before practical works and without the kinect sensor!  
🎬 | evaluated at the end of all the practical works  
🚨 | mandatory if you want at least 10/20
🟢 | difficulty: low 
🟡 | difficulty: medium
🔴 | difficulty: high  
🔖 | quality (it's always better when it's beautiful 🥹)
> Note about difficulty:  
> It's obviously completely subjective...  
  
## 🚨🟢🔖 KinectUtils class library
- Create a .NET Framework class library
- Add your KinectManager
- Create all the base classes (```BaseGesture``` and ```Posture```)
  
## 🚨🟡🔖 MyGesturesBank class library
- Create a .NET Framework class library
- Add 2 concrete postures to it
> Suggestions:  
> Hand up, Hand on the head, Join hands, hands on hips...
- Test your postures in a Console App (.NET Framework)

## 🚨🟡🔖 GestureManager
- add the ```GestureManager``` class to your KinectUtils class library
- manage the collection of gestures
- manage the acquisition of frames
- manage the ```GestureRecognized``` event so that the user subscribe only once to an event (this one) in order to be subscribed to all events of ```GestureManager``` gestures
- (not mandatory) find a way (or make your teacher talk) to allow automatic subscriptions to all gestures event, without event bouncing. In other words, ```GestureManager``` should not be subscribed to all gestures event, and re-fire an event if one occurs. 
- (not mandatory) find a way (or...) to allow late subscriptions to gestures event. In other words, if the user has already subscribed to ```GestureRecognized``` of ```GestureManager```, if she adds a new gesture to the collection, she should be also subscribed without having to reset the subscription. 
- Test your ```GestureManager``` in a Console App

## 🟡🔖 Posture specific events
As your posture is tested at every frame, it should send the event everytime it is recognized, so a dozen of times if you keep the pose.  
Modify your ```Posture``` class so that it sends to more events:
- PostureRecognized if it is recognized although it wasn't at the previous frame
- PostureUnrecognized if it is not recognized although it was at the previous frame
- Test it in a Console App

# Evaluation criteria
To earned points, remember that you must validate your knowledge with your teacher, during the practical work.


**Signification**  
symbol | signification  
--- | --- 
☢️ | if not respected => 0/20
🎬 | evaluated at the end of all the practical works  
🚨 | mandatory
🟢 | difficulty: low
🟡 | difficulty: medium
🔴 | difficulty: high  
🔖 | quality  
  

**Criteria**
@ | category | description | coeff 
--- | --- | --- | --- 
☢️ | | the repositories must be accessible by the teacher | ☢️ 
☢️ | | a .gitignore file must be use at the creation of the repository or at the first push | ☢️
🎬 | | all *class libraries* and *applications* build | 4 
🎬 | | *applications* run without any bug | 4 
🚨🟢🔖 | KinectUtils class library | with KinectManager | 1
🚨🟢🔖 | KinectUtils class library | BaseGesture with event | 4
🚨🟢🔖 | KinectUtils class library | Posture | 1
🚨🟢 | KinectUtils class library | Posture.TestPosture | 1
🚨🟡🔖 | MyGesturesBank class library | 1st posture | 6
🟡 | MyGesturesBank class library | 2nd posture | 2
🚨🟡 | Test | Console test | 4
🚨🟢🔖 | GestureManager | collection of gestures | 1
🚨🟡🔖 | GestureManager | acquiring frames | 6
🚨🟡 | GestureManager | event (dirty but working) | 6
🔴🔖 | GestureManager | event automatic subscriptions to collection of gestures | 6
🔴🔖 | GestureManager | event late subscriptions | 6
🚨🟡 | Test | Console test | 4
🟡🔖 | Posture specific events | PostureRecognized and PostureUnrecognized | 6
🟡🔖 | Posture specific events | Update GestureManager | 6
🟡 | Test | Console test | 4
🎬🟢 | Documentation | ReadMe, comments, wiki... | 4

> Some samples if you wonder...  
> - if you do only the 🚨 criteria and your application is building and running, you get => 11,05/20
> - for the Bases of *KinectUtils* class library (```BaseGesture``` and ```Posture```) => 1,84 pt
> - for two concrete postures => 2,1 pts
> - for ```GestureManager```  => 6,6 pts
> - for the management of the two specific events on ```Posture``` and ```GestureManager``` => 3,2 pts
> - for all your tests (the three ones) => 3,2 pts
> - quality (building, running and documentation) => 3,2 pts

> Note :  
> Coefficients may change and are here only indicative  
  
---

[Home](./README.md)
| [Exercise 1 - Kinect Streams](./exo1_subject.md)
| [Exercise 2 - Introduction](./exo2_subject.md) 
| **Exercise 2 part 1 - Postures**
| [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é

--- 

While preparing these practical works, I was listening to...  

<table>
    <tr>
        <td>
            <img src="./images/after_the_gold_rush.jpg" width="120"/>
        </td>
        <td>
            <div>
                <p><b>After The Gold Rush</b></p>
                <p><i>Neil Young</i> (1970)</p>
            </div>
        </td>
    </tr>
</table>
<table>
    <tr>
        <td>
            <img src="./images/monk_s_music.jpg" width="120"/>
        </td>
        <td>
            <div>
                <p><b>Monk's Music</b></p>
                <p><i>Thelonious Monk Septet</i> (1957)</p>
            </div>
        </td>
    </tr>
</table>
<table>
    <tr>
        <td>
            <img src="./images/special_identity.jpg" width="120"/>
        </td>
        <td>
            <div>
                <p><b>Special Identity</b></p>
                <p><i>Joanne Brackeen</i> (1982)</p>
            </div>
        </td>
    </tr>
</table>
<table>
    <tr>
        <td>
            <img src="./images/where_have_i_known_you_before.jpg" width="120"/>
        </td>
        <td>
            <div>
                <p><b>Where Have I Known You Before</b></p>
                <p><i>Return To Forever</i> (1974)</p>
            </div>
        </td>
    </tr>
</table>
<table>
    <tr>
        <td>
            <img src="./images/bozilo.jpg" width="120"/>
        </td>
        <td>
            <div>
                <p><b>Live</b></p>
                <p><i>Bozilo</i> (2009)</p>
            </div>
        </td>
    </tr>
</table>
<table>
    <tr>
        <td>
            <img src="./images/look_out.jpg" width="120"/>
        </td>
        <td>
            <div>
                <p><b>Look Out!</b></p>
                <p><i>Stanley Turrentine</i> (1960)</p>
            </div>
        </td>
    </tr>
</table>
<table>
    <tr>
        <td>
            <img src="./images/moanin.jpg" width="120"/>
        </td>
        <td>
            <div>
                <p><b>Moanin'</b></p>
                <p><i>Art Blakey and The Jazz Messengers</i> (1958)</p>
            </div>
        </td>
    </tr>
</table>