I am talking to a low-cost Tucsen camera through it's dll. Most of the commands are working, but there is one command that I can't seem to marshal correctly. The signature of the call in the CamApi.h file is:
CAM_API int GetRoi(int *pPtX, int *pPtY, int *wid, int *hei, const char *devName);
The SDK also came with a working c++ sample program that calls this as follows:
int Core::GetRoi(int *pPtX, int *pPtY, int *wid, int *hei, const char *devName)
{
return (*p_GetRoi)(pPtX, pPtY, wid, hei, devName);
}
which calls
p_GetRoi = (int (*)(int *, int *, int *, int *, const char *))Load_Fun("GetRoi");
My first c# attempt was:
public int TCgetRoi(
ref int pointx,
ref int pointy,
ref int wid,
ref int hei,
string devName)
{
int iOut = TC_getRoi(out pointx,
out pointy,
out wid,
out hei,
devName);
return iOut;
with
[DllImport("CamCore.dll", EntryPoint = "GetRoi",
CallingConvention = CallingConvention.StdCall)]
private static extern int TC_getRoi(
out int pointx, out int pointy,
out int wid,
out int hei,
string devName);
When I call it, the return int is 0 indicating a normal execution, and devName also comes out fine, but the four integers come out all wrong: 58532, 58528, 8024, 8276. When I run the c++ example they come out with very reasonable values: 0, 0, 1280, 1024.
In the c# code, am I reading a pointer that I have to deference again in order to get the int value??
I have tried many other things, and always with the same result. Can anyone see what I cannot?