public Boxes()
        {
            InitializeComponent();

            this.context = new OpenNI.Context(SAMPLE_XML_FILE);
            this.sessionManager = new NITE.SessionManager(this.context, "Wave", "RaiseHand");

            this.flowRouter = new NITE.FlowRouter();
            this.selectableSlider = new NITE.SelectableSlider1D(3, NITE.Axis.X);
            this.boxes = new MyBox[3];
            this.boxes[0] = new MyBox(this.Box1, "Box1");
            this.boxes[1] = new MyBox(this.Box2, "Box2");
            this.boxes[2] = new MyBox(this.Box3, "Box3");

            this.boxes[0].Leave += new MyBox.LeaveHandler(Boxes_Leave);
            this.boxes[1].Leave += new MyBox.LeaveHandler(Boxes_Leave);
            this.boxes[2].Leave += new MyBox.LeaveHandler(Boxes_Leave);

            this.selectableSlider.ItemHover += new EventHandler<NITE.IndexEventArgs>(selectableSlider_ItemHover);
            this.selectableSlider.ItemSelect += new EventHandler<NITE.IndexDirectionEventArgs>(selectableSlider_ItemSelect);
            this.selectableSlider.PrimaryPointCreate += new EventHandler<NITE.HandFocusEventArgs>(selectableSlider_PrimaryPointCreate);
            this.selectableSlider.PrimaryPointDestroy += new EventHandler<NITE.IdEventArgs>(selectableSlider_PrimaryPointDestroy);

            this.sessionManager.SessionStart += new EventHandler<NITE.PositionEventArgs>(sessionManager_SessionStart);

            this.sessionManager.AddListener(this.flowRouter);

            this.shouldRun = true;
            this.readerThread = new Thread(ReaderThread);
            this.readerThread.Start();
        }
Example #2
0
        /// <summary>
        /// Initializes the image and depth camera.
        /// </summary>
        /// <param name="configuration">Configuration file path.</param>
        private void InitializeCamera(string configuration)
        {
            try
            {
                this.Context = Context.CreateFromXmlFile(configuration, out scriptNode);
                this.sessionManager = new NITE.SessionManager(this.Context, "Wave", "RaiseHand");
            }
            catch
            {
                throw new Exception("Configuration file not found.");
            }

            ImageGenerator = Context.FindExistingNode(NodeType.Image) as ImageGenerator;
            DepthGenerator = Context.FindExistingNode(NodeType.Depth) as DepthGenerator;
            DepthGenerator.AlternativeViewpointCapability.SetViewpoint(ImageGenerator);
            Histogram = new int[DepthGenerator.DeviceMaxDepth];
        }