Sample code C# projects are provided along with the SDK. The examples below demonstrate the general usage of the Perfectly Clear SDK (class PerfectlyClear ).
Setting up License Protection
If you have been provided with a license protected SDK, then there are two ways that you can activate this license in your code. It is always safe to use the multi-threading approach, though it does take slightly more code. The scenarios below on the sections below show the single-threaded method, as it's simpler and our sample code is all single-threaded.
Single-Threaded
This method requires fewer calls to our SDK, but isn't intended for multithreaded applications where many concurrent calls will be made at once. The process is to setup the protection path when calling the class constructor.
Multi-Threaded
for (int i = 0; i < images.count; i++) {
PfC.Dispose()
}
Scenario #1 - Using 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 correcition parameters).
- Instantiate PerfectlyClear class instance:
- Perform full correction using the auto function:
int ret = Pfc.AutoCorrect(ref bm, -1, null, false);
Scenario #2 - Separate Calc and 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.
- Instantiate PerfectlyClear class instance:
- Initialize parameters: The parameters are set to default values when the PerfectlyClear class is instantiated. Alternately it can be imported from a preset file.
if (presetfile != "")
{
int rc = Pfc.ReadPresets(presetfile);
if (bVerbose)
{
Console.WriteLine("ReadPresets returns " + rc.ToString());
}
}
- Perform pre-calculation of image specific profile:
if (bVerbose)
{
Console.WriteLine("Precalc return code: " + cret.ToString());
Console.WriteLine("Noise removal return code: " + Pfc.LastStatus.NR_Status.ToString());
Console.WriteLine("Perfectly Clear core return code: " + Pfc.LastStatus.CORE_Status.ToString());
Console.WriteLine("Face beautification return code: " + Pfc.LastStatus.FB_Status.ToString());
Console.WriteLine("Red eye removal return code: " + Pfc.LastStatus.RE_Status.ToString());
}
Note: The pre-calculated profile for the source image will be store in the PerfectlyClear class instance.
- Apply the calculated profile (stored within the class instance) and parameters to the image.
if (bVerbose)
{
{
Console.WriteLine("Image processed successfully.");
}
else if (aret > 0)
{
Console.WriteLine("Noise removal return code: " + Pfc.LastStatus.NR_Status.ToString());
Console.WriteLine("Perfectly Clear core return code: " + Pfc.LastStatus.CORE_Status.ToString());
Console.WriteLine("Face beautification return code: " + Pfc.LastStatus.FB_Status.ToString());
Console.WriteLine("Red eye removal return code: " + Pfc.LastStatus.RE_Status.ToString());
}
else if (aret < 0)
{
Console.WriteLine("Perfectly Clear return code: " + aret.ToString());
}
}
- Copyright
- Copyright (C) 2021 EyeQ Imaging Inc