-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKinectClientPipe.cs
More file actions
56 lines (46 loc) · 1.68 KB
/
KinectClientPipe.cs
File metadata and controls
56 lines (46 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Pipes;
using Microsoft.Kinect;
using System.Runtime.Serialization.Formatters.Binary;
namespace KinectClient
{
class KinectClientPipe : KinectClient
{
string serverHandle;
AnonymousPipeClientStream clientStream;
public KinectClientPipe(string _handle, string _id)
{
this.serverHandle = _handle;
this.kinectId = _id;
}
public override void Start()
{
try
{
Console.WriteLine("[Client] Starting pipe stream");
clientStream = new AnonymousPipeClientStream(PipeDirection.Out, serverHandle);
Console.WriteLine("[Client] Stream opened");
//Console.WriteLine("Transmission mode: {0}", clientStream.TransmissionMode.ToString());
sensor = null;
Console.WriteLine("[Client] Found {0} Kinects", KinectSensor.KinectSensors.Count);
initKinect();
while (clientStream.IsConnected);
}
catch (Exception e)
{
Console.WriteLine("[Client] Exception:\n {0}\nTrace: {1}", e.Message, e.StackTrace);
}
}
protected override void SendSkeletonData()
{
// If the previous frame is still being read, wait for it to finish
clientStream.WaitForPipeDrain();
// Binary serialize and write the skeleton data over the pipe
BinaryFormatter binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(clientStream, skeletonData);
}
}
}