/// \~chinese IKapC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ \~english Return value of IKapC functions
ITKSTATUSres=ITKSTATUS_OK;
/// \~chinese IKapBoard <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ \~english Return value of IKapBoard functions
intret=IK_RTN_OK;
intcamCount=0;
/*******************************/
/// \~chinese <20><>ʼ<EFBFBD><CABC> IKapC <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> \~english Initialize IKapC runtime environment, Only need to run once
res=ItkManInitialize();
CHECK(res);
/// \~chinese <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ӵ<EFBFBD>PC<50><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> \~english Get the current number of camera devices connected to PC, Only need to run once
/// \~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
fprintf(stderr,"total device count: %d, the count of which you want to open is:",numDevices);
fflush(stderr);
intscanTmp=scanf_s("%u",&camCount);
if(scanTmp!=1){
fprintf(stderr,"Invalid input. Expect an integer.\n");
ItkManTerminate();
pressEnterToExit();
exit(EXIT_FAILURE);
}
{intgetCharTmp=getchar();}
if(camCount<=0){
fprintf(stderr,"count: %d is not more than 0.\n",camCount);
ItkManTerminate();
pressEnterToExit();
exit(EXIT_FAILURE);
}
if(camCount>(int)numDevices)
{
fprintf(stderr,"count: %d is more than %d.\n",camCount,numDevices);
ItkManTerminate();
pressEnterToExit();
exit(EXIT_FAILURE);
}
ItkCamera*cam=newItkCamera[camCount];
for(inti=0;i<camCount;i++){
{/// \~chinese <20><><EFBFBD><EFBFBD>buffer<65><72><EFBFBD><EFBFBD> \~english Set count of buffers
cam[i].g_bufferCount=10;
/// \~chinese <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>֡<EFBFBD><D6A1> \~english Set count of frames wanted
cam[i].g_grabCount=ITKSTREAM_CONTINUOUS;
/// \~chinese <20><><EFBFBD><EFBFBD>g_SerialNumberΪNULL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ConfigureCamera<72><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>index<65><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \~english Set
/// g_SerialNumber to NULL, ConfigureCamera function will use index to open camera later
/// \~chinese <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> \~english Set filename of image to be saved
fprintf(stderr,"index of camera you want to open is:");
fflush(stderr);
intscanTmp=scanf_s("%u",&tmpIndex);
if(scanTmp!=1){
fprintf(stderr,"Invalid input. Expect an integer.\n");
ItkManTerminate();
pressEnterToExit();
exit(EXIT_FAILURE);
}
{intgetCharTmp=getchar();}
if(tmpIndex>=(int)numDevices)
{
fprintf(stderr,"index: %d is more than %d.\n",tmpIndex,numDevices-1);
ItkManTerminate();
pressEnterToExit();
exit(EXIT_FAILURE);
}
if(tmpIndex<0)
{
fprintf(stderr,"index: %d is less than %d.\n",tmpIndex,0);
ItkManTerminate();
pressEnterToExit();
exit(EXIT_FAILURE);
}
for(size_ti=0;i<camCount;i++)
{
if(cam[i].g_index==tmpIndex)
{
fprintf(stderr,"index: %d is opened.\n",tmpIndex);
ItkManTerminate();
pressEnterToExit();
exit(EXIT_FAILURE);
}
}
ConfigureCamera(&cam[i],tmpIndex);
}
for(size_ti=0;i<camCount;i++){
if(cam[i].g_hBoard!=INVALID_HANDLE_VALUE){
/// \~chinese <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ \~english Configure trigger method of the camera
printf("Please intput t to softTrigger a frame and input e to exit: ");
}
}
}
}else{
/// \~chinese <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ \~english Configure trigger method of the camera
SetSoftTriggerWithoutGrabber(&cam[i]);
/// \~chinese <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>chunkdata \~english Configure chunkdata of the camera
SetChunkData(&cam[i],cam[i].benableChunkData);
/// \~chinese <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> \~english Create data stream and buffer
/// \~chinese <20>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> \~english Free data stream and buffers
ItkDevFreeStream(cam[i].g_hStream);
/// \~chinese <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸 \~english Close camera device
/// \~english Use a static function declared with 'static' to register a callback, if using a member function, be aware of the lifetime of the object that owns the member function and unregister the callback by IKapUnRegisterCallback() before the object is destroyed, or if the callback is triggered after the object has been released, it will cause an exception
/// \~english in OnFrameReady callback function, should not execute time-consuming operation, and finish in time of 1s/framerate, or could cause framelost
/// \~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
/// \~english Use a static function declared with 'static' to register a callback, if using a member function, be aware of the lifetime of the object that owns the member function and unregister the callback by ItkStreamUnregisterCallback() before the object is destroyed, or if the callback is triggered after the object has been released, it will cause an exception
/// \~english in cbOnEndOfFrame callback function, should not execute time-consuming operation, and finish in time of 1s/framerate, or could cause framelost
// \~chinese <20><>ȡ<EFBFBD><C8A1>ǰbuffer<65><72>Ϣ \~english get current buffer info
res=ItkBufferGetInfo(hBuffer,&bufferInfo);
CHECK(res);
/// \~chinese <20><>ͼ<EFBFBD><EFBFBD><F1BBBAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><F1BBBAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB7>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ֡ͼ<D6A1><CDBC>ʱ \~english When buffer is full or buffer is not full but cannot grab a complete frame of image
/// \~chinese <20><>ȡchunk<6E><6B><EFBFBD>ݣ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ChunkModeActive<76>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>ChunkSelector<6F><72><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> \~english Get chunk data provided that ChunkModeActive is on and the following corresponding parameters in ChunkSelector are enabled
/// \~chinese ֻ<>в<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD> \~english Only the color cameras have these parameters
/// \~chinese <20><><EFBFBD><EFBFBD>MultiExposureTimeCount<6E><74><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>1<EFBFBD><31><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.