public GestureController(IParkEngine parkEngine, ILogProvider logProvider, Context context)
        {
            this.ParkEngine = parkEngine;
            this.LogProvider = logProvider;

            _EventHandlers = new Dictionary<string, List<string>>();
            _ListenerLock = new object();

            _GestureGenerator = new GestureGenerator(context);
            _GestureGenerator.GestureRecognized += new EventHandler<GestureRecognizedEventArgs>(_GestureGenerator_GestureRecognized);
            _GestureGenerator.GestureProgress += new EventHandler<GestureProgressEventArgs>(_GestureGenerator_GestureProgress);
            _GestureGenerator.GestureChanged += new EventHandler(_GestureGenerator_GestureChanged);
            _GestureGenerator.StartGenerating();
        }
示例#2
0
        public HandSensor(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");

            string[] s = gestureGenerator.EnumerateAllGestures();

            Trace.WriteLine("HandSensor initialized");
        }
        // 初期化
        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);
              }

              // デプスジェネレータの作成
              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);
              }

              // ジェスチャーの作成と登録
              gestures = gesture.EnumerateAllGestures();
              gesture.AddGesture(gestures[gestureIndex]);
              string[] activeGestures = gesture.GetAllActiveGestures();

              // ジェスチャーの機能確認
              foreach (string name in gestures) {
            Trace.WriteLine(name + ":" +
              "Available:" + gesture.IsGestureAvailable(name) +
              " ProgressSupported:" + gesture.IsGestureProgressSupported(name));
              }

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

              // ジェスチャーの検出開始
              context.StartGeneratingAll();
        }
示例#4
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
        }
示例#5
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();
    }
示例#6
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();
    }
示例#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();
        }
示例#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
		}
示例#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();
        }
示例#10
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
        }
示例#11
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();
        }
示例#13
0
文件: Context.cs 项目: moeseth/OpenNI
        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
        }
示例#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();
    }