EyeQ Docs

AI scene detection

Automatically detect scenes and apply optimal corrections

The AI scene detection samples demonstrate how to use the SDK's machine learning capabilities to automatically identify image content and apply scene-appropriate corrections. This is the recommended approach for most applications.

What these samples demonstrate

The SimpleAiSample and DetailedAiSample projects show how to initialize the AI engine, process images with automatic scene detection, and optionally load custom presets for each scene type.

C/C++ implementation

The following excerpts are from SimpleAiSample.cpp. The same pattern applies to Linux, macOS, and Windows.

Initialize the AI engine

Create an engine instance and load the AI models. The AI engine initialization takes time, so keep a single instance per worker thread throughout your application session.

PFCENGINE *pAiEngine = PFC_CreateEngine();

// Load AI engine - binPath should point to the directory containing .pnn model files
std::string binPath = "/path/to/sdk/bin";
int aistatus = PFC_LoadAIEngine(pAiEngine, 
    AI_SCENE_DETECTION | AI_CORRECTIONS | AI_COLOR | AI_FACEMESH, 
    binPath.c_str());

// Verify required features loaded successfully
if ((aistatus & AI_SCENE_DETECTION) == 0) {
    printf("Cannot load AI Scene Detection\n");
    exit(1);
}

Load custom scene presets (optional)

By default, the SDK uses built-in presets for each scene. You can override these with custom presets exported from Perfectly Clear Workbench.

// Load custom presets (from DetailedAiSample)
int retLoadPresets = PFC_LoadScenePresets(pAiEngine, "path/to/custom.preset");
if (0 != retLoadPresets) {
    printf("Cannot load scene presets file, error %i\n", retLoadPresets);
}

// To reset to default presets, pass nullptr
// PFC_LoadScenePresets(pAiEngine, nullptr);

Apply corrections

Pass the AI engine to PFC_AutoCorrect. The PFCPARAM parameter is ignored when using AI scene detection.

PFCPARAM ignoredParam;
int status = PFC_AutoCorrect(&im, NULL, ignoredParam, -1, NULL, false, NULL, pAiEngine, true);

if (status == APPLY_SUCCESS) {
    printf("Image processed successfully\n");
}

Retrieve scene information

After correction, you can query which scene was detected and the confidence level.

int sceneLabel = 0;
int confidence = 0;
PFC_GetLastSceneProperties(pAiEngine, &sceneLabel, &confidence);
printf("Detected scene %i with confidence %i\n", sceneLabel, confidence);

C# implementation

The C# wrapper provides the same functionality with a simpler API. The following excerpts are from CSharp_SimpleAiSample.

Initialize and load AI engine

Create a PerfectlyClear instance and load the AI engine with the features you need.

// Create instance with license path
PerfectlyClearAdapter.PerfectlyClear Pfc = new PerfectlyClearAdapter.PerfectlyClear("C:\\path\\to\\sdk_license");

// Load AI engine
string execPath = AppDomain.CurrentDomain.BaseDirectory;
int aistatus = Pfc.LoadAiEngine(
    PFCAIFEATURE.AI_SCENE_DETECTION | PFCAIFEATURE.AI_CORRECTIONS | 
    PFCAIFEATURE.AI_COLOR | PFCAIFEATURE.AI_FACEMESH, 
    execPath);

Apply corrections

Load the image and apply AI-powered corrections with a single call.

// Load image using System.Drawing
Bitmap bm = new Bitmap(inputFile);

// Apply AI-powered corrections
int result = Pfc.AutoCorrect(ref bm);

// Save the corrected image
bm.Save(outputFile);

Load custom presets (optional)

To use custom presets instead of the built-in ones, load them before processing.

// From CSharp_DetailedAiSample
int retLoadPresets = Pfc.LoadScenePresets("path/to/custom.preset");
if (0 != retLoadPresets) {
    Console.WriteLine("Cannot load presets, error: " + retLoadPresets);
}

Source files

You can find the code snippets in the following files:

PlatformSamplePath
Linux/macOSSimpleAiSampleLinux/SimpleAiSample/SimpleAiSample.cpp
Linux/macOSDetailedAiSampleLinux/DetailedAiSample/DetailedAiSample.cpp
Windows (C++)SimpleAiSampleWin/SimpleAiSample/SimpleAiSample.cpp
Windows (C++)DetailedAiSampleWin/DetailedAiSample/DetailedAiSample.cpp
Windows (C#)SimpleAiSampleWin/CSharp_SimpleAiSample/Program.cs
Windows (C#)DetailedAiSampleWin/CSharp_DetailedAiSample/Program.cs

PFC-SDK Version 10.7.2.1269 built from 4fa849d8101945eea725a08dd0dae5101f090fa0 on 11-10-2025.

Copyright © 2026 EyeQ Imaging Inc. All rights reserved.

On this page