
Machine Vision Camera SDK (C) Developer Guide
MV_CC_RegisterImageCallBackEx
Example
The following sample code is for reference only.
#include "MvCameraControl.h"
void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO*
pFrameInfo, void* pUser)
{
if (pFrameInfo)
{
// Add current system time at output
char szInfo[128] = {0};
SYSTEMTIME sys;
GetLocalTime( &sys );
sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] :
GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds,
pFrameInfo->nWidth, pFrameInfo->nHeight);
printf("%s\n", szInfo);
}
}
void main()
{
int nRet = -1;
void* m_handle = NULL;
//Enumerate all devices corresponding to specified transport protocol
within subnet
unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
if (MV_OK != nRet)
{
printf("error: EnumDevices fail [%x]\n", nRet);
return;
}
int i = 0;
if (m_stDevList.nDeviceNum == 0)
{
printf("no camera found!\n");
return;
}
//Select the first found online device and create device handle
int nDeviceIndex = 0;
MV_CC_DEVICE_INFO m_stDevInfo = {0};
memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex],
159



































































































































































































































































































































































































