ADD : début ajout commentaires pour les classes ImageStream

bodyStream
Lou BRODA 1 year ago
parent f9eb86b849
commit d35b009b64

@ -12,6 +12,10 @@ using System.Windows.Shapes;
namespace KinectConnection
{
/// <summary>
/// Classe représentant un flux d'image du corps pour la Kinect.
/// Étend la classe KinectStream.
/// </summary>
public class BodyImageStream : KinectStream
{
private BodyFrameReader bodyFrameReader = null;
@ -34,11 +38,17 @@ namespace KinectConnection
private int displayHeight;
private int displayWidth;
/// <summary>
/// Obtient la source d'image de la classe.
/// </summary>
public override ImageSource Source
{
get { return this.imageSource; }
}
/// <summary>
/// Initialise une nouvelle instance de la classe BodyImageStream.
/// </summary>
public BodyImageStream() : base()
{
this.coordinateMapper = this.KinectSensor.CoordinateMapper;
@ -90,6 +100,9 @@ namespace KinectConnection
this.imageSource = new DrawingImage(this.drawingGroup);
}
/// <summary>
/// Démarre la lecture du flux de corps.
/// </summary>
public override void Start()
{
if (this.KinectSensor != null)
@ -103,19 +116,27 @@ namespace KinectConnection
}
}
/// <summary>
/// Arrête la lecture du flux de corps.
/// </summary>
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;
}
}
/// <summary>
/// Méthode appelée lors de l'arrivée d'un nouveau frame du corps
/// </summary>
/// <param name="sender">object sending the event</param>
/// <param name="e">event arguments</param>
private void Reader_BodyFrameArrived(object sender, BodyFrameArrivedEventArgs e)
{
bool dataReceived = false;
@ -185,6 +206,9 @@ namespace KinectConnection
}
}
/// <summary>
/// Méthode appelée pour le dessin du corps
/// </summary>
private void DrawBody(IReadOnlyDictionary<JointType, Joint> joints, IDictionary<JointType, Point> jointPoints, DrawingContext drawingContext, Pen drawingPen)
{
// Draw the bones
@ -216,6 +240,9 @@ namespace KinectConnection
}
}
/// <summary>
/// Méthode appelée pour le dessin d'une main
/// </summary>
private void DrawHand(HandState handState, Point handPosition, DrawingContext drawingContext)
{
switch (handState)
@ -234,6 +261,9 @@ namespace KinectConnection
}
}
/// <summary>
/// Méthode appelée pour le dessin d'un os
/// </summary>
private void DrawBone(IReadOnlyDictionary<JointType, Joint> joints, IDictionary<JointType, Point> 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]);
}
/// <summary>
/// Méthode appelée pour le dessin d'un joint
/// </summary>
private void DrawClippedEdges(Body body, DrawingContext drawingContext)
{
FrameEdges clippedEdges = body.ClippedEdges;

@ -7,7 +7,8 @@ using System.Windows.Media.Imaging;
namespace KinectConnection
{
/// <summary>
/// The color image stream.
/// Classe représentant un flux d'image coloré pour la Kinect.
/// Étend la classe KinectStream.
/// </summary>
public class ColorImageStream : KinectStream
{
@ -16,6 +17,9 @@ namespace KinectConnection
/// </summary>
private WriteableBitmap bitmap = null;
/// <summary>
/// Obtient la source d'image de la classe.
/// </summary>
public override ImageSource Source
{
get { return this.bitmap; }
@ -26,6 +30,9 @@ namespace KinectConnection
/// </summary>
private ColorFrameReader reader;
/// <summary>
/// Initialise une nouvelle instance de la classe ColorImageStream.
/// </summary>
public ColorImageStream() : base()
{
// create the colorFrameDescription from the ColorFrameSource using rgba format
@ -35,6 +42,9 @@ namespace KinectConnection
}
/// <summary>
/// Démarre la lecture du flux coloré.
/// </summary>
public override void Start()
{
if (this.KinectSensor != null)
@ -48,6 +58,9 @@ namespace KinectConnection
}
}
/// <summary>
/// Arrête la lecture du flux coloré.
/// </summary>
public override void Stop()
{
if (this.reader != null)
@ -62,8 +75,7 @@ namespace KinectConnection
}
/// <summary>
/// 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é.
/// </summary>
/// <param name="sender">object sending the event</param>
/// <param name="e">event arguments</param>

@ -10,12 +10,13 @@ using System.Windows.Media.Imaging;
namespace KinectConnection
{
/// <summary>
/// The depth image stream.
/// Classe représentant un flux d'image de profondeur pour la Kinect.
/// Étend la classe KinectStream.
/// </summary>
public class DepthImageStream : KinectStream
{
/// <summary>
/// Map depth range to byte range
/// Constante pour mapper la plage de profondeur à la plage de byte.
/// </summary>
private const int MapDepthToByte = 8000 / 256;
@ -45,7 +46,7 @@ namespace KinectConnection
private byte[] depthPixels = null;
/// <summary>
/// Gets the bitmap to display
/// Obtient la source d'image de la classe.
/// </summary>
public override ImageSource Source
{
@ -55,6 +56,24 @@ namespace KinectConnection
}
}
/// <summary>
/// Initialise une nouvelle instance de la classe DepthImageStream.
/// </summary>
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);
}
/// <summary>
/// Démarre la lecture du flux de profondeur.
/// </summary>
public override void Start()
{
if (this.KinectSensor != null)
@ -70,6 +89,9 @@ namespace KinectConnection
}
}
/// <summary>
/// Arrête la lecture du flux de profondeur.
/// </summary>
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);
}
/// <summary>
/// Handles the depth frame data arriving from the sensor
/// Méthode appelée lors de l'arrivée d'un nouveau frame de profondeur.
/// </summary>
/// <param name="sender">object sending the event</param>
/// <param name="e">event arguments</param>
@ -137,15 +147,15 @@ namespace KinectConnection
}
/// <summary>
/// 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.
/// </summary>
/// <param name="depthFrameData">Pointer to the DepthFrame image data</param>
/// <param name="depthFrameDataSize">Size of the DepthFrame image data</param>
/// <param name="minDepth">The minimum reliable depth value for the frame</param>
/// <param name="maxDepth">The maximum reliable depth value for the frame</param>
/// <param name="depthFrameData">Pointeur vers la DepthFrame image data</param>
/// <param name="depthFrameDataSize">Taille de la DepthFrame image data</param>
/// <param name="minDepth">La plus fiable valeur minimale pour la frame</param>
/// <param name="maxDepth">La plus fiable valeur maximale pour la frame</param>
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
}
/// <summary>
/// Renders color pixels into the writeableBitmap.
/// Rend les pixels de profondeur dans la bitmap.
/// </summary>
private void RenderDepthPixels()
{

@ -10,7 +10,8 @@ using System.Windows.Media.Imaging;
namespace KinectConnection
{
/// <summary>
/// The infrared image stream.
/// Classe représentant un flux d'image infrarouge pour la Kinect.
/// Étend la classe KinectStream.
/// </summary>
public class InfraredImageStream : KinectStream
{
@ -60,7 +61,7 @@ namespace KinectConnection
private string statusText = null;
/// <summary>
/// Gets the bitmap to display
/// Obtient la source d'image de la classe.
/// </summary>
public override ImageSource Source
{
@ -71,26 +72,8 @@ namespace KinectConnection
}
/// <summary>
/// Execute shutdown tasks
/// Initialise une nouvelle instance de la classe InfraredImageStream.
/// </summary>
/// <param name="sender">object sending the event</param>
/// <param name="e">event arguments</param>
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);
}
/// <summary>
/// Démarre la lecture du flux infrarouge.
/// </summary>
public override void Start()
{
if (this.KinectSensor != null)
@ -115,6 +101,9 @@ namespace KinectConnection
}
}
/// <summary>
/// Arrête la lecture du flux infrarouge.
/// </summary>
public override void Stop()
{
if (this.infraredFrameReader != null)
@ -129,7 +118,7 @@ namespace KinectConnection
}
/// <summary>
/// Handles the infrared frame data arriving from the sensor
/// Méthode appelée lors de l'arrivée d'un nouveau frame infrarouge.
/// </summary>
/// <param name="sender">object sending the event</param>
/// <param name="e">event arguments</param>
@ -156,13 +145,13 @@ namespace KinectConnection
}
/// <summary>
/// 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.
/// </summary>
/// <param name="infraredFrameData">Pointer to the InfraredFrame image data</param>
/// <param name="infraredFrameDataSize">Size of the InfraredFrame image data</param>
/// <param name="infraredFrameData">Pointeur vers les données d'image InfraredFrame</param>
/// <param name="infraredFrameDataSize">Taille des données d'image InfraredFrame</param>
private unsafe void ProcessInfraredFrameData(IntPtr infraredFrameData, uint infraredFrameDataSize)
{
// infrared frame data is a 16 bit value

Loading…
Cancel
Save