We are working with a C API for OpenCV. Most of the current OpenCV function calls don’t take separate width/length parameters, they use an internal structure called Size, which contains width and length as integers. In the C API:
typedef struct CVCSize {
int width, height;
} CVCSize;
In a Xojo Module I have external methods that match the C API functions, an internal method that calls this external method, and a structure that contains the width and height as integers:
C API:
void CVCresize(CVCMat src, CVCMat dst, CVCSize dsize, double fx, double fy, int interpolation)
{
cv::resize(ConstCVCMatRef(src), CVCMatRef(dst), CVCSizeParam(dsize), fx, fy, interpolation);
}
Xojo Module External Method CVCresize():
src as ptr, dst as ptr, dsize as CVCSize, fx as double, fy as double, interpolation as integer
Xojo Module Internal Method resize():
src as ptr, dst as ptr, dsize as CVCSize, fx as double, fy as double, interpolation as integer
and the code in the resize() method is:
CVCresize(src, dst, dsize, fx, fy, interpolation)
A Xojo structure called CVCSize, which contains width and height as integers
And the code that calls this is:
Var dsize as CVCSize
dsize.width = 640
dsize.height = 480
resize(source.cvmat, smaller.cvmat, dsize , 0, 0, 0 )
However, when I run this in the debugger, the application simply quits and drops me back in the IDE with no errors. I’ve tried catching exceptions in the resize() method, but I get the same result.
At first I thought I needed to pass the dsize structure as a pointer, so I changed both CVCresize() and resize() to expect pointers instead of type CVCSize, and then passed byref dsize in the call to the resize() function. However, that just resulted in a syntax error.
How do I get this Xojo structure to the API?
(Also, as an aside - why won’t this forum at least display the C code as fixed width if not with syntax coloring? I’ve wrapped the code above with the “</>” tag and it does nothing, so I had to put it in as a quote in order to separate it from the rest of the text).


