Added new UI for the Temporal Sync Feature, made the software more robust including:

-Settings window can only be opened once
    -When the client can't open a device, it tries multiple times
    -Recording bins are now saved with a unique ID per device, to allow multiple clients to record on the same PC
    -Synchronized & Unsynchronized devices can be both used in one server
    -Included a workaround for a bug in the Azure Kinect SDK regarding exposure (microsoft/Azure-Kinect-Sensor-SDK#1378)
This commit is contained in:
Christopher Remde
2020-10-14 23:21:18 +02:00
parent 2b15ed0f5b
commit 76bf5e9dba
15 changed files with 744 additions and 129 deletions
+90 -8
View File
@@ -18,12 +18,15 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
using OpenTK.Graphics;
namespace KinectServer
{
public delegate void SocketChangedHandler();
public delegate void SubOrdinateInitialized();
public delegate void MasterRestarted();
public delegate void RecievedSyncJackState();
public delegate void StandAloneInitialized();
public class KinectSocket
{
@@ -35,11 +38,19 @@ namespace KinectServer
public bool bNoMoreStoredFrames = true;
public bool bCalibrated = false;
public bool bSubStarted = false;
public bool bMasterStarted = false;
public enum eTempSyncConfig { MASTER, SUBORDINATE, STANDALONE, UNKNOWN }
//Shows how the *Device* is configured (Determined only by the Sync-Cables hooked up to the device)
public eTempSyncConfig currentDeviceTempSyncState = eTempSyncConfig.STANDALONE;
//Shows how the Client-Software is configured (This is set by the server)
public eTempSyncConfig currentClientTempSyncState = eTempSyncConfig.STANDALONE;
public enum eTempSyncConfig { MASTER, SUBORDINATE, STANDALONE }
public eTempSyncConfig currentTempSyncState = eTempSyncConfig.STANDALONE;
//The pose of the sensor in the scene (used by the OpenGLWindow to show the sensor)
public AffineTransform oCameraPose = new AffineTransform();
//The transform that maps the vertices in the sensor coordinate system to the world corrdinate system.
public AffineTransform oWorldTransform = new AffineTransform();
@@ -51,6 +62,9 @@ namespace KinectServer
public event SocketChangedHandler eChanged;
public event SubOrdinateInitialized eSubInitialized;
public event MasterRestarted eMasterRestart;
public event RecievedSyncJackState eSyncJackstate;
public event StandAloneInitialized eStandAloneInitialized;
public KinectSocket(Socket clientSocket)
{
@@ -135,7 +149,10 @@ namespace KinectServer
/// <param name="tempSyncOn">Enable/Disable Temporal Sync</param>
/// <param name="syncOffSetMultiplier">Only set when this device should be a subordinate. Should be a unique number in ascending order for each sub</param>
public void SendTemporalSyncStatus(bool tempSyncOn, byte syncOffSetMultiplier)
{
{
bSubStarted = false;
currentClientTempSyncState = eTempSyncConfig.UNKNOWN;
if (tempSyncOn)
{
byte[] data = new byte[2];
@@ -161,6 +178,49 @@ namespace KinectServer
SendByte();
}
/// <summary>
/// Asks the client in which way the Sync-Cables are hooked up to the device
/// </summary>
public void RequestTempSyncState()
{
currentDeviceTempSyncState = eTempSyncConfig.UNKNOWN;
byteToSend[0] = 10;
SendByte();
}
public void RecieveDeviceSyncState()
{
byte tempSyncState;
byte[] buffer = new byte[1024];
while (oSocket.Available == 0)
{
if (!SocketConnected())
return;
}
oSocket.Receive(buffer, 3, SocketFlags.None);
tempSyncState = buffer[0];
if (tempSyncState == 0)
{
currentDeviceTempSyncState = eTempSyncConfig.SUBORDINATE;
}
else if (tempSyncState == 1)
{
currentDeviceTempSyncState = eTempSyncConfig.MASTER;
}
else if (tempSyncState == 2)
{
currentDeviceTempSyncState = eTempSyncConfig.STANDALONE;
}
eSyncJackstate.Invoke();
}
public void ReceiveCalibrationData()
{
bCalibrated = true;
@@ -205,25 +265,36 @@ namespace KinectServer
if (tempSyncState == 0)
{
currentTempSyncState = eTempSyncConfig.SUBORDINATE;
currentClientTempSyncState = eTempSyncConfig.SUBORDINATE;
bSubStarted = true;
bMasterStarted = false;
eSubInitialized?.Invoke();
}
else if(tempSyncState == 1)
{
currentTempSyncState = eTempSyncConfig.MASTER;
currentClientTempSyncState = eTempSyncConfig.MASTER;
bSubStarted = false;
}
else if (tempSyncState == 2)
{
currentTempSyncState = eTempSyncConfig.STANDALONE;
currentClientTempSyncState = eTempSyncConfig.STANDALONE;
bSubStarted = false;
bMasterStarted = false;
eStandAloneInitialized?.Invoke();
}
UpdateSocketState();
}
public void RecieveMasterHasRestarted()
{
bMasterStarted = true;
eMasterRestart?.Invoke();
}
public void ReceiveFrame()
{
lFrameRGB.Clear();
@@ -241,6 +312,9 @@ namespace KinectServer
oSocket.Receive(buffer, 8, SocketFlags.None);
nToRead = BitConverter.ToInt32(buffer, 0);
int iCompressed = BitConverter.ToInt32(buffer, 4);
if (nToRead == -1)
@@ -249,6 +323,14 @@ namespace KinectServer
return;
}
//Sometimes we recieve negative values when the cameras are restarting, I don't know why yet.
//I'm just patching this up for now.s
if (nToRead <= 0)
{
return;
}
buffer = new byte[nToRead];
int nAlreadyRead = 0;
@@ -371,7 +453,7 @@ namespace KinectServer
{
string tempSyncMessage = "";
switch (currentTempSyncState)
switch (currentClientTempSyncState)
{
case eTempSyncConfig.MASTER:
tempSyncMessage = "[MASTER]";