Example #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="module">Gesture recognition module message</param>
 public GestureModule(GestureRecognitionModule module)
 {
     _gestures = new ObservableCollection<Gesture>();
     if (module != null)
     {
         Name = module.name;
         foreach (var gestureDescription in module.motions)
         {
             _gestures.Add(new Gesture(
                 gestureDescription.name,
                 (GestureMode) gestureDescription.type
                 ));
         }
     }
 }
Example #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);
            }
        }
Example #3
0
 /// <summary>
 /// Register the gesture recognition module to the context
 /// </summary>
 /// <param name="module">Module information</param>
 public void RegisterMotionRecognitionModule(GestureRecognitionModule module)
 {
     if (module != null && !string.IsNullOrEmpty(module.name))
     {
         lock (_object)
         {
             var regMod = _motionModules.FirstOrDefault(s => s.Name == module.name);
             if (regMod == null)
             {
                 _motionModules.Add(new GestureModule(module));
             }
             else
             {
                 regMod = new GestureModule(module);
             }
         }
     }
 }