public MainWindow() { InitializeComponent(); try { // ContextとImageGeneratorの作成 ScriptNode node; context = Context.CreateFromXmlFile( "../../SamplesConfig.xml", out node ); context.GlobalMirror = false; image = context.FindExistingNode( NodeType.Image ) as ImageGenerator; // ユーザーの作成 user = new UserGenerator( context ); context.StartGeneratingAll(); // 画像更新のためのスレッドを作成 shouldRun = true; readerThread = new Thread( new ThreadStart( ReaderThread ) ); readerThread.Start(); } catch ( Exception ex ) { MessageBox.Show( ex.Message ); } }
public MainWindow() { InitializeComponent(); try { // OpenNIの初期化 ScriptNode node; context = Context.CreateFromXmlFile("../../SamplesConfig.xml", out node); context.GlobalMirror = false; // depthの作成 depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator; // ユーザーの作成 user = new UserGenerator(context); // ポーズが必要な場合は、最新版を入れてもらう if (user.SkeletonCapability.DoesNeedPoseForCalibration) { throw new Exception("最新のOpenNIをインストールしてください"); } // ユーザー検出、キャリブレーション完了のイベントを登録する user.NewUser += new EventHandler<NewUserEventArgs>(user_NewUser); user.SkeletonCapability.CalibrationComplete += new EventHandler<CalibrationProgressEventArgs>(SkeletonCapability_CalibrationComplete); // すべての骨格を追跡する user.SkeletonCapability.SetSkeletonProfile(SkeletonProfile.All); // 動作を開始する context.StartGeneratingAll(); // 画像更新のためのスレッドを作成 shouldRun = true; readerThread = new Thread(new ThreadStart(ReaderThread)); readerThread.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// 初期化 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(); }
public MainWindow() { InitializeComponent(); try { // ContextとImageGeneratorの作成 ScriptNode node; context = Context.CreateFromXmlFile( "../../SamplesConfig.xml", out node ); context.GlobalMirror = true; image = context.FindExistingNode( NodeType.Image ) as ImageGenerator; depth = context.FindExistingNode( NodeType.Depth ) as DepthGenerator; depth.AlternativeViewpointCapability.SetViewpoint( image ); // ユーザーの作成 user = context.FindExistingNode( NodeType.User ) as UserGenerator; // ユーザー認識のコールバックを登録 user.NewUser += new EventHandler<NewUserEventArgs>( user_NewUser ); //キャリブレーションにポーズが必要か確認 if ( user.SkeletonCapability.DoesNeedPoseForCalibration ) { // ポーズ検出のサポートチェック if ( !user.IsCapabilitySupported( "User::PoseDetection" ) ) { throw new Exception( "ポーズ検出をサポートしていません" ); } // ポーズ検出のコールバックを登録 user.PoseDetectionCapability.PoseDetected += new EventHandler<PoseDetectedEventArgs>( poseDetect_PoseDetected ); } // スケルトン検出機能をサポートしているか確認 if ( !user.IsCapabilitySupported( "User::Skeleton" ) ) { throw new Exception( "ユーザー検出をサポートしていません" ); } // キャリブレーションのコールバックを登録 user.SkeletonCapability.CalibrationEnd += new EventHandler<CalibrationEndEventArgs>( skelton_CalibrationEnd ); // すべてをトラッキングする user.SkeletonCapability.SetSkeletonProfile( SkeletonProfile.HeadAndHands ); // ジェスチャーの検出開始 context.StartGeneratingAll(); // 画像更新のためのスレッドを作成 shouldRun = true; readerThread = new Thread( new ThreadStart( ReaderThread ) ); readerThread.Start(); } catch ( Exception ex ) { MessageBox.Show( ex.Message ); } }
// 初期化 private void xnInitialize() { // コンテキストの初期化 context = new Context(CONFIG_XML_PATH); // イメージジェネレータの作成 image = context.FindExistingNode(NodeType.Image) as ImageGenerator; if (image == null) { throw new Exception(context.GlobalErrorState); } // NITEのためのセッションマネージャを作成 sessionManager = new SessionManager(context, "Wave,Click", "RaiseHand"); // セッションの開始と終了を通知するコールバックを登録する sessionManager.SessionStart += new EventHandler<PositionEventArgs>(sessionManager_SessionStart); sessionManager.SessionEnd += new EventHandler(sessionManager_SessionEnd); sessionManager.SessionFocusProgress += new EventHandler<SessionProgressEventArgs>(sessionManager_SessionFocusProgress); // Push(前後運動の検出器) pushDetector = new NITE.PushDetector(); pushDetector.Push += new EventHandler<VelocityAngleEventArgs>(pushDetector_Push); // リスナーに追加する sessionManager.AddListener(pushDetector); // ジェネレータの動作を開始する context.StartGeneratingAll(); }
// 初期化 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); // ユーザージェネレータの作成 user = context.FindExistingNode(NodeType.User) as UserGenerator; if (depth == null) { throw new Exception(context.GlobalErrorState); } // ユーザー検出機能をサポートしているか確認 if (!user.IsCapabilitySupported("User::Skeleton")) { throw new Exception("ユーザー検出をサポートしていません"); } // ユーザー認識のコールバックを登録 user.NewUser += new EventHandler<NewUserEventArgs>(user_NewUser); user.LostUser += new EventHandler<UserLostEventArgs>(user_LostUser); //キャリブレーションにポーズが必要か確認 skelton = user.SkeletonCapability; if (skelton.DoesNeedPoseForCalibration) { // ポーズ検出のサポートチェック if (!user.IsCapabilitySupported("User::PoseDetection")) { throw new Exception("ユーザー検出をサポートしていません"); } // キャリブレーションポーズの取得 pose = skelton.CalibrationPose; // ポーズ検出のコールバックを登録 PoseDetectionCapability poseDetect = user.PoseDetectionCapability; poseDetect.PoseDetected += new EventHandler<PoseDetectedEventArgs>(poseDetect_PoseDetected); poseDetect.OutOfPose += new EventHandler<OutOfPoseEventArgs>( poseDetect_OutOfPose ); } // キャリブレーションのコールバックを登録 skelton.CalibrationStart += new EventHandler<CalibrationStartEventArgs>(skelton_CalibrationStart); skelton.CalibrationComplete += new EventHandler<CalibrationProgressEventArgs>( skelton_CalibrationComplete ); // すべてをトラッキングする skelton.SetSkeletonProfile(SkeletonProfile.All); // ジェスチャーの検出開始 context.StartGeneratingAll(); }
// 初期化 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); } // NITEのためのセッションマネージャを作成 sessionManager = new SessionManager(context, "Wave,Click", "RaiseHand"); // セッションの開始と終了を通知するコールバックを登録する sessionManager.SessionStart += new EventHandler<PositionEventArgs>(sessionManager_SessionStart); sessionManager.SessionEnd += new EventHandler(sessionManager_SessionEnd); sessionManager.SessionFocusProgress += new EventHandler<SessionProgressEventArgs>(sessionManager_SessionFocusProgress); // Wave(左右運動の検出器) steadyDetector = new NITE.SteadyDetector(); steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady); // リスナーに追加する sessionManager.AddListener(steadyDetector); // ジェネレータの動作を開始する context.StartGeneratingAll(); }
// 初期化 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(); }
/// <summary> /// Creates a new control instance with a recording as data /// source. The current image data can be obtained by the /// <see cref="Image"/>-property. The /// <see cref="NewImageDataAvailable"/> event informs about when the /// data is updated, the <see cref="ErrorOccured"/>-event about /// errors. /// </summary> /// <exception cref="System.Exception">Thrown if the stream could not /// be initialized properly.</exception> public OpenNIRecordingController(String recording_filename, String movementDataFileName, String userAnnotationFilename) { // Create a new context and the data-generating nodes. context = new Context(); context.OpenFileRecording(recording_filename); this.recording_filename = recording_filename; _userInformationReader = new BinaryReader( new FileStream(movementDataFileName, FileMode.Open)); using (FileStream annotation_stream = File.OpenRead(userAnnotationFilename)) { _userLocationInformation = (ImageDictionary)movementDataSerializer.Deserialize(annotation_stream); } // Image imageGenerator = (ImageGenerator)context.FindExistingNode(NodeType.Image); // Depth depthGenerator = (DepthGenerator)context.FindExistingNode(NodeType.Depth); histogram = new int[depthGenerator.DeviceMaxDepth]; // Player player = (Player)context.FindExistingNode(NodeType.Player); player.PlaybackSpeed = 1.0; if (depthGenerator == null || imageGenerator == null || player == null) { throw new Exception("Could not initialize recording stream."); } // Error handling context.ErrorStateChanged += context_ErrorStateChanged; context.StartGeneratingAll(); }