Beta1→Beta2への移行作業中。 Runtime()初期化の仕様変更 クラスに対して新しいインスタンスを作成する(インスタンスインデックスで指定)。 (使用例)Beta1では使えていた初期化 this.kinect= new Runtime(); このような指定をすると 'Microsoft.Research.Kinect.Nui.Runtime.Runtime()' は古い形式です: 'This constructor to be removed. Use Runtime.Kinects[0] instead.' という警告が出ます。 APIマニュアルを見ると「This constructor is obsolete starting with the Beta 2 release.」ということでBeta2では推奨されないようです。 「Overloaded」ということですが、Runtime Constructorにオーバーロードされたということでしょうか。 「Runtime Constructor ()」の項目を見ると、Remarksに Creates a new instance of this class with an Runtime.InstanceIndex of 0. ということです。手っ取り早く、Runtime()の正しい書式が知りたいわけですが。 <手っ取り早い方法> // Runtime kinect; //Kinectセンサクラス (Beta1) public Microsoft.Research.Kinect.Nui.Runtime kinect; //Beta2対応 --- //Kinectセンサクラスの初期化 // this.kinect = new Runtime(); //For SDK Beta1 this.kinect = Microsoft.Research.Kinect.Nui.Runtime.Kinects[0]; <回りくどいけどフル機能> SDK Beta2サンプルソースのKinectColorViewer.zaml.cs冒頭に面白い記述が。 using KinectNui = Microsoft.Research.Kinect.Nui; //Microsoft.Runtime is conflicting with using Runtime without an expicit namespace. This happens because the namespace starts with "Microsoft." public void ReInitRuntime() { // Will call Uninitialize followed by Initialize. this.Kinect = this.Kinect; } public KinectNui.Runtime Kinect { get { return _Kinect; } set { //Clean up existing runtime if we are being set to null, or a new Runtime. if (_Kinect != null) { kinectColorViewer.Kinect = null; kinectDepthViewer.Kinect = null; _Kinect.SkeletonFrameReady -= new EventHandler<SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady); _Kinect.Uninitialize(); } _Kinect = value; if (_Kinect != null) { InitRuntime(); kinectColorViewer.Kinect = _Kinect; kinectDepthViewer.RuntimeOptions = RuntimeOptions; kinectDepthViewer.Kinect = _Kinect; _Kinect.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady); UpdateUi(); } } } --- private void InitRuntime() { //Some Runtimes' status will be NotPowered, or some other error state. Only want to Initialize the runtime, if it is connected. if (_Kinect.Status == KinectStatus.Connected) { bool skeletalViewerAvailable = IsSkeletalViewerAvailable; // NOTE: Skeletal tracking only works on one Kinect per process right now. RuntimeOptions = skeletalViewerAvailable ? RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor : RuntimeOptions.UseDepth | RuntimeOptions.UseColor; _Kinect.Initialize(RuntimeOptions); skeletonPanel.Visibility = skeletalViewerAvailable ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; if (RuntimeOptions.HasFlag(RuntimeOptions.UseSkeletalTracking)) { _Kinect.SkeletonEngine.TransformSmooth = true; } } } ちなみに同じ事にハマっているひとは世界には何人かいたようで、 ”Migrating from Kinect for Windows SDK Beta 1 to Beta 2”に上記に関係したコードが掲載されています。Thanks. |