Frame Grabber SDK (Windows-C) Developer Guide
// Allocate image buffers.
pBuffer[i] = malloc(nPayloadSize);
if (NULL == pBuffer[i])
{
printf("Allocate buffer failed!\n");
nRet = MV_FG_ERR_OUT_OF_MEMORY;
break;
}
// Register buffer to SDK.
nRet = MV_FG_AnnounceBuffer(hStream, pBuffer[i], nPayloadSize, NULL, &(hBuffer[i]));
if (MV_FG_SUCCESS != nRet)
{
printf("Announce buffer failed! %#x\n", nRet);
break;
}
}
if (MV_FG_SUCCESS != nRet)
{
break;
}
// Refresh the buffer queue for image acquisition.
nRet = MV_FG_FlushQueue(hStream, MV_FG_BUFFER_QUEUE_ALL_TO_INPUT);
if (MV_FG_SUCCESS != nRet)
{
printf("Flush queue: all to input failed! %#x\n", nRet);
break;
}
// Create thread for image acquisition.
void* hThreadHandle = (void*)_beginthreadex(NULL, 0, GrabbingThread, hStream, 0, NULL);
if (NULL == hThreadHandle)
{
printf("Create thread failed!\n");
break;
}
printf("Press any key to stop acquisition.\n");
WaitForKeyPress();
// Stop image acquisition thread.
g_bExit = true;
WaitForSingleObject(hThreadHandle, INFINITE);
CloseHandle(hThreadHandle);
hThreadHandle = NULL;
} while (0);
// Release resources.
if (NULL != hStream)
{
93
    "