Пример #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);
        }
 /// base constructor
 /// @param timeToClick this is the time one needs to remain steady to for the event to fire
 /// (and the gesture recognized).
 /// @param timeToReset the time AFTER firing the event where the steady resets (i.e. as if
 /// the hand moved).
 /// @note this means that if one leaves his hand steady continuously then the event will fire
 /// every timeToClick+timeToReset seconds starting from timeToClick seconds after the initial
 /// steady.
 public NISteadyTracker(float timeToClick, float timeToReset)
 {
     NIOpenNICheckVersion.Instance.ValidatePrerequisite();
     m_steadyDetector            = new SteadyDetector();
     m_steadyDetector.Steady    += new System.EventHandler <SteadyEventArgs>(DetectSteadyEvent);
     m_steadyDetector.NotSteady += new System.EventHandler <SteadyEventArgs>(DetectNotSteadyEvent);
     m_currentSteady             = false;
     m_firstSteady      = float.MaxValue;
     m_firedSteadyEvent = false;
     m_timeToClick      = timeToClick;
     m_timeToReset      = timeToClick + timeToReset;
 }
Пример #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
        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
        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);
        }