示例#1
0
 public void StoreGestures()
 {
     if (_dtw != null)
     {
         FileLoader.SaveGestures(_dtw.RetrieveText());
     }
 }
示例#2
0
        /// <summary>
        /// Add a seqence with a label to the known sequences library.
        /// The gesture MUST start on the first observation of the sequence and end on the last one.
        /// Sequences may have different lengths.
        /// </summary>
        /// <param name="seq">The sequence</param>
        /// <param name="lab">Sequence name</param>
        /// <param name="ctxt"> </param>
        /// <param name="saveToFile"> </param>
        public void AddOrUpdate(ArrayList seq, string lab, string ctxt, bool saveToFile)
        {
            if (seq.Count == 0)
            {
                return;
            }
            // First we check whether there is already a recording for this label. If so overwrite it, otherwise add a new entry
            var existingIndex = -1;

            if (_gestures == null)
            {
                _gestures = new ArrayList();
            }

            for (var i = 0; i < _gestures.Count; i++)
            {
                var gesture = (Gesture)_gestures[i];

                if (gesture != null && lab.Equals(gesture.Name) && ctxt.Equals(gesture.Context))
                {
                    existingIndex = i;
                }
            }

            Gesture g;

            // If we have a match then remove the entries at the existing index to avoid duplicates. We will add the new entries later anyway
            if (existingIndex >= 0)
            {
                Log.Info("Found existing gesture, updating sequence.");
                g          = ((Gesture)_gestures[existingIndex]);
                g.Sequence = seq;
            }
            else
            {
                Log.Info("This is a new gesture, saving.");
                g = new Gesture(lab, ctxt, seq);
                _gestures.Add(g);
            }


            if (saveToFile)
            {
                FileLoader.SaveGestures(RetrieveText());
            }
        }