Esempio n. 1
0
 /// <summary>
 /// Starts the kinect and reads from a config file to setup gestures
 /// </summary>
 /// <param name="aDbLocation">location of a gesture database</param>
 /// <param name="aConfigLocation">a location for a config file</param>
 public void startKinect(string aDbLocation, string aConfigLocation)
 {
     // set the database location in gestureHandler
     this.gestureHandler = new GestureHandler(aDbLocation, eventHandler, configSerializer.deSerializeConfig(aConfigLocation));
     // setup the kinect
     kinectStartup();
 }
Esempio n. 2
0
 /// <summary>
 /// Starts the kinect but ignores any config file
 /// </summary>
 /// <param name="aDbLocation">location of gesture database</param>
 public void startKinect(string aDbLocation)
 {
     // set the database location in gestureHandler
     this.gestureHandler = new GestureHandler(aDbLocation, eventHandler);
     // setup the kinect
     kinectStartup();
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the GestureDetector class along with the gesture frame source and reader
        /// </summary>
        /// <param name="kinectSensor">Active sensor to initialize the VisualGestureBuilderFrameSource object with</param>
        /// <param name="aEventHandler">The main event handler that accepts all event triggers</param>
        /// <param name="aGestureHandler">A gesture configurator object</param>
        public GestureDetector(KinectSensor kinectSensor, LibEventHandler aEventHandler, GestureHandler aGestureHandler)
        {
            //test
            if (kinectSensor == null)
            {
                throw new ArgumentNullException("kinectSensor");
            }

            //store the location of the database
            this.dbLocation = aGestureHandler.DatabaseLocation;

            //store a reference to the gestureHandler
            this.gestureHandler = aGestureHandler;

            // store a reference to a common event handler
            this.eventHandler = aEventHandler;

            // create the vgb source. The associated body tracking ID will be set when a valid body frame arrives from the sensor.
            this.vgbFrameSource = new VisualGestureBuilderFrameSource(kinectSensor, 0);

            // open the reader for the vgb frames
            this.vgbFrameReader = this.vgbFrameSource.OpenReader();

            Console.WriteLine("VGB capture initialized on a body.");

            if (this.vgbFrameReader != null)
            {
                this.vgbFrameReader.IsPaused      = true;
                this.vgbFrameReader.FrameArrived += this.Reader_GestureFrameArrived;
            }

            try
            {
                // load the gesture database
                using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(this.dbLocation))
                {
                    // load all gestures from the gesture database
                    try
                    {
                        this.vgbFrameSource.AddGestures(database.AvailableGestures);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Couldn't locate AdaboostTech.dll and/or RFRProgressTech.dll");
                        Console.WriteLine(e.StackTrace);
                        eventHandler.raiseMessageEvent(1, "Couldn't locate AdaboostTech.dll and/or RFRProgressTech.dll");
                        throw;
                    }
                }
            }catch (Exception e)
            {
                Console.WriteLine("Couldn't locate database file");
                Console.WriteLine(e.StackTrace);
                eventHandler.raiseMessageEvent(1, "Couldn't locate database file");
                throw;
            }

            bufferSize              = gestureHandler.getBufferSize();
            discreteResultsBuffer   = new IReadOnlyDictionary <string, float> [bufferSize];
            continuousResultsBuffer = new IReadOnlyDictionary <string, float> [bufferSize];
        }