Corrected some issues with how skeletons were displayed.

This commit is contained in:
marek
2016-02-02 15:37:40 +01:00
parent 128645d299
commit 6dfccc42c0
7 changed files with 83 additions and 49 deletions
+1
View File
@@ -34,6 +34,7 @@ namespace KinectServer
public BindingList<MarkerPose> lMarkerPoses = new BindingList<MarkerPose>(); public BindingList<MarkerPose> lMarkerPoses = new BindingList<MarkerPose>();
public bool bStreamOnlyBodies = false; public bool bStreamOnlyBodies = false;
public bool bShowSkeletons = true;
public int nNumICPIterations = 10; public int nNumICPIterations = 10;
public int nNumRefineIters = 2; public int nNumRefineIters = 2;
+39 -34
View File
@@ -259,7 +259,7 @@ namespace KinectServer
if ((DateTime.Now - tFPSUpdateTimer).Seconds >= 1) if ((DateTime.Now - tFPSUpdateTimer).Seconds >= 1)
{ {
double FPS = nTickCounter / (DateTime.Now - tFPSUpdateTimer).TotalSeconds; double FPS = nTickCounter / (DateTime.Now - tFPSUpdateTimer).TotalSeconds;
this.Title = "FPS: " + string.Format("{0:F}", FPS); //this.Title = "FPS: " + string.Format("{0:F}", FPS);
tFPSUpdateTimer = DateTime.Now; tFPSUpdateTimer = DateTime.Now;
nTickCounter = 0; nTickCounter = 0;
@@ -292,42 +292,43 @@ namespace KinectServer
lock (vertices) lock (vertices)
{ {
lock (settings) bool bShowSkeletons = settings.bShowSkeletons;
{
PointCount = vertices.Count / 3; PointCount = vertices.Count / 3;
//bounding box //bounding box
LineCount = 12; LineCount = 12;
//markers //markers
LineCount += settings.lMarkerPoses.Count * 3; LineCount += settings.lMarkerPoses.Count * 3;
//cameras //cameras
LineCount += cameraPoses.Count * 3; LineCount += cameraPoses.Count * 3;
if (bShowSkeletons)
LineCount += 24 * bodies.Count; LineCount += 24 * bodies.Count;
VBO = new VertexC4ubV3f[PointCount + 2 * LineCount]; VBO = new VertexC4ubV3f[PointCount + 2 * LineCount];
for (int i = 0; i < PointCount; i++) for (int i = 0; i < PointCount; i++)
{ {
VBO[i].R = (byte)colors[i * 3]; VBO[i].R = (byte)colors[i * 3];
VBO[i].G = (byte)colors[i * 3 + 1]; VBO[i].G = (byte)colors[i * 3 + 1];
VBO[i].B = (byte)colors[i * 3 + 2]; VBO[i].B = (byte)colors[i * 3 + 2];
VBO[i].A = 255; VBO[i].A = 255;
VBO[i].Position.X = vertices[i * 3]; VBO[i].Position.X = vertices[i * 3];
VBO[i].Position.Y = vertices[i * 3 + 1]; VBO[i].Position.Y = vertices[i * 3 + 1];
VBO[i].Position.Z = vertices[i * 3 + 2]; VBO[i].Position.Z = vertices[i * 3 + 2];
}
int iCurLineCount = 0;
iCurLineCount += AddBoundingBox(PointCount + 2 * iCurLineCount);
for (int i = 0; i < settings.lMarkerPoses.Count; i++)
{
iCurLineCount += AddMarker(PointCount + 2 * iCurLineCount, settings.lMarkerPoses[i].pose);
}
for (int i = 0; i < cameraPoses.Count; i++)
{
iCurLineCount += AddCamera(PointCount + 2 * iCurLineCount, cameraPoses[i]);
}
iCurLineCount += AddBodies(PointCount + 2 * iCurLineCount);
} }
int iCurLineCount = 0;
iCurLineCount += AddBoundingBox(PointCount + 2 * iCurLineCount);
for (int i = 0; i < settings.lMarkerPoses.Count; i++)
{
iCurLineCount += AddMarker(PointCount + 2 * iCurLineCount, settings.lMarkerPoses[i].pose);
}
for (int i = 0; i < cameraPoses.Count; i++)
{
iCurLineCount += AddCamera(PointCount + 2 * iCurLineCount, cameraPoses[i]);
}
if (bShowSkeletons)
iCurLineCount += AddBodies(PointCount + 2 * iCurLineCount);
} }
} }
@@ -574,6 +575,9 @@ namespace KinectServer
for (int bodyIdx = 0; bodyIdx < bodies.Count; bodyIdx++) for (int bodyIdx = 0; bodyIdx < bodies.Count; bodyIdx++)
{ {
if (bodies[bodyIdx].bTracked == false)
continue;
//Torso //Torso
n += AddBone(bodyIdx, JointType.JointType_Head, JointType.JointType_Neck, startIdx + n); n += AddBone(bodyIdx, JointType.JointType_Head, JointType.JointType_Neck, startIdx + n);
n += AddBone(bodyIdx, JointType.JointType_Neck, JointType.JointType_SpineShoulder, startIdx + n); n += AddBone(bodyIdx, JointType.JointType_Neck, JointType.JointType_SpineShoulder, startIdx + n);
@@ -607,7 +611,8 @@ namespace KinectServer
n += AddBone(bodyIdx, JointType.JointType_HipLeft, JointType.JointType_KneeLeft, startIdx + n); n += AddBone(bodyIdx, JointType.JointType_HipLeft, JointType.JointType_KneeLeft, startIdx + n);
n += AddBone(bodyIdx, JointType.JointType_KneeLeft, JointType.JointType_AnkleLeft, startIdx + n); n += AddBone(bodyIdx, JointType.JointType_KneeLeft, JointType.JointType_AnkleLeft, startIdx + n);
n += AddBone(bodyIdx, JointType.JointType_AnkleLeft, JointType.JointType_FootLeft, startIdx + n); n += AddBone(bodyIdx, JointType.JointType_AnkleLeft, JointType.JointType_FootLeft, startIdx + n);
} }
return nLinesToAdd; return nLinesToAdd;
} }
+15 -1
View File
@@ -77,6 +77,7 @@
this.rAsciiPly = new System.Windows.Forms.RadioButton(); this.rAsciiPly = new System.Windows.Forms.RadioButton();
this.txtRefinIters = new System.Windows.Forms.TextBox(); this.txtRefinIters = new System.Windows.Forms.TextBox();
this.lbOuterIters = new System.Windows.Forms.Label(); this.lbOuterIters = new System.Windows.Forms.Label();
this.chSkeletons = new System.Windows.Forms.CheckBox();
this.grClient.SuspendLayout(); this.grClient.SuspendLayout();
this.grBody.SuspendLayout(); this.grBody.SuspendLayout();
this.grMarkers.SuspendLayout(); this.grMarkers.SuspendLayout();
@@ -137,6 +138,7 @@
// //
// grBody // grBody
// //
this.grBody.Controls.Add(this.chSkeletons);
this.grBody.Controls.Add(this.label1); this.grBody.Controls.Add(this.label1);
this.grBody.Controls.Add(this.chBodyData); this.grBody.Controls.Add(this.chBodyData);
this.grBody.Location = new System.Drawing.Point(9, 211); this.grBody.Location = new System.Drawing.Point(9, 211);
@@ -149,7 +151,7 @@
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(11, 43); this.label1.Location = new System.Drawing.Point(8, 61);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(187, 13); this.label1.Size = new System.Drawing.Size(187, 13);
this.label1.TabIndex = 20; this.label1.TabIndex = 20;
@@ -570,6 +572,17 @@
this.lbOuterIters.TabIndex = 26; this.lbOuterIters.TabIndex = 26;
this.lbOuterIters.Text = "Num of refinement iters:"; this.lbOuterIters.Text = "Num of refinement iters:";
// //
// chSkeletons
//
this.chSkeletons.AutoSize = true;
this.chSkeletons.Location = new System.Drawing.Point(11, 41);
this.chSkeletons.Name = "chSkeletons";
this.chSkeletons.Size = new System.Drawing.Size(154, 17);
this.chSkeletons.TabIndex = 21;
this.chSkeletons.Text = "show skeletons in live view";
this.chSkeletons.UseVisualStyleBackColor = true;
this.chSkeletons.CheckedChanged += new System.EventHandler(this.chSkeletons_CheckedChanged);
//
// SettingsForm // SettingsForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -648,6 +661,7 @@
private System.Windows.Forms.RadioButton rBinaryPly; private System.Windows.Forms.RadioButton rBinaryPly;
private System.Windows.Forms.Label lbFormat; private System.Windows.Forms.Label lbFormat;
private System.Windows.Forms.RadioButton rAsciiPly; private System.Windows.Forms.RadioButton rAsciiPly;
private System.Windows.Forms.CheckBox chSkeletons;
} }
} }
+7 -1
View File
@@ -51,7 +51,8 @@ namespace KinectServer
lisMarkers.DataSource = oSettings.lMarkerPoses; lisMarkers.DataSource = oSettings.lMarkerPoses;
chBodyData.Checked = oSettings.bStreamOnlyBodies; chBodyData.Checked = oSettings.bStreamOnlyBodies;
chSkeletons.Checked = oSettings.bShowSkeletons;
chMerge.Checked = oSettings.bMergeScansForSave; chMerge.Checked = oSettings.bMergeScansForSave;
txtICPIters.Text = oSettings.nNumICPIterations.ToString(); txtICPIters.Text = oSettings.nNumICPIterations.ToString();
@@ -310,5 +311,10 @@ namespace KinectServer
oSettings.bSaveAsBinaryPLY = true; oSettings.bSaveAsBinaryPLY = true;
} }
} }
private void chSkeletons_CheckedChanged(object sender, EventArgs e)
{
oSettings.bShowSkeletons = chSkeletons.Checked;
}
} }
} }
+6
View File
@@ -19,6 +19,12 @@
struct Body struct Body
{ {
Body()
{
bTracked = false;
vJoints.resize(JointType_Count);
vJointsInColorSpace.resize(JointType_Count);
}
bool bTracked; bool bTracked;
std::vector<Joint> vJoints; std::vector<Joint> vJoints;
std::vector<Point2f> vJointsInColorSpace; std::vector<Point2f> vJointsInColorSpace;
+3 -3
View File
@@ -187,11 +187,11 @@ void KinectCapture::GetBodyFrame(IMultiSourceFrame* pMultiFrame)
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
IBody* bodies[6] = { NULL }; IBody* bodies[BODY_COUNT] = { NULL };
pBodyFrame->GetAndRefreshBodyData(6, bodies); pBodyFrame->GetAndRefreshBodyData(BODY_COUNT, bodies);
vBodies = std::vector<Body>(BODY_COUNT); vBodies = std::vector<Body>(BODY_COUNT);
for (int i = 0; i < 6; i++) for (int i = 0; i < BODY_COUNT; i++)
{ {
if (bodies[i]) if (bodies[i])
{ {
+12 -10
View File
@@ -721,23 +721,25 @@ void LiveScanClient::StoreFrame(Point3f *vertices, Point2f *mapping, RGB *color,
} }
} }
for (unsigned int i = 0; i < bodies.size(); i++) vector<Body> tempBodies = bodies;
for (unsigned int i = 0; i < tempBodies.size(); i++)
{ {
for (unsigned int j = 0; j < bodies[i].vJoints.size(); j++) for (unsigned int j = 0; j < tempBodies[i].vJoints.size(); j++)
{ {
if (calibration.bCalibrated) if (calibration.bCalibrated)
{ {
bodies[i].vJoints[j].Position.X += calibration.worldT[0]; tempBodies[i].vJoints[j].Position.X += calibration.worldT[0];
bodies[i].vJoints[j].Position.Y += calibration.worldT[1]; tempBodies[i].vJoints[j].Position.Y += calibration.worldT[1];
bodies[i].vJoints[j].Position.Z += calibration.worldT[2]; tempBodies[i].vJoints[j].Position.Z += calibration.worldT[2];
Point3f tempPoint(bodies[i].vJoints[j].Position.X, bodies[i].vJoints[j].Position.Y, bodies[i].vJoints[j].Position.Z); Point3f tempPoint(tempBodies[i].vJoints[j].Position.X, tempBodies[i].vJoints[j].Position.Y, tempBodies[i].vJoints[j].Position.Z);
tempPoint = RotatePoint(tempPoint, calibration.worldR); tempPoint = RotatePoint(tempPoint, calibration.worldR);
bodies[i].vJoints[j].Position.X = tempPoint.X; tempBodies[i].vJoints[j].Position.X = tempPoint.X;
bodies[i].vJoints[j].Position.Y = tempPoint.Y; tempBodies[i].vJoints[j].Position.Y = tempPoint.Y;
bodies[i].vJoints[j].Position.Z = tempPoint.Z; tempBodies[i].vJoints[j].Position.Z = tempPoint.Z;
} }
} }
} }
@@ -752,7 +754,7 @@ void LiveScanClient::StoreFrame(Point3f *vertices, Point2f *mapping, RGB *color,
goodVerticesShort[i] = goodVertices[i]; goodVerticesShort[i] = goodVertices[i];
} }
m_vLastFrameBody = bodies; m_vLastFrameBody = tempBodies;
m_vLastFrameVertices = goodVerticesShort; m_vLastFrameVertices = goodVerticesShort;
m_vLastFrameRGB = goodColorPoints; m_vLastFrameRGB = goodColorPoints;
} }