-
January 8th, 2009, 02:47 PM
#1
Access native camera driver (sensoray)
I have done some PInvoke of native dlls but this one is beyond my capability.
The client of this driver (sx11.dll) has to declare a variable 'buffer' of type
Code:
typedef struct { //image buffer structure;
HBUF hbuf; //handle to buffer;
DWORD dwFrames; //number of frames in buffer;
FRAME frame[SYS_FRAMES]; //array of FRAME structures;
} BUFFER;
Then a function has to be called which initializes this variable and allocates the 'frame'
array. This type is
Code:
typedef struct { //frame structure;
LPBITMAPINFO lpbmi; //pointer to BITMAPINFO structure;
void *lpvbits; //pointer to image data;
} FRAME;
The native image acquisition function has to be called with the argument buffer.hbuf,
and it writes the image data into buffer.frame. My questions are:
1. How to translate the last BUFFER field 'FRAME frame[SYS_FRAMES]' into C#?
2. Call the acquisition function in a 'fixed' environment? How exactly?
3. How to copy lets say 'buffer.frame[1].lpvbits to a C# array byte[]?
Any suggestion is welcome.
-
January 7th, 2012, 02:31 AM
#2
Re: Access native camera driver (sensoray)
I have above problem, Is there any solution?
-
January 9th, 2012, 07:19 AM
#3
Re: Access native camera driver (sensoray)
Originally Posted by pajand
I have above problem, Is there any solution?
The interface I came up with follows. I don't remember my reasoning because I never worked again on that. I hope it helps.
Code:
// type aliases for sx11.dll
using ECODE = System.UInt32;
using DWORD = System.UInt32;
[StructLayout (LayoutKind.Sequential)]
struct PCI
{ public System.UInt32 board;
[MarshalAs (UnmanagedType.ByValArray, SizeConst=SYS_GRABBERS)]
public System.UInt32[] PCIslot;
}
[StructLayout (LayoutKind.Sequential)]
struct MODE_ADVANCED
{ public DWORD interlace; //interlacing flag;
public DWORD xTotal; //total hor pixels;
public DWORD xActive; //active hor pixels;
public DWORD xDelay; //hor delay;
public float yFactor; //vert scaling factor;
public DWORD yActive; //active vert pixels (lines);
public DWORD yDelay; //vert delay, lines;
public DWORD FORMAT; //input video format;
public DWORD BRIGHT; //brightness;
public DWORD CONTRAST; //contrast;
public DWORD SAT_U; //chroma (U) gain;
public DWORD SAT_V; //chroma (V) gain;
public DWORD HUE; //hue;
public DWORD LNOTCH; //luma notch filter control;
public DWORD LDEC; //luma decimation control;
public DWORD DEC_RAT; //temporal decimation control;
public DWORD PEAK; //luma LPF peaking control (Bt848A/849A);
public DWORD CAGC; //chroma ADC control;
public DWORD CKILL; //low color removal control;
public DWORD HFILT; //luma low pass filter mode;
public DWORD RANGE; //luma output range;
public DWORD CORE; //luma coring control;
public DWORD YCOMB; //luma comb enable;
public DWORD CCOMB; //chroma comb enable;
public DWORD ADELAY; //AGC gate delay for back-porch sampling;
public DWORD BDELAY; //burst gate delay for sub-carrier sampling;
public DWORD SLEEP; //ADCs' sleep mode;
public DWORD CRUSH; //adaptive AGC;
public DWORD VFILT; //vertical scaling filter control;
public DWORD COLOR_BARS; //color bars test enable;
public DWORD GAMMA; //gamma correction removal;
public DWORD PKTP; //FIFO trigger point;
public DWORD bimodal; //bimodal buffer flag;
public DWORD colorkey; //color key for DirectDraw overlay;
public DWORD buffertype; //type of buffer: memory, external, or video;
public DWORD gpintmode; //GP interrupt mode;
public DWORD reserved1; //reserved;
public DWORD reserved2; //reserved;
public DWORD reserved3; //reserved;
public DWORD reserved4; //reserved;
}
[StructLayout (LayoutKind.Sequential)]
struct MODE
{ public DWORD scale; //image scale;
public DWORD color; //output color encoding;
public DWORD store; //store as DIB or flat;
public DWORD input; //input channel;
public MODE_ADVANCED advanced;
}
[StructLayout (LayoutKind.Sequential)]
struct FRAME
{ public IntPtr lpbmi;
public byte[] lpvbits;
}
[StructLayout (LayoutKind.Sequential)]
struct BUFFER
{ public IntPtr hbuf;
public System.UInt32 dwFrames;
[MarshalAs (UnmanagedType.ByValArray, SizeConst=SYS_FRAMES)]
public FRAME[] frame;
}
[DllImport("sx11.dll")] static extern
ECODE X11_InitSystem (out PCI pci);
[DllImport("sx11.dll")] static extern
void X11_CloseSystem();
[DllImport("sx11.dll")] static extern
ECODE X11_GetHFG (out IntPtr fgHandle, System.UInt32 slot);
[DllImport("sx11.dll")] static extern
ECODE X11_AllocBuffer (ref MODE mode, ref BUFFER buffer, DWORD dwParameter);
[DllImport("sx11.dll")] static extern
ECODE X11_FreeBuffer (ref BUFFER buffer);
[DllImport("sx11.dll")] static extern
ECODE X11_SetMode (IntPtr fgHandle, ref MODE mode);
[DllImport("sx11.dll")] static extern
ECODE X11_GetImageSize (ref MODE mode, ref DWORD pxsize, ref DWORD pysize);
[DllImport("sx11.dll")] static extern
ECODE X11_Acquire (IntPtr fgHandle, IntPtr hbuf, float timeout,
out DWORD status);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|