예제 #1
0
        public ImageTracker(string name)
            : base()
        {
            Console.WriteLine("MyImage created");
            this.name = name;
            pushDetector = new PushDetector();
            circleDetector = new CircleDetector();
            circleDetector.MinimumPoints = 50;
            steadyDetector = new SteadyDetector();

            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(circleDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push += new EventHandler<VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady);
            circleDetector.OnCircle += new EventHandler<CircleEventArgs>(circleDetector_OnCircle);

            PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler<IdEventArgs>(MyBox_PrimaryPointDestroy);
            PrimaryPointUpdate += new EventHandler<HandEventArgs>(MyBox_PrimaryPointUpdate);
            OnUpdate += new EventHandler<UpdateMessageEventArgs>(MyBox_OnUpdate);
        }
예제 #2
0
        public bool initializeSensor(String xmlPath)
        {
            try

            {
                pbuffer   = new  Point[6];
                openpalm  = new OpenPalm();
                scrHeight = SystemInformation.PrimaryMonitorSize.Height;
                scrWidth  = SystemInformation.PrimaryMonitorSize.Width;

                mouseSpeed       = SystemInformation.MouseSpeed * 0.15;
                pointCollections = new PointCollection();
                /*OpenNI objects - Context, DepthGenerator and DepthMetaData are initialized here*/
                cxt              = new Context(xmlPath);
                depthGen         = cxt.FindExistingNode(NodeType.Depth) as DepthGenerator;
                gsHandsGenerator = cxt.FindExistingNode(NodeType.Hands) as HandsGenerator;
                gsHandsGenerator.SetSmoothing(0.1f);
                depthMeta = new DepthMetaData();
                if (depthGen == null)
                {
                    return(false);
                }

                xRes = depthGen.MapOutputMode.XRes;
                yRes = depthGen.MapOutputMode.YRes;

                /*NITE objects - Session manager, PointControl is initialized here*/
                sessionMgr = new SessionManager(cxt, "Wave", "RaiseHand");

                pointCtrl      = new PointControl("PointTracker");
                steadydetector = new SteadyDetector();
                flrouter       = new FlowRouter();
                brodcaster     = new Broadcaster();
                steadydetector.DetectionDuration = 200;

                steadydetector.Steady    += new EventHandler <SteadyEventArgs>(steadydetector_Steady);
                steadydetector.NotSteady += new EventHandler <SteadyEventArgs>(steadydetector_NotSteady);

                /*  pointCtrl.PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(pointCtrl_PrimaryPointCreate);
                 * pointCtrl.PrimaryPointUpdate += new EventHandler<HandEventArgs>(pointCtrl_PrimaryPointUpdate);
                 * pointCtrl.PrimaryPointDestroy += new EventHandler<IdEventArgs>(pointCtrl_PrimaryPointDestroy);*/
                pointCtrl.PointCreate  += new EventHandler <HandEventArgs>(pointCtrl_PointCreate);
                pointCtrl.PointUpdate  += new EventHandler <HandEventArgs>(pointCtrl_PointUpdate);
                pointCtrl.PointDestroy += new EventHandler <IdEventArgs>(pointCtrl_PointDestroy);


                sessionMgr.AddListener(steadydetector);
                sessionMgr.AddListener(pointCtrl); //make the session manager listen to the point control

                isActive = false;                  //set lifecycle flag to false
                //fill the handpoint coordinates with invalid values
                //initialize the clipping matrix

                HandPointBuffer = new ArrayList();
            }
            catch (Exception e) { return(false); }

            return(true);
        }
        void Setup()
        {
            //build the context
            Context = new Context(CONFIG);

            //build the session manager
            SeshManager = new SessionManager(Context,"RaiseHand","RaiseHand");
            SeshManager.SetQuickRefocusTimeout(15000);

            //build the flow router
            Flowy = new FlowRouter();

            //build the Broadcaster
        }
예제 #4
0
        public HandData()
            : base()
        {
            Console.WriteLine("Constructing MyCanvas");
            pushDetector = new PushDetector();
            swipeDetector = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push += new EventHandler<VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new EventHandler<DirectionVelocityAngleEventArgs>(swipeDetector_GeneralSwipe);

            PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(MyCanvas_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler<IdEventArgs>(MyCanvas_PrimaryPointDestroy);
            PrimaryPointUpdate += new EventHandler<HandEventArgs>(MyCanvas_PrimaryPointUpdate);
            OnUpdate += new EventHandler<UpdateMessageEventArgs>(MyCanvas_OnUpdate);
        }
예제 #5
0
        public MyBox(System.Windows.Forms.Panel box, string name) :
            base()
        {
            this.name = name;
            this.box = box;

            pushDetector = new PushDetector();
            swipeDetector = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push +=new EventHandler<VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new EventHandler<DirectionVelocityAngleEventArgs>(swipeDetector_GeneralSwipe);

            PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler<IdEventArgs>(MyBox_PrimaryPointDestroy);
            OnUpdate += new EventHandler<UpdateMessageEventArgs>(MyBox_OnUpdate);
        }
예제 #6
0
파일: MyBox.cs 프로젝트: martindale/nestk
        public MyBox(System.Windows.Forms.Panel box, string name) :
            base()
        {
            this.name = name;
            this.box  = box;

            pushDetector   = new PushDetector();
            swipeDetector  = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter     = new FlowRouter();
            broadcaster    = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push          += new PushDetector.PushHandler(pushDetector_Push);
            steadyDetector.Steady      += new SteadyDetector.SteadyHandler(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new SwipeDetector.GeneralSwipeHandler(swipeDetector_GeneralSwipe);

            PrimaryPointCreate  += new PrimaryPointCreateHandler(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new PrimaryPointDestroyHandler(MyBox_PrimaryPointDestroy);
            OnUpdate            += new UpdateHandler(MyBox_OnUpdate);
        }
예제 #7
0
        public MyBox(System.Windows.Forms.Panel box, string name) :
            base()
        {
            this.name = name;
            this.box  = box;

            pushDetector   = new PushDetector();
            swipeDetector  = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter     = new FlowRouter();
            broadcaster    = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push          += new EventHandler <VelocityAngleEventArgs>(pushDetector_Push);
            steadyDetector.Steady      += new EventHandler <SteadyEventArgs>(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new EventHandler <DirectionVelocityAngleEventArgs>(swipeDetector_GeneralSwipe);

            PrimaryPointCreate  += new EventHandler <HandFocusEventArgs>(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new EventHandler <IdEventArgs>(MyBox_PrimaryPointDestroy);
            OnUpdate            += new EventHandler <UpdateMessageEventArgs>(MyBox_OnUpdate);
        }
        public bool initializeSensor(String xmlPath)
        {
            try

            {

                pbuffer =new  Point[6];
                openpalm = new OpenPalm();
                scrHeight = SystemInformation.PrimaryMonitorSize.Height;
                scrWidth = SystemInformation.PrimaryMonitorSize.Width;

                mouseSpeed = SystemInformation.MouseSpeed * 0.15;
                pointCollections = new PointCollection();
                /*OpenNI objects - Context, DepthGenerator and DepthMetaData are initialized here*/
                cxt = new Context(xmlPath);
                depthGen = cxt.FindExistingNode(NodeType.Depth) as DepthGenerator;
                gsHandsGenerator = cxt.FindExistingNode(NodeType.Hands) as HandsGenerator;
                gsHandsGenerator.SetSmoothing(0.1f);
                depthMeta = new DepthMetaData();
                if (depthGen == null) return false;

                xRes = depthGen.MapOutputMode.XRes;
                yRes = depthGen.MapOutputMode.YRes;

                /*NITE objects - Session manager, PointControl is initialized here*/
                sessionMgr = new SessionManager(cxt, "Wave", "RaiseHand");

                pointCtrl = new PointControl("PointTracker");
                steadydetector = new SteadyDetector();
                flrouter = new FlowRouter();
                brodcaster = new Broadcaster();
                steadydetector.DetectionDuration = 200;

                steadydetector.Steady+=new EventHandler<SteadyEventArgs>(steadydetector_Steady);
                steadydetector.NotSteady+=new EventHandler<SteadyEventArgs>(steadydetector_NotSteady);
              /*  pointCtrl.PrimaryPointCreate += new EventHandler<HandFocusEventArgs>(pointCtrl_PrimaryPointCreate);
                pointCtrl.PrimaryPointUpdate += new EventHandler<HandEventArgs>(pointCtrl_PrimaryPointUpdate);
                pointCtrl.PrimaryPointDestroy += new EventHandler<IdEventArgs>(pointCtrl_PrimaryPointDestroy);*/
                pointCtrl.PointCreate += new EventHandler<HandEventArgs>(pointCtrl_PointCreate);
                pointCtrl.PointUpdate += new EventHandler<HandEventArgs>(pointCtrl_PointUpdate);
                pointCtrl.PointDestroy += new EventHandler<IdEventArgs>(pointCtrl_PointDestroy);

                sessionMgr.AddListener(steadydetector);
               sessionMgr.AddListener(pointCtrl);  //make the session manager listen to the point control

                isActive = false;                   //set lifecycle flag to false
                            //fill the handpoint coordinates with invalid values
                         //initialize the clipping matrix

                HandPointBuffer = new ArrayList();

            }
            catch (Exception e) { return false; }

            return true;
        }
예제 #9
0
        //constructor function
        public ViewingPaneForm()
        {
            InitializeComponent();

            #region Initializations
            CheckForIllegalCrossThreadCalls = false;
            this.context                  = Context.CreateFromXmlFile(SAMPLE_XML_FILE, out this.scriptNode);
            this.sessionManager           = new NITE.SessionManager(this.context, "Wave,Click", "RaiseHand");
            this.Instruction_Display.Text = "Connected to the Kinect Camera";
            this.depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator;
            if (this.depth == null)
            {
                throw new Exception("Viewer must have a depth node!");
            }
            this.hands = context.FindExistingNode(NodeType.Hands) as HandsGenerator;
            this.hands.SetSmoothing(0.8f);
            #endregion

            #region Setup Components
            pushDetector    = new PushDetector("PushDetector");
            aux_pushDect    = new PushDetector("Auxilary Push Detector");
            slider          = new SelectableSlider1D(1, Axis.X);
            swipeDetector   = new SwipeDetector("SwipeDectector");
            steadyDetector  = new SteadyDetector(350, 15);
            broadcaster     = new Broadcaster("Broadcaster");
            aux_broadcaster = new Broadcaster("Auxilary Broadcaster");
            router          = new FlowRouter("router");
            #endregion

            #region SignalRouting
            this.sessionManager.AddListener(this.router);
            this.router.ActiveListener = this.steadyDetector;

            this.broadcaster.AddListener(pushDetector);
            this.broadcaster.AddListener(swipeDetector);

            this.aux_broadcaster.AddListener(this.slider);
            this.aux_broadcaster.AddListener(this.aux_pushDect);
            #endregion

            #region SetUp Drawing Function
            this.histogram = new int[this.depth.DeviceMaxDepth];
            MapOutputMode mapMode = this.depth.MapOutputMode;
            this.bitmap       = new Bitmap((int)mapMode.XRes, (int)mapMode.YRes, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            this.shouldRun    = true;
            this.readerThread = new Thread(RenderThread);
            this.readerThread.Start();
            #endregion

            #region setProp values

            vars = new configurationVars();
            this.sessionManager.PrimaryStaticTimeout = 7;
            vars.SteadyReq        = 1000;
            vars.SteadyStddevReq  = 1;
            vars.SwipeVelmin      = 0.2f;
            vars.SwipeMinDuration = 500;
            vars.SwipeXangle      = 45;
            vars.SwipeYangle      = 45;
            vars.CircleMaxError   = 2;
            vars.CircleRadMin     = 80;
            vars.SliderHeight     = 100;
            vars.SliderWidth      = 200;
            vars.SwipeUseSteady   = true;
            vars.SwipeSteadyDur   = 75;

            this.populateConfiguration();
            this.customizeSwipe();
            this.customizeSteady();
            this.customizeCircle();
            #endregion

            #region Event Registration
            this.sessionManager.SessionStart         += new EventHandler <PositionEventArgs>(sessionManager_SessionStart);
            this.sessionManager.SessionFocusProgress += new EventHandler <SessionProgressEventArgs>(sessionManager_SessionFocusProgress);
            this.sessionManager.SessionEnd           += new EventHandler(sessionManager_SessionEnd);
            this.hands.HandDestroy        += new EventHandler <HandDestroyEventArgs>(hands_HandDestroy);
            this.hands.HandCreate         += new EventHandler <HandCreateEventArgs>(hands_HandCreate);
            this.pushDetector.Push        += new EventHandler <VelocityAngleEventArgs>(pushDetector_Push);
            this.swipeDetector.SwipeRight += new EventHandler <VelocityAngleEventArgs>(swipeDetector_SwipeRight);
            this.swipeDetector.SwipeLeft  += new EventHandler <VelocityAngleEventArgs>(swipeDetector_SwipeLeft);
            this.swipeDetector.SwipeUp    += new EventHandler <VelocityAngleEventArgs>(swipeDetector_SwipeUp);
            this.swipeDetector.SwipeDown  += new EventHandler <VelocityAngleEventArgs>(swipeDetector_SwipeDown);
            this.steadyDetector.Steady    += new EventHandler <SteadyEventArgs>(steadyDetector_Steady);
            this.slider.ValueChange       += new EventHandler <ValueEventArgs>(slider_ValueChange);
            this.aux_pushDect.Push        += new EventHandler <VelocityAngleEventArgs>(aux_pushDect_Push);


            //aux_pushDect.
            #endregion
        }
예제 #10
0
 /// <summary>
 /// Setup builds an XN Context, Session Manager and all the detectors. 
 /// It also adds the callbacks for the SessionManager and adds the listeners on the Broadcaster. 
 /// </summary>
 private void Setup()
 {
     //build the context
     Context = new Context(CONFIG);
     //build session manager
     SeshManager = new SessionManager(Context,"RaiseHand","RaiseHand");
     SeshManager.SetQuickRefocusTimeout(15000);
     //build the FlowRouter
     Flowy  = new FlowRouter();
     //build the Broadcaster
     BCaster = new Broadcaster();
     //build the detectors
     Pushy = new PushDetector();
     Swipy = new SwipeDetector();
     //setup all the callbacks
     SetupCallbacks();
     Flowy.SetActive(BCaster);
     //add the flow router to the session
     SeshManager.AddListener(Flowy);
     SeshManager.SessionStart += SessionStarted;
     //add the listeners to BCaster
     BCaster.AddListener(Pushy);
     BCaster.AddListener(Swipy);
 }
예제 #11
0
        public MyBox(System.Windows.Forms.Panel box, string name)
            : base()
        {
            this.name = name;
            this.box = box;

            pushDetector = new PushDetector();
            swipeDetector = new SwipeDetector();
            steadyDetector = new SteadyDetector();
            flowRouter = new FlowRouter();
            broadcaster = new Broadcaster();

            broadcaster.AddListener(pushDetector);
            broadcaster.AddListener(flowRouter);

            pushDetector.Push += new PushDetector.PushHandler(pushDetector_Push);
            steadyDetector.Steady += new SteadyDetector.SteadyHandler(steadyDetector_Steady);
            swipeDetector.GeneralSwipe += new SwipeDetector.GeneralSwipeHandler(swipeDetector_GeneralSwipe);

            PrimaryPointCreate += new PrimaryPointCreateHandler(MyBox_PrimaryPointCreate);
            PrimaryPointDestroy += new PrimaryPointDestroyHandler(MyBox_PrimaryPointDestroy);
            OnUpdate += new UpdateHandler(MyBox_OnUpdate);
        }