MIG Grabber SDK Manual 1.0
This is the manual for MIG Grabber SDK
Loading...
Searching...
No Matches
Example cpp

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

nRet = OpenGrabber(nBoardID, 1, NULL); // grabber system open
if (nRet == MIG_OK)
{
char sSNGet[32] = { 0, };
int nRet2 = GetSerialNo(nBoardID, sSNGet, 32);
if (nRet2 == MIG_OK)
{
printf("SN:x%s ", sSNGet);
}
}
#define MIG_OK
function is success.
Definition MIG_ErrCode.h:17
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

nRet = SetParamInt(nBoardID, MIG_PARAM_VIDEO_FMT, video_format);
nRet = SetParamInt(nBoardID, MIG_PARAM_PIXEL_ORDER, pxl_order);
nRet = SetParamInt(nBoardID, MIG_PARAM_HOR_RES, width);
nRet = SetParamInt(nBoardID, MIG_PARAM_VER_RES, height);
nRet = SetParamInt(nBoardID, MIG_PARAM_BITS_PER_PIXEL, bitPerPxl);
nRet = SetParamInt(nBoardID, MIG_PARAM_SRC_BITS_PER_PIXEL, bitPerPxl);
#define MIG_PARAM_SRC_BITS_PER_PIXEL
bits per pixel for source
Definition migGrabber.h:23
#define MIG_PARAM_VER_RES
Vertical resolution (ex> 1080)
Definition migGrabber.h:21
#define MIG_PARAM_BITS_PER_PIXEL
bits per pixel (for internal image buffer and source)
Definition migGrabber.h:22
#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
Definition migGrabber.h:19
#define MIG_PARAM_HOR_RES
Horizontal resolution (ex> 1920)
Definition migGrabber.h:20
#define MIG_PARAM_VIDEO_FMT
0:BAYER, 1:GRAY, 2:YUV422, 3:RGB16
Definition migGrabber.h:18

Power On and Sensor Init

char test_file[] = "c:\\Test\\test.ini";
char sec_poweron[] = "POWERON";
char sec_sensorinit[] = "REGISTER_INIT";
nRet = WriteRegisterSet(nBoardID, test_file, sec_poweron, &nErrIndex);
nRet = WriteRegisterSet(nBoardID, test_file, sec_sensorinit, &nErrIndex);
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 (nRet == MIG_OK)
{
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);
if (nRet == MIG_OK)
{
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.