Ar domino with asus xtion pro live

Mar 14, 2012 at 10:55 AM

Hi, I'm trying to build the ardomino project included in goblin XNA. The solution build successfully but the application does not run. Why? Maybe because i'm using the asus xtion pro live kinect instead of the microsoft kinect?? In this case, how could i run the project using asus xtion pro live as camera device?

 

cheers,

salvo

Coordinator
Mar 14, 2012 at 6:35 PM

Which library are you using? DirectShowCapture or KinectMSCapture? DirectShowCapture is for regular webcam (non-RGBZ cameras) and KinectMSCapture is for MS Kinect. You probably need to create your own IVideoCapture implementation for your asus xtion pro live. I would assume that they provide specific library for you to get their color and depth streams. You can see how I implement KinectMSCapture as an example to make your own class.

Ohan

Mar 14, 2012 at 8:25 PM
Edited Mar 14, 2012 at 8:32 PM

I used kinectMSCaptute because when i build the goblinXNA sln,visual
studio gave me an error. In fact it said that Microsoft kinect
reference was missing. So i need to create a new ".cs" file in which i
implement the class for asus xtion pro live, is it correct?


Thanks in
advance,

Salvo

Coordinator
Mar 14, 2012 at 9:37 PM

Yes, that's correct. 

Ohan

Mar 14, 2012 at 10:58 PM
Edited Mar 14, 2012 at 10:58 PM

thanks for replying! Now i've got a more serius problem: I compiled correcty CameraCalibration and i tried to run the application. But it ended immediatly with the following message of error:

 

"Alvar Library 1.5.0Copyright 2008-2010 VTT Technical Research Centre of FinlandCompiled on Windows 5.1 x86 on Jan  4 2011Licensed to Public (00000000000000000000)Day 435/365 of usage period for this licenceEXPIREDThe program '[7064] CameraCalibration.exe: Managed (v4.0.30319)' has exited with code 1 (0x1)."

I downloaded that library yesterday following the instruction written in the installation guide. How could i resolve it??

 

thanks in advance

 

salvo

Coordinator
Mar 14, 2012 at 11:49 PM

Did you download their latest 1.5? The latest one has the timebomb removed.

Ohan

Mar 15, 2012 at 9:08 AM

I solved this problem, thanks.

However, i noticed that when i run ArDomino, it starts the webcam of my notebook instead of the kinect. why? Do i have to delete any references in particular?

 

salvo

Coordinator
Mar 15, 2012 at 4:23 PM

That's because the original code uses DirectShowCapture which is only for regular webcams, so it will only recognize your webcam. Kinect is not a regular webcam. If you want to use Kinect, you should change the code to use KinectMSCapture instead.

Ohan

Mar 15, 2012 at 6:00 PM

that's ok ohan. thank you! ;) Obviously i need to change only the code of the ARDomino project. Is that right?. 

Coordinator
Mar 15, 2012 at 6:59 PM

yes

Mar 16, 2012 at 9:33 AM
Edited Mar 16, 2012 at 10:08 AM

Ok, i'm trying to change the code. Let's see if i'm doing it correcly :D

I change the following code in DominoGame.cs  from:

 

private void SetupMarkerTracking()
        {
            DirectShowCapture captureDevice = new DirectShowCapture();
            captureDevice.InitVideoCapture(0, FrameRate._30Hz, Resolution._640x480,
                ImageFormat.R8G8B8_24, false);

            scene.AddVideoCaptureDevice(captureDevice);


...

}

 

to:

 

private void SetupMarkerTracking()
        {
            KinectMSCapture captureDevice = new KinectMSCapture(true);
            captureDevice.InitVideoCapture(0, FrameRate._30Hz, Resolution._640x480,
                ImageFormat.R8G8B8_24, false);

            scene.AddVideoCaptureDevice(captureDevice);

            ...
        }

 

so far so good?

the Build ends successfully, but the debug gives me a error back: Null Reference Exception Was Unhandled and it tells me that the error is situated in this part of the code of KinectMSCapture.cs file:

sensor = (from sensorToCheck in KinectSensor.KinectSensors
                      where sensorToCheck.Status == KinectStatus.Connected
                      select sensorToCheck).ElementAtOrDefault(videoDeviceID);

            sensor.ColorStream.Enable(colorFormat);

            sensor.Start();


am i missing something?
Mar 17, 2012 at 9:47 AM

ok i got it. I resolved the problem by connecting the kinect. Now i would like to use the Asus Xtion Pro live, and I'm finding a lot of difficulties to implement it XD

Mar 17, 2012 at 11:40 AM

However,  my asus xtion pro live uses both OpenNI and primesense, as the microsoft kinect. I had to add only Primesense Sensor to use it. So i can't find any solution to run ARdomino with asus xtion pro live :( any other suggestion??

 

thanks

 

salvo

Coordinator
Mar 17, 2012 at 8:27 PM

It's not just swapping the driver, but you also need to implement the IVideoCapture class using OpenNI.

Ohan

Mar 18, 2012 at 12:09 AM

Ok, as a matter of fact I've added OpenNI references. In IvideoCapture.cs, do I have to write "using OpenNI" and change the declaretion of namespace or I leave it as it is (i.e. goblinXNA.device.Capture)? 

Coordinator
Mar 18, 2012 at 4:14 AM

You have to write the actual code similar to other IVideoCapture implementations (DirectShowCapture, OpenCVCapture, KinectMSCapture, etc) using OpenNI library for your case.

Ohan

Mar 20, 2012 at 1:06 PM
Thanks for replying. Ok, i managed to work asus xtion pro live. I mean,
the device is recognized by the program, and i can see because the
light of the Infrared is turned on. But the window is completely dark.


In kinectMSCapture, what is the part of the code in which you enable
the kinect camera in order to find the equivalent function in OpenNI
library?

thanks

salvo


E' nata indoona: chiama, videochiama e messaggia Gratis. Scarica indoona per iPhone, Android e PC: http://www.indoona.com/
Coordinator
Mar 20, 2012 at 9:47 PM

There isn't much equivalence between MS SDK and OpenNI, so you need to look into the OpenNI sample codes to figure out what you need to do.

Ohan

Mar 22, 2012 at 6:27 PM

I've created a class for my asus following, more or less, what you've done, for example, in kinetmscapture.cs file. But, i've a lot of difficult to implement the function "GetImageTexture" defined in IVideoCapture.cs. And I think this function is important because it captures the stream video from RGB camera and it passes to ARDominos. Is that right? 

So, ones I've Updated Image and Depth values in this way:

 

  private unsafe void CameraThread()
        {
            while (_isRunning) 
            {
                Context.WaitAndUpdateAll();

                ImageGenerator.GetMetaData(_imgMD);
                DepthGenerator.GetMetaData(_depthMD);
            }
        }

what do i have to do?

Maybe, if you want, i could send you the entire .cs file so you can have a look and tell me where i'm missing.

 

Mar 23, 2012 at 8:54 PM

hi, i've found some useful tips following the openni forum. I tryed to implement the function GetImageTexture in this way: 

 

public unsafe void GetImageTexture(int[] returnImage, ref IntPtr imagePtr)
        {

            Texture2D imageTexture = null;
            byte[] bmpBytes = null;

           // this.ImageGenerator.GetMetaData(_imgMD);
            lock (this)
            {
                int byteCount = _imgMD.XRes * _imgMD.YRes * 4;    // 4-byte color representation - RGBA 

                if (bmpBytes == null || bmpBytes.Length != byteCount)
                    bmpBytes = new byte[byteCount];

                fixed (byte* texturePointer = &bmpBytes[0])
                {
                    RGB24Pixel* pImage = (RGB24Pixel*)this.ImageGenerator.GetImageMapPtr().ToPointer();
                    int pointerWalker = 0;

                    for (int y = 0; y < _imgMD.YRes; ++y)
                    {
                        for (int x = 0; x < _imgMD.XRes; ++x, ++pImage, pointerWalker += 4)
                        {
                            texturePointer[pointerWalker] = pImage->nRed;
                            texturePointer[pointerWalker + 1] = pImage->nGreen;
                            texturePointer[pointerWalker + 2] = pImage->nBlue;
                            texturePointer[pointerWalker + 3] = 255;    //Set alpha to 1 
                        }
                    }
                }
            }

            if (imageTexture == null)
                imageTexture = new Texture2D(State.Device, _imgMD.XRes, _imgMD.YRes);

            imageTexture.SetData(bmpBytes);
            
            //return imageTexture; 
        }

 

 

could it be a sort of first solution? sorry but i'm a beginner in XNA and C# so i'm doing my best :D

Coordinator
Mar 27, 2012 at 8:32 PM

I won't have time to look into your implementation unfortunately.

Ohan

Mar 28, 2012 at 10:47 AM

ok ohan, never mind, you were helpful anyway. For now i'm going to use microsoft kinect and in the mid time i will try to solve the problem with the class by my self and if I get it, i will certainly send you the new class. :D

However, i would ask you another thing; is it possible to have the source code of the other goblinxna projects? i'm referring in particular to game race(the last screeshot of the http://goblinxna.codeplex.com home page and the labyrint game (the second screenshot)? 

 

regards

 

salvo

Coordinator
Mar 28, 2012 at 4:22 PM

Sorry, but we don't distribute our projects for reason 1. it contains bunch of stuff and it's not really cleaned up for release and 2. that there might be some copyright/license issues or conflicts. For anything that we can distribute will be in the distribution package, and anything that is not there is something that we can't or not planning to distribute to the public. 

Ohan

Mar 28, 2012 at 10:25 PM

Don't worry ohan :D 

however, i solved my problem with my asus xtion pro live. The rgb video works! :D:D:D This class is compatible also with microsoft kinect and other nui sensors that use openni library! The problem now is the color displayed: blu object become red, and vice versa: red goes blu, sky-blue goes yellow and so on...

which may be the cause?

Coordinator
Mar 28, 2012 at 11:11 PM

Just swap your red and blue channel assignment like: (using your code above)

texturePointer[pointerWalker] = pImage->nBlue;
texturePointer[pointerWalker + 1] = pImage->nGreen;
texturePointer[pointerWalker + 2] = pImage->nRed;
Mar 29, 2012 at 7:48 AM
Thank you ohan, you were right! Now it works well!! Are you interested in Source code so you Can update goblinXNA with the new IVideoCapture class?