Dynamically load dll and functions.
CString sFile;
sFile.Format(_T("%s\\migGrabber.dll"), Helper::GetCurrentProcessPath());
HMODULE hSdk = LoadLibrary(sFile);
if (hSdk)
{
SetParamInt = (_SetParamInt)GetProcAddress(hSdk,
"SetParamInt");
GetParamInt = (_GetParamInt)GetProcAddress(hSdk,
"GetParamInt");
EnumerateBoard = (_EnumerateBoard)GetProcAddress(hSdk,
"EnumerateBoard");
OpenGrabber = (_OpenGrabber)GetProcAddress(hSdk,
"OpenGrabber");
}
int GetParamInt(int BoardId, int type)
Get the parameter.
int OpenGrabber(int BoardId, int nGrabberType, MIG_HANDLE hwndParent)
Open Grabber board.
int SetParamInt(int BoardId, int type, int val)
Set the parameter.
int EnumerateBoard(_BOARD_LIST *pDest)
Get the list of connected boards.
Get connected Board List
Open Grabber System
{
char sSNGet[32] = { 0, };
{
printf("SN:x%s ", sSNGet);
}
}
#define MIG_OK
function is success.
int GetSerialNo(int BoardId, char *pSn, int sizeSN)
Get the Serial Number.
Get Firmware Version
int verFW =
GetParamInt(nBoardID, MIG_PARAM_BOARD_VERSION_FW);
int verFPGA =
GetParamInt(nBoardID, MIG_PARAM_BOARD_VERSION_FPGA);
printf("Version. FW:x%04X FPGA:x%04X", verFW, verFPGA);
Set test module parameter
#define MIG_PARAM_SRC_BITS_PER_PIXEL
bits per pixel for source
#define MIG_PARAM_VER_RES
Vertical resolution (ex> 1080)
#define MIG_PARAM_BITS_PER_PIXEL
bits per pixel (for internal image buffer and source)
#define MIG_PARAM_PIXEL_ORDER
0:BGGR, 1:GBRG, 2:RGGB, 3:GRBG, / 0:YCBYCR;YUYV, 1:YCRYCB;YVYU, 2:CBYCRY;UYVY, 3:CRYCBY;VYUY
#define MIG_PARAM_HOR_RES
Horizontal resolution (ex> 1920)
#define MIG_PARAM_VIDEO_FMT
0:BAYER, 1:GRAY, 2:YUV422, 3:RGB16
Power On and Sensor Init
char test_file[] = "c:\\Test\\test.ini";
char sec_poweron[] = "POWERON";
char sec_sensorinit[] = "REGISTER_INIT";
int WriteRegisterSet(int BoardId, const char *pFile, const char *pSection, int *pnErrorIndex)
Apply power or Sensor init configuration. ex> [POWERON] [REGISTER_INIT].
Check module image output sync
DWORD dwTimeout = 500;
int nSyncH = 0;
int nSyncV = 0;
ULONG ulPClk_Hz = 0;
for (int i = 0; i < 2; i++)
{
nRet =
ReadSyncCount(nBoardID, dwTimeout, &nSyncH, &nSyncV, &ulPClk_Hz);
{
if (nValidSyncH == nSyncH && nValidSyncV == nSyncV)
{
break;
}
nRet = -100;
}
Sleep(100);
}
printf("ReadSyncCount. nRet=%d / SyncH:%d(%d) / SyncV:%d(%d)", nRet, nSyncH, nValidSyncH, nSyncV, nValidSyncV);
int ReadSyncCount(int BoardId, DWORD dwTimeOut_ms, int *pDestHsync, int *pDestVsync, ULONG *pDestPClk_Hz)
Read sync count to check module output.
Get image data
int nRet =
Grab(nBoardID, 1, 1000);
printf("Grab. nRet=%d ", nRet);
{
timer.StartTimer();
nRet =
GetImage(nBoardID, pBuff, m_nWidth, m_nHeight, m_nLineBytes);
printf("GetImage. nRet=%d ", nRet);
}
int GetImage(int BoardId, unsigned char *pDstBuffer, int dstWidth, int dstHeight, int dstPitchBytes)
Get image data.
int Grab(int BoardId, int nNbImage, DWORD dwTimeOut_ms)
Captures the specified number of frames.