Exemplo n.º 1
0
 public override void Send(int pointScale, JSONWriter osc, StreamWriter fileWriter)
 {
     if (osc != null)
     {
         osc.Send(new OscElement(
                      "/osceleton2/face_property",
                      sensorId, user,
                      happy, engaged, wearingGlasses, leftEyeClosed, rightEyeClosed, mouthOpen, mouthMoved, lookingAway,
                      time));
     }
     if (fileWriter != null)
     {
         fileWriter.WriteLine("FaceProperty," +
                              sensorId + "," + user + "," +
                              happy.ToString().Replace(",", ".") + "," +
                              engaged.ToString().Replace(",", ".") + "," +
                              wearingGlasses.ToString().Replace(",", ".") + "," +
                              leftEyeClosed.ToString().Replace(",", ".") + "," +
                              rightEyeClosed.ToString().Replace(",", ".") + "," +
                              mouthOpen.ToString().Replace(",", ".") + "," +
                              mouthMoved.ToString().Replace(",", ".") + "," +
                              lookingAway.ToString().Replace(",", ".") + "," +
                              time.ToString().Replace(",", "."));
     }
 }
Exemplo n.º 2
0
        public void Initialise(int oscPort, String oscHost)
        {
            this.oscHost = oscHost;
            this.oscPort = oscPort;
            // Parse commandline arguments
            string[] args = Environment.GetCommandLineArgs();
            for (int index = 1; index < args.Length; index += 2)
            {
                args[index] = args[index].ToLower();
                if ("allUsers".ToLower().Equals(args[index]))
                {
                    allUsers = StringToBool(args[index + 1]);
                }
                if ("faceTracking".ToLower().Equals(args[index]))
                {
                    faceTracking = StringToBool(args[index + 1]);
                }
                if ("writeOSC".ToLower().Equals(args[index]))
                {
                    writeOSC = StringToBool(args[index + 1]);
                }
                if ("useUnixEpochTime".ToLower().Equals(args[index]))
                {
                    useUnixEpochTime = StringToBool(args[index + 1]);
                }
                if ("oscHost".ToLower().Equals(args[index]))
                {
                    oscHost = args[index + 1];
                }
                if ("oscPort".ToLower().Equals(args[index]))
                {
                    if (!int.TryParse(args[index + 1], out oscPort))
                    {
                        System.Windows.MessageBox.Show("Failed to parse the oscPort argument: " + args[index + 1]);
                    }
                }
            }

            // Initialisation
            stopwatch = new Stopwatch();
            stopwatch.Reset();
            stopwatch.Start();
            if (writeOSC)
            {
                osc = new JSONWriter(oscHost, oscPort);
            }
            if (sendTracking == null)
            {
                sendTracking = new Thread(SendTrackingInformation);
                sendTracking.Start();
            }
        }
Exemplo n.º 3
0
 public override void Send(int pointScale, JSONWriter osc, StreamWriter fileWriter)
 {
     if (osc != null)
     {
         osc.Send(new OscElement(
                      "/osceleton2/face_rotation",
                      sensorId, user,
                      pitch, yaw, roll,
                      time));
     }
     if (fileWriter != null)
     {
         fileWriter.WriteLine("FaceRotation," +
                              sensorId + "," + user + "," +
                              pitch + "," + yaw + "," + roll + "," +
                              time.ToString().Replace(",", "."));
     }
 }
Exemplo n.º 4
0
        public override void Send(int pointScale, JSONWriter osc, StreamWriter fileWriter)
        {
            if (body == null)
            {
                return;
            }
            if (body.Joints == null)
            {
                return;
            }
            if (body.Joints.Count < 20)
            {
                return;
            }
            if (body.JointOrientations == null)
            {
                return;
            }
            if (body.JointOrientations.Count < 20)
            {
                return;
            }
            if (!body.IsTracked)
            {
                return;
            }
            try
            {
                if (handsOnly)
                {
                    ProcessHandStateInformation(1, body.Joints[JointType.HandLeft], body.JointOrientations[JointType.HandLeft], body.HandLeftState, body.HandLeftConfidence, time, pointScale);
                    ProcessHandStateInformation(2, body.Joints[JointType.HandRight], body.JointOrientations[JointType.HandRight], body.HandRightState, body.HandRightConfidence, time, pointScale);
                }
                else
                {
                    var elements = new OscElement[] {
                        ProcessJointInformation(1, body.Joints[JointType.Head], body.JointOrientations[JointType.Head], time, pointScale),
                        ProcessJointInformation(2, body.Joints[JointType.SpineShoulder], body.JointOrientations[JointType.SpineShoulder], time, pointScale),
                        ProcessJointInformation(3, body.Joints[JointType.SpineMid], body.JointOrientations[JointType.SpineMid], time, pointScale),
                        ProcessJointInformation(4, body.Joints[JointType.SpineBase], body.JointOrientations[JointType.SpineBase], time, pointScale),
                        // ProcessJointInformation(5, body.Joints[JointType.], body.JointOrientations[JointType.], time, pointScale, osc, fileWriter);
                        ProcessJointInformation(6, body.Joints[JointType.ShoulderLeft], body.JointOrientations[JointType.ShoulderLeft], time, pointScale),
                        ProcessJointInformation(7, body.Joints[JointType.ElbowLeft], body.JointOrientations[JointType.ElbowLeft], time, pointScale),
                        ProcessJointInformation(8, body.Joints[JointType.WristLeft], body.JointOrientations[JointType.WristLeft], time, pointScale),
                        ProcessJointInformation(9, body.Joints[JointType.HandLeft], body.JointOrientations[JointType.HandLeft], time, pointScale),
                        // ProcessJointInformation(10, body.Joints[JointType.], body.JointOrientations[JointType.], time, pointScale, osc, fileWriter);
                        // ProcessJointInformation(11, body.Joints[JointType.], body.JointOrientations[JointType.], time, pointScale, osc, fileWriter);
                        ProcessJointInformation(12, body.Joints[JointType.ShoulderRight], body.JointOrientations[JointType.ShoulderRight], time, pointScale),
                        ProcessJointInformation(13, body.Joints[JointType.ElbowRight], body.JointOrientations[JointType.ElbowRight], time, pointScale),
                        ProcessJointInformation(14, body.Joints[JointType.WristRight], body.JointOrientations[JointType.WristRight], time, pointScale),
                        ProcessJointInformation(15, body.Joints[JointType.HandRight], body.JointOrientations[JointType.HandRight], time, pointScale),
                        // ProcessJointInformation(16, body.Joints[JointType.], body.JointOrientations[JointType.], time, pointScale, osc, fileWriter);
                        ProcessJointInformation(17, body.Joints[JointType.HipLeft], body.JointOrientations[JointType.HipLeft], time, pointScale),
                        ProcessJointInformation(18, body.Joints[JointType.KneeLeft], body.JointOrientations[JointType.KneeLeft], time, pointScale),
                        ProcessJointInformation(19, body.Joints[JointType.AnkleLeft], body.JointOrientations[JointType.AnkleLeft], time, pointScale),
                        ProcessJointInformation(20, body.Joints[JointType.FootLeft], body.JointOrientations[JointType.FootLeft], time, pointScale),
                        ProcessJointInformation(21, body.Joints[JointType.HipRight], body.JointOrientations[JointType.HipRight], time, pointScale),
                        ProcessJointInformation(22, body.Joints[JointType.KneeRight], body.JointOrientations[JointType.KneeRight], time, pointScale),
                        ProcessJointInformation(23, body.Joints[JointType.AnkleRight], body.JointOrientations[JointType.AnkleRight], time, pointScale),
                        ProcessJointInformation(24, body.Joints[JointType.FootRight], body.JointOrientations[JointType.FootRight], time, pointScale)
                    };

                    //ProcessHandStateInformation(1, body.Joints[JointType.HandLeft], body.JointOrientations[JointType.HandLeft], body.HandLeftState, body.HandLeftConfidence, time, pointScale, osc, fileWriter);
                    //ProcessHandStateInformation(2, body.Joints[JointType.HandRight], body.JointOrientations[JointType.HandRight], body.HandRightState, body.HandRightConfidence, time, pointScale, osc, fileWriter);
                    osc.Send("/skeleton", new OscBundle(0, elements));
                }
            }
            catch (NullReferenceException ex)
            {
                // Happens sometimes. Probably because we should copy body before processing it in another thread.
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 5
0
 public abstract void Send(int pointScale, JSONWriter osc, StreamWriter fileWriter);