當前位置: 首頁>>代碼示例>>C#>>正文


C# OpenNI.Context類代碼示例

本文整理匯總了C#中OpenNI.Context的典型用法代碼示例。如果您正苦於以下問題:C# Context類的具體用法?C# Context怎麽用?C# Context使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Context類屬於OpenNI命名空間,在下文中一共展示了Context類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            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!");
            }

            this.userGenerator = new UserGenerator(this.context);
            this.skeletonCapbility = this.userGenerator.SkeletonCapability;
            this.poseDetectionCapability = this.userGenerator.PoseDetectionCapability;
            this.calibPose = this.skeletonCapbility.CalibrationPose;

            this.userGenerator.NewUser += userGenerator_NewUser;
            this.userGenerator.LostUser += userGenerator_LostUser;
            this.poseDetectionCapability.PoseDetected += poseDetectionCapability_PoseDetected;
            this.skeletonCapbility.CalibrationComplete += skeletonCapbility_CalibrationComplete;

            this.skeletonCapbility.SetSkeletonProfile(SkeletonProfile.All);
            this.joints = new Dictionary<int,Dictionary<SkeletonJoint,SkeletonJointPosition>>();
            this.userGenerator.StartGenerating();

            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(ReaderThread);
            this.readerThread.Start();
        }
開發者ID:wair,項目名稱:Patched_Kinect_Drivers_for_Ubuntu,代碼行數:34,代碼來源:MainWindow.cs

示例2: WebNect

        public WebNect()
        {
            this.context = new OpenNI.Context(SAMPLE_XML_FILE);
            this.sessionManager = new NITE.SessionManager(this.context, "Click", "RaiseHand");
            this.context.StartGeneratingAll();

            this.sessionManager.SessionStart += new
                    EventHandler<NITE.PositionEventArgs>(sessionManager_SessionStart);
            this.sessionManager.SessionFocusProgress += new
                    EventHandler<NITE.SessionProgressEventArgs>(sessionManager_SessionProgress);
            this.sessionManager.SessionEnd += sessionManager_SessionEnd;

            this.waveDetector = new NITE.WaveDetector();
            this.waveDetector.Wave += waveDetector_Wave;
            this.waveDetector.PointUpdate += new EventHandler<HandEventArgs>(waveDetector_PointUpdate);
            this.sessionManager.AddListener(this.waveDetector);

            this.zmq_context = new ZMQ.Context(1);
            this.zmq_publisher = this.zmq_context.Socket(SocketType.PUB);
            this.zmq_publisher.Bind(this.SOCKET_SOURCE);
            Console.WriteLine("ZMQ Socket at {0}", this.SOCKET_SOURCE);

            this.shouldRun = true;
            this.readerThread = new Thread(ReaderThread);
            this.readerThread.Start();
        }
開發者ID:victorpoluceno,項目名稱:python_kinect_socketio,代碼行數:26,代碼來源:WebNect.cs

示例3: Player

 internal Player(Context context, IntPtr nodeHandle, bool addRef)
     : base(context, nodeHandle, addRef)
 {
     this.endOfFileReachedEvent = new StateChangedEvent(this,
         SafeNativeMethods.xnRegisterToEndOfFileReached,
         SafeNativeMethods.xnUnregisterFromEndOfFileReached);
 }
開發者ID:nemesit,項目名稱:OpenNI,代碼行數:7,代碼來源:Player.cs

示例4: xnInitialize

        // 初期化
        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);

              // ユーザージェネレータの作成
              user = context.FindExistingNode(NodeType.User) as UserGenerator;
              if (depth == null) {
            throw new Exception(context.GlobalErrorState);
              }

              // ユーザー検出機能をサポートしているか確認
              if (!user.IsCapabilitySupported("User::Skeleton")) {
            throw new Exception("ユーザー検出をサポートしていません");
              }
        }
開發者ID:ninuxsoft,項目名稱:KinectSensorProgramming,代碼行數:33,代碼來源:Form1_DrawUser.cs

示例5: Run

        static void Run()
        {
            string SAMPLE_XML_FILE = @"../../../../Data/SamplesConfig.xml";

            Context context = new Context(SAMPLE_XML_FILE);

            DepthGenerator depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator;
            if (depth == null)
            {
                Console.WriteLine("Sample must have a depth generator!");
                return;
            }

            MapOutputMode mapMode = depth.MapOutputMode;

            DepthMetaData depthMD = new DepthMetaData();

            Console.WriteLine("Press any key to stop...");

            while (!Console.KeyAvailable)
            {
                context.WaitOneUpdateAll(depth);

                depth.GetMetaData(depthMD);

                Console.WriteLine("Frame {0} Middle point is: {1}.", depthMD.FrameID, depthMD[(int)mapMode.XRes/2, (int)mapMode.YRes/2]);
            }
        }
開發者ID:nemesit,項目名稱:OpenNI,代碼行數:28,代碼來源:Program.cs

示例6: DepthGenerator

 internal DepthGenerator(Context context, IntPtr nodeHandle, bool addRef)
     : base(context, nodeHandle, addRef)
 {
     this.fovChanged = new StateChangedEvent(this,
         SafeNativeMethods.xnRegisterToDepthFieldOfViewChange,
         SafeNativeMethods.xnUnregisterFromDepthFieldOfViewChange);
 }
開發者ID:nemesit,項目名稱:OpenNI,代碼行數:7,代碼來源:DepthGenerator.cs

示例7: Create

 private static IntPtr Create(Context context, CodecID codecID, ProductionNode initializer)
 {
     IntPtr nodeHandle;
     int status = SafeNativeMethods.xnCreateCodec(context.InternalObject, codecID.InternalValue, initializer.InternalObject, out nodeHandle);
     WrapperUtils.ThrowOnError(status);
     return nodeHandle;
 }
開發者ID:nemesit,項目名稱:OpenNI,代碼行數:7,代碼來源:Codec.cs

示例8: ImageGenerator

 internal ImageGenerator(Context context, IntPtr nodeHandle, bool addRef)
     : base(context, nodeHandle, addRef)
 {
     this.pixelFormatChanged = new StateChangedEvent(this,
         SafeNativeMethods.xnRegisterToPixelFormatChange,
         SafeNativeMethods.xnUnregisterFromPixelFormatChange);
 }
開發者ID:penyatree,項目名稱:openni,代碼行數:7,代碼來源:ImageGenerator.cs

示例9: Create

		private static IntPtr Create(Context context, string format)
		{
			IntPtr nodeHandle;
			int status = SafeNativeMethods.xnCreateScriptNode(context.InternalObject, format, out nodeHandle);
			WrapperUtils.ThrowOnError(status);
			return nodeHandle;
		}
開發者ID:FreeMiles,項目名稱:OpenNI,代碼行數:7,代碼來源:ScriptNode.cs

示例10: Create

 private static IntPtr Create(Context context, string name)
 {
     IntPtr handle;
     int status = SafeNativeMethods.xnCreateMockNode(context.InternalObject, NodeType.Image, name, out handle);
     WrapperUtils.ThrowOnError(status);
     return handle;
 }
開發者ID:nemesit,項目名稱:OpenNI,代碼行數:7,代碼來源:MockImageGenerator.cs

示例11: MainWindow

        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 );
            }
        }
開發者ID:kaorun55,項目名稱:openni_sandbox,代碼行數:25,代碼來源:MainWindow.xaml.cs

示例12: xnInitialize

        // 初期化
        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);

              // レコーダーの作成と記録対象の追加
              recoder = new OpenNI.Recorder(context);
              recoder.SetDestination(RecordMedium.File, RECORD_PATH);
              recoder.AddNodeToRecording(image);
              recoder.AddNodeToRecording(depth);
              recoder.Record();
        }
開發者ID:ninuxsoft,項目名稱:KinectSensorProgramming,代碼行數:29,代碼來源:Form1_Recorder.cs

示例13: InitOpenNI

        private void InitOpenNI()
        {
            // ContextとImageGeneratorの作成
            ScriptNode node;
            context = Context.CreateFromXmlFile( "SamplesConfig.xml", out node );
            context.GlobalMirror = false;
            image = context.FindExistingNode( NodeType.Image ) as ImageGenerator;

            // 畫像更新のためのスレッドを作成
            shouldRun = true;
            readerThread = new Thread( new ThreadStart( () =>
            {
                while ( shouldRun ) {
                    context.WaitAndUpdateAll();
                    ImageMetaData imageMD = image.GetMetaData();

                    // ImageMetaDataをBitmapSourceに変換する(unsafeにしなくてもOK!!)
                    this.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action( () =>
                    {
                        imageOpenNI.Source = BitmapSource.Create( imageMD.XRes, imageMD.YRes,
                            96, 96, PixelFormats.Rgb24, null, imageMD.ImageMapPtr,
                            imageMD.DataSize, imageMD.XRes * imageMD.BytesPerPixel );
                    } ) );
                }
            } ) );
            readerThread.Start();
        }
開發者ID:kaorun55,項目名稱:kinect_sdk_sandbox,代碼行數:27,代碼來源:MainWindow.xaml.cs

示例14: AudioGenerator

 internal AudioGenerator(Context context, IntPtr nodeHandle, bool addRef)
     : base(context, nodeHandle, addRef)
 {
     this.outputModeChanged = new StateChangedEvent(this,
         SafeNativeMethods.xnRegisterToWaveOutputModeChanges,
         SafeNativeMethods.xnUnregisterFromWaveOutputModeChanges);
 }
開發者ID:penyatree,項目名稱:openni,代碼行數:7,代碼來源:AudioGenerator.cs

示例15: UserGenerator

 public UserGenerator(Context context, IntPtr nodeHandle, bool addRef)
     : base(context, nodeHandle, addRef)
 {
     this.internalNewUser = new SafeNativeMethods.XnUserHandler(this.InternalNewUser);
     this.internalLostUser = new SafeNativeMethods.XnUserHandler(this.InternalLostUser);
     this.internalUserExit = new SafeNativeMethods.XnUserHandler(this.InternalUserExit);
     this.internalUserReEnter = new SafeNativeMethods.XnUserHandler(this.InternalUserReEnter);
 }
開發者ID:huangxm,項目名稱:OpenNI,代碼行數:8,代碼來源:UserGenerator.cs


注:本文中的OpenNI.Context類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。