Hello Abhishek
The reason cause this problem is that the video and depth stream are already opened by the library when it initialized the kinect NUI. I check your code and I open the streams with the same settings you want so in your case just remove this lines from your code :
try
{
nui.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
nui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);
}
catch (InvalidOperationException)
{
System.Windows.MessageBox.Show("Failed to open stream. Please make sure to specify a supported image type and resolution.");
return;
}
Furthermore, I update the library (you have to download the new version of the dll under the download section) so you can initialize externally the kinect nui and give a reference of its instance to the library (in some cases people may need different settings rather than the one I use to initialize the nui )here is a sample of use : instead of BTC.Start()
nui = new Runtime();
try
{
nui.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);
}
catch (InvalidOperationException)
{
System.Windows.MessageBox.Show("Runtime initialization failed. Please make sure Kinect device is plugged in.");
return;
}
try
{
nui.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
nui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);
}
catch (InvalidOperationException)
{
System.Windows.MessageBox.Show("Failed to open stream. Please make sure to specify a supported image type and resolution.");
return;
}
BTC.Start(nui);
}
PS. If you don’t care about the settings of the NUI then you can just use BTC.Start()
Please let me know if it will fix the problem
Nick