Perfectly Clear SDK Documentation  10.7.1.1191
Examples (iOS)

Using Perfectly Clear in iOS is very similar to using it on OSX. See example usage in your SDK package in Demo/ImageEngine.

Simple AI Sample - Using Scene Detection

  1. Create AI-enabled engine - this should be done once when the app loads
  2. Enable AI features (Dynamic and Scene Detection) in PFCENGINE. This requires passing your PFC SDK apikey, certificate, and paths to PFC AI models (PFCDynamicModel.pnnc and pfcsdcoreml.pnn) in the app bundle
    int featuresLoaded = PFC_LoadAIEngineNative(m_PFCEngine, features, pathDynamic, 0, pathSD, 0, 0, apiKey.UTF8String,certificate.UTF8String, &statusCertificate);
  3. OPTIONALLY: load custom AI presets (presets to be selected based on scene detection). If custom presets are not loaded, default AI presets from the SD model will be used. Export these .preset files from Pefectly Clear Workbench.
    int ret = PFC_LoadScenePresets(m_PFCEngine, pathAIPresets);
  4. Detect scene. This is needs to be done once per loaded image
    PFCPROFILE pProfile;
    pProfile = PFC_Calc(&im, NULL, m_PFCEngine, CALC_ALL | CALC_SCENE_DETECTION, -1, NULL, NULL, NULL, PFC_REJECT_CLIPART, m_PFCEngine);
    int version = 0;
    int detectedScene = PFC_GetScene(pProfile, &version);
  5. Read correction params from scene preset
    PFCPARAM param;
    if (detectedScene > 0) {
    PFC_ReadScenePreset(param, m_PFCEngine, *detectedScene);
    }
  6. Or optionally read correction params from preset, ignoring scene detection
    PFC_ReadPresetsFromStream(param, (const char*)preset);
  7. Apply Perfectly Clear:
    int status = PFC_AutoCorrect(&im, NULL, param);
  8. Cleanup: Run this as the app is closing.

The calling patterns are very similar to OSX or Linux, so you can also review those samples for more use-cases.

PFC_LoadAIEngineNative
int PFC_LoadAIEngineNative(PFCENGINE *pEngineAI, unsigned int aifeatures, const char *modelDynamic, int lenDynamic, const char *modelSD, int lenSD, const char *modelSkintone, int lenSkintone, const char *modelAicolor, int lenAicolor, const char *modelFDFront, int lenFDFront, const char *modelFDBack, int lenFDBack, const char *modelFaceMesh, int lenFaceMesh, const char *modelBlendShape, int lenBlendShape, int bUseAngroidGPU, const char *apikey, const char *certificate, int *statusCertificate)
Loads/reloads platform-native (CoreML or TFLite) version of AI models into engine....
PFC_GetScene
int PFC_GetScene(PFCPROFILE precalc, int *version)
Get scene detection label from profile obtained with PFC_Calc For this to work you need to pass AI_SC...
PFCPARAM
Struct PFCPARAM the master structure of all processing parameters.
Definition: PerfectlyClearPro.h:640
AI_CORRECTIONS
@ AI_CORRECTIONS
Loads AI-based corrections model, requiring the file dynamic.pnn
Definition: PerfectlyClearPro.h:1109
CALC_ALL
@ CALC_ALL
Calculates for all classic features, all of the above.
Definition: PerfectlyClearPro.h:167
PFCPROFILE
#define PFCPROFILE
Define.
Definition: PerfectlyClearPro.h:675
PFCENGINE
Struct defining an PFC engine instance.
Definition: PerfectlyClearPro.h:250
PFC_LoadScenePresets
int PFC_LoadScenePresets(PFCENGINE *pEngine, const char *filePath, int modelUuid=0, int *presetUuid=NULL, int arrProfileUUIDLen=0)
Loads AI Scene Detection group presets from presets file, and optionally re-loading different Scene D...
PFC_DestroyEngine
void PFC_DestroyEngine(PFCENGINE *p)
Destroy PFCENGINE instance and release associated resources.
PFC_ReadScenePreset
int PFC_ReadScenePreset(PFCPARAM &param, PFCENGINE *pEngineAI, int scene)
Fill param for the scene from the engine with previously loaded scene presets with PFC_LoadScenePrese...
PFC_AutoCorrect
int PFC_AutoCorrect(PFCIMAGE *pImage, PFCIMAGE *pImageds, PFCPARAM &param, int iISO=-1, char *pCameraModel=NULL, BOOL bFastFAE=FALSE, PFC_PROGRESS progfn=NULL, PFCENGINE *pEngineAI=NULL, BOOL bUseAutoSDPreset=FALSE)
Single function to perform Perfectly Clear correction.
PFC_REJECT_CLIPART
@ PFC_REJECT_CLIPART
Reject images classified as clipart, used by default.
Definition: PerfectlyClearPro.h:414
AI_SCENE_DETECTION
@ AI_SCENE_DETECTION
Loads scene detection model, requiring one or two pnn files with filenames like pro_and_universal_202...
Definition: PerfectlyClearPro.h:1108
PFC_CreateEngine
PFCENGINE * PFC_CreateEngine()
Create PFCENGINE instance.
PFC_ReadPresetsFromStream
int PFC_ReadPresetsFromStream(PFCPARAM &param, const char *s)
Load image processing settings from a char buffer.
CALC_SCENE_DETECTION
@ CALC_SCENE_DETECTION
Calculate Scene Detection.
Definition: PerfectlyClearPro.h:173
PFC_Calc
PFCPROFILE PFC_Calc(PFCIMAGE *pImage, PFCIMAGE *pImageds, PFCENGINE *pEngine, unsigned int feature=CALC_ALL, int iISO=-1, char *pCameraModel=NULL, PFCPROFILE pImageProfile=NULL, PFC_PROGRESS progfn=NULL, int iRejectOption=PFC_REJECT_CLIPART, PFCENGINE *pEngineAI=NULL)
Perform initial analysis on images.