Ejemplo n.º 1
0
        public HandTracker(Context context)
        {
            this.context = context;

            //gestureGenerator = context.FindExistingNode(NodeType.Gesture) as GestureGenerator;
            handsGenerator = context.FindExistingNode(NodeType.Hands) as HandsGenerator;

            //gestureGenerator.GestureRecognized += new EventHandler<GestureRecognizedEventArgs>(gestureGenerator_GestureRecognized);

            handsGenerator.HandCreate += new EventHandler<HandCreateEventArgs>(handsGenerator_HandCreate);
            handsGenerator.HandDestroy += new EventHandler<HandDestroyEventArgs>(handsGenerator_HandDestroy);
            handsGenerator.HandUpdate += new EventHandler<HandUpdateEventArgs>(handsGenerator_HandUpdate);

            handsGenerator.StartGenerating();
            //gestureGenerator.AddGesture("Wave");

            Trace.WriteLine("HandSensor initialized");
        }
Ejemplo n.º 2
0
        private ProductionNode CreateProductionNodeObject(IntPtr nodeHandle, NodeType? type)
        {
            lock (this)
            {
                if (!this.allNodes.ContainsKey(nodeHandle))
                {
                    if (type == null)
                    {
                        IntPtr pNodeInfo = SafeNativeMethods.xnGetNodeInfo(nodeHandle);
                        type = NodeInfo.FromNative(pNodeInfo).Description.Type;
                    }

                    ProductionNode node;

                    switch (type)
                    {
                        case NodeType.Device:
                            node = new Device(this, nodeHandle, true);
                            break;
                        case NodeType.Depth:
                            node = new DepthGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Image:
                            node = new ImageGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Audio:
                            node = new AudioGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.IR:
                            node = new IRGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.User:
                            node = new UserGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Recorder:
                            node = new Recorder(this, nodeHandle, true);
                            break;
                        case NodeType.Player:
                            node = new Player(this, nodeHandle, true);
                            break;
                        case NodeType.Gesture:
                            node = new GestureGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Scene:
                            node = new SceneAnalyzer(this, nodeHandle, true);
                            break;
                        case NodeType.Hands:
                            node = new HandsGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.Codec:
                            node = new Codec(this, nodeHandle, true);
                            break;
                        case NodeType.ProductionNode:
                            node = new ProductionNode(this, nodeHandle, true);
                            break;
                        case NodeType.Generator:
                            node = new Generator(this, nodeHandle, true);
                            break;
                        case NodeType.MapGenerator:
                            node = new MapGenerator(this, nodeHandle, true);
                            break;
                        case NodeType.ScriptNode:
                            node = new ScriptNode(this, nodeHandle, true);
                            break;
                        default:
                            throw new NotImplementedException("C# wrapper: Unknown generator type!");
                    }
                    this.allNodes[nodeHandle] = node;
                }

                return this.allNodes[nodeHandle];
            } // lock
        }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        player=GameObject.Find("Player");
        Debug.Log ("---------"+player.transform.localPosition);
        camaraMenu=GameObject.Find(CAMARA_MENU).camera;
        camaraPlayer=GameObject.Find(CAMARA_PLAYER).camera;
        seleccionarCamara(CAMARA_PLAYER);
        playMemory="1";
        audio.clip = clip1;
        audio.Play();
        puntoInicial=GameObject.Find("puntoInicial");
        puntoFinal=GameObject.Find("puntoFinal");
        determinaEspacioUnity();
        determinaCentro();
        transform.position=new Vector3(xMedia,yMedia,zMedia);
        //
        this.context=Context.CreateFromXmlFile(XML_CONFIG, out scriptNode);
        this.depth=this.context.FindExistingNode(NodeType.Depth) as DepthGenerator;
        if(depth==null){
            throw new Exception("Nodo de Profundidad no encontrado");
        }
        this.hands=this.context.FindExistingNode(NodeType.Hands) as HandsGenerator;
        if(this.hands==null){
            throw new Exception("Nodo de Manos no encontrado");
        }
        this.gesture=this.context.FindExistingNode(NodeType.Gesture) as GestureGenerator;
        if(this.gesture==null){
            throw new Exception("Nodo de Gestos no encontrado");
        }

        fadeCountCircle();
        //handdlers
        this.hands.HandCreate+=hands_HandCreate;
        this.hands.HandUpdate+=hands_HandUpdate;
        this.hands.HandDestroy+=hands_HandDestroy;

        this.gesture.AddGesture(WAVE);
        this.gesture.AddGesture(CLICK);
        this.gesture.GestureRecognized+=gesture_GestureRecognized;
        this.gesture.StartGenerating();
        //iniciaPuntos
        iniciaPuntos();
    }
Ejemplo n.º 4
0
    void Start()
    {
        //Debug.Log("START");
        determinaCentro();

        //Debug.Log("X "+xMedia+" Y "+yMedia+" Z "+zMedia);
        transform.position=new Vector3(xMedia,yMedia,zMedia);

        this.context=Context.CreateFromXmlFile(XML_CONFIG, out scriptNode);
        this.depth=this.context.FindExistingNode(NodeType.Depth) as DepthGenerator;
        if(depth==null){
            throw new Exception("Nodo de Profundidad no encontrado");
        }
        this.hands=this.context.FindExistingNode(NodeType.Hands) as HandsGenerator;
        if(this.hands==null){
            throw new Exception("Nodo de Manos no encontrado");
        }
        this.gesture=this.context.FindExistingNode(NodeType.Gesture) as GestureGenerator;
        if(this.gesture==null){
            throw new Exception("Nodo de Gestos no encontrado");
        }
        //handdlers
        this.hands.HandCreate+=hands_HandCreate;
        this.hands.HandUpdate+=hands_HandUpdate;
        this.hands.HandDestroy+=hands_HandDestroy;

        this.gesture.AddGesture(WAVE);
        this.gesture.GestureRecognized+=gesture_GestureRecognized;
        this.gesture.StartGenerating();
    }
        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;
        }
Ejemplo n.º 6
0
		private ProductionNode CreateProductionNodeObject(IntPtr nodeHandle, NodeType? type)
		{
			lock (this)
			{
				if (!this.allNodes.ContainsKey(nodeHandle))
				{
					if (type == null)
					{
						IntPtr pNodeInfo = SafeNativeMethods.xnGetNodeInfo(nodeHandle);
                        type = NodeInfo.FromNative(pNodeInfo).Description.Type;
					}

					ProductionNode node;

                   	// start with concrete types
                    if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Device))
                    {
                        node = new Device(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Depth))
                    {
                        node = new DepthGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Image))
                    {
                        node = new ImageGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Audio))
                    {
                        node = new AudioGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.IR))
                    {
                        node = new IRGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.User))
                    {
                        node = new UserGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Recorder))
                    {
                        node = new Recorder(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Player))
                    {
                        node = new Player(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Gesture))
                    {
                        node = new GestureGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Scene))
                    {
                        node = new SceneAnalyzer(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Hands))
                    {
                        node = new HandsGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Codec))
                    {
                        node = new Codec(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.ScriptNode))
                    {
                        node = new ScriptNode(this, nodeHandle, true);
                    }
                    // move on to abstract types
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.MapGenerator))
                    {
                        node = new MapGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Generator))
                    {
                        node = new Generator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.ProductionNode))
                    {
                        node = new ProductionNode(this, nodeHandle, true);
                    }
                    else
                    {
                        throw new NotImplementedException("C# wrapper: Unknown generator type!");
                    }

					this.allNodes[nodeHandle] = node;
				}

				return this.allNodes[nodeHandle];
			} // lock
		}
Ejemplo n.º 7
0
        public MainWindow()
        {
            InitializeComponent();

            history = new Dictionary<int, List<Point3D>>();

            //MessageBox.Show("test");

            this.context = Context.CreateFromXmlFile(SAMPLE_XML_FILE, out scriptNode);
            this.depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator;
            if (this.depth == null)
            {
                throw new Exception("Viewer must have a depth node!");
            }

            //--- OpenNI Generators
            this.gestureGenerator = new GestureGenerator(this.context);
            this.gestureGenerator.AddGesture("Wave");
            this.gestureGenerator.AddGesture("Click");
            this.gestureGenerator.GestureRecognized += new EventHandler<GestureRecognizedEventArgs>(gestureGenerator_GestureRecognized);

            this.handsGenerator = new HandsGenerator(this.context);
            this.handsGenerator.HandCreate += new EventHandler<HandCreateEventArgs>(handsGenerator_HandCreate);
            this.handsGenerator.HandUpdate += new EventHandler<HandUpdateEventArgs>(handsGenerator_HandUpdate);
            this.handsGenerator.HandDestroy += new EventHandler<HandDestroyEventArgs>(handsGenerator_HandDestroy);
            if (smoothMouseMovement)
                this.handsGenerator.SetSmoothing(smoothingValue);
            //--- OpenNI Generators

            /*
            //--- NITE Generators
            sessionManager = new SessionManager(context, "Click", "RaiseHand");
            sessionManager.SessionStart += new EventHandler<PositionEventArgs>(sessionManager_SessionStart);
            sessionManager.SessionEnd += new System.EventHandler(sessionManager_SessionEnd);

            myControl = new PointControl();
            myControl.PrimaryPointUpdate += new System.EventHandler<HandEventArgs>(myControl_PrimaryPointUpdate);
            myControl.PrimaryPointCreate += new System.EventHandler<HandFocusEventArgs>(myControl_PrimaryPointCreate);
            myControl.PrimaryPointDestroy += new System.EventHandler<IdEventArgs>(myControl_PrimaryPointDestroy);

            sessionManager.AddListener(myControl);
            //--- NITE Generators
             */

            this.context.StartGeneratingAll();

            this.histogram = new int[this.depth.DeviceMaxDepth];

            MapOutputMode mapMode = this.depth.MapOutputMode;

            /*
             * Create the directory for the recorded frames
             */
            if (this.captureFrames)
            {
                String subDir = DateTime.Now.ToString().Replace("/", "-").Replace(" ", "_").Replace(":", "-");
                this.frameDir = System.IO.Path.Combine("C:/GoogleDrive/opsei/kinect/src/misc/frames/", subDir);
                System.IO.Directory.CreateDirectory(frameDir);
            }
            stopwatch = new Stopwatch();
            this.fingersDetectedHistory = new int[fingersDetectedHistorySize];
            this.hullRatios = new double[3];

            this.mouseHistoryX = new double[mouseHistorySize];
            this.mouseHistoryY = new double[mouseHistorySize];

            this.palmPositionXHistory = new double[palmHistorySize];
            this.palmPositionYHistory = new double[palmHistorySize];
            this.palmPositionZHistory = new double[palmHistorySize];

            this.startClickLag = false;

            this.minFingerDistance = 120;
            this.frame = 0;
            this.bitmap = new Bitmap((int)mapMode.XRes, (int)mapMode.YRes);
            this.shouldRun = true;
            this.readerThread = new Thread(ReaderThread);
            this.readerThread.Start();
        }
Ejemplo n.º 8
0
        private ProductionNode CreateProductionNodeObject(IntPtr nodeHandle, NodeType?type)
        {
            lock (this)
            {
                if (!this.allNodes.ContainsKey(nodeHandle))
                {
                    if (type == null)
                    {
                        IntPtr pNodeInfo = SafeNativeMethods.xnGetNodeInfo(nodeHandle);
                        type = NodeInfo.FromNative(pNodeInfo).Description.Type;
                    }

                    ProductionNode node;

                    // start with concrete types
                    if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Device))
                    {
                        node = new Device(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Depth))
                    {
                        node = new DepthGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Image))
                    {
                        node = new ImageGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Audio))
                    {
                        node = new AudioGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.IR))
                    {
                        node = new IRGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.User))
                    {
                        node = new UserGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Recorder))
                    {
                        node = new Recorder(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Player))
                    {
                        node = new Player(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Gesture))
                    {
                        node = new GestureGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Scene))
                    {
                        node = new SceneAnalyzer(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Hands))
                    {
                        node = new HandsGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Codec))
                    {
                        node = new Codec(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.ScriptNode))
                    {
                        node = new ScriptNode(this, nodeHandle, true);
                    }
                    // move on to abstract types
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.MapGenerator))
                    {
                        node = new MapGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Generator))
                    {
                        node = new Generator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.ProductionNode))
                    {
                        node = new ProductionNode(this, nodeHandle, true);
                    }
                    else
                    {
                        throw new NotImplementedException("C# wrapper: Unknown generator type!");
                    }

                    this.allNodes[nodeHandle] = node;
                }

                return(this.allNodes[nodeHandle]);
            }             // lock
        }
Ejemplo n.º 9
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();
        }
Ejemplo n.º 10
0
    void Start()
    {
        player=GameObject.Find("Player");
        camaraMenu=GameObject.Find(CAMARA_MENU).camera;
        camaraPlayer=GameObject.Find(CAMARA_PLAYER).camera;
        seleccionarCamara(CAMARA_PLAYER);
        Debug.Log("Start");
        playMemory="1";
        playAudioNext(playMemory);
        //iTween.MoveTo(player,iTween.Hash("path",iTweenPath.GetPath(RECORRIDO),"time",60,"orientToPath",true));
        determinaEspacioUnity();
        determinaCentro();
        transform.position=new Vector3(xMedia,yMedia,zMedia);
        //
        this.context=Context.CreateFromXmlFile(XML_CONFIG, out scriptNode);
        this.depth=this.context.FindExistingNode(NodeType.Depth) as DepthGenerator;
        if(depth==null){
            throw new Exception("Nodo de Profundidad no encontrado");
        }
        this.hands=this.context.FindExistingNode(NodeType.Hands) as HandsGenerator;
        if(this.hands==null){
            throw new Exception("Nodo de Manos no encontrado");
        }
        this.gesture=this.context.FindExistingNode(NodeType.Gesture) as GestureGenerator;
        if(this.gesture==null){
            throw new Exception("Nodo de Gestos no encontrado");
        }
        fadeCountCircle();
        //handdlers
        this.hands.HandCreate+=hands_HandCreate;
        this.hands.HandUpdate+=hands_HandUpdate;
        this.hands.HandDestroy+=hands_HandDestroy;

        this.gesture.AddGesture(WAVE);
        this.gesture.AddGesture(CLICK);
        this.gesture.GestureRecognized+=gesture_GestureRecognized;
        this.gesture.StartGenerating();
    }
        // 初期化
        private void xnInitialize()
        {
            // コンテキストの初期化
              ScriptNode scriptNode;
              context = Context.CreateFromXmlFile( CONFIG_XML_PATH, out scriptNode );

              // 鏡モード(反転)にしない
              context.GlobalMirror = false;

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

              // デプスジェネレータの作成
              depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator;
              if (depth == null) {
            throw new Exception(context.GlobalErrorState);
              }

              // デプスの座標をイメージに合わせる
              depth.AlternativeViewpointCapability.SetViewpoint(image);

              // ジェスチャージェネレータの作成
              gesture = context.FindExistingNode(NodeType.Gesture) as GestureGenerator;
              if (depth == null) {
            throw new Exception(context.GlobalErrorState);
              }

              // ジェスチャーの登録
              gesture.AddGesture("RaiseHand");

              // ジェスチャー用のコールバックを登録
              gesture.GestureRecognized += new EventHandler<GestureRecognizedEventArgs>(gesture_GestureRecognized);
              gesture.GestureProgress += new EventHandler<GestureProgressEventArgs>(gesture_GestureProgress);

              // ハンドジェネレータの作成
              hands = context.FindExistingNode(NodeType.Hands) as HandsGenerator;
              if (depth == null) {
            throw new Exception(context.GlobalErrorState);
              }

              // ハンドトラッキング用のコールバックを登録する
              hands.HandCreate += new EventHandler<HandCreateEventArgs>(hands_HandCreate);
              hands.HandUpdate += new EventHandler<HandUpdateEventArgs>(hands_HandUpdate);
              hands.HandDestroy += new EventHandler<HandDestroyEventArgs>(hands_HandDestroy);

              // ジェスチャーの検出開始
              context.StartGeneratingAll();
        }
Ejemplo n.º 12
0
        private ProductionNode CreateProductionNodeObject(IntPtr nodeHandle, NodeType?type)
        {
            lock (this)
            {
                if (!this.allNodes.ContainsKey(nodeHandle))
                {
                    if (type == null)
                    {
                        IntPtr pNodeInfo = SafeNativeMethods.xnGetNodeInfo(nodeHandle);
                        type = SafeNativeMethods.xnNodeInfoGetDescription(pNodeInfo).Type;
                    }

                    ProductionNode node;

                    switch (type)
                    {
                    case NodeType.Device:
                        node = new Device(this, nodeHandle, true);
                        break;

                    case NodeType.Depth:
                        node = new DepthGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.Image:
                        node = new ImageGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.Audio:
                        node = new AudioGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.IR:
                        node = new IRGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.User:
                        node = new UserGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.Recorder:
                        node = new Recorder(this, nodeHandle, true);
                        break;

                    case NodeType.Player:
                        node = new Player(this, nodeHandle, true);
                        break;

                    case NodeType.Gesture:
                        node = new GestureGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.Scene:
                        node = new SceneAnalyzer(this, nodeHandle, true);
                        break;

                    case NodeType.Hands:
                        node = new HandsGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.Codec:
                        node = new Codec(this, nodeHandle, true);
                        break;

                    case NodeType.ProductionNode:
                        node = new ProductionNode(this, nodeHandle, true);
                        break;

                    case NodeType.Generator:
                        node = new Generator(this, nodeHandle, true);
                        break;

                    case NodeType.MapGenerator:
                        node = new MapGenerator(this, nodeHandle, true);
                        break;

                    case NodeType.ScriptNode:
                        node = new ScriptNode(this, nodeHandle, true);
                        break;

                    default:
                        throw new NotImplementedException("C# wrapper: Unknown generator type!");
                    }
                    this.allNodes[nodeHandle] = node;
                }

                return(this.allNodes[nodeHandle]);
            }             // lock
        }
Ejemplo n.º 13
0
    void Start()
    {
        InitializeCharacter ();
        context = new Context (XML_SETUP_FILE);
        sessionManager = new SessionManager(context, "Wave", "RaiseHand");
        depthGenerator = context.FindExistingNode(NodeType.Depth) as DepthGenerator;
        handsGenerator = context.FindExistingNode(NodeType.Hands) as HandsGenerator;

        //image = context.FindExistingNode(NodeType.Image) as ImageGenerator;
        //gesture = context.FindExistingNode(NodeType.Gesture) as GestureGenerator;
        if (depthGenerator == null) throw new Exception("Viewer must have a depth node!");
        //if (gesture == null) throw new Exception("Viewer must have a gesture node!");
        //if (image == null) throw new Exception("Viewer must have a image node!");

        userGenerator = new UserGenerator (context);
        skeletonCapability = userGenerator.SkeletonCapability;
        poseDetectionCapability = userGenerator.PoseDetectionCapability;
        calibPose = skeletonCapability.CalibrationPose;
        //gestureGenerator = new GestureGenerator(context);

        foreach (String s in poseDetectionCapability.GetAllAvailablePoses())
            Debug.LogWarning("available pose found: " +s);

        //foreach (String s in gestureGenerator.EnumerateAllGestures())
        //	Debug.LogWarning("available gesture found: " + s);

        //gestureGenerator.GestureRecognized += HandleGestureGestureRecognized;
        //gesture.AddGesture("Click");
        //gestureGenerator.AddGesture("RaiseHand"); //seems buggy
        //gestureGenerator.AddGesture("Wave");

        swipeDetector = new SwipeDetector();
        //steadyDetector = new SteadyDetector();//(3, 1f);

        //swipeDetector.SwipeLeft += HandleSwipeDetectorSwipeLeft;

        //Session Managment
        sessionManager.SessionStart += HandleSessionManagerSessionStart;
        sessionManager.SessionEnd += HandleSessionManagerSessionEnd;

        //User Generator
        userGenerator.NewUser += HandleUserGeneratorNewUser;
        userGenerator.LostUser += HandleUserGeneratorLostUser;
        poseDetectionCapability.PoseDetected += HandlePoseDetectionCapabilityPoseDetected;
        skeletonCapability.CalibrationEnd += HandleSkeletonCapabilityCalibrationEnd;

        skeletonCapability.SetSkeletonProfile (SkeletonProfile.All);
        skeletonCapability.SetSmoothing(.5f); // give us some smooothing

        //Start generating
        userGenerator.StartGenerating();
        //handsGenerator.MirrorCapability.SetMirror(true); // TODO: should this be true?
        handsGenerator.StartGenerating();
        //gestureGenerator.StartGenerating();

        //slider selector
        //selectableSlider2D = new SelectableSlider2D(Screen.width, Screen.height);
        //selectableSlider2D.ValueChange += HandleSelectableSlider2DValueChange;
        //selectableSlider2D.ItemHover += HandleSelectableSlider2DItemHover;
        //selectableSlider2D.ItemSelect += HandleSelectableSlider2DItemSelect;

        pointDenoiser = new PointDenoiser();
        pointDenoiser.AddListener(swipeDetector);
        //pointDenoiser.AddListener(steadyDetector);
        //pointDenoiser.AddListener(selectableSlider2D);

        //flowRouter = new FlowRouter();
        //flowRouter.ActiveListener = pointDenoiser;

        sessionManager.AddListener(pointDenoiser);

        MapOutputMode mapMode = depthGenerator.MapOutputMode;

        // Init depth & label map related stuff
        usersMapSize = mapMode.XRes * mapMode.YRes;
        //usersLabelTexture = new Texture2D(mapMode.XRes, mapMode.YRes); //nonPOT slow
        usersLabelTexture = new Texture2D(1024,512);
        //speed up by using power of two and then setpixel() with blockwidth (640) and blockheight (480)
        usersMapColors = new Color[usersMapSize];
        usersMapRect = new Rect(Screen.width - usersLabelTexture.width / 2, Screen.height - usersLabelTexture.height / 2, usersLabelTexture.width / 2, usersLabelTexture.height / 2);
        usersLabelMap = new short[usersMapSize];
        usersDepthMap = new short[usersMapSize];
        usersHistogramMap = new float[5000];

        this.shouldRun = true;

        if (NiteInitializingEvent != null) //notify others that we're done initializing
            NiteInitializingEvent(this, EventArgs.Empty);
    }
Ejemplo n.º 14
0
    void Start()
    {
        //inicia objetos
        avanzar=GameObject.Find("BotonAvanzar");
        repetir=GameObject.Find("BotonRepetir");
        retroceder=GameObject.Find("BotonRetroceder");
        mano=GameObject.Find("Mano");
        determinaCentro();
        acomodaManoDerecha();

        this.context=Context.CreateFromXmlFile(XML_CONFIG, out scriptNode);
        this.depth=this.context.FindExistingNode(NodeType.Depth) as DepthGenerator;
        if(depth==null){
            throw new Exception("Nodo de Profundidad no encontrado");
        }
        this.hands=this.context.FindExistingNode(NodeType.Hands) as HandsGenerator;
        if(this.hands==null){
            throw new Exception("Nodo de Manos no encontrado");
        }
        this.gesture=this.context.FindExistingNode(NodeType.Gesture) as GestureGenerator;
        if(this.gesture==null){
            throw new Exception("Nodo de Gestos no encontrado");
        }

        //handdlers
        this.hands.HandCreate+=hands_HandCreate;
        this.hands.HandUpdate+=hands_HandUpdate;
        this.hands.HandDestroy+=hands_HandDestroy;

        this.gesture.AddGesture(WAVE);
        this.gesture.GestureRecognized+=gesture_GestureRecognized;
        this.gesture.StartGenerating();
    }