119 lines
3.3 KiB
C++
119 lines
3.3 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>⣬<EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
|
|||
|
|
*
|
|||
|
|
* @brief<EFBFBD><EFBFBD>This example shows users how to use IKapC and IKapBoard libraries to
|
|||
|
|
* configure camera. */
|
|||
|
|
|
|||
|
|
#include <malloc.h>
|
|||
|
|
#include <shlwapi.h>
|
|||
|
|
#include <stdio.h>
|
|||
|
|
#include <stdlib.h>
|
|||
|
|
#include <tchar.h>
|
|||
|
|
|
|||
|
|
#include "../GeneralConfigureCamera/ConfigureCamera.h"
|
|||
|
|
|
|||
|
|
#pragma comment(lib, "IKapBoard.lib")
|
|||
|
|
#pragma comment(lib, "IKapC.lib")
|
|||
|
|
#pragma comment(lib, "shlwapi.lib")
|
|||
|
|
|
|||
|
|
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 = 0;
|
|||
|
|
|
|||
|
|
cam.g_bLoadGrabberConfig = 0;
|
|||
|
|
|
|||
|
|
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);
|
|||
|
|
}
|
|||
|
|
ConfigureCamera(&cam, tmpIndex);
|
|||
|
|
|
|||
|
|
res = SetWidth(&cam, 1024);
|
|||
|
|
CHECK_IKAPC(res);
|
|||
|
|
|
|||
|
|
int64_t width = 0;
|
|||
|
|
res = GetWidth(&cam, &width);
|
|||
|
|
CHECK_IKAPC(res);
|
|||
|
|
printf("%d camera's width is %lld.\n",tmpIndex,width);
|
|||
|
|
|
|||
|
|
res = SetHeight(&cam, 1024);
|
|||
|
|
int64_t height = 0;
|
|||
|
|
res = GetHeight(&cam, &height);
|
|||
|
|
CHECK_IKAPC(res);
|
|||
|
|
printf("%d camera's height is %lld.\n", tmpIndex, height);
|
|||
|
|
|
|||
|
|
res = SetExposureTime(&cam, 100.0);
|
|||
|
|
CHECK_IKAPC(res);
|
|||
|
|
|
|||
|
|
double exposure = 0;
|
|||
|
|
res = GetExposureTime(&cam, &exposure);
|
|||
|
|
CHECK_IKAPC(res);
|
|||
|
|
printf("%d camera's exposureTime is %f.\n", tmpIndex, exposure);
|
|||
|
|
|
|||
|
|
/// \~chinese <20>رղɼ<D5B2><C9BC><EFBFBD><EFBFBD>豸 \~english Close frame grabber device
|
|||
|
|
if (cam.g_hBoard != INVALID_HANDLE_VALUE) {
|
|||
|
|
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> IKapC <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD> \~english Release IKapC runtime environment
|
|||
|
|
ItkManTerminate();
|
|||
|
|
|
|||
|
|
pressEnterToExit();
|
|||
|
|
return 0;
|
|||
|
|
}
|