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
+9 -37
View File
@@ -12,64 +12,36 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveScanServer", "LiveScanS
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ICP", "ICP\ICP.vcxproj", "{973EE923-B423-4BCD-AA08-B03DA40CB51F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveScanPlayer", "LiveScanPlayer\LiveScanPlayer.csproj", "{E52AB19C-F67D-4932-90BD-CC549C1FEC8B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Release ICP as exe|Any CPU = Release ICP as exe|Any CPU
Release ICP as exe|Mixed Platforms = Release ICP as exe|Mixed Platforms
Release ICP as exe|Win32 = Release ICP as exe|Win32
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Debug|Any CPU.ActiveCfg = Debug|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Debug|Win32.ActiveCfg = Debug|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Debug|Win32.Build.0 = Debug|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Release ICP as exe|Any CPU.ActiveCfg = Release|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Release ICP as exe|Mixed Platforms.ActiveCfg = Release|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Release ICP as exe|Mixed Platforms.Build.0 = Release|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Release ICP as exe|Win32.ActiveCfg = Release|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Release ICP as exe|Win32.Build.0 = Release|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Release|Any CPU.ActiveCfg = Release|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Release|Mixed Platforms.Build.0 = Release|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Release|Win32.ActiveCfg = Release|Win32
{9B550BBA-EAFB-4D12-8B1C-8FDA39361F52}.Release|Win32.Build.0 = Release|Win32
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Debug|Win32.ActiveCfg = Debug|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release ICP as exe|Any CPU.ActiveCfg = Release|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release ICP as exe|Any CPU.Build.0 = Release|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release ICP as exe|Mixed Platforms.ActiveCfg = Release|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release ICP as exe|Mixed Platforms.Build.0 = Release|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Debug|Win32.Build.0 = Debug|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release ICP as exe|Win32.ActiveCfg = Release|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release|Any CPU.Build.0 = Release|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release|Win32.ActiveCfg = Release|Any CPU
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Debug|Any CPU.ActiveCfg = Debug|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{78422B2C-0EF1-4A28-A40E-2A7C4A9204B1}.Release|Win32.Build.0 = Release|Any CPU
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Debug|Win32.ActiveCfg = Debug|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Debug|Win32.Build.0 = Debug|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Release ICP as exe|Any CPU.ActiveCfg = Release|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Release ICP as exe|Mixed Platforms.ActiveCfg = Release|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Release ICP as exe|Mixed Platforms.Build.0 = Release|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Release ICP as exe|Win32.ActiveCfg = Release|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Release ICP as exe|Win32.Build.0 = Release|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Release|Any CPU.ActiveCfg = Release DLL|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Release|Mixed Platforms.ActiveCfg = Release DLL|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Release|Mixed Platforms.Build.0 = Release DLL|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Release|Win32.ActiveCfg = Release DLL|Win32
{973EE923-B423-4BCD-AA08-B03DA40CB51F}.Release|Win32.Build.0 = Release DLL|Win32
{E52AB19C-F67D-4932-90BD-CC549C1FEC8B}.Debug|Win32.ActiveCfg = Debug|Any CPU
{E52AB19C-F67D-4932-90BD-CC549C1FEC8B}.Debug|Win32.Build.0 = Debug|Any CPU
{E52AB19C-F67D-4932-90BD-CC549C1FEC8B}.Release ICP as exe|Win32.ActiveCfg = Release|Any CPU
{E52AB19C-F67D-4932-90BD-CC549C1FEC8B}.Release|Win32.ActiveCfg = Release|Any CPU
{E52AB19C-F67D-4932-90BD-CC549C1FEC8B}.Release|Win32.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
+122
View File
@@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace LiveScanPlayer
{
class FrameFileReader
{
BinaryReader binaryReader;
int currentFrameIdx = 0;
string filename;
public FrameFileReader(string filename)
{
this.filename = filename;
binaryReader = new BinaryReader(File.Open(this.filename, FileMode.Open));
}
~FrameFileReader()
{
Dispose();
}
public int frameIdx
{
get
{
return currentFrameIdx;
}
set
{
JumpToFrame(value);
}
}
public void Dispose()
{
binaryReader.Dispose();
}
public void ReadFrame(List<float> vertices, List<byte> colors)
{
if (binaryReader.BaseStream.Position == binaryReader.BaseStream.Length)
Rewind();
string[] lineParts = ReadLine().Split(' ');
int nPoints = Int32.Parse(lineParts[1]);
lineParts = ReadLine().Split(' ');
int frameTimestamp = Int32.Parse(lineParts[1]);
Console.WriteLine((frameTimestamp / 1000).ToString());
short[] tempVertices = new short[3 * nPoints];
byte[] tempColors = new byte[4 * nPoints];
int bytesPerVertexPoint = 3 * sizeof(short);
int bytesPerColorPoint = 4 * sizeof(byte);
int bytesPerPoint = bytesPerVertexPoint + bytesPerColorPoint;
byte[] frameData = binaryReader.ReadBytes(bytesPerPoint * nPoints);
if (frameData.Length < bytesPerPoint * nPoints)
{
Rewind();
ReadFrame(vertices, colors);
return;
}
int vertexDataSize = nPoints * bytesPerVertexPoint;
int colorDataSize = nPoints * bytesPerColorPoint;
Buffer.BlockCopy(frameData, 0, tempVertices, 0, vertexDataSize);
Buffer.BlockCopy(frameData, vertexDataSize, tempColors, 0, colorDataSize);
for (int i = 0; i < nPoints; i++)
{
for (int j = 0; j < 3; j++)
{
vertices.Add(tempVertices[3 * i + j] / 1000.0f);
colors.Add(tempColors[4 * i + j]);
}
}
binaryReader.ReadByte();
currentFrameIdx++;
}
public void JumpToFrame(int frameIdx)
{
Rewind();
for (int i = 0; i < frameIdx; i++)
{
List<float> vertices = new List<float>();
List<byte> colors = new List<byte>();
ReadFrame(vertices, colors);
}
}
public string ReadLine()
{
StringBuilder builder = new StringBuilder();
byte buffer = binaryReader.ReadByte();
while (buffer != '\n')
{
builder.Append((char)buffer);
buffer = binaryReader.ReadByte();
}
return builder.ToString();
}
public void Rewind()
{
currentFrameIdx = 0;
binaryReader.BaseStream.Seek(0, SeekOrigin.Begin);
}
}
}
+99
View File
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E52AB19C-F67D-4932-90BD-CC549C1FEC8B}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LiveScanPlayer</RootNamespace>
<AssemblyName>LiveScanPlayer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\OpenTK.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="PlayerWindowForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PlayerWindowForm.Designer.cs">
<DependentUpon>PlayerWindowForm.cs</DependentUpon>
</Compile>
<Compile Include="FrameFileReader.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="PlayerWindowForm.resx">
<DependentUpon>PlayerWindowForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LiveScanServer\LiveScanServer.csproj">
<Project>{78422b2c-0ef1-4a28-a40e-2a7c4a9204b1}</Project>
<Name>LiveScanServer</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+156
View File
@@ -0,0 +1,156 @@
namespace LiveScanPlayer
{
partial class PlayerWindowForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btSelect = new System.Windows.Forms.Button();
this.btStart = new System.Windows.Forms.Button();
this.btShow = new System.Windows.Forms.Button();
this.updateWorker = new System.ComponentModel.BackgroundWorker();
this.OpenGLWorker = new System.ComponentModel.BackgroundWorker();
this.btRewind = new System.Windows.Forms.Button();
this.btRemove = new System.Windows.Forms.Button();
this.lFrameFilesListView = new System.Windows.Forms.ListView();
this.chSaveFrames = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// btSelect
//
this.btSelect.Location = new System.Drawing.Point(12, 41);
this.btSelect.Name = "btSelect";
this.btSelect.Size = new System.Drawing.Size(75, 23);
this.btSelect.TabIndex = 0;
this.btSelect.Text = "Select files";
this.btSelect.UseVisualStyleBackColor = true;
this.btSelect.Click += new System.EventHandler(this.btSelect_Click);
//
// btStart
//
this.btStart.Location = new System.Drawing.Point(12, 12);
this.btStart.Name = "btStart";
this.btStart.Size = new System.Drawing.Size(75, 23);
this.btStart.TabIndex = 1;
this.btStart.Text = "Start player";
this.btStart.UseVisualStyleBackColor = true;
this.btStart.Click += new System.EventHandler(this.btStart_Click);
//
// btShow
//
this.btShow.Location = new System.Drawing.Point(12, 128);
this.btShow.Name = "btShow";
this.btShow.Size = new System.Drawing.Size(75, 23);
this.btShow.TabIndex = 2;
this.btShow.Text = "Show live";
this.btShow.UseVisualStyleBackColor = true;
this.btShow.Click += new System.EventHandler(this.btShow_Click);
//
// updateWorker
//
this.updateWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.updateWorker_DoWork);
//
// OpenGLWorker
//
this.OpenGLWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.OpenGLWorker_DoWork);
//
// btRewind
//
this.btRewind.Location = new System.Drawing.Point(12, 99);
this.btRewind.Name = "btRewind";
this.btRewind.Size = new System.Drawing.Size(75, 23);
this.btRewind.TabIndex = 5;
this.btRewind.Text = "Rewind";
this.btRewind.UseVisualStyleBackColor = true;
this.btRewind.Click += new System.EventHandler(this.btRewind_Click);
//
// btRemove
//
this.btRemove.Location = new System.Drawing.Point(12, 70);
this.btRemove.Name = "btRemove";
this.btRemove.Size = new System.Drawing.Size(75, 23);
this.btRemove.TabIndex = 6;
this.btRemove.Text = "Remove file";
this.btRemove.UseVisualStyleBackColor = true;
this.btRemove.Click += new System.EventHandler(this.btRemove_Click);
//
// lFrameFilesListView
//
this.lFrameFilesListView.LabelEdit = true;
this.lFrameFilesListView.Location = new System.Drawing.Point(93, 12);
this.lFrameFilesListView.MultiSelect = false;
this.lFrameFilesListView.Name = "lFrameFilesListView";
this.lFrameFilesListView.Size = new System.Drawing.Size(422, 97);
this.lFrameFilesListView.TabIndex = 7;
this.lFrameFilesListView.UseCompatibleStateImageBehavior = false;
this.lFrameFilesListView.View = System.Windows.Forms.View.Details;
this.lFrameFilesListView.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.lFrameFilesListView_AfterLabelEdit);
this.lFrameFilesListView.DoubleClick += new System.EventHandler(this.lFrameFilesListView_DoubleClick);
//
// chSaveFrames
//
this.chSaveFrames.AutoSize = true;
this.chSaveFrames.Location = new System.Drawing.Point(435, 128);
this.chSaveFrames.Name = "chSaveFrames";
this.chSaveFrames.Size = new System.Drawing.Size(83, 17);
this.chSaveFrames.TabIndex = 8;
this.chSaveFrames.Text = "save frames";
this.chSaveFrames.UseVisualStyleBackColor = true;
//
// PlayerWindowForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(527, 166);
this.Controls.Add(this.chSaveFrames);
this.Controls.Add(this.lFrameFilesListView);
this.Controls.Add(this.btRemove);
this.Controls.Add(this.btRewind);
this.Controls.Add(this.btShow);
this.Controls.Add(this.btStart);
this.Controls.Add(this.btSelect);
this.Name = "PlayerWindowForm";
this.Text = "LiveScanPlayer";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PlayerWindowForm_FormClosing);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btSelect;
private System.Windows.Forms.Button btStart;
private System.Windows.Forms.Button btShow;
private System.ComponentModel.BackgroundWorker updateWorker;
private System.ComponentModel.BackgroundWorker OpenGLWorker;
private System.Windows.Forms.Button btRewind;
private System.Windows.Forms.Button btRemove;
private System.Windows.Forms.ListView lFrameFilesListView;
private System.Windows.Forms.CheckBox chSaveFrames;
}
}
+219
View File
@@ -0,0 +1,219 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using KinectServer;
namespace LiveScanPlayer
{
public partial class PlayerWindowForm : Form
{
BindingList<FrameFileReader> lFrameFiles = new BindingList<FrameFileReader>();
bool bPlayerRunning = false;
List<float> lAllVertices = new List<float>();
List<byte> lAllColors = new List<byte>();
TransferServer oTransferServer = new TransferServer();
AutoResetEvent eUpdateWorkerFinished = new AutoResetEvent(false);
public PlayerWindowForm()
{
InitializeComponent();
oTransferServer.lVertices = lAllVertices;
oTransferServer.lColors = lAllColors;
lFrameFilesListView.Columns.Add("Current frame", 75);
lFrameFilesListView.Columns.Add("Filename", 300);
}
private void PlayerWindowForm_FormClosing(object sender, FormClosingEventArgs e)
{
bPlayerRunning = false;
oTransferServer.StopServer();
}
private void btSelect_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = true;
dialog.ShowDialog();
lock (lFrameFiles)
{
for (int i = 0; i < dialog.FileNames.Length; i++)
{
lFrameFiles.Add(new FrameFileReader(dialog.FileNames[i]));
var item = new ListViewItem(new [] { "0", dialog.FileNames[i]});
lFrameFilesListView.Items.Add(item);
}
}
}
private void btStart_Click(object sender, EventArgs e)
{
bPlayerRunning = !bPlayerRunning;
if (bPlayerRunning)
{
oTransferServer.StartServer();
updateWorker.RunWorkerAsync();
btStart.Text = "Stop player";
}
else
{
oTransferServer.StopServer();
btStart.Text = "Start player";
eUpdateWorkerFinished.WaitOne();
}
}
private void btRemove_Click(object sender, EventArgs e)
{
if (lFrameFilesListView.SelectedIndices.Count == 0)
return;
lock (lFrameFiles)
{
int idx = lFrameFilesListView.SelectedIndices[0];
lFrameFilesListView.Items.RemoveAt(idx);
lFrameFiles[idx].Dispose();
lFrameFiles.RemoveAt(idx);
}
}
private void btRewind_Click(object sender, EventArgs e)
{
lock (lFrameFiles)
{
for (int i = 0; i < lFrameFiles.Count; i++)
{
lFrameFiles[i].Rewind();
lFrameFilesListView.Items[i].Text = "0";
}
}
}
private void btShow_Click(object sender, EventArgs e)
{
if (!OpenGLWorker.IsBusy)
OpenGLWorker.RunWorkerAsync();
}
private void updateWorker_DoWork(object sender, DoWorkEventArgs e)
{
int curFrameIdx = 0;
string outDir = "outPlayer\\";
DirectoryInfo di = Directory.CreateDirectory(outDir);
while (bPlayerRunning)
{
Thread.Sleep(50);
List<float> tempAllVertices = new List<float>();
List<byte> tempAllColors = new List<byte>();
lock (lFrameFiles)
{
for (int i = 0; i < lFrameFiles.Count; i++)
{
List<float> vertices = new List<float>();
List<byte> colors = new List<byte>();
lFrameFiles[i].ReadFrame(vertices, colors);
tempAllVertices.AddRange(vertices);
tempAllColors.AddRange(colors);
}
}
Thread frameIdxUpdate = new Thread(() => this.Invoke((MethodInvoker)delegate { this.UpdateDisplayedFrameIndices(); }));
frameIdxUpdate.Start();
lock (lAllVertices)
{
lAllVertices.Clear();
lAllColors.Clear();
lAllVertices.AddRange(tempAllVertices);
lAllColors.AddRange(tempAllColors);
}
if (chSaveFrames.Checked)
SaveCurrentFrameToFile(outDir, curFrameIdx);
curFrameIdx++;
}
eUpdateWorkerFinished.Set();
}
private void OpenGLWorker_DoWork(object sender, DoWorkEventArgs e)
{
OpenGLWindow openGLWindow = new OpenGLWindow();
openGLWindow.vertices = lAllVertices;
openGLWindow.colors = lAllColors;
openGLWindow.Run();
}
private void lFrameFilesListView_DoubleClick(object sender, EventArgs e)
{
lFrameFilesListView.SelectedItems[0].BeginEdit();
}
private void lFrameFilesListView_AfterLabelEdit(object sender, LabelEditEventArgs e)
{
int fileIdx = lFrameFilesListView.SelectedIndices[0];
int frameIdx;
bool res = Int32.TryParse(e.Label, out frameIdx);
if (!res)
{
e.CancelEdit = true;
return;
}
lock (lFrameFiles)
{
lFrameFiles[fileIdx].JumpToFrame(frameIdx);
}
}
private void UpdateDisplayedFrameIndices()
{
lock (lFrameFiles)
{
for (int i = 0; i < lFrameFiles.Count; i++)
{
lFrameFilesListView.Items[i].SubItems[0].Text = lFrameFiles[i].frameIdx.ToString();
}
}
}
private void SaveCurrentFrameToFile(string outDir, int frameIdx)
{
List<float> lVertices = new List<float>();
List<byte> lColors = new List<byte>();
lock (lAllVertices)
{
lVertices.AddRange(lAllVertices);
lColors.AddRange(lAllColors);
}
string outputFilename = outDir + frameIdx.ToString().PadLeft(5, '0') + ".ply";
Utils.saveToPly(outputFilename, lVertices, lColors, true);
}
}
}
+126
View File
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="updateWorker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>133, 17</value>
</metadata>
<metadata name="OpenGLWorker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>263, 17</value>
</metadata>
</root>
+22
View File
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LiveScanPlayer
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new PlayerWindowForm());
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LiveScanPlayer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LiveScanPlayer")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b435173f-8157-41c6-b94f-3cc1feb6153e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+71
View File
@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LiveScanPlayer.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LiveScanPlayer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
+117
View File
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+30
View File
@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LiveScanPlayer.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
+1 -1
View File
@@ -39,7 +39,7 @@ namespace KinectServer
public int nNumICPIterations = 10;
public int nNumRefineIters = 2;
public bool bMergeScansForSave = false;
public bool bMergeScansForSave = true;
public bool bSaveAsBinaryPLY = true;
public KinectSettings()
+1
View File
@@ -80,6 +80,7 @@
// lClientListBox
//
this.lClientListBox.FormattingEnabled = true;
this.lClientListBox.HorizontalScrollbar = true;
this.lClientListBox.Location = new System.Drawing.Point(113, 12);
this.lClientListBox.Name = "lClientListBox";
this.lClientListBox.Size = new System.Drawing.Size(219, 108);
+9 -58
View File
@@ -42,7 +42,7 @@ namespace KinectServer
static extern float ICP(IntPtr verts1, IntPtr verts2, int nVerts1, int nVerts2, float[] R, float[] t, int maxIter = 200);
KinectServer oServer;
TransferServer oTranfserServer;
TransferServer oTransferServer;
//Those three variables are shared with the OpenGLWindow class and are used to exchange data with it.
//Vertices from all of the sensors
@@ -83,9 +83,9 @@ namespace KinectServer
oServer = new KinectServer(oSettings);
oServer.eSocketListChanged += new SocketListChangedHandler(UpdateListView);
oTranfserServer = new TransferServer();
oTranfserServer.lVertices = lAllVertices;
oTranfserServer.lColors = lAllColors;
oTransferServer = new TransferServer();
oTransferServer.lVertices = lAllVertices;
oTransferServer.lColors = lAllColors;
InitializeComponent();
}
@@ -100,7 +100,7 @@ namespace KinectServer
stream.Close();
oServer.StopServer();
oTranfserServer.StopServer();
oTransferServer.StopServer();
}
//Starts the server
@@ -111,13 +111,13 @@ namespace KinectServer
if (bServerRunning)
{
oServer.StartServer();
oTranfserServer.StartServer();
oTransferServer.StartServer();
btStart.Text = "Stop server";
}
else
{
oServer.StopServer();
oTranfserServer.StopServer();
oTransferServer.StopServer();
btStart.Text = "Start server";
}
}
@@ -224,7 +224,7 @@ namespace KinectServer
if (!oSettings.bMergeScansForSave)
{
string outputFilename = outDir + "\\" + nFrames.ToString().PadLeft(5, '0') + i.ToString() + ".ply";
saveToPly(outputFilename, lFrameVertsAllDevices[i], lFrameRGBAllDevices[i], oSettings.bSaveAsBinaryPLY);
Utils.saveToPly(outputFilename, lFrameVertsAllDevices[i], lFrameRGBAllDevices[i], oSettings.bSaveAsBinaryPLY);
}
}
@@ -232,7 +232,7 @@ namespace KinectServer
if (oSettings.bMergeScansForSave)
{
string outputFilename = outDir + "\\" + nFrames.ToString().PadLeft(5, '0') + ".ply";
saveToPly(outputFilename, lFrameVerts, lFrameRGB, oSettings.bSaveAsBinaryPLY);
Utils.saveToPly(outputFilename, lFrameVerts, lFrameRGB, oSettings.bSaveAsBinaryPLY);
}
}
}
@@ -457,55 +457,6 @@ namespace KinectServer
refineWorker.RunWorkerAsync();
}
private 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();
}
void RestartUpdateWorker()
{
if (!updateWorker.IsBusy)
+1 -1
View File
@@ -33,7 +33,7 @@ enum ECameraMode
namespace KinectServer
{
class OpenGLWindow : GameWindow
public class OpenGLWindow : GameWindow
{
int PointCount;
int LineCount;
+6 -1
View File
@@ -11,7 +11,7 @@ using System.Net;
namespace KinectServer
{
class TransferServer
public class TransferServer
{
public List<float> lVertices = new List<float>();
public List<byte> lColors = new List<byte>();
@@ -22,6 +22,11 @@ namespace KinectServer
object oClientSocketLock = new object();
bool bServerRunning = false;
~TransferServer()
{
StopServer();
}
public void StartServer()
{
if (!bServerRunning)
+1 -1
View File
@@ -9,7 +9,7 @@ using System.Runtime.Serialization.Formatters.Binary;
namespace KinectServer
{
class TransferSocket
public class TransferSocket
{
TcpClient oSocket;
+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();
}
}
}
-3
View File
@@ -55,7 +55,6 @@ private:
bool m_bShowDepth;
bool m_bFrameCompression;
int m_iCompressionLevel;
bool m_bCaptureToFile; // false if capture frames to memory
FrameFileWriterReader m_framesFileWriterReader;
@@ -66,8 +65,6 @@ private:
std::vector<Point3s> m_vLastFrameVertices;
std::vector<RGB> m_vLastFrameRGB;
std::vector<Body> m_vLastFrameBody;
std::vector<std::vector<Point3s>> m_vGatheredVertices;
std::vector<std::vector<RGB>> m_vGatheredRGBPoints;
HWND m_hWnd;
INT64 m_nLastCounter;
+1 -1
View File
@@ -46,7 +46,7 @@ void FrameFileWriterReader::openNewFileForWriting()
char filename[1024];
time_t t = time(0);
struct tm * now = localtime(&t);
sprintf(filename, "recording_%04d_%02d_%02d_%02d_%02d.bin", now->tm_year, now->tm_mon, now->tm_mday, now->tm_hour, now->tm_min, now->tm_sec);
sprintf(filename, "recording_%04d_%02d_%02d_%02d_%02d.bin", now->tm_year + 1900, now->tm_mon + 1, now->tm_mday, now->tm_hour, now->tm_min, now->tm_sec);
m_sFilename = filename;
m_pFileHandle = fopen(filename, "wb");
+13 -45
View File
@@ -53,7 +53,6 @@ LiveScanClient::LiveScanClient() :
m_bFilter(false),
m_bStreamOnlyBodies(false),
m_bCaptureFrame(false),
m_bCaptureToFile(true),
m_bConnected(false),
m_bConfirmCaptured(false),
m_bConfirmCalibrated(false),
@@ -208,19 +207,9 @@ void LiveScanClient::UpdateFrame()
if (m_bCaptureFrame)
{
if (m_bCaptureToFile)
{
m_framesFileWriterReader.writeFrame(m_vLastFrameVertices, m_vLastFrameRGB);
m_bConfirmCaptured = true;
m_bCaptureFrame = false;
}
else
{
m_vGatheredVertices.push_back(m_vLastFrameVertices);
m_vGatheredRGBPoints.push_back(m_vLastFrameRGB);
m_bConfirmCaptured = true;
m_bCaptureFrame = false;
}
m_framesFileWriterReader.writeFrame(m_vLastFrameVertices, m_vLastFrameRGB);
m_bConfirmCaptured = true;
m_bCaptureFrame = false;
}
}
@@ -340,8 +329,6 @@ LRESULT CALLBACK LiveScanClient::DlgProc(HWND hWnd, UINT message, WPARAM wParam,
}
else
{
m_vGatheredVertices.clear();
m_vGatheredRGBPoints.clear();
try
{
char address[20];
@@ -532,33 +519,16 @@ void LiveScanClient::HandleSocket()
{
byteToSend = MSG_STORED_FRAME;
m_pClientSocket->SendBytes(&byteToSend, 1);
if (m_bCaptureToFile)
{
vector<Point3s> points;
vector<RGB> colors;
bool res = m_framesFileWriterReader.readFrame(points, colors);
if (res == false)
{
int size = -1;
m_pClientSocket->SendBytes((char*)&size, 4);
} else
SendFrame(points, colors, m_vLastFrameBody);
}
else
{
if (m_vGatheredRGBPoints.size() > 0)
{
SendFrame(m_vGatheredVertices[0], m_vGatheredRGBPoints[0], m_vLastFrameBody);
m_vGatheredRGBPoints.erase(m_vGatheredRGBPoints.begin(), m_vGatheredRGBPoints.begin() + 1);
m_vGatheredVertices.erase(m_vGatheredVertices.begin(), m_vGatheredVertices.begin() + 1);
}
else
{
int size = -1;
m_pClientSocket->SendBytes((char*)&size, 4);
}
}
vector<Point3s> points;
vector<RGB> colors;
bool res = m_framesFileWriterReader.readFrame(points, colors);
if (res == false)
{
int size = -1;
m_pClientSocket->SendBytes((char*)&size, 4);
} else
SendFrame(points, colors, m_vLastFrameBody);
}
//send last frame
else if (received[i] == MSG_REQUEST_LAST_FRAME)
@@ -591,8 +561,7 @@ void LiveScanClient::HandleSocket()
}
else if (received[i] == MSG_CLEAR_STORED_FRAMES)
{
m_vGatheredVertices.clear();
m_vGatheredRGBPoints.clear();
m_framesFileWriterReader.closeFileIfOpened();
}
}
@@ -644,7 +613,6 @@ void LiveScanClient::SendFrame(vector<Point3s> vertices, vector<RGB> RGB, vector
buffer[pos++] = RGB[i].rgbGreen;
buffer[pos++] = RGB[i].rgbBlue;
memcpy(buffer.data() + pos, ptr2, sizeof(short)* 3);
ptr2 += sizeof(short) * 3;
pos += sizeof(short) * 3;