diff --git a/LiveScanServer/KinectServer.cs b/LiveScanServer/KinectServer.cs index 6454822..4f9045c 100644 --- a/LiveScanServer/KinectServer.cs +++ b/LiveScanServer/KinectServer.cs @@ -232,6 +232,19 @@ namespace KinectServer } } + public void SendTemporalSyncData() + { + lock (oClientSocketLock) + { + lClientSockets[0].SendTemporalSyncStatus(true, false); + + for (int i = 1; i < lClientSockets.Count; i++) + { + lClientSockets[i].SendTemporalSyncStatus(false, true); + } + } + } + public bool GetStoredFrame(List> lFramesRGB, List> lFramesVerts) { bool bNoMoreStoredFrames; @@ -436,6 +449,11 @@ namespace KinectServer lClientSockets[i].bLatestFrameReceived = true; } + else if (buffer[0] == 4) + { + lClientSockets[i].ReceiveTemporalSyncStatus(); + } + buffer = lClientSockets[i].Receive(1); } } diff --git a/LiveScanServer/KinectSettings.cs b/LiveScanServer/KinectSettings.cs index 3627eb3..987e845 100644 --- a/LiveScanServer/KinectSettings.cs +++ b/LiveScanServer/KinectSettings.cs @@ -42,6 +42,8 @@ namespace KinectServer public bool bMergeScansForSave = true; public bool bSaveAsBinaryPLY = true; + public bool bEnableSync = false; + public KinectSettings() { aMinBounds[0] = -5f; diff --git a/LiveScanServer/KinectSocket.cs b/LiveScanServer/KinectSocket.cs index 32c9ca8..065a9a0 100644 --- a/LiveScanServer/KinectSocket.cs +++ b/LiveScanServer/KinectSocket.cs @@ -33,6 +33,8 @@ namespace KinectServer public bool bStoredFrameReceived = false; public bool bNoMoreStoredFrames = true; public bool bCalibrated = false; + public bool bIsMaster = false; + public bool bIsSubOrdinate = false; //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. @@ -121,6 +123,23 @@ namespace KinectServer SendByte(); } + public void SendTemporalSyncStatus(bool isMaster, bool isSubOrdinate) + { + if (isMaster) + { + byteToSend[0] = 7; + SendByte(); + return; + } + + if (isSubOrdinate) + { + byteToSend[0] = 8; + SendByte(); + return; + } + } + public void ReceiveCalibrationData() { bCalibrated = true; @@ -148,6 +167,37 @@ namespace KinectServer UpdateSocketState(); } + public void ReceiveTemporalSyncStatus() + { + int nToRead; + byte[] buffer = new byte[1024]; + + while (oSocket.Available == 0) + { + if (!SocketConnected()) + return; + } + + oSocket.Receive(buffer, 4, SocketFlags.None); + nToRead = BitConverter.ToInt32(buffer, 0); + + if (nToRead == -1) + { + bIsSubOrdinate = true; + bIsMaster = false; + return; + } + + if(nToRead == 0) + { + bIsMaster = true; + bIsSubOrdinate = false; + return; + } + + UpdateSocketState(); + } + public void ReceiveFrame() { lFrameRGB.Clear(); @@ -293,10 +343,19 @@ namespace KinectServer public void UpdateSocketState() { - if (bCalibrated) - sSocketState = oSocket.RemoteEndPoint.ToString() + " Calibrated = true"; - else - sSocketState = oSocket.RemoteEndPoint.ToString() + " Calibrated = false"; + string tempSyncStatus = ""; + + if (bIsMaster) + { + tempSyncStatus = "[Master]"; + } + + if (bIsSubOrdinate) + { + tempSyncStatus = "[Subordinate]"; + } + + sSocketState = oSocket.RemoteEndPoint.ToString() + " Calibrated = " + bCalibrated + " " + tempSyncStatus; if (eChanged != null) eChanged(); diff --git a/LiveScanServer/SettingsForm.Designer.cs b/LiveScanServer/SettingsForm.Designer.cs index 0a4a91b..c8b4a6c 100644 --- a/LiveScanServer/SettingsForm.Designer.cs +++ b/LiveScanServer/SettingsForm.Designer.cs @@ -28,11 +28,14 @@ /// private void InitializeComponent() { + System.Windows.Forms.Label lbSyncWarning; this.lbMerge = new System.Windows.Forms.Label(); this.chMerge = new System.Windows.Forms.CheckBox(); this.lbICPIters = new System.Windows.Forms.Label(); this.txtICPIters = new System.Windows.Forms.TextBox(); this.grClient = new System.Windows.Forms.GroupBox(); + this.grSync = new System.Windows.Forms.GroupBox(); + this.chSync = new System.Windows.Forms.CheckBox(); this.grBody = new System.Windows.Forms.GroupBox(); this.chSkeletons = new System.Windows.Forms.CheckBox(); this.chBodyData = new System.Windows.Forms.CheckBox(); @@ -72,14 +75,16 @@ this.lbFilterDistance = new System.Windows.Forms.Label(); this.txtFilterDistance = new System.Windows.Forms.TextBox(); this.grServer = new System.Windows.Forms.GroupBox(); + this.cbCompressionLevel = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); this.rBinaryPly = new System.Windows.Forms.RadioButton(); this.lbFormat = new System.Windows.Forms.Label(); this.rAsciiPly = new System.Windows.Forms.RadioButton(); this.txtRefinIters = new System.Windows.Forms.TextBox(); this.lbOuterIters = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.cbCompressionLevel = new System.Windows.Forms.ComboBox(); + lbSyncWarning = new System.Windows.Forms.Label(); this.grClient.SuspendLayout(); + this.grSync.SuspendLayout(); this.grBody.SuspendLayout(); this.grMarkers.SuspendLayout(); this.grBounding.SuspendLayout(); @@ -90,20 +95,18 @@ // lbMerge // this.lbMerge.AutoSize = true; - this.lbMerge.Location = new System.Drawing.Point(7, 69); - this.lbMerge.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbMerge.Location = new System.Drawing.Point(5, 45); this.lbMerge.Name = "lbMerge"; - this.lbMerge.Size = new System.Drawing.Size(99, 20); + this.lbMerge.Size = new System.Drawing.Size(69, 13); this.lbMerge.TabIndex = 22; this.lbMerge.Text = "Scan saving:"; // // chMerge // this.chMerge.AutoSize = true; - this.chMerge.Location = new System.Drawing.Point(156, 70); - this.chMerge.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.chMerge.Location = new System.Drawing.Point(104, 45); this.chMerge.Name = "chMerge"; - this.chMerge.Size = new System.Drawing.Size(126, 24); + this.chMerge.Size = new System.Drawing.Size(86, 17); this.chMerge.TabIndex = 23; this.chMerge.Text = "merge scans"; this.chMerge.UseVisualStyleBackColor = true; @@ -112,46 +115,74 @@ // lbICPIters // this.lbICPIters.AutoSize = true; - this.lbICPIters.Location = new System.Drawing.Point(7, 34); - this.lbICPIters.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbICPIters.Location = new System.Drawing.Point(5, 22); this.lbICPIters.Name = "lbICPIters"; - this.lbICPIters.Size = new System.Drawing.Size(128, 20); + this.lbICPIters.Size = new System.Drawing.Size(86, 13); this.lbICPIters.TabIndex = 24; this.lbICPIters.Text = "Num of ICP iters:"; // // txtICPIters // - this.txtICPIters.Location = new System.Drawing.Point(156, 31); - this.txtICPIters.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtICPIters.Location = new System.Drawing.Point(104, 20); this.txtICPIters.Name = "txtICPIters"; - this.txtICPIters.Size = new System.Drawing.Size(55, 26); + this.txtICPIters.Size = new System.Drawing.Size(38, 20); this.txtICPIters.TabIndex = 25; this.txtICPIters.TextChanged += new System.EventHandler(this.txtICPIters_TextChanged); // // grClient // + this.grClient.Controls.Add(this.grSync); this.grClient.Controls.Add(this.grBody); this.grClient.Controls.Add(this.grMarkers); this.grClient.Controls.Add(this.grBounding); this.grClient.Controls.Add(this.grFiltering); - this.grClient.Location = new System.Drawing.Point(18, 18); - this.grClient.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.grClient.Location = new System.Drawing.Point(12, 12); this.grClient.Name = "grClient"; - this.grClient.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.grClient.Size = new System.Drawing.Size(948, 447); + this.grClient.Size = new System.Drawing.Size(632, 291); this.grClient.TabIndex = 43; this.grClient.TabStop = false; this.grClient.Text = "KinectClient settings"; + // + // grSync + // + this.grSync.Controls.Add(lbSyncWarning); + this.grSync.Controls.Add(this.chSync); + this.grSync.Location = new System.Drawing.Point(271, 211); + this.grSync.Name = "grSync"; + this.grSync.Size = new System.Drawing.Size(355, 66); + this.grSync.TabIndex = 48; + this.grSync.TabStop = false; + this.grSync.Text = "Temporal Sync (Azure Kinect Only)"; + // + // lbSyncWarning + // + lbSyncWarning.AutoSize = true; + lbSyncWarning.CausesValidation = false; + lbSyncWarning.Location = new System.Drawing.Point(3, 41); + lbSyncWarning.Name = "lbSyncWarning"; + lbSyncWarning.Size = new System.Drawing.Size(347, 13); + lbSyncWarning.TabIndex = 1; + lbSyncWarning.Text = "Notice: Devices need to be connected via sync cabel before enabeling!\r\n"; + // + // chSync + // + this.chSync.AutoSize = true; + this.chSync.Location = new System.Drawing.Point(6, 19); + this.chSync.Name = "chSync"; + this.chSync.Size = new System.Drawing.Size(133, 17); + this.chSync.TabIndex = 0; + this.chSync.Text = "Enable Temporal Sync"; + this.chSync.UseVisualStyleBackColor = true; + this.chSync.CheckedChanged += new System.EventHandler(this.chSync_CheckedChanged); + // // grBody // this.grBody.Controls.Add(this.chSkeletons); this.grBody.Controls.Add(this.chBodyData); - this.grBody.Location = new System.Drawing.Point(14, 325); - this.grBody.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.grBody.Location = new System.Drawing.Point(9, 211); this.grBody.Name = "grBody"; - this.grBody.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.grBody.Size = new System.Drawing.Size(374, 101); + this.grBody.Size = new System.Drawing.Size(249, 66); this.grBody.TabIndex = 47; this.grBody.TabStop = false; this.grBody.Text = "Body data"; @@ -159,10 +190,9 @@ // chSkeletons // this.chSkeletons.AutoSize = true; - this.chSkeletons.Location = new System.Drawing.Point(16, 63); - this.chSkeletons.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.chSkeletons.Location = new System.Drawing.Point(11, 41); this.chSkeletons.Name = "chSkeletons"; - this.chSkeletons.Size = new System.Drawing.Size(220, 24); + 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; @@ -171,10 +201,9 @@ // chBodyData // this.chBodyData.AutoSize = true; - this.chBodyData.Location = new System.Drawing.Point(16, 29); - this.chBodyData.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.chBodyData.Location = new System.Drawing.Point(11, 19); this.chBodyData.Name = "chBodyData"; - this.chBodyData.Size = new System.Drawing.Size(167, 24); + this.chBodyData.Size = new System.Drawing.Size(113, 17); this.chBodyData.TabIndex = 19; this.chBodyData.Text = "stream only bodies"; this.chBodyData.UseVisualStyleBackColor = true; @@ -198,11 +227,9 @@ this.grMarkers.Controls.Add(this.txtTranslationX); this.grMarkers.Controls.Add(this.lisMarkers); this.grMarkers.Controls.Add(this.txtTranslationY); - this.grMarkers.Location = new System.Drawing.Point(406, 29); - this.grMarkers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.grMarkers.Location = new System.Drawing.Point(271, 19); this.grMarkers.Name = "grMarkers"; - this.grMarkers.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.grMarkers.Size = new System.Drawing.Size(530, 285); + this.grMarkers.Size = new System.Drawing.Size(353, 185); this.grMarkers.TabIndex = 45; this.grMarkers.TabStop = false; this.grMarkers.Text = "Calibration markers"; @@ -210,19 +237,17 @@ // lbX2 // this.lbX2.AutoSize = true; - this.lbX2.Location = new System.Drawing.Point(345, 29); - this.lbX2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbX2.Location = new System.Drawing.Point(230, 19); this.lbX2.Name = "lbX2"; - this.lbX2.Size = new System.Drawing.Size(20, 20); + this.lbX2.Size = new System.Drawing.Size(14, 13); this.lbX2.TabIndex = 49; this.lbX2.Text = "X"; // // btRemove // - this.btRemove.Location = new System.Drawing.Point(350, 195); - this.btRemove.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.btRemove.Location = new System.Drawing.Point(233, 127); this.btRemove.Name = "btRemove"; - this.btRemove.Size = new System.Drawing.Size(138, 35); + this.btRemove.Size = new System.Drawing.Size(92, 23); this.btRemove.TabIndex = 59; this.btRemove.Text = "Remove marker"; this.btRemove.UseVisualStyleBackColor = true; @@ -230,76 +255,68 @@ // // txtOrientationZ // - this.txtOrientationZ.Location = new System.Drawing.Point(458, 58); - this.txtOrientationZ.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtOrientationZ.Location = new System.Drawing.Point(305, 38); this.txtOrientationZ.Name = "txtOrientationZ"; - this.txtOrientationZ.Size = new System.Drawing.Size(55, 26); + this.txtOrientationZ.Size = new System.Drawing.Size(38, 20); this.txtOrientationZ.TabIndex = 48; this.txtOrientationZ.TextChanged += new System.EventHandler(this.txtOrientationZ_TextChanged); // // txtId // - this.txtId.Location = new System.Drawing.Point(326, 143); - this.txtId.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtId.Location = new System.Drawing.Point(217, 93); this.txtId.Name = "txtId"; - this.txtId.Size = new System.Drawing.Size(55, 26); + this.txtId.Size = new System.Drawing.Size(38, 20); this.txtId.TabIndex = 58; this.txtId.TextChanged += new System.EventHandler(this.txtId_TextChanged); // // lbY2 // this.lbY2.AutoSize = true; - this.lbY2.Location = new System.Drawing.Point(411, 29); - this.lbY2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbY2.Location = new System.Drawing.Point(274, 19); this.lbY2.Name = "lbY2"; - this.lbY2.Size = new System.Drawing.Size(20, 20); + this.lbY2.Size = new System.Drawing.Size(14, 13); this.lbY2.TabIndex = 50; this.lbY2.Text = "Y"; // // txtOrientationY // - this.txtOrientationY.Location = new System.Drawing.Point(392, 58); - this.txtOrientationY.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtOrientationY.Location = new System.Drawing.Point(261, 38); this.txtOrientationY.Name = "txtOrientationY"; - this.txtOrientationY.Size = new System.Drawing.Size(55, 26); + this.txtOrientationY.Size = new System.Drawing.Size(38, 20); this.txtOrientationY.TabIndex = 47; this.txtOrientationY.TextChanged += new System.EventHandler(this.txtOrientationY_TextChanged); // // lbId // this.lbId.AutoSize = true; - this.lbId.Location = new System.Drawing.Point(198, 148); - this.lbId.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbId.Location = new System.Drawing.Point(132, 96); this.lbId.Name = "lbId"; - this.lbId.Size = new System.Drawing.Size(78, 20); + this.lbId.Size = new System.Drawing.Size(54, 13); this.lbId.TabIndex = 57; this.lbId.Text = "Marker id:"; // // lbZ2 // this.lbZ2.AutoSize = true; - this.lbZ2.Location = new System.Drawing.Point(476, 29); - this.lbZ2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbZ2.Location = new System.Drawing.Point(317, 19); this.lbZ2.Name = "lbZ2"; - this.lbZ2.Size = new System.Drawing.Size(19, 20); + this.lbZ2.Size = new System.Drawing.Size(14, 13); this.lbZ2.TabIndex = 51; this.lbZ2.Text = "Z"; // // txtOrientationX // - this.txtOrientationX.Location = new System.Drawing.Point(326, 58); - this.txtOrientationX.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtOrientationX.Location = new System.Drawing.Point(217, 38); this.txtOrientationX.Name = "txtOrientationX"; - this.txtOrientationX.Size = new System.Drawing.Size(55, 26); + this.txtOrientationX.Size = new System.Drawing.Size(38, 20); this.txtOrientationX.TabIndex = 46; this.txtOrientationX.TextChanged += new System.EventHandler(this.txtOrientationX_TextChanged); // // btAdd // - this.btAdd.Location = new System.Drawing.Point(202, 195); - this.btAdd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.btAdd.Location = new System.Drawing.Point(135, 127); this.btAdd.Name = "btAdd"; - this.btAdd.Size = new System.Drawing.Size(138, 35); + this.btAdd.Size = new System.Drawing.Size(92, 23); this.btAdd.TabIndex = 56; this.btAdd.Text = "Add marker"; this.btAdd.UseVisualStyleBackColor = true; @@ -308,58 +325,51 @@ // lbTranslation // this.lbTranslation.AutoSize = true; - this.lbTranslation.Location = new System.Drawing.Point(198, 105); - this.lbTranslation.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbTranslation.Location = new System.Drawing.Point(132, 68); this.lbTranslation.Name = "lbTranslation"; - this.lbTranslation.Size = new System.Drawing.Size(91, 20); + this.lbTranslation.Size = new System.Drawing.Size(62, 13); this.lbTranslation.TabIndex = 52; this.lbTranslation.Text = "Translation:"; // // lbOrientation // this.lbOrientation.AutoSize = true; - this.lbOrientation.Location = new System.Drawing.Point(198, 63); - this.lbOrientation.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbOrientation.Location = new System.Drawing.Point(132, 41); this.lbOrientation.Name = "lbOrientation"; - this.lbOrientation.Size = new System.Drawing.Size(91, 20); + this.lbOrientation.Size = new System.Drawing.Size(61, 13); this.lbOrientation.TabIndex = 45; this.lbOrientation.Text = "Orientation:"; // // txtTranslationZ // - this.txtTranslationZ.Location = new System.Drawing.Point(458, 100); - this.txtTranslationZ.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtTranslationZ.Location = new System.Drawing.Point(305, 65); this.txtTranslationZ.Name = "txtTranslationZ"; - this.txtTranslationZ.Size = new System.Drawing.Size(55, 26); + this.txtTranslationZ.Size = new System.Drawing.Size(38, 20); this.txtTranslationZ.TabIndex = 55; this.txtTranslationZ.TextChanged += new System.EventHandler(this.txtTranslationZ_TextChanged); // // txtTranslationX // - this.txtTranslationX.Location = new System.Drawing.Point(326, 100); - this.txtTranslationX.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtTranslationX.Location = new System.Drawing.Point(217, 65); this.txtTranslationX.Name = "txtTranslationX"; - this.txtTranslationX.Size = new System.Drawing.Size(55, 26); + this.txtTranslationX.Size = new System.Drawing.Size(38, 20); this.txtTranslationX.TabIndex = 53; this.txtTranslationX.TextChanged += new System.EventHandler(this.txtTranslationX_TextChanged); // // lisMarkers // this.lisMarkers.FormattingEnabled = true; - this.lisMarkers.ItemHeight = 20; - this.lisMarkers.Location = new System.Drawing.Point(9, 63); - this.lisMarkers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.lisMarkers.Location = new System.Drawing.Point(6, 41); this.lisMarkers.Name = "lisMarkers"; - this.lisMarkers.Size = new System.Drawing.Size(178, 164); + this.lisMarkers.Size = new System.Drawing.Size(120, 108); this.lisMarkers.TabIndex = 43; this.lisMarkers.SelectedIndexChanged += new System.EventHandler(this.lisMarkers_SelectedIndexChanged); // // txtTranslationY // - this.txtTranslationY.Location = new System.Drawing.Point(392, 100); - this.txtTranslationY.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtTranslationY.Location = new System.Drawing.Point(261, 65); this.txtTranslationY.Name = "txtTranslationY"; - this.txtTranslationY.Size = new System.Drawing.Size(55, 26); + this.txtTranslationY.Size = new System.Drawing.Size(38, 20); this.txtTranslationY.TabIndex = 54; this.txtTranslationY.TextChanged += new System.EventHandler(this.txtTranslationY_TextChanged); // @@ -376,11 +386,9 @@ this.grBounding.Controls.Add(this.lbZ); this.grBounding.Controls.Add(this.lbY); this.grBounding.Controls.Add(this.lbX); - this.grBounding.Location = new System.Drawing.Point(14, 29); - this.grBounding.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.grBounding.Location = new System.Drawing.Point(9, 19); this.grBounding.Name = "grBounding"; - this.grBounding.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.grBounding.Size = new System.Drawing.Size(374, 140); + this.grBounding.Size = new System.Drawing.Size(249, 91); this.grBounding.TabIndex = 46; this.grBounding.TabStop = false; this.grBounding.Text = "Bounding box"; @@ -388,104 +396,93 @@ // lbMin // this.lbMin.AutoSize = true; - this.lbMin.Location = new System.Drawing.Point(12, 58); - this.lbMin.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbMin.Location = new System.Drawing.Point(8, 38); this.lbMin.Name = "lbMin"; - this.lbMin.Size = new System.Drawing.Size(95, 20); + this.lbMin.Size = new System.Drawing.Size(65, 13); this.lbMin.TabIndex = 13; this.lbMin.Text = "Min bounds:"; // // txtMaxZ // - this.txtMaxZ.Location = new System.Drawing.Point(272, 95); - this.txtMaxZ.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtMaxZ.Location = new System.Drawing.Point(181, 62); this.txtMaxZ.Name = "txtMaxZ"; - this.txtMaxZ.Size = new System.Drawing.Size(55, 26); + this.txtMaxZ.Size = new System.Drawing.Size(38, 20); this.txtMaxZ.TabIndex = 23; this.txtMaxZ.TextChanged += new System.EventHandler(this.txtMaxZ_TextChanged); // // txtMaxY // - this.txtMaxY.Location = new System.Drawing.Point(206, 95); - this.txtMaxY.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtMaxY.Location = new System.Drawing.Point(137, 62); this.txtMaxY.Name = "txtMaxY"; - this.txtMaxY.Size = new System.Drawing.Size(55, 26); + this.txtMaxY.Size = new System.Drawing.Size(38, 20); this.txtMaxY.TabIndex = 22; this.txtMaxY.TextChanged += new System.EventHandler(this.txtMaxY_TextChanged); // // txtMinX // - this.txtMinX.Location = new System.Drawing.Point(140, 54); - this.txtMinX.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtMinX.Location = new System.Drawing.Point(93, 35); this.txtMinX.Name = "txtMinX"; - this.txtMinX.Size = new System.Drawing.Size(55, 26); + this.txtMinX.Size = new System.Drawing.Size(38, 20); this.txtMinX.TabIndex = 14; this.txtMinX.TextChanged += new System.EventHandler(this.txtMinX_TextChanged); // // txtMaxX // - this.txtMaxX.Location = new System.Drawing.Point(140, 95); - this.txtMaxX.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtMaxX.Location = new System.Drawing.Point(93, 62); this.txtMaxX.Name = "txtMaxX"; - this.txtMaxX.Size = new System.Drawing.Size(55, 26); + this.txtMaxX.Size = new System.Drawing.Size(38, 20); this.txtMaxX.TabIndex = 21; this.txtMaxX.TextChanged += new System.EventHandler(this.txtMaxX_TextChanged); // // txtMinY // - this.txtMinY.Location = new System.Drawing.Point(206, 54); - this.txtMinY.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtMinY.Location = new System.Drawing.Point(137, 35); this.txtMinY.Name = "txtMinY"; - this.txtMinY.Size = new System.Drawing.Size(55, 26); + this.txtMinY.Size = new System.Drawing.Size(38, 20); this.txtMinY.TabIndex = 15; this.txtMinY.TextChanged += new System.EventHandler(this.txtMinY_TextChanged); // // lbMax // this.lbMax.AutoSize = true; - this.lbMax.Location = new System.Drawing.Point(12, 100); - this.lbMax.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbMax.Location = new System.Drawing.Point(8, 65); this.lbMax.Name = "lbMax"; - this.lbMax.Size = new System.Drawing.Size(99, 20); + this.lbMax.Size = new System.Drawing.Size(68, 13); this.lbMax.TabIndex = 20; this.lbMax.Text = "Max bounds:"; // // txtMinZ // - this.txtMinZ.Location = new System.Drawing.Point(272, 54); - this.txtMinZ.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtMinZ.Location = new System.Drawing.Point(181, 35); this.txtMinZ.Name = "txtMinZ"; - this.txtMinZ.Size = new System.Drawing.Size(55, 26); + this.txtMinZ.Size = new System.Drawing.Size(38, 20); this.txtMinZ.TabIndex = 16; this.txtMinZ.TextChanged += new System.EventHandler(this.txtMinZ_TextChanged); // // lbZ // this.lbZ.AutoSize = true; - this.lbZ.Location = new System.Drawing.Point(290, 25); - this.lbZ.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbZ.Location = new System.Drawing.Point(193, 16); this.lbZ.Name = "lbZ"; - this.lbZ.Size = new System.Drawing.Size(19, 20); + this.lbZ.Size = new System.Drawing.Size(14, 13); this.lbZ.TabIndex = 19; this.lbZ.Text = "Z"; // // lbY // this.lbY.AutoSize = true; - this.lbY.Location = new System.Drawing.Point(225, 25); - this.lbY.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbY.Location = new System.Drawing.Point(150, 16); this.lbY.Name = "lbY"; - this.lbY.Size = new System.Drawing.Size(20, 20); + this.lbY.Size = new System.Drawing.Size(14, 13); this.lbY.TabIndex = 18; this.lbY.Text = "Y"; // // lbX // this.lbX.AutoSize = true; - this.lbX.Location = new System.Drawing.Point(159, 25); - this.lbX.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbX.Location = new System.Drawing.Point(106, 16); this.lbX.Name = "lbX"; - this.lbX.Size = new System.Drawing.Size(20, 20); + this.lbX.Size = new System.Drawing.Size(14, 13); this.lbX.TabIndex = 17; this.lbX.Text = "X"; // @@ -496,31 +493,27 @@ this.grFiltering.Controls.Add(this.lbFilterNeighbors); this.grFiltering.Controls.Add(this.lbFilterDistance); this.grFiltering.Controls.Add(this.txtFilterDistance); - this.grFiltering.Location = new System.Drawing.Point(14, 178); - this.grFiltering.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.grFiltering.Location = new System.Drawing.Point(9, 116); this.grFiltering.Name = "grFiltering"; - this.grFiltering.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.grFiltering.Size = new System.Drawing.Size(374, 135); + this.grFiltering.Size = new System.Drawing.Size(249, 88); this.grFiltering.TabIndex = 45; this.grFiltering.TabStop = false; this.grFiltering.Text = "Filtering"; // // txtFilterNeighbors // - this.txtFilterNeighbors.Location = new System.Drawing.Point(140, 60); - this.txtFilterNeighbors.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtFilterNeighbors.Location = new System.Drawing.Point(93, 39); this.txtFilterNeighbors.Name = "txtFilterNeighbors"; - this.txtFilterNeighbors.Size = new System.Drawing.Size(55, 26); + this.txtFilterNeighbors.Size = new System.Drawing.Size(38, 20); this.txtFilterNeighbors.TabIndex = 20; this.txtFilterNeighbors.TextChanged += new System.EventHandler(this.txtFilterNeighbors_TextChanged); // // chFilter // this.chFilter.AutoSize = true; - this.chFilter.Location = new System.Drawing.Point(140, 25); - this.chFilter.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.chFilter.Location = new System.Drawing.Point(93, 16); this.chFilter.Name = "chFilter"; - this.chFilter.Size = new System.Drawing.Size(147, 24); + this.chFilter.Size = new System.Drawing.Size(100, 17); this.chFilter.TabIndex = 18; this.chFilter.Text = "filtering enabled"; this.chFilter.UseVisualStyleBackColor = true; @@ -529,29 +522,26 @@ // lbFilterNeighbors // this.lbFilterNeighbors.AutoSize = true; - this.lbFilterNeighbors.Location = new System.Drawing.Point(12, 65); - this.lbFilterNeighbors.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbFilterNeighbors.Location = new System.Drawing.Point(8, 42); this.lbFilterNeighbors.Name = "lbFilterNeighbors"; - this.lbFilterNeighbors.Size = new System.Drawing.Size(98, 20); + this.lbFilterNeighbors.Size = new System.Drawing.Size(67, 13); this.lbFilterNeighbors.TabIndex = 19; this.lbFilterNeighbors.Text = "N neighbors:"; // // lbFilterDistance // this.lbFilterDistance.AutoSize = true; - this.lbFilterDistance.Location = new System.Drawing.Point(12, 105); - this.lbFilterDistance.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lbFilterDistance.Location = new System.Drawing.Point(8, 68); this.lbFilterDistance.Name = "lbFilterDistance"; - this.lbFilterDistance.Size = new System.Drawing.Size(106, 20); + this.lbFilterDistance.Size = new System.Drawing.Size(73, 13); this.lbFilterDistance.TabIndex = 21; this.lbFilterDistance.Text = "Max distance:"; // // txtFilterDistance // - this.txtFilterDistance.Location = new System.Drawing.Point(140, 100); - this.txtFilterDistance.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtFilterDistance.Location = new System.Drawing.Point(93, 65); this.txtFilterDistance.Name = "txtFilterDistance"; - this.txtFilterDistance.Size = new System.Drawing.Size(55, 26); + this.txtFilterDistance.Size = new System.Drawing.Size(38, 20); this.txtFilterDistance.TabIndex = 22; this.txtFilterDistance.TextChanged += new System.EventHandler(this.txtFilterDistance_TextChanged); // @@ -568,79 +558,13 @@ this.grServer.Controls.Add(this.txtICPIters); this.grServer.Controls.Add(this.chMerge); this.grServer.Controls.Add(this.lbICPIters); - this.grServer.Location = new System.Drawing.Point(18, 478); - this.grServer.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.grServer.Location = new System.Drawing.Point(12, 311); this.grServer.Name = "grServer"; - this.grServer.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.grServer.Size = new System.Drawing.Size(948, 175); + this.grServer.Size = new System.Drawing.Size(632, 114); this.grServer.TabIndex = 44; this.grServer.TabStop = false; this.grServer.Text = "KinectServer settings"; // - // rBinaryPly - // - this.rBinaryPly.AutoSize = true; - this.rBinaryPly.Location = new System.Drawing.Point(277, 105); - this.rBinaryPly.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.rBinaryPly.Name = "rBinaryPly"; - this.rBinaryPly.Size = new System.Drawing.Size(110, 24); - this.rBinaryPly.TabIndex = 30; - this.rBinaryPly.TabStop = true; - this.rBinaryPly.Text = "binary PLY"; - this.rBinaryPly.UseVisualStyleBackColor = true; - this.rBinaryPly.CheckedChanged += new System.EventHandler(this.PlyFormat_CheckedChanged); - // - // lbFormat - // - this.lbFormat.AutoSize = true; - this.lbFormat.Location = new System.Drawing.Point(7, 106); - this.lbFormat.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.lbFormat.Name = "lbFormat"; - this.lbFormat.Size = new System.Drawing.Size(88, 20); - this.lbFormat.TabIndex = 29; - this.lbFormat.Text = "File format:"; - // - // rAsciiPly - // - this.rAsciiPly.AutoSize = true; - this.rAsciiPly.Location = new System.Drawing.Point(156, 105); - this.rAsciiPly.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.rAsciiPly.Name = "rAsciiPly"; - this.rAsciiPly.Size = new System.Drawing.Size(111, 24); - this.rAsciiPly.TabIndex = 28; - this.rAsciiPly.TabStop = true; - this.rAsciiPly.Text = "ASCII PLY"; - this.rAsciiPly.UseVisualStyleBackColor = true; - this.rAsciiPly.CheckedChanged += new System.EventHandler(this.PlyFormat_CheckedChanged); - // - // txtRefinIters - // - this.txtRefinIters.Location = new System.Drawing.Point(408, 31); - this.txtRefinIters.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.txtRefinIters.Name = "txtRefinIters"; - this.txtRefinIters.Size = new System.Drawing.Size(55, 26); - this.txtRefinIters.TabIndex = 27; - this.txtRefinIters.TextChanged += new System.EventHandler(this.txtRefinIters_TextChanged); - // - // lbOuterIters - // - this.lbOuterIters.AutoSize = true; - this.lbOuterIters.Location = new System.Drawing.Point(222, 36); - this.lbOuterIters.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.lbOuterIters.Name = "lbOuterIters"; - this.lbOuterIters.Size = new System.Drawing.Size(178, 20); - this.lbOuterIters.TabIndex = 26; - this.lbOuterIters.Text = "Num of refinement iters:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(8, 139); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(141, 20); - this.label2.TabIndex = 31; - this.label2.Text = "Compression level:"; - // // cbCompressionLevel // this.cbCompressionLevel.FormattingEnabled = true; @@ -657,26 +581,88 @@ "15", "17", "19"}); - this.cbCompressionLevel.Location = new System.Drawing.Point(154, 136); + this.cbCompressionLevel.Location = new System.Drawing.Point(103, 88); + this.cbCompressionLevel.Margin = new System.Windows.Forms.Padding(2); this.cbCompressionLevel.Name = "cbCompressionLevel"; - this.cbCompressionLevel.Size = new System.Drawing.Size(169, 28); + this.cbCompressionLevel.Size = new System.Drawing.Size(114, 21); this.cbCompressionLevel.TabIndex = 32; this.cbCompressionLevel.SelectedIndexChanged += new System.EventHandler(this.cbCompressionLevel_SelectedIndexChanged); // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(5, 90); + this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(95, 13); + this.label2.TabIndex = 31; + this.label2.Text = "Compression level:"; + // + // rBinaryPly + // + this.rBinaryPly.AutoSize = true; + this.rBinaryPly.Location = new System.Drawing.Point(185, 68); + this.rBinaryPly.Name = "rBinaryPly"; + this.rBinaryPly.Size = new System.Drawing.Size(76, 17); + this.rBinaryPly.TabIndex = 30; + this.rBinaryPly.TabStop = true; + this.rBinaryPly.Text = "binary PLY"; + this.rBinaryPly.UseVisualStyleBackColor = true; + this.rBinaryPly.CheckedChanged += new System.EventHandler(this.PlyFormat_CheckedChanged); + // + // lbFormat + // + this.lbFormat.AutoSize = true; + this.lbFormat.Location = new System.Drawing.Point(5, 69); + this.lbFormat.Name = "lbFormat"; + this.lbFormat.Size = new System.Drawing.Size(58, 13); + this.lbFormat.TabIndex = 29; + this.lbFormat.Text = "File format:"; + // + // rAsciiPly + // + this.rAsciiPly.AutoSize = true; + this.rAsciiPly.Location = new System.Drawing.Point(104, 68); + this.rAsciiPly.Name = "rAsciiPly"; + this.rAsciiPly.Size = new System.Drawing.Size(75, 17); + this.rAsciiPly.TabIndex = 28; + this.rAsciiPly.TabStop = true; + this.rAsciiPly.Text = "ASCII PLY"; + this.rAsciiPly.UseVisualStyleBackColor = true; + this.rAsciiPly.CheckedChanged += new System.EventHandler(this.PlyFormat_CheckedChanged); + // + // txtRefinIters + // + this.txtRefinIters.Location = new System.Drawing.Point(272, 20); + this.txtRefinIters.Name = "txtRefinIters"; + this.txtRefinIters.Size = new System.Drawing.Size(38, 20); + this.txtRefinIters.TabIndex = 27; + this.txtRefinIters.TextChanged += new System.EventHandler(this.txtRefinIters_TextChanged); + // + // lbOuterIters + // + this.lbOuterIters.AutoSize = true; + this.lbOuterIters.Location = new System.Drawing.Point(148, 23); + this.lbOuterIters.Name = "lbOuterIters"; + this.lbOuterIters.Size = new System.Drawing.Size(118, 13); + this.lbOuterIters.TabIndex = 26; + this.lbOuterIters.Text = "Num of refinement iters:"; + // // SettingsForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(984, 663); + this.ClientSize = new System.Drawing.Size(656, 431); this.Controls.Add(this.grServer); this.Controls.Add(this.grClient); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.MaximizeBox = false; this.Name = "SettingsForm"; this.Text = "Settings"; this.Load += new System.EventHandler(this.SettingsForm_Load); this.grClient.ResumeLayout(false); + this.grSync.ResumeLayout(false); + this.grSync.PerformLayout(); this.grBody.ResumeLayout(false); this.grBody.PerformLayout(); this.grMarkers.ResumeLayout(false); @@ -744,6 +730,7 @@ private System.Windows.Forms.CheckBox chSkeletons; private System.Windows.Forms.ComboBox cbCompressionLevel; private System.Windows.Forms.Label label2; - + private System.Windows.Forms.GroupBox grSync; + private System.Windows.Forms.CheckBox chSync; } } \ No newline at end of file diff --git a/LiveScanServer/SettingsForm.cs b/LiveScanServer/SettingsForm.cs index 8bae0b1..ddb9b65 100644 --- a/LiveScanServer/SettingsForm.cs +++ b/LiveScanServer/SettingsForm.cs @@ -61,6 +61,9 @@ namespace KinectServer chMerge.Checked = oSettings.bMergeScansForSave; txtICPIters.Text = oSettings.nNumICPIterations.ToString(); txtRefinIters.Text = oSettings.nNumRefineIters.ToString(); + + chSync.Checked = oSettings.bEnableSync; + if (oSettings.bSaveAsBinaryPLY) { rBinaryPly.Checked = true; @@ -78,7 +81,11 @@ namespace KinectServer void UpdateClients() { if (bFormLoaded) + { oServer.SendSettings(); + oServer.SendTemporalSyncData(); + } + } void UpdateMarkerFields() @@ -340,5 +347,14 @@ namespace KinectServer } UpdateClients(); } + + + private void chSync_CheckedChanged(object sender, EventArgs e) + { + oSettings.bEnableSync = chSync.Checked; + UpdateClients(); + } + + } } diff --git a/LiveScanServer/SettingsForm.resx b/LiveScanServer/SettingsForm.resx index 1af7de1..7c1ce7f 100644 --- a/LiveScanServer/SettingsForm.resx +++ b/LiveScanServer/SettingsForm.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + False + \ No newline at end of file diff --git a/include/LiveScanClient/liveScanClient.h b/include/LiveScanClient/liveScanClient.h index 0fcc273..cf4b33d 100644 --- a/include/LiveScanClient/liveScanClient.h +++ b/include/LiveScanClient/liveScanClient.h @@ -43,6 +43,9 @@ private: bool m_bFilter; bool m_bStreamOnlyBodies; + bool m_bIsMaster; + bool m_bIsSubOrdinate; + ICapture *pCapture; int m_nFilterNeighbors; @@ -51,6 +54,8 @@ private: bool m_bCaptureFrame; bool m_bConnected; bool m_bConfirmCaptured; + bool m_bConfirmMaster; + bool m_bConfirmSubOrdinate; bool m_bConfirmCalibrated; bool m_bShowDepth; bool m_bFrameCompression; diff --git a/include/LiveScanClient/utils.h b/include/LiveScanClient/utils.h index ce85698..8dcb5ca 100644 --- a/include/LiveScanClient/utils.h +++ b/include/LiveScanClient/utils.h @@ -27,7 +27,9 @@ enum INCOMING_MESSAGE_TYPE MSG_REQUEST_STORED_FRAME, MSG_REQUEST_LAST_FRAME, MSG_RECEIVE_CALIBRATION, - MSG_CLEAR_STORED_FRAMES + MSG_CLEAR_STORED_FRAMES, + MSG_SET_MASTER, + MSG_SET_SUBORDINATE }; enum OUTGOING_MESSAGE_TYPE @@ -35,7 +37,8 @@ enum OUTGOING_MESSAGE_TYPE MSG_CONFIRM_CAPTURED, MSG_CONFIRM_CALIBRATED, MSG_STORED_FRAME, - MSG_LAST_FRAME + MSG_LAST_FRAME, + MSG_CONFIRM_TEMP_SYNC_STATUS }; typedef struct Point3f diff --git a/src/LiveScanClient/liveScanClient.cpp b/src/LiveScanClient/liveScanClient.cpp index 5ea01f7..f3d69a1 100644 --- a/src/LiveScanClient/liveScanClient.cpp +++ b/src/LiveScanClient/liveScanClient.cpp @@ -444,6 +444,16 @@ void LiveScanClient::HandleSocket() //calibrate else if (received[i] == MSG_CALIBRATE) m_bCalibrate = true; + //Set this client as master + else if (received[i] == MSG_SET_MASTER) { + m_bIsMaster = true; + m_bIsSubOrdinate = false; + } + //Set this client as subordinate + else if (received[i] == MSG_SET_SUBORDINATE) { + m_bIsMaster = false; + m_bIsSubOrdinate = true; + } //receive settings //TODO: what if packet is split? else if (received[i] == MSG_RECEIVE_SETTINGS) @@ -567,6 +577,24 @@ void LiveScanClient::HandleSocket() m_bConfirmCaptured = false; } + if (m_bConfirmMaster) + { + int size = 2; + char *buffer = new char[size]; + buffer[0] = MSG_CONFIRM_TEMP_SYNC_STATUS; + buffer[1] = 0; + m_pClientSocket->SendBytes(buffer, size); + } + + if (m_bConfirmSubOrdinate) + { + int size = 2; + char* buffer = new char[size]; + buffer[0] = MSG_CONFIRM_TEMP_SYNC_STATUS; + buffer[1] = -1; + m_pClientSocket->SendBytes(buffer, size); + } + if (m_bConfirmCalibrated) { int size = (9 + 3) * sizeof(float) + sizeof(int) + 1;