PVCAM  3.9.x
Programmable Virtual Camera Access Method library
Post-Processing Parameters

This sample demonstrates usage of post-processing features and parameters. It shows how to access the post-processing features of a camera without hard-coding values, independently of which camera is detected and used.

Every camera may support different set of post-processing 'features'. Features are groups which group one or more 'parameters'. These 'parameters' are similar to regular PVCAM parameters, but they need to be discovered by the application at run-time. The 'parameters' are currently limited to uns32 data type.

The application will usually build a tree similar to the following one:

Because the indexes and their order may be different for every camera, the PVCAM also provides a PARAM_PP_FEAT_ID and PARAM_PP_PARAM_ID parameters. These IDs are uniquely defined in pvcam.h and they are assigned to a particular feature/parameter.

If the application needs to programmatically control a particular PP parameter, it should use the ID to find to corresponding indexes first and then set the indexes to PVCAM and control the parameter state via PARAM_PP_PARAM parameter.

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];

Check if the camera supports post-processing parameters:

if (!IsParamAvailable(ctx->hcam, PARAM_PP_INDEX, "PARAM_PP_INDEX"))
{
CloseAllCamerasAndUninit(contexts);
return APP_EXIT_ERROR;
}

Detect all available post-processing features using the DiscoverCameraPostProcessing helper function and display them in a tree structure:

const std::vector<PvcamPpFeature> ppFeatures = DiscoverCameraPostProcessing(ctx);
printf("Camera Post-Processing tree:\n");
for (const PvcamPpFeature& ppFeature : ppFeatures)
{
// Print IDs as signed integers to display invalid value as -1 instead of a large number.
// Valid ID is usually a small number based on current pattern in pvcam.h.
printf("- FEATURE at index %d: id=%d, name='%s'\n",
ppFeature.index, (int32)ppFeature.id, ppFeature.name.c_str());
for (const PvcamPpParameter& ppParam : ppFeature.parameterList)
{
printf(" - PARAMETER at index %d: id=%d, name='%s'\n",
ppParam.index, (int32)ppParam.id, ppParam.name.c_str());
}
}

Build a selection list for the post-processing features and display it in the console as an interactive menu.

NVPC menuPpFeatures;
for (const PvcamPpFeature& ppFeature : ppFeatures)
{
NVP nvpFeature;
nvpFeature.value = ppFeature.index; // Post-Processing Feature selection
nvpFeature.name = ppFeature.name;
menuPpFeatures.push_back(nvpFeature);
}
if (!GetMenuSelection("Choose Post-Processing Feature",
menuPpFeatures, menuSelection))
{
printf("No valid Feature selected, exiting...\n");
CloseAllCamerasAndUninit(contexts);
return 0; // Not an error, exit the app
}
const PvcamPpFeature& ppFeature = ppFeatures[menuSelection];
Note
Please, refer to the GetMenuSelection section.

Allow the user to interact with the PP features' parameters as long as valid input is entered.

NVPC menuPpParams;
for (const PvcamPpParameter& ppParam : ppFeature.parameterList)
{
if (!GetPpParamValue(ctx, ppFeature.index, ppParam.index, curValue))
{
CloseAllCamerasAndUninit(contexts);
return APP_EXIT_ERROR;
}
NVP nvpParam;
nvpParam.value = ppParam.index; // Post-Processing Parameter selection
nvpParam.name = ppParam.name + ", current value " + std::to_string(curValue);
menuPpParams.push_back(nvpParam);
}
if (!GetMenuSelection("Choose Post-Processing Parameter",
menuPpParams, menuSelection))
{
printf("No valid Parameter selected, exiting...\n");
break; // Not an error, exit the app
}
const PvcamPpParameter& ppParam = ppFeature.parameterList[menuSelection];

Once the PP feature and PP parameter indexes are retrieved from the user, ask the user to enter a new value for this particular PP parameter. Once obtained, set the new value with the SetPpParamValue helper function and verify it by reading back the value with the GetPpParamValue function.

Clean up before exiting the application. For more details, please, refer to the Closing Camera and Uninitializing PVCAM section.

CloseCameraAndUninit();
return 0;