Common Errors
Solutions for frequently encountered issues when using the Perfectly Clear SDK
This page covers the most common errors developers encounter when integrating the Perfectly Clear SDK, along with their causes and solutions.
Invalid image
The SDK returns APPLY_NOSOURCE (-4) or APPLY_BADFORMAT (-5) when it cannot process the provided image data.
Symptoms
These indicators suggest an invalid image error:
PFC_AutoCorrect()orPFC_Apply()returns-4or-5.- Error message indicates the source image is missing or has an unsupported format.
- Image appears corrupted or displays incorrectly after processing.
Causes
The APPLY_NOSOURCE error occurs when:
- The
pImagepointer passed to the function isNULL - The image data buffer has been freed or is inaccessible
- The
PFCIMAGEstructure was not properly initialized
The APPLY_BADFORMAT error occurs when:
- The pixel format specified in
PFCIMAGE.formatdoesn't match the actual data - The image uses an unsupported bit depth or channel configuration
- The stride value is incorrect for the image dimensions
Solutions
Verify your PFCIMAGE structure is correctly populated:
PFCIMAGE im;
im.width = imageWidth;
im.height = imageHeight;
im.stride = imageWidth * bytesPerPixel; // Must match actual row width in bytes
im.format = PFC_PixelFormat24bppRGB; // Must match actual pixel layout
im.data = imageBuffer; // Must point to valid, allocated memoryEnsure the pixel format constant matches your image data:
| Format constant | Description |
|---|---|
PFC_PixelFormat24bppRGB | 24-bit RGB (B, G, R byte order) |
PFC_PixelFormat24bppBGR | 24-bit BGR (R, G, B byte order) |
PFC_PixelFormat32bppARGB | 32-bit ARGB with alpha channel |
PFC_PixelFormat32bppABGR | 32-bit ABGR with alpha channel |
PFC_PixelFormat48bppRGB | 48-bit RGB (16 bits per channel) |
PFC_PixelFormat64bppARGB | 64-bit ARGB (16 bits per channel) |
Unsupported format
The SDK has specific requirements for color spaces and image formats.
Symptoms
These signs indicate a format compatibility issue:
- Images appear with incorrect colors after processing.
- The SDK skips processing without returning an explicit error.
- Color profile warnings appear in verbose output.
CMYK color space
The Perfectly Clear SDK operates on RGB or RGBA image data. If your source images are in CMYK, Indexed color, or monochrome color spaces, you must convert them to RGB before processing.
Color profile handling
The SDK is fully color-managed, ensuring color consistency across devices and for different color profiles. This support is provided by the optional PFCImageFile class. When using PFCImageFile to read and write images, you can control color profile conversion as follows:
- Convert to sRGB: Set
bConvertToSRGBtotruewhen loading, and setbConvertToOriginalColorSpacetofalsewhen saving. This converts the images to sRGB, processes thenm, then leaved them in sRGB on save:
// Load converting to sRGB
sRGBImageFile.LoadImageFile(filename, true, iccFolderPath);
// Process the image...
// Save leaving in sRGB
sRGBImageFile.SaveImageFile(
outputFilename,
quality,
false, // bConvertToSRGB
true // bPreserveOriginalMetadata
); - Preserve original profile: Convert to sRGB, then return to the input profile:
// Load preserving original color space
originalImageFile.LoadImageFile(filename, true, iccFolderPath);
// Process the image...
// Save converting back to original color space
originalImageFile.SaveImageFile(
outputFilename,
quality,
true, // bConvertToOriginalColorSpace
true // bPreserveOriginalMetadata
);- No color management: Load and save without any profile conversion. This should only be used if the rest of your imaging pipeline is handling color management.
// Load without color management
noColorMgmtImageFile.LoadImageFile(filename, false, iccFolderPath);
// Process the image...
// Save without color management
noColorMgmtImageFile.SaveImageFile(
outputFilename,
quality,
false, // bConvertToSRGB
false // bPreserveOriginalMetadata
);Out-of-memory
Memory exhaustion can occur when processing very large images or running batch operations.
Symptoms
These indicators suggest memory-related issues:
PFCCORE_STATUSreturnsPFC_CORE_INSUFFICIENTMEMORY(4).- The application crashes or becomes unresponsive.
- Processing slows dramatically before failing.
Causes
Memory issues typically arise from these scenarios:
- Processing images with very high resolution (500+ megapixels)
- Creating multiple
PFCENGINEinstances simultaneously - Not releasing
PFCPROFILEobjects after processing - Batch processing without proper memory management
Solutions
Release resources properly:
// Always release the profile after processing each image
PFC_ReleaseProfile(pProfile);
// Release the engine when done with the session
PFC_DestroyEngine(pEngine);Reuse engine instances:
// Create ONE engine for your session
PFCENGINE* pEngine = PFC_CreateEngine();
// Process multiple images with the same engine
for (int i = 0; i < imageCount; i++) {
PFCPROFILE pProfile = PFC_Calc(&images[i], NULL, pEngine, CALC_ALL, -1, NULL, NULL, NULL, PFC_REJECT_CLIPART);
PFC_Apply(&images[i], pEngine, pProfile, param, NULL, 100, NULL);
PFC_ReleaseProfile(pProfile); // Release after each image
}
// Destroy engine at end of session
PFC_DestroyEngine(pEngine);Parameter mismatch
Incorrect or incompatible parameter configurations can cause unexpected behavior or processing failures.
Symptoms
These signs indicate parameter configuration issues:
PFC_ReadPresets()returns a negative error code- Image corrections don't match expected results
- Features are unexpectedly disabled or produce no visible effect
Preset file errors
There are two functions to load presets:
PFC_ReadPresets()- This loads a single Perfectly Clear preset file.PFC_LoadScenePresets()- This loads an AI Scene Detection preset file - containing multiple presets for different scene types.
Ensure you are using the correct function for the preset file type. Both of these functions return specific error codes:
| Return code | Meaning | Solution |
|---|---|---|
0 | Success | — |
-1 | Attribute errors | Check preset file for malformed attributes |
-2 | Unable to open file | Verify file path and permissions |
-3 | File read error | Check file isn't locked or corrupted |
-4 | Parse error | Preset file has invalid XML structure |
-5 | Cannot convert text | Encoding issue in preset file |
-6 | No text node | Preset file is missing required content |
-7 | Element depth exceeded | Preset file structure is too deeply nested |
-8 | Invalid preset file | File is not a valid Perfectly Clear preset |
For all errors - the most common issue is a malformed or corrupted preset file. Try exporting a new preset from the Perfectly Clear application to ensure the file is valid. Ensure single presets are loaded with PFC_ReadPresets() and scene presets with PFC_LoadScenePresets().
Missing license
License validation failures prevent the SDK from processing images.
Symptoms
These indicators point to license-related issues:
PFC_Apply()returnsAPPLY_INVALIDLICENSE(-6)PFC_SetProtectionPath()returns an error code other than0,102, or103- Images are returned unprocessed
License setup requirements
The SDK license requires three files in a writable folder:
| File | Purpose |
|---|---|
license.key | Contains your valid license key |
registration_email.txt | Email address for registration |
ShaferFilechck.dll / .so / .dylib | License handling library |
PFCAppTrack.dll / libPFCAppTrack.so / libPFCAppTrack.dylib | Usage tracking library |
Common causes
License validation can fail for several reasons:
- Incorrect path: The path provided to
PFC_SetProtectionPath()doesn't exist or isn't accessible - Missing files: One or more license files are missing from the folder
- Permission issues: The SDK cannot read from or write to the license folder
- Network connectivity: License validation requires periodic internet access
- Expired license: The license has reached its expiration date
- Node limit exceeded: All available activations have been used
Solutions
Verify the license path:
int status = PFC_SetProtectionPath("/path/to/sdk_license", NULL);
if (status != 0 && status != 102 && status != 103) {
printf("License error: %d\n", status);
}Interpret license status codes:
| Code | Meaning | Action |
|---|---|---|
0 | OK | License is valid |
102 | Active license | License is valid and active |
103 | Active trial | Trial license is active |
104 | License expired | Contact EyeQ to renew |
108 | Invalid license | Verify license.key file |
112 | Too many activations | Contact EyeQ to reset activations |
113 | Trial expired | Purchase a full license |
115 | Exceed allowed activations | Node limit reached |
119 | No available licenses | All seats are in use |
Ensure network connectivity:
The SDK validates the license periodically, by default every 12 hours, and needs access to these addresses:
- IP: 184.106.60.185
appsmanager.athentech.com(IPs: 52.72.235.36 or 52.203.55.148)
Ensure your firewall allows outbound connections to these addresses.
Handle license in multithreaded applications:
// Call PFC_SetProtectionPath ONCE before spawning threads
PFC_SetProtectionPath("/path/to/sdk_license", NULL);
// Then call PFC_Apply or PFC_AutoCorrect from individual threads
// Do NOT call PFC_SetProtectionPath from multiple threadsSee the error code index for a complete list of license-related return codes.
PFC-SDK Version 10.7.2.1269 built from 4fa849d8101945eea725a08dd0dae5101f090fa0 on 11-10-2025.
Copyright © 2026 EyeQ Imaging Inc. All rights reserved.