Closed bharatrocks100 closed 10 years ago
As far as I know you must have both depth and color video streams in your code. (Unlike other devices) Then you must make sure that they are using same resolution (I believe this is your problem, you changed one but not other). Then you can request for Image registration.
Shortest code you can write to test this functionality is as follow:
Device device = Device.Open(Device.ANY_DEVICE);
VideoStream depthStream = device.CreateVideoStream(device.SensorType.DEPTH);
VideoStream colorStream = device.CreateVideoStream(device.SensorType.COLOR);
device.ImageRegistration = device.ImageRegistrationMode.DEPTH_TO_COLOR;
depthStream.Start();
colorStream.Start();
But, anyway problem still persists.
It said: Device setProperty(5) failed
Please note that I'm using kinect xbox sensor, not prime sense! as said before, NiViewer sample application runs both streams at a time.
Hi, I had the same problem (i'm using kinect xbox sensor). For some reason i had to start the streams and then set the DepthToColor registration mode, to avoid such error. I dont know if this is the correct way though.
Edit: However following the example of Openi Cookbook for Color to depth overlay seems to work fine.
@npapadop , As you said, I turned on both streams before DepthToColor registration. But, it does NOT help me. Also, please elaborate which example of openni cookbook are you talking about ??
Detailed error info attached here: As you can see, its a "System.NonImplementedException" occurred with kinect xbox sensor on this line:
this.device.ImageRegistration = Device.ImageRegistrationMode.DEPTH_TO_COLOR;
Can you run "CustomBitmapCopyVB" sample?
I tested with Kinect for Xbox and it was fine. Using Kinect SDK 1.7.
I'm referring to example of Openni Cookbook (falahati's book) in page 193, Chapter: Overlaying the depth frame over the image frame. I attached you the sequence of my code. Working also with SDK 1.7 as falahati mentioned above.
Sorry guys, I was away from code for last couple of days. Today, I returned to same project and tried above code that @npapadop had suggested previously. However, despite different efforts, same could not work for me !! As you can see here in screenshot, that error is still same as previous...
@falahati Please, reopen this issue thread. I could not checked "CustomBitmapCopyVB" on my VS 2010 . But, Can you please refer some c# project if you have in place to check working on kinect xbox !
Following code worked perfect for me:
namespace ConsoleImageRegistration
{
using System;
using System.Drawing;
using OpenNIWrapper;
class Program
{
private static Device device;
private static VideoStream depthStream, colorStream;
static void Main(string[] args)
{
try
{
OpenNI.Initialize();
device = Device.Open(Device.ANY_DEVICE);
depthStream = device.CreateVideoStream(Device.SensorType.DEPTH);
depthStream.VideoMode = new VideoMode
{
DataPixelFormat = VideoMode.PixelFormat.DEPTH_1MM,
FPS = 30,
Resolution = new Size(640, 480)
};
colorStream = device.CreateVideoStream(Device.SensorType.COLOR);
colorStream.VideoMode = new VideoMode
{
DataPixelFormat = VideoMode.PixelFormat.RGB888,
FPS = 30,
Resolution = new Size(640, 480)
};
device.DepthColorSyncEnabled = true;
depthStream.Start();
colorStream.Start();
device.ImageRegistration = Device.ImageRegistrationMode.DEPTH_TO_COLOR;
Console.WriteLine("Image registration is active and working well.");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine("Press enter to exit.");
Console.ReadLine();
if (device != null)
device.Close();
OpenNI.Shutdown();
}
}
}
Based on same code I created a sample named "ConsoleImageRegistration" that you can find in "Samples" directory.
If you still failed to run the above code, there is probably a problem with Kinect SDK, device or OpenNI itself.
Hi Falahati, Firstly, thank you for reopening this thread again..! Perhaps, I have to check kinect xbox and your console sample code on another machine, as your sample code ConsoleImageRegistration on my machine, still returns same error as below: (Yeah...I am using Kinect xbox 360)
You use latest version of NiWrapper and Kinect SDK right? Because there wasn't support for Kinect Color over Depth registration prior to the OpenNI 2.1.x (NiWrapper 2.1.x)
I am using Kinect SDK v1.7 and OpenNI 2.2 sdk + NiTE 2.2.0.5... Further, Can you please provide me URL to latest (kinect xbox compatible) release of NiWrapper.NET, NiWrapper files that worked for your kinect xbox ??
Here is NiWrapper: NiWrapper x64: http://falahati.net/gitBackups/NiWrapper.Net/Packages/NiWrapper.Net%20x64.zip NiWrapper x86: http://falahati.net/gitBackups/NiWrapper.Net/Packages/NiWrapper.Net%20x86.zip NiWrapper.NiTE x64: http://falahati.net/gitBackups/NiWrapper.Net/Packages/NiWrapper.NiTE.Net%20x64.zip NiWrapper.NiTE x86: http://falahati.net/gitBackups/NiWrapper.Net/Packages/NiWrapper.NiTE.Net%20x86.zip
And here is Kinect SDK v1.8: http://download.microsoft.com/download/E/1/D/E1DEC243-0389-4A23-87BF-F47DE869FC1A/KinectSDK-v1.8-Setup.exe
And you don't need to download OpenNI separately if you use NiWrapper.
On a positive note, I guess, that problem has been resolved with files you have provided to me in the URL previously and Kinect SDK v1.8 :-) Now, image registration works perfectly on kienct xbox.
Thanks a ton, for your immense help !
Hi, I am wondering, why am I not able to change image registration mode for Kinect xbox as follows:
"if(device.isImageRegistrationModeSupported(Device.ImageRegistrationMode.DEPTH_TO_COLOR)) device.ImageRegistration = Device.ImageRegistrationMode.DEPTH_TO_COLOR;"
Above code with xbox Kinect just skips registration part, as if it does not support DEPTH_TO_COLOR mapping. However, it runs well both depth and Image stream simultaneously on NiViewer Sample application. How ???
Any help appreciated ! Thank you :)