Added LiveScanPlayer, as well as some bug fixes and improvements.

This commit is contained in:
MarekKowalski
2017-02-03 16:31:06 +01:00
parent d15f242aca
commit a1e8ba5345
23 changed files with 1107 additions and 148 deletions
+54
View File
@@ -14,6 +14,8 @@
// }
using System;
using System.Collections.Generic;
using System.IO;
using System.Globalization;
namespace KinectServer
{
@@ -157,4 +159,56 @@ namespace KinectServer
public List<Joint> lJoints;
public List<Point2f> lJointsInColorSpace;
}
public class Utils
{
public static void saveToPly(string filename, List<Single> vertices, List<byte> colors, bool binary)
{
int nVertices = vertices.Count / 3;
FileStream fileStream = File.Open(filename, FileMode.Create);
System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(fileStream);
System.IO.BinaryWriter binaryWriter = new System.IO.BinaryWriter(fileStream);
//PLY file header is written here.
if (binary)
streamWriter.WriteLine("ply\nformat binary_little_endian 1.0");
else
streamWriter.WriteLine("ply\nformat ascii 1.0\n");
streamWriter.Write("element vertex " + nVertices.ToString() + "\n");
streamWriter.Write("property float x\nproperty float y\nproperty float z\nproperty uchar red\nproperty uchar green\nproperty uchar blue\nend_header\n");
streamWriter.Flush();
//Vertex and color data are written here.
if (binary)
{
for (int j = 0; j < vertices.Count / 3; j++)
{
for (int k = 0; k < 3; k++)
binaryWriter.Write(vertices[j * 3 + k]);
for (int k = 0; k < 3; k++)
{
byte temp = colors[j * 3 + k];
binaryWriter.Write(temp);
}
}
}
else
{
for (int j = 0; j < vertices.Count / 3; j++)
{
string s = "";
for (int k = 0; k < 3; k++)
s += vertices[j * 3 + k].ToString(CultureInfo.InvariantCulture) + " ";
for (int k = 0; k < 3; k++)
s += colors[j * 3 + k].ToString(CultureInfo.InvariantCulture) + " ";
streamWriter.WriteLine(s);
}
}
streamWriter.Flush();
binaryWriter.Flush();
fileStream.Close();
}
}
}