Sample code for both C and C# projects are provided along with the SDK. The examples below demonstrate the general usage of the Perfectly Clear SDK.
Scenario #1 - Using PCF_AutoCorrect
This is the simplest way to use Perfectly Clear library suite. This protocol is more suitable for developing a server type software project or in scenarios where every image will be corrected with one set of parameters (no user-facing option to adjust correction parameters).
- Initialize parameters:
- Populate image data into PFCIMAGE structure:
im.
data = (
unsigned char*)pbd->Scan0;
- Perform full correction using the auto function:
if (bVerbose)
{
if (status == 0)
{
printf("Image processed successfully\n");
}
else if (status > 0)
{
printf(
" Pre-calculation on noise returns %d\n",
PFCNR_STATUS(status));
printf(
" Pre-calculation on face details returns %d\n",
PFCFB_STATUS(status));
printf(
" Pre-calculation on red eye returns %d\n",
PFCRE_STATUS(status));
}
else if (status < 0)
{
printf("Image processed failed with return code: %d\n", status);
}
}
Scenario #2 - Separate PFC_Calc and PFC_Apply
More advanced way to use Perfectly Clear library suite. This protocol is more suitable for developing a desktop photo editing type software where user parameters will vary under the same session of an image.
- Create process engine:
if (bVerbose)
{
{
printf("Engine created successfully.\n");
}
else
{
{
printf("Face Beautification library not available.");
}
}
}
- Initialize the parameter structure (using default parameter values): The parameters can be imported from a preset file.
if (bVerbose)
printf("PFC_ReadPresets returns %d\n", ret);
Alternatively the parameters can be initialized using PFC_SetParam() function. Example:
if (profilename != NULL)
{
if (bVerbose)
printf("PFC_ReadPresets returns %d\n", ret);
if (ret != 0)
{
if (ret == -2)
{
printf("Unable to open preset file %s. Using default settings.\n", profilename);
}
else if (ret == -8)
{
printf("Invalid preset file.\n");
exit(0);
}
else
{
printf("Unable to read preset file.\n");
exit(0);
}
}
}
else
{
}
- Populate image data into PFCIMAGE structure:
im.
data = (
unsigned char*)pbd->Scan0;
- Perform pre-calculation of image specific profile:
if (bVerbose)
{
if (pProfile->Status != 0)
{
{
printf(" Pre-calculation on noise returns %d\n", pProfile->NR_Status);
}
{
printf(" Core pre-calculation returns %d\n", pProfile->CORE_Status);
}
{
printf(" Pre-calculation on face details returns %d\n", pProfile->FB_Status);
}
{
printf(" Pre-calculation on red eye returns %d\n", pProfile->RE_Status);
}
}
printf("Calc returns %d\n", pProfile->Status);
}
(pEngine is created from step 1.)
- Apply the calculated profile and parameters to the image.
if (bVerbose)
{
{
printf("Image processed successfully.\n");
}
{
int code;
printf("Noise removal status %d\n", code);
printf("Perfectly Clear correction status %d\n", code);
printf("Face beautification status %d\n", code);
printf("Red eye removal status %d\n", code);
}
else
{
printf("Image processing failed with return code: %d\n", status);
}
}
- Release resources used by PFCPROFILE:
- Release the engine to release resource:
- Copyright
- Copyright (C) 2019 Athentech Imaging Inc