[Mono-list] P/Invoke question

Kelly Leahy kellyleahy@swbell.net
Wed, 16 Mar 2005 16:19:50 -0800 (PST)


Just looking at your code, I can say this looks a
little wierd:

<<
   CvPoint2D32f* crs = null;
 		 	
   cvFindChessBoardCornerGuesses( 
       image.ImageHandle,
       thresh.ImageHandle,
       System.IntPtr.Zero, 
       etalonSize, 
       crs, 
       &cornerCount);
>>

You are probably more interested in doing something
like:

   CvPoint2D32f crs;
   cvFindChessBoardCornerGuesses(..., &crs, ...);

since unless you pass a reference to crs, it cannot be
filled by the code.

However, I don't think this is right either.  I think
perhaps your C declaration is either wrong, or the
caller has to preallocate the array of CvPoint2D32f
elements before calling this function.  The reason I
believe this to be true is that in order for the C
function to allocate this block of memory and pass
back the pointer (of type CvPoint2D32f*) it would have
to be passed a value of type CvPoint2D32f** or a
reference variable of type CvPoint2D32f*, neither of
which is done in the declaration you gave here.

<<
int cvFindChessBoardCornerGuesses( 
        const CvArr* image, 
              CvArr* thresh,
       CvMemStorage* storage, 
              CvSize board_size,
       CvPoint2D32f* corners,
                int* corner_count=NULL );
>>

best of luck,
Kelly