示例#1
0
        public GestureProcessor(IKinect kinectHandler, KinectData kinect)
        {
            _pointer = new ObjectPointer();
            Log.Debug("objectPointer loaded");
            _pointer.SetObjects(FileLoader.LoadObj("livingRoom.obj", FileLoader.Units.cm));

            Log.Debug("objects loaded");

            _kinectHandler = kinectHandler;
            _kinect        = kinect;
            _seqCoords     = new ArrayList();

            if (kinect != null)
            {
                kinect.attachSkeletonHandler(SkeletonDataReadyHandler);
            }

            _dtw = new DtwGestureRecognizer(12, 0.6, 2, 2, 10);
            Skeleton2DDataExtract.Skeleton2DdataCoordReady += NuiSkeleton2DdataCoordReady;
            _pointer.ContextSelected += PointerContextSelected;
        }
示例#2
0
        public static string[] LoadGestures(DtwGestureRecognizer dtw)
        {
            if (dtw == null)
            {
                Log.Error("DtwGestureRecognizer is null");
                return(null);
            }

            Log.Debug("Loading gestures");
            string[] result    = null;
            var      itemCount = 0;
            string   line;
            var      gestureName = "";
            var      contextName = "";
            var      frames      = new ArrayList();
            var      items       = new double[12];

            // Read the file and display it line by line.
            if (!File.Exists(DefaultPath + "gestures.sav"))
            {
                Log.Error("Gesture file not found");
                return(null);
            }

            var file = new StreamReader(DefaultPath + "gestures.sav");

            var counter = 0;

            while ((line = file.ReadLine()) != null)
            {
                if (line.StartsWith("//"))
                {
                    var numGestures = Int32.Parse(line.Split('=')[1]);
                    if (numGestures != 0)
                    {
                        result = new string[numGestures];
                    }
                    else
                    {
                        return(null);
                    }
                    continue;
                }
                if (line.StartsWith("@"))
                {
                    gestureName = line.Substring(1);
                    if (result != null)
                    {
                        result[counter] = gestureName;
                    }
                    continue;
                }

                if (line.StartsWith("$"))
                {
                    contextName = line.Substring(1);
                    if (result != null)
                    {
                        result[counter] += ";" + contextName;
                    }
                    continue;
                }

                if (line.StartsWith("~"))
                {
                    frames.Add(items);
                    itemCount = 0;
                    items     = new double[12];
                    continue;
                }

                if (!line.StartsWith("----"))
                {
                    items[itemCount] = Double.Parse(line);
                }

                itemCount++;

                if (line.StartsWith("----"))
                {
                    if (frames.Count == 0)
                    {
                        continue;
                    }
                    Log.Debug("Gesture frames loaded. Saving...");
                    dtw.AddOrUpdate(frames, gestureName, contextName, false);
                    frames      = new ArrayList();
                    gestureName = String.Empty;
                    contextName = String.Empty;
                    counter++;
                    itemCount = 0;
                }
            }

            Log.Debug(counter + " Gestures loaded");
            file.Close();
            return(result);
        }
示例#3
0
        public static string[] LoadGestures(DtwGestureRecognizer dtw)
        {
            if(dtw == null )
            {
                Log.Error("DtwGestureRecognizer is null");
                return null;
            }

            Log.Debug("Loading gestures");
            string[] result = null;
            var itemCount = 0;
            string line;
            var gestureName = "";
            var contextName = "";
            var frames = new ArrayList();
            var items = new double[12];

            // Read the file and display it line by line.
            if (!File.Exists(DefaultPath + "gestures.sav"))
            {
                Log.Error("Gesture file not found");
                return null;
            }

            var file = new StreamReader(DefaultPath + "gestures.sav");

            var counter = 0;

            while ((line = file.ReadLine()) != null)
            {
                if (line.StartsWith("//"))
                {
                    var numGestures = Int32.Parse(line.Split('=')[1]);
                    if (numGestures != 0)
                    {
                        result = new string[numGestures];
                    }
                    else
                    {
                        return null;
                    }
                    continue;
                }
                if (line.StartsWith("@"))
                {
                    gestureName = line.Substring(1);
                    if (result != null) result[counter] = gestureName;
                    continue;
                }

                if (line.StartsWith("$"))
                {
                    contextName = line.Substring(1);
                    if (result != null) result[counter] += ";" + contextName;
                    continue;
                }

                if (line.StartsWith("~"))
                {
                    frames.Add(items);
                    itemCount = 0;
                    items = new double[12];
                    continue;
                }

                if (!line.StartsWith("----"))
                {
                    items[itemCount] = Double.Parse(line);
                }

                itemCount++;

                if (line.StartsWith("----"))
                {
                    if (frames.Count == 0) continue;
                    Log.Debug("Gesture frames loaded. Saving...");
                    dtw.AddOrUpdate(frames, gestureName, contextName, false);
                    frames = new ArrayList();
                    gestureName = String.Empty;
                    contextName = String.Empty;
                    counter++;
                    itemCount = 0;
                }
            }

            Log.Debug(counter + " Gestures loaded");
            file.Close();
            return result;
        }