Skip to content

Commit

Permalink
minor fix for skeleon painter
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasbaur committed Feb 22, 2019
1 parent 412c278 commit d233a93
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Types/MediaKit.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public void OnMouseUp(object sender, MouseButtonEventArgs e)
} }


public void Move(double time) public void Move(double time)
{ {
//First Frame appears to be bugged in the library, therefore we move the video position for 1 frame //First Frame appears to be bugged in the library, therefore we move the video position for 1 frame
double offset = 1.0f / sampleRate; double offset = 1.0f / sampleRate;
time = (time >= offset) ? time - offset : 0; time = (time >= offset) ? time - offset : 0;
MediaPosition = (long)(time * 10000000.0); MediaPosition = (long)(time * 10000000.0);
Expand Down
64 changes: 38 additions & 26 deletions Types/Skeleton.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Skeleton(string filepath, Signal signal, int width = 640, int height = 48


BackColor = Defaults.Colors.Background; BackColor = Defaults.Colors.Background;
SignalColor = Defaults.Colors.Foreground; SignalColor = Defaults.Colors.Foreground;
HeadColor = Defaults.Colors.Foreground; HeadColor = Colors.YellowGreen; // Defaults.Colors.Foreground;


numSkeletons = 0; numSkeletons = 0;
if (signal.Meta.ContainsKey("num")) if (signal.Meta.ContainsKey("num"))
Expand Down Expand Up @@ -170,11 +170,27 @@ public void Draw(double time)
{ {
case SkeletonType.SSI: case SkeletonType.SSI:
{ {

writeableBmp.DrawLine((int)points[3].X, (int)points[3].Y, (int)points[12].X, (int)points[12].Y, getColor(12)); // Hip Center to Left Hip
writeableBmp.DrawLine((int)points[3].X, (int)points[3].Y, (int)points[16].X, (int)points[16].Y, getColor(16)); //Hip Center to Right Hip

writeableBmp.DrawLine((int)points[12].X, (int)points[12].Y, (int)points[13].X, (int)points[13].Y, getColor(13)); // Left Hip to Knee
writeableBmp.DrawLine((int)points[16].X, (int)points[16].Y, (int)points[17].X, (int)points[17].Y, getColor(17)); // Right Hip to Knee

writeableBmp.DrawLine((int)points[13].X, (int)points[13].Y, (int)points[14].X, (int)points[14].Y, getColor(14)); // Left Knee to Ankle
writeableBmp.DrawLine((int)points[17].X, (int)points[17].Y, (int)points[18].X, (int)points[18].Y, getColor(18)); // Right Knee to Ankle

writeableBmp.DrawLine((int)points[14].X, (int)points[14].Y, (int)points[15].X, (int)points[15].Y, getColor(15)); // Left Ankle to foot
writeableBmp.DrawLine((int)points[18].X, (int)points[18].Y, (int)points[19].X, (int)points[19].Y, getColor(19)); // Right Ankle to foot




//head //head
writeableBmp.DrawLine((int)points[23].X, (int)points[23].Y, (int)points[21].X, (int)points[21].Y, colhead); writeableBmp.DrawLine((int)points[23].X, (int)points[23].Y, (int)points[21].X, (int)points[21].Y, getColor(21, true));
writeableBmp.DrawLine((int)points[23].X, (int)points[23].Y, (int)points[22].X, (int)points[22].Y, colhead); writeableBmp.DrawLine((int)points[21].X, (int)points[21].Y, (int)points[24].X, (int)points[24].Y, getColor(24, true));
writeableBmp.DrawLine((int)points[21].X, (int)points[21].Y, (int)points[24].X, (int)points[24].Y, colhead); writeableBmp.DrawLine((int)points[24].X, (int)points[24].Y, (int)points[22].X, (int)points[22].Y, getColor(22, true));
writeableBmp.DrawLine((int)points[22].X, (int)points[22].Y, (int)points[24].X, (int)points[24].Y, colhead); writeableBmp.DrawLine((int)points[22].X, (int)points[22].Y, (int)points[23].X, (int)points[23].Y, getColor(23, true));


writeableBmp.DrawLine((int)points[0].X, (int)points[0].Y, (int)points[1].X, (int)points[1].Y, getColor(1)); //Head to Neck writeableBmp.DrawLine((int)points[0].X, (int)points[0].Y, (int)points[1].X, (int)points[1].Y, getColor(1)); //Head to Neck


Expand All @@ -193,17 +209,7 @@ public void Draw(double time)
writeableBmp.DrawLine((int)points[1].X, (int)points[1].Y, (int)points[2].X, (int)points[2].Y, getColor(2)); //Neck to Torso writeableBmp.DrawLine((int)points[1].X, (int)points[1].Y, (int)points[2].X, (int)points[2].Y, getColor(2)); //Neck to Torso
writeableBmp.DrawLine((int)points[2].X, (int)points[2].Y, (int)points[3].X, (int)points[3].Y, getColor(3)); //Torso to Hip Center writeableBmp.DrawLine((int)points[2].X, (int)points[2].Y, (int)points[3].X, (int)points[3].Y, getColor(3)); //Torso to Hip Center


writeableBmp.DrawLine((int)points[3].X, (int)points[3].Y, (int)points[12].X, (int)points[12].Y, getColor(12)); // Hip Center to Left Hip
writeableBmp.DrawLine((int)points[3].X, (int)points[3].Y, (int)points[16].X, (int)points[16].Y, getColor(16)); //Hip Center to Right Hip

writeableBmp.DrawLine((int)points[12].X, (int)points[12].Y, (int)points[13].X, (int)points[13].Y, getColor(13)); // Left Hip to Knee
writeableBmp.DrawLine((int)points[16].X, (int)points[16].Y, (int)points[17].X, (int)points[17].Y, getColor(17)); // Right Hip to Knee

writeableBmp.DrawLine((int)points[13].X, (int)points[13].Y, (int)points[14].X, (int)points[14].Y, getColor(14)); // Left Knee to Ankle
writeableBmp.DrawLine((int)points[17].X, (int)points[17].Y, (int)points[18].X, (int)points[18].Y, getColor(18)); // Right Knee to Ankle

writeableBmp.DrawLine((int)points[14].X, (int)points[14].Y, (int)points[15].X, (int)points[15].Y, getColor(15)); // Left Ankle to foot
writeableBmp.DrawLine((int)points[18].X, (int)points[18].Y, (int)points[19].X, (int)points[19].Y, getColor(19)); // Right Ankle to foot
break; break;
} }
case SkeletonType.KINECT1: case SkeletonType.KINECT1:
Expand Down Expand Up @@ -281,29 +287,35 @@ public void Draw(double time)
writeableBmp.Unlock(); writeableBmp.Unlock();
} }


private Color getColor(int i) private Color getColor(int i, bool isheadcolor = false)
{ {
Color c = SignalColor; Color c = isheadcolor ? HeadColor : SignalColor;
double pos = MainHandler.Time.CurrentPlayPosition; double pos = MainHandler.Time.CurrentPlayPosition;
int index = (int)(pos * signal.rate); int index = (int)(pos * signal.rate);


if (signal.data.Length >= (index * signal.dim) + i * jointValues + 3) if (signal.data.Length >= (index * signal.dim) + i * jointValues + 3)


{ {
if ((signal.data[(index * signal.dim) + i * jointValues + 3]) < 0.5) if ((signal.data[(index * signal.dim) + i * jointValues + 3]) < 0.1 || (signal.data[(index * signal.dim) + i * jointValues] == 0))
{ {
c = SignalColor; c = Colors.White;
c.A = 128; // c.A = 0;
} }
else if ((signal.data[(index * signal.dim) + i * jointValues + 3]) < 1.0)
else if ((signal.data[(index * signal.dim) + i * jointValues + 3]) < 0.5)
{ {
c = SignalColor;
c.A = 0; c.A = 128;
} }
else else if ((signal.data[(index * signal.dim) + i * jointValues + 3]) < 1.0)
{ {
c = SignalColor;
c.A = 255;
} }
//else
//{
// c = SignalColor;
//}
} }
return c; return c;
} }
Expand Down
Binary file modified bin/nova.exe
Binary file not shown.
Binary file modified bin/updater.exe
Binary file not shown.

0 comments on commit d233a93

Please sign in to comment.