342 lines
12 KiB
C++
342 lines
12 KiB
C++
|
|
// main.cpp
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IKapC<70><43><EFBFBD><EFBFBD>IKapBoard<72>⣬ͨ<E2A3AC><CDA8>IKapWaitOneFrameReady<64>ӿںͲɼ<CDB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>This example shows users how to use IKapC and IKapBoard libraries to
|
|||
|
|
* grab images continuously with grabber linked camera and IKapWaitOneFrameReady api. */
|
|||
|
|
|
|||
|
|
#include <malloc.h>
|
|||
|
|
#include <shlwapi.h>
|
|||
|
|
#include <stdio.h>
|
|||
|
|
#include <stdlib.h>
|
|||
|
|
#include <tchar.h>
|
|||
|
|
#include <process.h>
|
|||
|
|
|
|||
|
|
#include "../GeneralConfigureCamera/ConfigureCamera.h"
|
|||
|
|
#include "../GeneralGrabWithGrabber/GeneralGrabWithGrabber.h"
|
|||
|
|
|
|||
|
|
#pragma comment(lib, "IKapBoard.lib")
|
|||
|
|
#pragma comment(lib, "IKapC.lib")
|
|||
|
|
#pragma comment(lib, "shlwapi.lib")
|
|||
|
|
|
|||
|
|
// ָʾ<D6B8>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//
|
|||
|
|
// indicate whether exit the program or not
|
|||
|
|
bool g_bExit = false;
|
|||
|
|
|
|||
|
|
/* @brief<65><66>ע<EFBFBD><D7A2><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>Register callback functions. */
|
|||
|
|
void RegisterCallbackWithGrabber(pItkCamera pCam);
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>Unregister callback functions. */
|
|||
|
|
void UnRegisterCallbackWithGrabber(pItkCamera pCam);
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>Ϊһ<CEAA><D2BB><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>ʼʱ<CABC><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
|
|||
|
|
* @param[in] pContext<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>This function is registered as a callback function. When starting
|
|||
|
|
* grabbing images, the function will be called.
|
|||
|
|
* @param[in] pContext<EFBFBD><EFBFBD>Input parameter. */
|
|||
|
|
void CALLBACK OnGrabStart(void* pContext);
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>Ϊһ<CEAA><D2BB><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>ʱʱ<CAB1><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
|
|||
|
|
* @param[in] pContext<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>This function is registered as a callback function. When grabbing
|
|||
|
|
* images time out, the function will be called.
|
|||
|
|
* @param[in] pContext<EFBFBD><EFBFBD>Input parameter. */
|
|||
|
|
void CALLBACK OnTimeout(void* pContext);
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>Ϊһ<CEAA><D2BB><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>֡ʱ<D6A1><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
|
|||
|
|
* @param[in] pContext<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>This function is registered as a callback function. When grabbing
|
|||
|
|
* frame lost, the function will be called.
|
|||
|
|
* @param[in] pContext<EFBFBD><EFBFBD>Input parameter. */
|
|||
|
|
void CALLBACK OnFrameLost(void* pContext);
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>Ϊһ<CEAA><D2BB><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ɼ<EFBFBD>ֹͣʱ<D6B9><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
|
|||
|
|
* @param[in] pContext<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>This function is registered as a callback function. When stopping
|
|||
|
|
* grabbing images, the function will be called.
|
|||
|
|
* @param[in] pContext<EFBFBD><EFBFBD>Input parameter. */
|
|||
|
|
void CALLBACK OnGrabStop(void* pContext);
|
|||
|
|
|
|||
|
|
/* @brief<65><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD><C7B9><EFBFBD><EFBFBD>̵߳<DFB3>ִ<EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲɼ<DAB2>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
|
|||
|
|
* @param[in] pUser<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>This function is the execution function of the work thread for image acquisition.
|
|||
|
|
* @param[in] pUser<EFBFBD><EFBFBD>Input parameter. */
|
|||
|
|
unsigned int __stdcall WorkThread(void* pUser);
|
|||
|
|
|
|||
|
|
int main()
|
|||
|
|
{
|
|||
|
|
/// \~chinese IKapC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ \~english Return value of IKapC functions
|
|||
|
|
ITKSTATUS res = ITKSTATUS_OK;
|
|||
|
|
|
|||
|
|
/// \~chinese IKapBoard <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ \~english Return value of IKapBoard functions
|
|||
|
|
int ret = IK_RTN_OK;
|
|||
|
|
|
|||
|
|
/// \~chinese <20><>ʼ<EFBFBD><CABC> IKapC <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD> \~english Initialize IKapC runtime environment
|
|||
|
|
res = ItkManInitialize();
|
|||
|
|
CHECK_IKAPC(res);
|
|||
|
|
|
|||
|
|
ItkCamera cam;
|
|||
|
|
|
|||
|
|
cam.g_bufferCount = 10;
|
|||
|
|
|
|||
|
|
sprintf_s(cam.g_saveFileName, "D:\\CImage.tif");
|
|||
|
|
|
|||
|
|
cam.g_SerialNumber = NULL;
|
|||
|
|
|
|||
|
|
cam.g_bSoftTriggerUsed = 1;
|
|||
|
|
|
|||
|
|
cam.g_bLoadGrabberConfig = 1;
|
|||
|
|
|
|||
|
|
uint32_t numDevices = 0;
|
|||
|
|
res = ItkManGetDeviceCount(&numDevices);
|
|||
|
|
CHECK(res);
|
|||
|
|
|
|||
|
|
// <20><>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>豸ʱ<E8B1B8><CAB1>
|
|||
|
|
//
|
|||
|
|
// When there is no connected devices.
|
|||
|
|
if (numDevices == 0) {
|
|||
|
|
fprintf(stderr, "No device.\n");
|
|||
|
|
ItkManTerminate();
|
|||
|
|
pressEnterToExit();
|
|||
|
|
exit(EXIT_FAILURE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
printCameraInfo(numDevices);
|
|||
|
|
|
|||
|
|
/// \~chinese <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸 \~english Open camera with 0 index and configure camera device
|
|||
|
|
int tmpIndex = -1;
|
|||
|
|
fprintf(stderr, "total device count: %d, the index of which you want to open is:", numDevices);
|
|||
|
|
fflush(stderr);
|
|||
|
|
int scanTmp = scanf_s("%u", &tmpIndex);
|
|||
|
|
if (scanTmp != 1) {
|
|||
|
|
fprintf(stderr, "Invalid input. Expect an integer.\n");
|
|||
|
|
ItkManTerminate();
|
|||
|
|
pressEnterToExit();
|
|||
|
|
exit(EXIT_FAILURE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (tmpIndex >= numDevices)
|
|||
|
|
{
|
|||
|
|
fprintf(stderr, "index: %d is more than %d.\n", tmpIndex, numDevices - 1);
|
|||
|
|
ItkManTerminate();
|
|||
|
|
pressEnterToExit();
|
|||
|
|
exit(EXIT_FAILURE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
{ int getCharTmp = getchar(); }
|
|||
|
|
|
|||
|
|
ConfigureCamera(&cam, tmpIndex);
|
|||
|
|
|
|||
|
|
if (cam.g_hBoard == INVALID_HANDLE_VALUE) {
|
|||
|
|
fprintf(stderr, "Please select camera with grabber.\n");
|
|||
|
|
ItkManTerminate();
|
|||
|
|
pressEnterToExit();
|
|||
|
|
exit(EXIT_FAILURE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// \~chinese <20><><EFBFBD>òɼ<C3B2><C9BC><EFBFBD><EFBFBD>豸 \~english Configure frame grabber device
|
|||
|
|
ConfigureFrameGrabber(&cam);
|
|||
|
|
|
|||
|
|
/// \~chinese ע<><D7A2><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> \~english Register callback functions.
|
|||
|
|
RegisterCallbackWithGrabber(&cam);
|
|||
|
|
|
|||
|
|
/// \~chinese <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ \~english Configure trigger method of the camera
|
|||
|
|
SetSoftTriggerWithGrabber(&cam);
|
|||
|
|
|
|||
|
|
/// \~chinese <20><>ʼͼ<CABC><CDBC><EFBFBD>ɼ<EFBFBD> \~english Start grabbing images
|
|||
|
|
StartGrabImage(&cam);
|
|||
|
|
|
|||
|
|
/// \~chinese <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD>ڻ<EFBFBD>ȡͼ<C8A1><CDBC> \~english Create a worker thread that is used to acquire the images
|
|||
|
|
unsigned int nThreadID = 0;
|
|||
|
|
void* hThreadHandle = (void*)_beginthreadex(NULL, 0, WorkThread, &cam, 0, &nThreadID);
|
|||
|
|
if (NULL == hThreadHandle)
|
|||
|
|
{
|
|||
|
|
printf("fail to create workThread to grab image.\n");
|
|||
|
|
ItkManTerminate();
|
|||
|
|
pressEnterToExit();
|
|||
|
|
exit(EXIT_FAILURE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cam.g_bSoftTriggerUsed) {
|
|||
|
|
printf("Please intput t to softTrigger a frame and input e to exit: ");
|
|||
|
|
while (true) {
|
|||
|
|
char T = 0;
|
|||
|
|
int scanTmp = scanf_s("%c", &T, (unsigned)sizeof(T));
|
|||
|
|
if (T == 't') {
|
|||
|
|
if (strcmp(cam.g_devInfo.DeviceClass, "CoaXPress") == 0 ||
|
|||
|
|
strcmp(cam.g_devInfo.DeviceClass, "CameraLink") == 0) {
|
|||
|
|
ret = IKapSetInfo(cam.g_hBoard, IKP_SOFTWARE_TRIGGER_START, 1);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
res = ItkDevExecuteCommand(cam.g_hCamera, "TriggerSoftware");
|
|||
|
|
}
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
}
|
|||
|
|
else if (T == 'e') {
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
else if (T != '\n') {
|
|||
|
|
printf("Please intput t to softTrigger a frame and input e to exit: ");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// \~chinese <20>ȴ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD> \~english Wait for grabbing images finished
|
|||
|
|
{ int getCharTmp = getchar(); }
|
|||
|
|
|
|||
|
|
g_bExit = true;
|
|||
|
|
|
|||
|
|
/// \~chinese ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD> \~english stop workThread
|
|||
|
|
WaitForSingleObject(hThreadHandle, INFINITE);
|
|||
|
|
CloseHandle(hThreadHandle);
|
|||
|
|
|
|||
|
|
/// \~chinese ֹͣͼ<D6B9><CDBC><EFBFBD>ɼ<EFBFBD> \~english Stop grabbing images
|
|||
|
|
ret = IKapStopGrab(cam.g_hBoard);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
/// \~chinese <20><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> \~english Unregister callback functions
|
|||
|
|
UnRegisterCallbackWithGrabber(&cam);
|
|||
|
|
|
|||
|
|
/// \~chinese <20>رղɼ<D5B2><C9BC><EFBFBD><EFBFBD>豸 \~english Close frame grabber device
|
|||
|
|
ret = IKapClose(cam.g_hBoard);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
/// \~chinese <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸 \~english Close camera device
|
|||
|
|
res = ItkDevClose(cam.g_hCamera);
|
|||
|
|
CHECK_IKAPC(res);
|
|||
|
|
|
|||
|
|
/// \~chinese <20>ͷ<EFBFBD><CDB7>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Buffer<65><72>ַ<EFBFBD><D6B7><EFBFBD>ڴ<EFBFBD> \~english Release the memory that the user requests for setting the Buffer address
|
|||
|
|
/*if (cam.g_user_buffer!=NULL)
|
|||
|
|
free(cam.g_user_buffer);*/
|
|||
|
|
|
|||
|
|
/// \~chinese <20>ͷ<EFBFBD> IKapC <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD> \~english Release IKapC runtime environment
|
|||
|
|
ItkManTerminate();
|
|||
|
|
|
|||
|
|
pressEnterToExit();
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void RegisterCallbackWithGrabber(pItkCamera pCam)
|
|||
|
|
{
|
|||
|
|
int ret = IK_RTN_OK;
|
|||
|
|
|
|||
|
|
ret = IKapRegisterCallback(pCam->g_hBoard, IKEvent_GrabStart, OnGrabStart, pCam);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
ret = IKapRegisterCallback(pCam->g_hBoard, IKEvent_FrameLost, OnFrameLost, pCam);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
ret = IKapRegisterCallback(pCam->g_hBoard, IKEvent_TimeOut, OnTimeout, pCam);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
ret = IKapRegisterCallback(pCam->g_hBoard, IKEvent_GrabStop, OnGrabStop, pCam);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void UnRegisterCallbackWithGrabber(pItkCamera pCam)
|
|||
|
|
{
|
|||
|
|
int ret = IK_RTN_OK;
|
|||
|
|
|
|||
|
|
ret = IKapUnRegisterCallback(pCam->g_hBoard, IKEvent_GrabStart);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
ret = IKapUnRegisterCallback(pCam->g_hBoard, IKEvent_FrameLost);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
ret = IKapUnRegisterCallback(pCam->g_hBoard, IKEvent_TimeOut);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
ret = IKapUnRegisterCallback(pCam->g_hBoard, IKEvent_GrabStop);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CALLBACK OnGrabStart(void* pContext)
|
|||
|
|
{
|
|||
|
|
printf("Start grabbing image.\n");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
unsigned int __stdcall WorkThread(void* pUser)
|
|||
|
|
{
|
|||
|
|
ITKSTATUS res = ITKSTATUS_OK;
|
|||
|
|
|
|||
|
|
int ret = IK_RTN_OK;
|
|||
|
|
|
|||
|
|
unsigned char* pUserBuffer = NULL;
|
|||
|
|
int64_t nFrameSize = 0;
|
|||
|
|
int nFrameCount = 0;
|
|||
|
|
int nFrameIndex = 0;
|
|||
|
|
IKAPBUFFERSTATUS status;
|
|||
|
|
|
|||
|
|
pItkCamera cam = (pItkCamera)pUser;
|
|||
|
|
if (NULL == cam)
|
|||
|
|
{
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
do
|
|||
|
|
{
|
|||
|
|
/// \~chinese timeout_ms <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>֡<EFBFBD><D6A1><EFBFBD>ڣ<EFBFBD><DAA3>˴<EFBFBD><CBB4><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \~english timeout_ms needs to be greater than the actual camera frame period, which needs to be modified according to the actual situation
|
|||
|
|
res = IKapWaitOneFrameReady(cam->g_hBoard, &nFrameIndex, 5000);
|
|||
|
|
if (g_bExit)
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
printf("Grab frame ready of camera with serialNumber:%s.\n",
|
|||
|
|
cam->g_devInfo.SerialNumber);
|
|||
|
|
|
|||
|
|
ret = IKapGetInfo(cam->g_hBoard, IKP_FRAME_COUNT, &nFrameCount);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
ret = IKapGetBufferStatus(cam->g_hBoard, nFrameIndex, &status);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
/// \~chinese <20><>ͼ<EFBFBD><EFBFBD><F1BBBAB3><EFBFBD><EFBFBD><EFBFBD>ʱ \~english When the buffer is full
|
|||
|
|
if (status.uFull == 1) {
|
|||
|
|
/// \~chinese <20><>ȡһ֡ͼ<D6A1><CDBC><EFBFBD>Ĵ<EFBFBD>С \~english Get the size of a frame of image
|
|||
|
|
ret = IKapGetInfo64(cam->g_hBoard, IKP_FRAME_SIZE, &nFrameSize);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
/// \~chinese <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MultiExposureTimeCount<6E><74><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD>Ҳɼ<D2B2><C9BC><EFBFBD><EFBFBD><EFBFBD>IKP_MULTIPLE_LIGHT_COUNT<4E><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>MultiExposureTimeCount<6E><74>ͬ<EFBFBD><CDAC>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD><EFBFBD>ع<D8B9>ܣ<EFBFBD><DCA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪN<CEAA><4E><EFBFBD>ع<EFBFBD>ʱ<EFBFBD>䣬[0~1*Height/N-1]<5D>ж<EFBFBD>ӦExposureSelectΪ1ʱ<31><CAB1>ExposureTime<6D><65>[1*Height/N~2*Height/N-1]<5D>ж<EFBFBD>ӦExposureSelectΪ2ʱ<32><CAB1>ExposureTime<6D><65>...<2E><>[(N-1)*Height/N~Height-1]<5D>ж<EFBFBD>ӦExposureSelectΪNʱ<4E><CAB1>ExposureTime. \~english If the MultiExposureTimeCount feature value is greater than 1, the multiple exposure function is turned on, The collected images were all divided into N exposure times, line [0~1 * Height / N-1] corresponds to the ExposureTime at a ExposureSelect of 1, line [1 * Height / N~2 * Height / N-1] corresponds to ExposureTime at ExposureSelect 2,..., line [(N-1) * Height / N~Height-1] corresponds to ExposureTime at ExposureSelect N.
|
|||
|
|
/// \~chinese <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ \~english Get the buffer address
|
|||
|
|
ret = IKapGetBufferAddress(cam->g_hBoard, nFrameIndex,
|
|||
|
|
(void **)&pUserBuffer);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
/// \~chinese <20><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> \~english Save image
|
|||
|
|
/*
|
|||
|
|
ret=IKapSaveBuffer(cam->g_hBoard,nFrameIndex,cam->g_saveFileName,IKP_DEFAULT_COMPRESSION);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
*/
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// \~chinese <20>ͷ<EFBFBD>buffer \~english release buffer
|
|||
|
|
ret = IKapReleaseBuffer(cam->g_hBoard,nFrameIndex);
|
|||
|
|
CHECK_IKAPBOARD(ret);
|
|||
|
|
|
|||
|
|
} while (!g_bExit);
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CALLBACK OnTimeout(void* pContext)
|
|||
|
|
{
|
|||
|
|
printf("Grab image timeout.\n");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CALLBACK OnFrameLost(void* pContext)
|
|||
|
|
{
|
|||
|
|
printf("Grab frame lost.\n");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CALLBACK OnGrabStop(void* pContext)
|
|||
|
|
{
|
|||
|
|
printf("Stop grabbing image.\n");
|
|||
|
|
}
|