public MainWindow()
        {
            this.InitializeComponent();
            main = this;

            KinectRegion.SetKinectRegion(this, kinectRegion);

            App app = ((App)Application.Current);

            app.KinectRegion = kinectRegion;

            this.kinectSensor = KinectSensor.GetDefault();

            // Use the default sensor
            this.kinectRegion.KinectSensor = this.kinectSensor;

            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;
            guildList = new List <Guild>();
            coms      = new ComModule(this);

            this.gestureDetector = new GestureDetector(kinectSensor, coms);
            this.activeBodyIndex = -1;

            /*if (!kinectSensor.IsAvailable)
             * {
             *  Console.WriteLine("Kinect Sensor is not available!");
             *  Environment.Exit(1);
             * }*/
        }
示例#2
0
        public GestureDetector(KinectSensor kinectSensor, ComModule coms)
        {
            this.coms = coms;
            if (kinectSensor == null)
            {
                throw new ArgumentNullException("kinectSensor");
            }

            this.vgbFrameSource = new VisualGestureBuilderFrameSource(kinectSensor, 0);
            this.vgbFrameReader = this.vgbFrameSource.OpenReader();

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

            if (database == null)
            {
                Console.WriteLine("No gesture database!");
                Environment.Exit(1);
            }

            lce  = new LifeCycleEvents("GESTURES", "FUSION", "gesture-1", "acoustic", "command"); // LifeCycleEvents(string source, string target, string id, string medium, string mode)
            mmic = new MmiCommunication("localhost", 9876, "User1", "GESTURES");                  // MmiCommunication(string IMhost, int portIM, string UserOD, string thisModalityName)
            mmic.Send(lce.NewContextRequest());

            this.vgbFrameSource.AddGestures(database.AvailableGestures);
            fpsCounter         = 0;
            gestureWasDetected = false;
        }