Dynamic Framework Examples
NOTE: If your project uses GPUImage
Under the hood Dynamic uses GPUImage (v1)
. If your project uses the same version of GPUImage
, you might experience unexpected issues because of the namespace collisions.
Setup
Drag & drop DynamicFramework.xcframework
into your Xcode project. You might have to go into your target's settings, General -> Frameworks, Libraries, and Embedded Content
and set the framework to Embed & Sign
. You will also have to disable Bitcode
for your target because Dynamic doesn't support Bitcode
yet. To disable Bitcode
go to your target's Build Settings
and set Enable Bitcode
to No
.
Add framework import statement to a file where you intend to use Dynamic.
Initializing and and setting up the license protection
let pfcDynamic = PFCDynamic(apiKey: "your_api_key", certificate: #"your_certificate"#)
let status = pfcDynamic.checkStatus()
if status >= 0 { // Anything less than 0 is an error
print("Initialization successful")
} else {
// Check status description in the documentation
// to understand why initialization failed.
print("Initialization failed")
}
Applying Dynamic to an image
let image = UIImage(named: "your_image_name")!
guard let cgImage = image.cgImage else {
// Dynamic can work only with CGImage instances.
print("Failed to retrieve CGImage")
return
}
do {
// applying Dynamic to an image might throw an error
let processedCgImage = try pfcDynamic.processImage(cgImage, strength: 1.0)
let processedImage = UIImage(cgImage: processedCgImage, scale: image.scale, orientation: image.imageOrientation)
} catch {
// Most likely, there's an issue with the license.
// Use `PFCDynamic.checkStatus()` to get the error code.
print("Applying Dynamic failed.")
print(error)
}
Deflickering and skipping frames
Deflickering and skipping frames can be controlled via PFCDynamic.setParams(deflickerCurve:deflickerImage:skip:)
method.
// Recommended value for deflickerCurve is 0.08
// Recommended value for deflickerImage is 0.9
// Setting skip to 1 means that inference will be calculated only
// every second frame which will insignificantly speed up image processing
pfcDynamic.setParams(deflickerCurve: 0.08, deflickerImage: 0.9, skip: 1)
Because deflickering has a cumulative effect, sometimes you might want to reset deflicker.
PFCDynamic.resetDeflicker()
- Copyright
- Copyright (C) 2022 EyeQ Imaging Inc