예제 #1
0
 /// <summary>
 /// Refreshed the gesture with the gesture trigger
 /// </summary>
 /// <param name="trigger">Gesture Trigger</param>
 public void Refresh(GestureDescription trigger)
 {
     if (trigger != null)
     {
         Name = trigger.name;
         Mode = (GestureMode) trigger.type;
         Active = trigger.active;
         Confidence = trigger.confidence;
         Progress = trigger.progress;
         _gestureSeries.Add(DateTime.Now.Ticks, trigger.confidence);
         UpdateConfidenceLevels(Confidence);
     }
 }
예제 #2
0
        private static void SendMotionRecognitionModuleInfo(Node node, string server, int timeout = 1000)
        {
            try
            {
                if (node == null)
                {
                    return;
                }

                var module = new GestureRecognitionModule { name = node.name };
                var desc = new GestureDescription
                {
                    name = "IMU_WAVE",
                    type = GestureDescription.GestureType.Discrete
                };

                module.motions.Add(desc);

               

                using (var context = NetMQContext.Create())
                {
                    using (var socket = context.CreateRequestSocket())
                    {
                        socket.Connect(server);
                        socket.SendMore("register_motions");
                        socket.SendMore(node.name);
                        using (var ms = new MemoryStream())
                        {
                            Serializer.Serialize(ms, module);
                            socket.Send(ms.GetBuffer(), (int)ms.Length);
                        }

                        var msg = socket.ReceiveString(new TimeSpan(0, 0, 0, 0, timeout));
                        if (msg != null)
                        {
                            Log.InfoFormat("Motion registration response: {0}", msg);
                        }
                        else
                        {
                            Log.Info("Message buffer empty!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.InfoFormat("{1} : {0}", ex.StackTrace, ex.Message);
            }
        }
예제 #3
0
        private void PublishDiscreteGestureResult(IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults)
        {
            try
            {
                if (discreteResults != null && _vgbFrameSource != null && _vgbFrameSource.Gestures != null &&
                    _vgbFrameSource.Gestures.Count > 0 && GestureResultView != null)
                {
                    GestureTriggers triggers = new GestureTriggers {id = GestureResultView.BodyIndex};
                    //GestureTriggers triggers = new GestureTriggers { id = (int)TrackingId };
                    //Log.InfoFormat("Publishing gesture results for body: {0}", GestureResultView.BodyIndex);
                    //Console.WriteLine(@"Publishing gesture results for body: {0}", GestureResultView.BodyIndex);
                    Console.WriteLine(GestureResultView.BodyIndex);
                    // For publishing

#if ORIGINAL
                    foreach (Gesture gesture in _vgbFrameSource.Gestures)
                    {
                        //System.Diagnostics.Debug.WriteLine(gesture.Name);
                        if (gesture.GestureType == GestureType.Discrete && _gestures.Contains(gesture.Name))
                            //if (gesture.GestureType == GestureType.Discrete)
                            //if (gesture.Name.Equals(this.seatedGestureName) && gesture.GestureType == GestureType.Discrete)
                        {
                            //if (gesture.Name != GestureNames.HandwaveRight)
                            //{
                            //    continue;
                            //}
                            DiscreteGestureResult result;
                            discreteResults.TryGetValue(gesture, out result);
                            var trigger = new GestureDescription
                            {
                                name = gesture.Name,
                                progress = 0,
                                type = (GestureDescription.GestureType) gesture.GestureType,
                                active = result != null && result.Detected,
                                confidence = result != null ? (int) (result.Confidence*100.00) : 0
                            };
                            triggers.motion.Add(trigger);
                        }
                    }
#else
                    foreach (var discreteResult in discreteResults)
                    {
                        var gesture = discreteResult.Key;
                        var result = discreteResult.Value;
                        var trigger = new GestureDescription
                        {
                            name = gesture.Name,
                            progress = 0,
                            type = (GestureDescription.GestureType)gesture.GestureType,
                            active = result != null && result.Detected,
                            confidence = result != null ? (int)(result.Confidence * 100.00) : 0
                        };
                        triggers.motion.Add(trigger);
                    }
#endif

                    GestureTriggerPublisher.Instance.PublishGestureTrigger(triggers);

                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Exception occured while publishing gesture data: {0}", ex.Message);
            }
        }