public WebNect()
        {
            this.context = new OpenNI.Context(SAMPLE_XML_FILE);
            this.sessionManager = new NITE.SessionManager(this.context, "Click", "RaiseHand");
            this.context.StartGeneratingAll();

            this.sessionManager.SessionStart += new
                    EventHandler<NITE.PositionEventArgs>(sessionManager_SessionStart);
            this.sessionManager.SessionFocusProgress += new
                    EventHandler<NITE.SessionProgressEventArgs>(sessionManager_SessionProgress);
            this.sessionManager.SessionEnd += sessionManager_SessionEnd;

            this.waveDetector = new NITE.WaveDetector();
            this.waveDetector.Wave += waveDetector_Wave;
            this.waveDetector.PointUpdate += new EventHandler<HandEventArgs>(waveDetector_PointUpdate);
            this.sessionManager.AddListener(this.waveDetector);

            this.zmq_context = new ZMQ.Context(1);
            this.zmq_publisher = this.zmq_context.Socket(SocketType.PUB);
            this.zmq_publisher.Bind(this.SOCKET_SOURCE);
            Console.WriteLine("ZMQ Socket at {0}", this.SOCKET_SOURCE);

            this.shouldRun = true;
            this.readerThread = new Thread(ReaderThread);
            this.readerThread.Start();
        }
        // 初期化
        private void xnInitialize()
        {
            // コンテキストの初期化
            ScriptNode scriptNode;

            context = Context.CreateFromXmlFile(CONFIG_XML_PATH, out scriptNode);

            // イメージジェネレータの作成
            image = context.FindExistingNode(NodeType.Image) as ImageGenerator;
            if (image == null)
            {
                throw new Exception(context.GlobalErrorState);
            }

            // NITEのためのセッションマネージャを作成
            sessionManager = new NITE.SessionManager(context,
                                                     "Wave,Click", "RaiseHand");

            // セッションの開始と終了を通知するコールバックを登録する
            sessionManager.SessionStart         += new EventHandler <PositionEventArgs>(sessionManager_SessionStart);
            sessionManager.SessionEnd           += new EventHandler(sessionManager_SessionEnd);
            sessionManager.SessionFocusProgress += new EventHandler <SessionProgressEventArgs>(sessionManager_SessionFocusProgress);
        }
        // 初期化
        private void xnInitialize()
        {
            // コンテキストの初期化
              ScriptNode scriptNode;
              context = Context.CreateFromXmlFile( CONFIG_XML_PATH, out scriptNode );

              // イメージジェネレータの作成
              image = context.FindExistingNode(NodeType.Image) as ImageGenerator;
              if (image == null) {
            throw new Exception(context.GlobalErrorState);
              }

              // NITEのためのセッションマネージャを作成
              sessionManager = new NITE.SessionManager(context,
                              "Wave,Click", "RaiseHand");

              // セッションの開始と終了を通知するコールバックを登録する
              sessionManager.SessionStart += new EventHandler<PositionEventArgs>(sessionManager_SessionStart);
              sessionManager.SessionEnd += new EventHandler(sessionManager_SessionEnd);
              sessionManager.SessionFocusProgress += new EventHandler<SessionProgressEventArgs>(sessionManager_SessionFocusProgress);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new instance of SensorData with the specified configuration file.
        /// </summary>
        /// <param name="configuration">Configuration file path.</param>
        public HandTracker(string configuration)
        {
            InitializeCamera(configuration);
            InitializeBitmaps();
            InitializeThread();

            this.DepthGenerator.AlternativeViewpointCapability.SetViewpoint(this.ImageGenerator);
            this.userGenerator = new UserGenerator(this.Context);
            this.skeletonCapbility = this.userGenerator.SkeletonCapability;
            this.poseDetectionCapability = this.userGenerator.PoseDetectionCapability;
            this.calibPose = this.skeletonCapbility.CalibrationPose;
            this.poseDetectionCapability.PoseDetected += poseDetectionCapability_PoseDetected;
            this.skeletonCapbility.CalibrationComplete += skeletonCapbility_CalibrationComplete;

            this.skeletonCapbility.SetSkeletonProfile(SkeletonProfile.All);
            this.joints = new Dictionary<int, Dictionary<SkeletonJoint, SkeletonJointPosition>>();

            this.sessionManager = new NITE.SessionManager(this.Context, "Wave,Click", "RaiseHand");
            _handsGenerator = new HandsGenerator(Context);
            _handsGenerator.SetSmoothing(0.1f);

            _gestureGenerator = new GestureGenerator(Context);

            this.Context.StartGeneratingAll();
            Console.WriteLine("Start Generating All");

            pointControl = new PointControl("PointTracker");
            pointControl.PointCreate += new EventHandler<HandEventArgs>(pointControl_PointCreate);
            pointControl.PointUpdate += new EventHandler<HandEventArgs>(pointControl_PointUpdate);
            pointControl.PointDestroy += new EventHandler<IdEventArgs>(pointControl_PointDestroy);
            sessionManager.AddListener(pointControl);

            this.userGenerator.NewUser += userGenerator_NewUser;
            this.userGenerator.LostUser += userGenerator_LostUser;
            this.userGenerator.StartGenerating();
        }