[Mono-list] P/Invoke question
James Fitzsimons
James Fitzsimons <james.fitzsimons@gmail.com>
Thu, 17 Mar 2005 11:47:13 +0000
Hi Kelly,
Thanks very much for your reply.
On Wed, 16 Mar 2005 16:37:12 -0800 (PST), Kelly Leahy
<kellyleahy@swbell.net> wrote:
> Looking at the documentation for this function at:
> http://www.cs.bham.ac.uk/resources/courses/robotics/doc/opencvdocs/ref/OpenCVRef_3dReconstruction.htm#decl_cvFindChessBoardCornerGuesses
>
> I was correct.
>
> The caller is responsible for preallocating the array
> of CvPoint2D32f records.
> For instance, you could declare the P/Invoke function
> to take an array of CvPoint2D32f elements, then
> construct this array in the code that calls this
> function (the wrapper) with the appropriate size.
> Perhaps, if you know CvPoint2D32f to be of type float,
> you could even pass this array to the Marshal.Copy
> function directly.
This was actually what I originally had in mind, however CvPoint2D32f
is actually a struct that looks like this (from memory)
struct CvPoint2D32f
{
float x;
float y;
}
So I guess the question becomes how do I marshal an array of structs?
Or, could I marshal it as an array of floats of size 2 * number of
CvPoint2D32f's, and put it back into struct form once it has been
returned from the C function?
Thanks very much for your help. I really appreciate the effort you
went to, even finding the documentation!
Regards,
James