PVCAM  3.9.x
Programmable Virtual Camera Access Method library
Extended Binning Factors

This example code demonstrates acquisition of a single frame with callback notification and selected binning factors. This is repeated in a loop until user enters an empty or invalid input. Each acquisition is started by the host with an 'emulated' software trigger (pl_exp_start_seq).

Please note that the extended binning factors are fully supported on new cameras only. The extended binning factors are reported by a pair of parameters: PARAM_BINNING_SER and PARAM_BINNING_PAR. The acquisition is then configured using the setup function as usually. Please see Binning Factors Discovery chapter for details.

The code snippet below initializes PVCAM and opens the first available camera. Please refer to the actual code sample in the SDK installation directory for more details about the common helper functions used in this documentation.

std::vector<CameraContext*> contexts;
if (!InitAndOpenOneCamera(contexts, cSingleCamIndex))
return APP_EXIT_ERROR;
CameraContext* ctx = contexts[cSingleCamIndex];

This code example uses the recommended callbacks acquisition (see Polling versus Callbacks). A part of the code omitted here defines a static callback function and registers the function with PVCAM. This approach is used in other code samples as well. The relevant code part is described in Frame Callback Handler section.

The next code block fills the NVP containers with serial and parallel binning factors.

NVPC binsSer;
if (!ReadEnumeration(ctx->hcam, &binsSer, PARAM_BINNING_SER, "PARAM_BINNING_SER"))
{
CloseAllCamerasAndUninit(contexts);
return APP_EXIT_ERROR;
}
NVPC binsPar;
if (!ReadEnumeration(ctx->hcam, &binsPar, PARAM_BINNING_PAR, "PARAM_BINNING_PAR"))
{
CloseAllCamerasAndUninit(contexts);
return APP_EXIT_ERROR;
}
Note
Please, refer to the Getting Error Messages section.
Please, refer to the ReadEnumeration section and Enumeration Parameters in general.

Let the user select binning factors and repeat the acquisition until invalid or no value is entered.

bool errorOccured = false;
std::string binFactors;
for(;;)
{

Print the binning values and names returned from PVCAM. The string description for each enum value already combines the serial and parallel binning value. For example, if the serial binning is 4 and parallel binning is 2, the string value is reported as '4x2'.

printf("Supported extended binning factors:\n");
printf("==============================================\n");
for (uns32 n = 0; n < binCount; n++)
{
printf(" %s (serial %d x parallel %d)\n",
binsSer[n].name.c_str(), binsSer[n].value, binsPar[n].value);
}
printf("Type the required binning factors combination and press <Enter>: ");
if (!WaitForInputString(binFactors))
{
errorOccured = true;
break;
}

Find the index of the matching binning factors and break the loop if no or invalid value is entered. Update the binning factors in the region variable.

for (n = 0; n < binCount; n++)
{
if (binsSer[n].name == binFactors)
break;
}
if (n >= binCount)
{
printf("Invalid binning factors entered, exiting...\n");
break;
}
ctx->region.sbin = (uns16)binsSer[n].value;
ctx->region.pbin = (uns16)binsPar[n].value;

Rest of the code sample is similar to Single Image Callbacks :

  • prepare the acquisition by calling pl_exp_setup_seq,
  • allocate buffer with sufficient size,
  • start the acquisition with pl_exp_start_seq,
  • wait for EOF event notification from the callback handler,
  • print the first few pixel values,
  • exit gracefully on user's request.