Skeleton data can now be seen in the client and in the live window. No skeleton merging/saving yet.

This commit is contained in:
marek
2015-11-05 18:56:53 +01:00
parent 6df7380372
commit 948eee769e
12 changed files with 584 additions and 123 deletions
+55 -5
View File
@@ -19,6 +19,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
namespace KinectServer
{
public delegate void SocketChangedHandler();
@@ -40,6 +41,7 @@ namespace KinectServer
public List<byte> lFrameRGB = new List<byte>();
public List<Single> lFrameVerts = new List<Single>();
public List<Body> lBodies = new List<Body>();
public event SocketChangedHandler eChanged;
@@ -150,6 +152,7 @@ namespace KinectServer
{
lFrameRGB.Clear();
lFrameVerts.Clear();
lBodies.Clear();
int nToRead;
byte[] buffer = new byte[1024];
@@ -160,7 +163,6 @@ namespace KinectServer
return;
}
oSocket.Receive(buffer, 4, SocketFlags.None);
//string result = System.Text.Encoding.UTF8.GetString(buffer);
@@ -185,16 +187,64 @@ namespace KinectServer
nAlreadyRead += oSocket.Receive(buffer, nAlreadyRead, nToRead - nAlreadyRead, SocketFlags.None);
}
int point_size = 3 + 3 * 4;
int n_vertices = nToRead / point_size;
//Receive depth and color data
int startIdx = 0;
int n_vertices = BitConverter.ToInt32(buffer, startIdx);
startIdx += 4;
for (int i = 0; i < n_vertices; i++)
{
for (int j = 0; j < 3; j++)
{
lFrameRGB.Add(buffer[i * point_size + j]);
lFrameVerts.Add(BitConverter.ToSingle(buffer, i * point_size + j * 4 + 3));
lFrameRGB.Add(buffer[startIdx++]);
}
for (int j = 0; j < 3; j++)
{
lFrameVerts.Add(BitConverter.ToSingle(buffer, startIdx));
startIdx += 4;
}
}
//Receive body data
int nBodies = BitConverter.ToInt32(buffer, startIdx);
startIdx += 4;
for (int i = 0; i < nBodies; i++)
{
Body tempBody = new Body();
tempBody.bTracked = BitConverter.ToBoolean(buffer, startIdx++);
int nJoints = BitConverter.ToInt32(buffer, startIdx);
startIdx += 4;
tempBody.lJoints = new List<Joint>(nJoints);
tempBody.lJointsInColorSpace = new List<Point2f>(nJoints);
for (int j = 0; j < nJoints; j++)
{
Joint tempJoint = new Joint();
Point2f tempPoint = new Point2f();
tempJoint.jointType = (JointType)BitConverter.ToInt32(buffer, startIdx);
startIdx += 4;
tempJoint.trackingState = (TrackingState)BitConverter.ToInt32(buffer, startIdx);
startIdx += 4;
tempJoint.position.X = BitConverter.ToSingle(buffer, startIdx);
startIdx += 4;
tempJoint.position.Y = BitConverter.ToSingle(buffer, startIdx);
startIdx += 4;
tempJoint.position.Z = BitConverter.ToSingle(buffer, startIdx);
startIdx += 4;
tempPoint.X = BitConverter.ToSingle(buffer, startIdx);
startIdx += 4;
tempPoint.Y = BitConverter.ToSingle(buffer, startIdx);
startIdx += 4;
tempBody.lJoints.Add(tempJoint);
tempBody.lJointsInColorSpace.Add(tempPoint);
}
lBodies.Add(tempBody);
}
}