|
|
@ -18,10 +18,14 @@ namespace Lib
|
|
|
|
public BodyFrameReader Reader
|
|
|
|
public BodyFrameReader Reader
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get { return reader; }
|
|
|
|
get { return reader; }
|
|
|
|
set { reader = value; }
|
|
|
|
private set { reader = value; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//private ColorFrameReader colorReader;
|
|
|
|
private ColorFrameReader _colorReader;
|
|
|
|
|
|
|
|
public ColorFrameReader ColorReader {
|
|
|
|
|
|
|
|
get { return _colorReader; }
|
|
|
|
|
|
|
|
private set { _colorReader = value; }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Body[] bodies;
|
|
|
|
private Body[] bodies;
|
|
|
|
public Body[] Bodies
|
|
|
|
public Body[] Bodies
|
|
|
@ -36,6 +40,11 @@ namespace Lib
|
|
|
|
Reader.Dispose();
|
|
|
|
Reader.Dispose();
|
|
|
|
Reader = null;
|
|
|
|
Reader = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ColorReader != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColorReader.Dispose();
|
|
|
|
|
|
|
|
ColorReader = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -45,6 +54,8 @@ namespace Lib
|
|
|
|
Bitmap = new WriteableBitmap(framedescription.Width, framedescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);
|
|
|
|
Bitmap = new WriteableBitmap(framedescription.Width, framedescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);
|
|
|
|
reader = kinectmanager.Sensor.BodyFrameSource.OpenReader();
|
|
|
|
reader = kinectmanager.Sensor.BodyFrameSource.OpenReader();
|
|
|
|
reader.FrameArrived += Reader_BodyFrameArrived;
|
|
|
|
reader.FrameArrived += Reader_BodyFrameArrived;
|
|
|
|
|
|
|
|
ColorReader = KinectManager.Sensor.ColorFrameSource.OpenReader();
|
|
|
|
|
|
|
|
ColorReader.FrameArrived += Reader_ColorFrameArrived;
|
|
|
|
// initialiser le tableau des corps
|
|
|
|
// initialiser le tableau des corps
|
|
|
|
this.bodies = new Body[kinectmanager.Sensor.BodyFrameSource.BodyCount];
|
|
|
|
this.bodies = new Body[kinectmanager.Sensor.BodyFrameSource.BodyCount];
|
|
|
|
Canvas = skeletonCanvas;
|
|
|
|
Canvas = skeletonCanvas;
|
|
|
@ -167,5 +178,36 @@ namespace Lib
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Reader_ColorFrameArrived(object sender, ColorFrameArrivedEventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (ColorFrame colorFrame = e.FrameReference.AcquireFrame())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (colorFrame != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// ... Logique existante pour traiter la frame
|
|
|
|
|
|
|
|
//Debug.WriteLine("Traitement de la frame de couleur.");
|
|
|
|
|
|
|
|
FrameDescription colorFrameDescription = colorFrame.FrameDescription;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (KinectBuffer colorBuffer = colorFrame.LockRawImageBuffer())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.Bitmap.Lock();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Vérifier si la taille de l'image a changé
|
|
|
|
|
|
|
|
if ((colorFrameDescription.Width == this.Bitmap.PixelWidth) && (colorFrameDescription.Height == this.Bitmap.PixelHeight))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
colorFrame.CopyConvertedFrameDataToIntPtr(
|
|
|
|
|
|
|
|
this.Bitmap.BackBuffer,
|
|
|
|
|
|
|
|
(uint)(colorFrameDescription.Width * colorFrameDescription.Height * 4),
|
|
|
|
|
|
|
|
ColorImageFormat.Bgra);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.Bitmap.AddDirtyRect(new Int32Rect(0, 0, this.Bitmap.PixelWidth, this.Bitmap.PixelHeight));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.Bitmap.Unlock();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Debug.WriteLine("Frame de couleur traitée.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|