mirror of
https://github.com/storytold/LiveScan3D.git
synced 2026-10-09 00:09:58 +00:00
Corrected some issues with how skeletons were displayed.
This commit is contained in:
@@ -34,6 +34,7 @@ namespace KinectServer
|
||||
public BindingList<MarkerPose> lMarkerPoses = new BindingList<MarkerPose>();
|
||||
|
||||
public bool bStreamOnlyBodies = false;
|
||||
public bool bShowSkeletons = true;
|
||||
|
||||
public int nNumICPIterations = 10;
|
||||
public int nNumRefineIters = 2;
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace KinectServer
|
||||
if ((DateTime.Now - tFPSUpdateTimer).Seconds >= 1)
|
||||
{
|
||||
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;
|
||||
nTickCounter = 0;
|
||||
@@ -292,42 +292,43 @@ namespace KinectServer
|
||||
|
||||
lock (vertices)
|
||||
{
|
||||
lock (settings)
|
||||
{
|
||||
PointCount = vertices.Count / 3;
|
||||
//bounding box
|
||||
LineCount = 12;
|
||||
//markers
|
||||
LineCount += settings.lMarkerPoses.Count * 3;
|
||||
//cameras
|
||||
LineCount += cameraPoses.Count * 3;
|
||||
bool bShowSkeletons = settings.bShowSkeletons;
|
||||
|
||||
PointCount = vertices.Count / 3;
|
||||
//bounding box
|
||||
LineCount = 12;
|
||||
//markers
|
||||
LineCount += settings.lMarkerPoses.Count * 3;
|
||||
//cameras
|
||||
LineCount += cameraPoses.Count * 3;
|
||||
if (bShowSkeletons)
|
||||
LineCount += 24 * bodies.Count;
|
||||
|
||||
VBO = new VertexC4ubV3f[PointCount + 2 * LineCount];
|
||||
VBO = new VertexC4ubV3f[PointCount + 2 * LineCount];
|
||||
|
||||
for (int i = 0; i < PointCount; i++)
|
||||
{
|
||||
VBO[i].R = (byte)colors[i * 3];
|
||||
VBO[i].G = (byte)colors[i * 3 + 1];
|
||||
VBO[i].B = (byte)colors[i * 3 + 2];
|
||||
VBO[i].A = 255;
|
||||
VBO[i].Position.X = vertices[i * 3];
|
||||
VBO[i].Position.Y = vertices[i * 3 + 1];
|
||||
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);
|
||||
for (int i = 0; i < PointCount; i++)
|
||||
{
|
||||
VBO[i].R = (byte)colors[i * 3];
|
||||
VBO[i].G = (byte)colors[i * 3 + 1];
|
||||
VBO[i].B = (byte)colors[i * 3 + 2];
|
||||
VBO[i].A = 255;
|
||||
VBO[i].Position.X = vertices[i * 3];
|
||||
VBO[i].Position.Y = vertices[i * 3 + 1];
|
||||
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]);
|
||||
}
|
||||
if (bShowSkeletons)
|
||||
iCurLineCount += AddBodies(PointCount + 2 * iCurLineCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,6 +575,9 @@ namespace KinectServer
|
||||
|
||||
for (int bodyIdx = 0; bodyIdx < bodies.Count; bodyIdx++)
|
||||
{
|
||||
if (bodies[bodyIdx].bTracked == false)
|
||||
continue;
|
||||
|
||||
//Torso
|
||||
n += AddBone(bodyIdx, JointType.JointType_Head, JointType.JointType_Neck, 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_KneeLeft, JointType.JointType_AnkleLeft, startIdx + n);
|
||||
n += AddBone(bodyIdx, JointType.JointType_AnkleLeft, JointType.JointType_FootLeft, startIdx + n);
|
||||
}
|
||||
}
|
||||
|
||||
return nLinesToAdd;
|
||||
}
|
||||
|
||||
|
||||
Generated
+15
-1
@@ -77,6 +77,7 @@
|
||||
this.rAsciiPly = new System.Windows.Forms.RadioButton();
|
||||
this.txtRefinIters = new System.Windows.Forms.TextBox();
|
||||
this.lbOuterIters = new System.Windows.Forms.Label();
|
||||
this.chSkeletons = new System.Windows.Forms.CheckBox();
|
||||
this.grClient.SuspendLayout();
|
||||
this.grBody.SuspendLayout();
|
||||
this.grMarkers.SuspendLayout();
|
||||
@@ -137,6 +138,7 @@
|
||||
//
|
||||
// grBody
|
||||
//
|
||||
this.grBody.Controls.Add(this.chSkeletons);
|
||||
this.grBody.Controls.Add(this.label1);
|
||||
this.grBody.Controls.Add(this.chBodyData);
|
||||
this.grBody.Location = new System.Drawing.Point(9, 211);
|
||||
@@ -149,7 +151,7 @@
|
||||
// label1
|
||||
//
|
||||
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.Size = new System.Drawing.Size(187, 13);
|
||||
this.label1.TabIndex = 20;
|
||||
@@ -570,6 +572,17 @@
|
||||
this.lbOuterIters.TabIndex = 26;
|
||||
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
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -648,6 +661,7 @@
|
||||
private System.Windows.Forms.RadioButton rBinaryPly;
|
||||
private System.Windows.Forms.Label lbFormat;
|
||||
private System.Windows.Forms.RadioButton rAsciiPly;
|
||||
private System.Windows.Forms.CheckBox chSkeletons;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,8 @@ namespace KinectServer
|
||||
|
||||
lisMarkers.DataSource = oSettings.lMarkerPoses;
|
||||
|
||||
chBodyData.Checked = oSettings.bStreamOnlyBodies;
|
||||
chBodyData.Checked = oSettings.bStreamOnlyBodies;
|
||||
chSkeletons.Checked = oSettings.bShowSkeletons;
|
||||
|
||||
chMerge.Checked = oSettings.bMergeScansForSave;
|
||||
txtICPIters.Text = oSettings.nNumICPIterations.ToString();
|
||||
@@ -310,5 +311,10 @@ namespace KinectServer
|
||||
oSettings.bSaveAsBinaryPLY = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void chSkeletons_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
oSettings.bShowSkeletons = chSkeletons.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
|
||||
struct Body
|
||||
{
|
||||
Body()
|
||||
{
|
||||
bTracked = false;
|
||||
vJoints.resize(JointType_Count);
|
||||
vJointsInColorSpace.resize(JointType_Count);
|
||||
}
|
||||
bool bTracked;
|
||||
std::vector<Joint> vJoints;
|
||||
std::vector<Point2f> vJointsInColorSpace;
|
||||
|
||||
@@ -187,11 +187,11 @@ void KinectCapture::GetBodyFrame(IMultiSourceFrame* pMultiFrame)
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
IBody* bodies[6] = { NULL };
|
||||
pBodyFrame->GetAndRefreshBodyData(6, bodies);
|
||||
IBody* bodies[BODY_COUNT] = { NULL };
|
||||
pBodyFrame->GetAndRefreshBodyData(BODY_COUNT, bodies);
|
||||
|
||||
vBodies = std::vector<Body>(BODY_COUNT);
|
||||
for (int i = 0; i < 6; i++)
|
||||
for (int i = 0; i < BODY_COUNT; i++)
|
||||
{
|
||||
if (bodies[i])
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
bodies[i].vJoints[j].Position.X += calibration.worldT[0];
|
||||
bodies[i].vJoints[j].Position.Y += calibration.worldT[1];
|
||||
bodies[i].vJoints[j].Position.Z += calibration.worldT[2];
|
||||
tempBodies[i].vJoints[j].Position.X += calibration.worldT[0];
|
||||
tempBodies[i].vJoints[j].Position.Y += calibration.worldT[1];
|
||||
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);
|
||||
|
||||
bodies[i].vJoints[j].Position.X = tempPoint.X;
|
||||
bodies[i].vJoints[j].Position.Y = tempPoint.Y;
|
||||
bodies[i].vJoints[j].Position.Z = tempPoint.Z;
|
||||
tempBodies[i].vJoints[j].Position.X = tempPoint.X;
|
||||
tempBodies[i].vJoints[j].Position.Y = tempPoint.Y;
|
||||
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];
|
||||
}
|
||||
|
||||
m_vLastFrameBody = bodies;
|
||||
m_vLastFrameBody = tempBodies;
|
||||
m_vLastFrameVertices = goodVerticesShort;
|
||||
m_vLastFrameRGB = goodColorPoints;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user