Continuous Transfer¶
Start continuous transfer to repeatedly retrieve images from the device in the SDK. The SDK includes a ring buffer for storing images. Retrieved images are stored in the buffer in sequence.
As retrieving an image in the SDK will call a preset function (referred to as the callback function below), run a save process within this function.
The buffer will be locked and cannot be overwritten while the callback function is running. When the callback function processing time is too long, image retrieval in the SDK catches up and image retrieval is put in standby. In this case, the chance of frame dropping increases. To avoid this, set the ring buffer to the highest possible value.
Note
A single buffer will use about 0.4 MB of memory.
Warning
Increasing the number of ring buffers does not guarantee that frame dropping will not occur. Frame dropping may occur due to an interruption of another software on the OS.
Configuring Ring buffer count¶
Use the following function to set the ring buffer count.
result = PUC_SetRingBufferCount(hDevice, 1024);
if (PUC_CHK_FAILED(result))
{
return;
}
Note
The maximum ring buffer count that can be set is defined in PUC_MAX_RING_BUF_COUNT.
Starting continuous transfer¶
FILE* fp; _tfopen_s(&fp, _T("test.dat"), _T("wb")); result = PUC_BeginXferData(hDevice, RecieveProc, fp); if (PUC_CHK_FAILED(result)) return; }
For the “PUC_BeginXferData” argument, specify a pointer to the callback function called when retrieving images, and arguments given to the callback function. In the example above, the file pointer already opened is passed.
void RecieveProc(PPUC_XFER_DATA_INFO pXferData, void* arg) { FILE* fp = (FILE*)arg; fwrite(pXferData->pData, pXferData->nDataSize, 1, fp); }
Images are written to the file with the callback function. Reduce processing as much as possible. The frame dropping might occur when the callback function takes time.
Finishing continuous transfer¶
result = PUC_EndXferData(hDevice); if (PUC_CHK_FAILED(result)) { return; }