forums.naturalpoint.com

Discussion and Support for the OptiTrack, SmartNav and TrackIR brands by NaturalPoint

.net wrappers for c++ SDK

by kelmer » Wed Mar 23, 2011 5:52 am

Okay, problem solved, I was missing the cameralibrary.dll :P

Now looking at the wrapper, I can't find a way to actually get the pixels from a frame, something like the Rasterize function in the demos, is this possible? Looking at the source code for the wrapper, Rasterize functions seem to be commented, is there a reason for this?
kelmer
 
Posts: 9
Joined: Fri Feb 05, 2010 2:26 am

by kelmer » Wed Mar 23, 2011 9:48 am

Okay, I've tried to wrap the Bitmap class myself and try to extend the wrapper into supporting the Rasterize function. The problem is, I'm new to this wrapping stuff so I'm having some trouble in the process.

This is the MBitmap class I've added to the exsitent wrapper by Brad:

Code: Select all
public ref class MBitmap{
   public:

      /* Wrapping constructors */
      MBitmap( int pixelWidth, int pixelHeight, int byteSpan, mColorDepth mcd, const unsigned char *bits){
         CameraLibrary::Bitmap::ColorDepth cd = static_cast<CameraLibrary::Bitmap::ColorDepth>(mcd);
         bitmap = new Bitmap(pixelWidth, pixelHeight, byteSpan, cd, bits );
      }


      MBitmap( int pixelWidth, int pixelHeight, int byteSpan, mColorDepth mcd){
         MBitmap(pixelWidth, pixelHeight, byteSpan, mcd, 0);
      }
      

        ~MBitmap(){
         delete this->bitmap;
         bitmap = 0;
      }
      
      //Wrapping functions
      int      PixelWidth()         {return bitmap->PixelWidth();}
      int      PixelHeight()         {return bitmap->PixelHeight();}
      int      ByteSpan()            {return bitmap->ByteSpan();}   
      int      GetPixel(int X, int Y)   {return bitmap->GetPixel(X,Y);}

      // GUI uses this to draw.
      const unsigned char *GetBits() {return bitmap->GetBits();}
             
                int      BufferSize()         {return bitmap->BufferSize();}
   public:
   //private:
      Bitmap * bitmap;
   };


And this is the rasterize function on the MFrame managed class:
Code: Select all
      ///== Rasterization Functionality ==========--
      void Rasterize(MBitmap bitmapRef){frame->Rasterize(bitmapRef.bitmap);}




The problem is, when calling this Rasterize function from my application, I get a criptic error saying "Rasterize is not supported by the language".

Any ideas on what I'm doing wrong?
kelmer
 
Posts: 9
Joined: Fri Feb 05, 2010 2:26 am

by Robbie86 » Mon Sep 26, 2011 4:28 am

Code: Select all
///== Rasterization Functionality ==========--
void Rasterize(MBitmap^ bitmapRef){frame->Rasterize(bitmapRef->bitmap);}


This is how you get it working ;)
Robbie86
 
Posts: 5
Joined: Mon Sep 26, 2011 4:21 am

by Robbie86 » Tue Sep 27, 2011 2:18 am

Someone else have tried to wrap the ModuleVectorProcessor?

I seem to have a problem getting the Position after processing the vector.

Code is something as follows

Wrappercode getposition for ModuleVectorProcessor (bit ugly value call by reference is a bit strange in managed c++ :\ maybe thats the problem?):
Code: Select all
void GetPosition(double % x, double % y, double % z)
{
    double dX;
    double dX;
    double dX;

    // passing x directly is giving cast (double) to (double&) compiler error
    moduleVectorProcessor->GetPosition(dX, dY, dZ);

    x = dX;
    y = dY;
    z = dZ;
}


When processing the vectors like the sample application and calling in my C# app:
Code: Select all
// starting getframe
...
// processing vector
...
vectorProcessor.GetPosition(ref x, ref y, ref z);

// the x,z,y = NaN or very low probaly Double.MinValue :(
...


the processor is return Double.MinValue or Double.NaN. I tried to look if i was missing something out but everything looks correct compared to the C++ implementation. Is it my "call by reference" function which is implemented incorrect? Or does it mean that my vector module wrapper implementation is not correctly pushing vectors to the processor?
Robbie86
 
Posts: 5
Joined: Mon Sep 26, 2011 4:21 am

by Robbie86 » Tue Sep 27, 2011 2:43 am

A bit to fast with posting ;) I tested the call by reference function and it seems the way to implement a C++ CLI call by reference to a native function to make a temporary variable ;) so that must not be the problem.

I will try to look again to my ModuleVector implementation for calculation and pushing it to the vector processor maybe its not working there :(
Robbie86
 
Posts: 5
Joined: Mon Sep 26, 2011 4:21 am

by johnbsys » Mon Oct 10, 2011 11:40 pm

This looks exactly what I seem to need. I am trying to get the 2d blob frames from my TrackIR 5 camera using C# and have been unsuccessful. Doug, you say that is unnecessary now. How do I now access it?

Thanks.
johnbsys
 
Posts: 15
Joined: Mon Oct 10, 2011 4:20 pm
Location: Iowa

by Robbie86 » Tue Oct 11, 2011 2:02 am

My problem has been resolved btw just forgot to setup some settings for the camera ;)
Robbie86
 
Posts: 5
Joined: Mon Sep 26, 2011 4:21 am

by johnbsys » Tue Oct 11, 2011 5:09 am

I am a newbee and trying to access the trackir 5 with C#. Can you tell me what dll you are accessing to communicate with the camera?

Thanks
johnbsys
 
Posts: 15
Joined: Mon Oct 10, 2011 4:20 pm
Location: Iowa

by Birch » Thu Oct 13, 2011 9:47 am

They are using cameralibrary.dll which is included with the Camera SDK when it is installed.
Birch
NaturalPoint Employee
NaturalPoint Employee
 
Posts: 1139
Joined: Thu Jan 30, 2003 5:00 am
Location: Corvallis, Oregon

by jjreilly » Thu Oct 20, 2011 2:37 pm

Hi all,

I'm using this wrapper with VS 2010 Express, SP1. Works fine under both 64-bit Win 7 and 32-bit XP, on machines that have VS installed; both release and debug builds.

On machines without VS, the call to CameraManager::Ptr() (or X()) fails. I know this by dropping OutputDebugString() statements in the wrapper and running DebugView from SysInternals. I've run Dependency Walker and only get the missing MSJAVA DLL, which is delay-loaded and doesn't apply.

I installed .NET 4, which I'm using, and the SDK 1.1 final. I do not want to have to install VS 2010 Express just to run, but I'm kind of out of ideas. Anything clever out there?

Thanks.

-reilly.
jjreilly
 
Posts: 3
Joined: Thu Oct 13, 2011 7:52 am

PreviousNext

Return to Camera SDK

cron