diff --git a/KinectConnection/BodyImageStream.cs b/KinectConnection/BodyImageStream.cs index 99aa3ae..96b6024 100644 --- a/KinectConnection/BodyImageStream.cs +++ b/KinectConnection/BodyImageStream.cs @@ -12,6 +12,10 @@ using System.Windows.Shapes; namespace KinectConnection { + /// + /// Classe représentant un flux d'image du corps pour la Kinect. + /// Étend la classe KinectStream. + /// public class BodyImageStream : KinectStream { private BodyFrameReader bodyFrameReader = null; @@ -34,11 +38,17 @@ namespace KinectConnection private int displayHeight; private int displayWidth; + /// + /// Obtient la source d'image de la classe. + /// public override ImageSource Source { get { return this.imageSource; } } + /// + /// Initialise une nouvelle instance de la classe BodyImageStream. + /// public BodyImageStream() : base() { this.coordinateMapper = this.KinectSensor.CoordinateMapper; @@ -90,6 +100,9 @@ namespace KinectConnection this.imageSource = new DrawingImage(this.drawingGroup); } + /// + /// Démarre la lecture du flux de corps. + /// public override void Start() { if (this.KinectSensor != null) @@ -103,19 +116,27 @@ namespace KinectConnection } } + /// + /// Arrête la lecture du flux de corps. + /// public override void Stop() { if (this.bodyFrameReader != null) { this.bodyFrameReader.FrameArrived -= this.Reader_BodyFrameArrived; - // Dispose the reader to free resources. - // If we don't dispose manualy, the gc will do it for us, but we don't know when. + // Dispose le lecteur pour libérer les ressources. + // Si on ne le fait pas manuellement, le GC le fera pour nous, mais nous ne savons pas quand. this.bodyFrameReader.Dispose(); this.bodyFrameReader = null; } } + /// + /// Méthode appelée lors de l'arrivée d'un nouveau frame du corps + /// + /// object sending the event + /// event arguments private void Reader_BodyFrameArrived(object sender, BodyFrameArrivedEventArgs e) { bool dataReceived = false; @@ -185,6 +206,9 @@ namespace KinectConnection } } + /// + /// Méthode appelée pour le dessin du corps + /// private void DrawBody(IReadOnlyDictionary joints, IDictionary jointPoints, DrawingContext drawingContext, Pen drawingPen) { // Draw the bones @@ -216,6 +240,9 @@ namespace KinectConnection } } + /// + /// Méthode appelée pour le dessin d'une main + /// private void DrawHand(HandState handState, Point handPosition, DrawingContext drawingContext) { switch (handState) @@ -234,6 +261,9 @@ namespace KinectConnection } } + /// + /// Méthode appelée pour le dessin d'un os + /// private void DrawBone(IReadOnlyDictionary joints, IDictionary jointPoints, JointType jointType0, JointType jointType1, DrawingContext drawingContext, Pen drawingPen) { Joint joint0 = joints[jointType0]; @@ -256,6 +286,9 @@ namespace KinectConnection drawingContext.DrawLine(drawPen, jointPoints[jointType0], jointPoints[jointType1]); } + /// + /// Méthode appelée pour le dessin d'un joint + /// private void DrawClippedEdges(Body body, DrawingContext drawingContext) { FrameEdges clippedEdges = body.ClippedEdges; diff --git a/KinectConnection/ColorImageStream.cs b/KinectConnection/ColorImageStream.cs index 1f14a00..3cf70d2 100644 --- a/KinectConnection/ColorImageStream.cs +++ b/KinectConnection/ColorImageStream.cs @@ -7,7 +7,8 @@ using System.Windows.Media.Imaging; namespace KinectConnection { /// - /// The color image stream. + /// Classe représentant un flux d'image coloré pour la Kinect. + /// Étend la classe KinectStream. /// public class ColorImageStream : KinectStream { @@ -16,6 +17,9 @@ namespace KinectConnection /// private WriteableBitmap bitmap = null; + /// + /// Obtient la source d'image de la classe. + /// public override ImageSource Source { get { return this.bitmap; } @@ -26,6 +30,9 @@ namespace KinectConnection /// private ColorFrameReader reader; + /// + /// Initialise une nouvelle instance de la classe ColorImageStream. + /// public ColorImageStream() : base() { // create the colorFrameDescription from the ColorFrameSource using rgba format @@ -35,6 +42,9 @@ namespace KinectConnection } + /// + /// Démarre la lecture du flux coloré. + /// public override void Start() { if (this.KinectSensor != null) @@ -48,6 +58,9 @@ namespace KinectConnection } } + /// + /// Arrête la lecture du flux coloré. + /// public override void Stop() { if (this.reader != null) @@ -62,8 +75,7 @@ namespace KinectConnection } /// - /// METHOD FROM THE SAMPLE - /// Handles the color frame data arriving from the sensor. + /// Méthode appelée lors de l'arrivée d'un nouveau frame coloré. /// /// object sending the event /// event arguments diff --git a/KinectConnection/DepthImageStream.cs b/KinectConnection/DepthImageStream.cs index aab4c76..40c7503 100644 --- a/KinectConnection/DepthImageStream.cs +++ b/KinectConnection/DepthImageStream.cs @@ -10,12 +10,13 @@ using System.Windows.Media.Imaging; namespace KinectConnection { /// - /// The depth image stream. + /// Classe représentant un flux d'image de profondeur pour la Kinect. + /// Étend la classe KinectStream. /// public class DepthImageStream : KinectStream { /// - /// Map depth range to byte range + /// Constante pour mapper la plage de profondeur à la plage de byte. /// private const int MapDepthToByte = 8000 / 256; @@ -45,7 +46,7 @@ namespace KinectConnection private byte[] depthPixels = null; /// - /// Gets the bitmap to display + /// Obtient la source d'image de la classe. /// public override ImageSource Source { @@ -55,6 +56,24 @@ namespace KinectConnection } } + /// + /// Initialise une nouvelle instance de la classe DepthImageStream. + /// + public DepthImageStream() : base() + { + // get FrameDescription from DepthFrameSource + this.depthFrameDescription = this.KinectSensor.DepthFrameSource.FrameDescription; + + // allocate space to put the pixels being received and converted + this.depthPixels = new byte[this.depthFrameDescription.Width * this.depthFrameDescription.Height]; + + // create the bitmap to display + this.depthBitmap = new WriteableBitmap(this.depthFrameDescription.Width, this.depthFrameDescription.Height, 96.0, 96.0, PixelFormats.Gray8, null); + } + + /// + /// Démarre la lecture du flux de profondeur. + /// public override void Start() { if (this.KinectSensor != null) @@ -70,6 +89,9 @@ namespace KinectConnection } } + /// + /// Arrête la lecture du flux de profondeur. + /// public override void Stop() { if (this.depthFrameReader != null) @@ -83,20 +105,8 @@ namespace KinectConnection } } - public DepthImageStream() : base() - { - // get FrameDescription from DepthFrameSource - this.depthFrameDescription = this.KinectSensor.DepthFrameSource.FrameDescription; - - // allocate space to put the pixels being received and converted - this.depthPixels = new byte[this.depthFrameDescription.Width * this.depthFrameDescription.Height]; - - // create the bitmap to display - this.depthBitmap = new WriteableBitmap(this.depthFrameDescription.Width, this.depthFrameDescription.Height, 96.0, 96.0, PixelFormats.Gray8, null); - } - /// - /// Handles the depth frame data arriving from the sensor + /// Méthode appelée lors de l'arrivée d'un nouveau frame de profondeur. /// /// object sending the event /// event arguments @@ -137,15 +147,15 @@ namespace KinectConnection } /// - /// Directly accesses the underlying image buffer of the DepthFrame to - /// create a displayable bitmap. - /// This function requires the /unsafe compiler option as we make use of direct - /// access to the native memory pointed to by the depthFrameData pointer. + /// Accède directement au tampon d'image sous-jacent du DepthFrame + /// pour créer une bitmap affichable. + /// Cette méthode nécessite l'option du compilateur "/unsafe" pour avoir directement accès + /// à la mémoire native pointée par le pointer depthFrameData. /// - /// Pointer to the DepthFrame image data - /// Size of the DepthFrame image data - /// The minimum reliable depth value for the frame - /// The maximum reliable depth value for the frame + /// Pointeur vers la DepthFrame image data + /// Taille de la DepthFrame image data + /// La plus fiable valeur minimale pour la frame + /// La plus fiable valeur maximale pour la frame private unsafe void ProcessDepthFrameData(IntPtr depthFrameData, uint depthFrameDataSize, ushort minDepth, ushort maxDepth) { // depth frame data is a 16 bit value @@ -164,7 +174,7 @@ namespace KinectConnection } /// - /// Renders color pixels into the writeableBitmap. + /// Rend les pixels de profondeur dans la bitmap. /// private void RenderDepthPixels() { diff --git a/KinectConnection/InfraredImageStream.cs b/KinectConnection/InfraredImageStream.cs index e77d3bd..3e457dc 100644 --- a/KinectConnection/InfraredImageStream.cs +++ b/KinectConnection/InfraredImageStream.cs @@ -10,7 +10,8 @@ using System.Windows.Media.Imaging; namespace KinectConnection { /// - /// The infrared image stream. + /// Classe représentant un flux d'image infrarouge pour la Kinect. + /// Étend la classe KinectStream. /// public class InfraredImageStream : KinectStream { @@ -60,7 +61,7 @@ namespace KinectConnection private string statusText = null; /// - /// Gets the bitmap to display + /// Obtient la source d'image de la classe. /// public override ImageSource Source { @@ -71,26 +72,8 @@ namespace KinectConnection } /// - /// Execute shutdown tasks + /// Initialise une nouvelle instance de la classe InfraredImageStream. /// - /// object sending the event - /// event arguments - private void MainWindow_Closing(object sender, CancelEventArgs e) - { - if (this.infraredFrameReader != null) - { - // InfraredFrameReader is IDisposable - this.infraredFrameReader.Dispose(); - this.infraredFrameReader = null; - } - - if (this.kinectSensor != null) - { - this.kinectSensor.Close(); - this.kinectSensor = null; - } - } - public InfraredImageStream() { // get FrameDescription from InfraredFrameSource @@ -100,6 +83,9 @@ namespace KinectConnection this.infraredBitmap = new WriteableBitmap(this.infraredFrameDescription.Width, this.infraredFrameDescription.Height, 96.0, 96.0, PixelFormats.Gray32Float, null); } + /// + /// Démarre la lecture du flux infrarouge. + /// public override void Start() { if (this.KinectSensor != null) @@ -115,6 +101,9 @@ namespace KinectConnection } } + /// + /// Arrête la lecture du flux infrarouge. + /// public override void Stop() { if (this.infraredFrameReader != null) @@ -129,7 +118,7 @@ namespace KinectConnection } /// - /// Handles the infrared frame data arriving from the sensor + /// Méthode appelée lors de l'arrivée d'un nouveau frame infrarouge. /// /// object sending the event /// event arguments @@ -156,13 +145,13 @@ namespace KinectConnection } /// - /// Directly accesses the underlying image buffer of the InfraredFrame to - /// create a displayable bitmap. - /// This function requires the /unsafe compiler option as we make use of direct - /// access to the native memory pointed to by the infraredFrameData pointer. + /// Accède directement au tampon d'image sous-jacent du InfraredFrame pour + /// créer une bitmap affichable. + /// Cette fonction nécessite l'option /unsafe du compilateur car nous utilisons un accès direct + /// à la mémoire native pointée par le pointeur infraredFrameData. /// - /// Pointer to the InfraredFrame image data - /// Size of the InfraredFrame image data + /// Pointeur vers les données d'image InfraredFrame + /// Taille des données d'image InfraredFrame private unsafe void ProcessInfraredFrameData(IntPtr infraredFrameData, uint infraredFrameDataSize) { // infrared frame data is a 16 bit value